External Publication
Visit Post

An attempt at Vulkan

jMonkeyEngine Hub April 1, 2026
Source

icyboxs/jmonkeyengine-vulkan

package com.example.JmeTest;

import com.jme3.app.FlyCamAppState;
import com.jme3.app.SimpleApplication;
import com.jme3.app.StatsAppState;
import com.jme3.asset.TextureKey;
import com.jme3.audio.AudioListenerState;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.renderer.vulkan.context.LwjglVulkanContext;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.shader.BufferObject;
import com.jme3.system.AppSettings;
import com.jme3.texture.Image;
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture;
import com.jme3.texture.Texture2D;
import com.jme3.texture.image.ColorSpace;
import com.jme3.util.BufferUtils;
import java.awt.image.BufferedImage;
import java.io.File;
import java.nio.ByteBuffer;
import javax.imageio.ImageIO;

public class HelloVulkan extends SimpleApplication {

    public static void main(String[] args) {
        HelloVulkan app = new HelloVulkan();

        AppSettings settings = new AppSettings(true);
        settings.setTitle("JME Vulkan");
        settings.setWidth(1280);
        settings.setHeight(720);
        settings.setRenderer(AppSettings.LWJGL_VULKAN);
        settings.setVSync(true);
        settings.setCustomRenderer(LwjglVulkanContext.class);
        app.setShowSettings(false);
        app.setSettings(settings);
        app.start();
    }

    public HelloVulkan() {
        //new StatsAppState(),
        super(new AudioListenerState(), new FlyCamAppState());
    }

    @Override
    public void simpleInitApp() {
        Box box = new Box(2f, 2f, 2f);
        Geometry geom = new Geometry("MultiSetBox", box);

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/VKUnshaded.j3md");

        geom.setMaterial(mat);



        Texture tex = assetManager.loadTexture("sky.png");


        mat.setTexture("ColorMap", tex);
        rootNode.attachChild(geom);
        viewPort.setBackgroundColor(ColorRGBA.Green);
    }



}

This is my test class. Currently, only VKUnshaded.j3md can be used. Of course, you can try to write the GLSL for Vulkan by yourself for a test. This week seems to have very little time left.

I might convert all my current OpenGL GLSL shaders to Vulkan GLSL this weekend, placing them in separately named files. For example, renaming Unshaded to VKUnshaded, so that the Vulkan shaders are listed separately to reduce mixing with OpenGL code. Initially, I wanted to write the Vulkan shaders into the current OpenGL shaders and use macros to differentiate them, but that seemed too messy. For now, let’s do it this way and gradually transition to find a way to make the shader code compatible with both.

Everything runs smoothly on Windows 10. However, I cannot guarantee that it will work properly on other systems. Of course, if there are any issues, you can leave a message here.

Discussion in the ATmosphere

Loading comments...