Hello Guest

Recent Posts

Pages: 1 ... 8 9 [10]
91
General Java Game Development / Re: Introducing StbImageJava
« Last post by rds on February 11, 2020, 11:11:14 »
The library is now available at the bintray/jcenter: https://bintray.com/rds1983/maven/stb.image/_latestVersion
92
General Java Game Development / Introducing StbImageJava
« Last post by rds on February 08, 2020, 09:14:15 »
StbImageJava is Java port of stb_image.h 2.22. Or - in other words - it's a pure Java library without any native dependencies that can load images in JPG, PNG, BMP, TGA, PSD and GIF formats.

If the project will attract interest, I may also port stb_imagewrite.h and stb_truetype.h

https://github.com/StbJava/StbImageJava
93
Lightweight Java Gaming Library / GLFW callbacks not working
« Last post by nbilyk on February 06, 2020, 15:31:27 »
I'm having a strange issue that I'm not sure how to troubleshoot.
Sometimes the GLFW window callbacks aren't getting triggered. Any of them.
Everything else works, the window is created, I can draw like normal, but no callbacks are invoked, not even window close.

Any ideas what I should check? (I'm on Windows 10, I believe it happens in different JDKs)
94
OpenGL / Re: Libretro porting of LWJGL (and Libgdx)
« Last post by spasi on January 31, 2020, 18:45:56 »
You shouldn't need to understand how TLU works. Or use libretro's get_proc_address function. If you use GL.createCapabilities and GL.setCapabilities properly, it should work without any issues. The crash you describe sounds like an OpenGL context mismanagement issue. If libretro has a context management API, you should look into that.
95
OpenGL / Re: Libretro porting of LWJGL (and Libgdx)
« Last post by msx on January 31, 2020, 13:20:02 »
OpenGL functions are called using static methods. However, OpenGL function addresses are specific to the context that is bound to the current thread. Normally, this would require a thread-local lookup on each method call, which is not terribly expensive, but it adds up and also affects the optimization of surrounding code. Unfortunately, Hotspot cannot hoist the lookup outside of loops, etc. That's why LWJGL handles OpenGL calls differently, to avoid the thread-local lookup completely without sacrificing correctness. This is indeed black magic (i.e. nasty hack that messes with JVM internals), see the ThreadLocalUtil class for more details.

Uhm i've tryed to look into the ThreadLocalUtil description but haven't understand much.

it says:

Quote
    1) The first capabilities instance encountered is stored in a static write-once holder. This is optimistically assumed to be compatible with all other (if
    any) instances we encounter, which is indeed the case for the vast majority of programs. If an incompatible instance is encountered, there is a fall back
    to the thread-local lookup.

So do you think i'm falling on the regular use case or in the fallback? The fallback encounters the performances penality you mentioned early? Am i actually using opengl32.dll that's loaded in java or not?

Anyway, i digged a little more on the Libretro documentations, and it turns out they give you a
Code: [Select]
retro_hw_get_proc_address_t lookup function:

Quote
A callback to grab OpenGL symbols is exposed via retro_hw_get_proc_address_t. Use this to retrieve symbols and extensions.

So would it be teoretically possible to use that function to get all OpenGL function pointers and then call them via the "callPPI" style, avoiding the need to load any external DLL ? What would the performances be?


All of this becouse my core runs perfectly the first time, but after it's unloaded and reloaded by the frontend, everything crashes. I'm thinking it's some kind of DLL mess up.

Also, if that matters the system will be single threaded (or at lease, all opengl calls will originate from the same thread).

Thanks again.

96
Hello there.

I watch a lot of openvr examples and most of it do VRCompositor_Submit(Eye,Texure, null, Submit).
But when i try do this it do nothing.
Can someone explain me what i do wrong?

Headset Oculus rift dk1.

Code below runs steamvr but dont draw what i want.

Code: [Select]
package openvr;

import static org.lwjgl.glfw.GLFW.glfwCreateWindow;
import static org.lwjgl.glfw.GLFW.glfwInit;
import static org.lwjgl.glfw.GLFW.glfwMakeContextCurrent;
import static org.lwjgl.glfw.GLFW.glfwPollEvents;
import static org.lwjgl.glfw.GLFW.glfwSetWindowPos;
import static org.lwjgl.glfw.GLFW.glfwSetWindowSizeLimits;
import static org.lwjgl.glfw.GLFW.glfwShowWindow;
import static org.lwjgl.glfw.GLFW.glfwSwapBuffers;
import static org.lwjgl.glfw.GLFW.glfwWindowShouldClose;
import static org.lwjgl.opengl.GL11.GL_BLEND;
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
import static org.lwjgl.opengl.GL11.GL_QUADS;
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
import static org.lwjgl.opengl.GL11.glBegin;
import static org.lwjgl.opengl.GL11.glBindTexture;
import static org.lwjgl.opengl.GL11.glBlendFunc;
import static org.lwjgl.opengl.GL11.glClear;
import static org.lwjgl.opengl.GL11.glClearColor;
import static org.lwjgl.opengl.GL11.glColor3f;
import static org.lwjgl.opengl.GL11.glEnable;
import static org.lwjgl.opengl.GL11.glEnd;
import static org.lwjgl.opengl.GL11.glOrtho;
import static org.lwjgl.opengl.GL11.glTexCoord2f;
import static org.lwjgl.opengl.GL11.glVertex2f;
import static org.lwjgl.opengl.GL11.glViewport;
import static org.lwjgl.opengl.GL12.GL_TEXTURE_3D;
import java.awt.Dimension;
import java.awt.Toolkit;
import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GL11;
import org.lwjgl.openvr.*;
import org.lwjgl.system.*;
import java.nio.*;
import static org.lwjgl.openvr.VR.*;
import static org.lwjgl.openvr.VRSystem.*;
import static org.lwjgl.system.MemoryStack.*;
import graphics.frameBuffers.frameBuffer;
import voxelRayCast.GSTextures;

public class helpme {

static long window;
static Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
static int w=(int) screenSize.getWidth()/2;
static int h=(int) screenSize.getHeight()/2;

public static GSTextures tex0=new GSTextures();

public static int VRtoken;

    public void run(){//START HERE---START HERE---START HERE---START HERE---START HERE---START HERE---START HERE---START HERE---START HERE---START HERE
    HelloOpenVR();
initWindow();
tex0.initText();
DrawLoop();
}

    public static void HelloOpenVR(){

        System.err.println("VR_IsRuntimeInstalled()="+VR_IsRuntimeInstalled());
        System.err.println("VR_RuntimePath() ="+VR_RuntimePath());
        System.err.println("VR_IsHmdPresent()="+VR_IsHmdPresent());

        try(MemoryStack stack=stackPush()){
            IntBuffer peError=stack.mallocInt(1);

            VRtoken=VR_InitInternal(peError, VR.EVRApplicationType_VRApplication_Overlay);
            if(peError.get(0)==0){
                OpenVR.create(VRtoken);

                System.err.println("Model Number:"+VRSystem_GetStringTrackedDeviceProperty(
                    k_unTrackedDeviceIndex_Hmd,
                    ETrackedDeviceProperty_Prop_ModelNumber_String,
                    peError
                ));
                System.err.println("Serial Number:"+VRSystem_GetStringTrackedDeviceProperty(
                    k_unTrackedDeviceIndex_Hmd,
                    ETrackedDeviceProperty_Prop_SerialNumber_String,
                    peError
                ));

                IntBuffer www=stack.mallocInt(1);
                IntBuffer hhh=stack.mallocInt(1);
                VRSystem_GetRecommendedRenderTargetSize(www, hhh);
                System.err.println("Recommended width :"+www.get(0));
                System.err.println("Recommended height:"+hhh.get(0));
            }else{
                System.out.println("INIT ERROR SYMBOL:"+VR_GetVRInitErrorAsSymbol(peError.get(0)));
                System.out.println("INIT ERROR  DESCR:"+VR_GetVRInitErrorAsEnglishDescription(peError.get(0)));
            }
        }
    }

public void initWindow(){

    System.out.println("win Init Start.");

    if(glfwInit()!=true){
        System.err.println("INIT_GLFW_FAILED");
System.exit(1);
    }
    window=glfwCreateWindow( w, h, "test", 0, 0);
    glfwSetWindowPos(window, w/2, h/2);
    glfwSetWindowSizeLimits(window, w, h, w, h);
    glfwShowWindow(window);
    glfwMakeContextCurrent(window);
    GL.createCapabilities();
    glViewport(0, 0, w, h);
    glOrtho(0, w, h, 0, -1, 1);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_TEXTURE_2D);
    glEnable(GL_TEXTURE_3D);

    System.out.println("win Init End.");
}

public void Draw(){

    glEnable(GL_BLEND);
    GL11.glViewport(0, 0, w, h);

    glColor3f(0,0,1);

    glBegin(GL_QUADS);
        glVertex2f(0, 0);
        glVertex2f(w, 0);
        glVertex2f(w, h);
        glVertex2f(0, h);
        glEnd();
}

public void FinalDraw(int tex){

    glEnable(GL_BLEND);
    GL11.glViewport(0, 0, w, h);

    glBindTexture(GL_TEXTURE_2D, tex);

    glBegin(GL_QUADS);
    glTexCoord2f(0,1);
        glVertex2f(0, 0);
        glTexCoord2f(1,1);
        glVertex2f(w, 0);
        glTexCoord2f(1,0);
        glVertex2f(w, h);
        glTexCoord2f(0,0);
        glVertex2f(0, h);
        glEnd();
       
            glBindTexture(GL_TEXTURE_2D, 0);
}

    public void DrawLoop(){
    frameBuffer fb=new frameBuffer(w, h);
   
while(!glfwWindowShouldClose(window)){
    glfwPollEvents();
            glClearColor(0, 0, 0, 1);
            glClear(GL_COLOR_BUFFER_BIT);

            fb.updateTexture(w,h);
            fb.bindFrameBuffer();
            Draw();//draw blue screen
            fb.unbindCurrentFrameBuffer();
            FinalDraw(fb.getTexture());//draw frame buffer to window
       
            Texture t1=Texture.create();
             t1.set(tex0.noise.get(), VR.ETextureType_TextureType_OpenGL, VR.EColorSpace_ColorSpace_Gamma);
                VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Left, t1, null, VR.EVRSubmitFlags_Submit_GlRenderBuffer);

Texture t2=Texture.create();
                t2.set(fb.getTexture(), VR.ETextureType_TextureType_OpenGL, VR.EColorSpace_ColorSpace_Gamma);
VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Right, t2, null, VR.EVRSubmitFlags_Submit_GlRenderBuffer);

glfwSwapBuffers(window);
}
VR.VR_ShutdownInternal();
}
}
97
I am experiencing the same issue, I think, after going making my project modular (java 9 modules). I'm also using IntelliJ IDEA. I have all the jars added as a library, and this worked just fine until I switched to java modules.

I get the output below.

Code: [Select]
"C:\Program Files\Java\jdk-13.0.2\bin\java.exe" -Dorg.lwjgl.util.DebugAllocator=true -Dorg.lwjgl.util.Debug=true --enable-preview "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.2\lib\idea_rt.jar=62427:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.2\bin" -Dfile.encoding=UTF-8 -p D:\OneDrive\workspace_intellij\3dgame\out\production\yt.hydrozoa.threedgame;D:\OneDrive\workspace_intellij\3dgame\out\production\yt.hydrozoa.engine;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-stb.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-glfw.jar;D:\OneDrive\workspace_intellij\3dgame\lib\joml-1.9.20.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-assimp.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-openal.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-opengl.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-javadoc.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-sources.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-stb-javadoc.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-stb-sources.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-glfw-javadoc.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-glfw-sources.jar;D:\OneDrive\workspace_intellij\3dgame\lib\joml-1.9.20-javadoc.jar;D:\OneDrive\workspace_intellij\3dgame\lib\joml-1.9.20-sources.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-assimp-javadoc.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-assimp-sources.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-openal-javadoc.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-openal-sources.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-opengl-javadoc.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-opengl-sources.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-natives-windows.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-stb-natives-windows.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-glfw-natives-windows.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-assimp-natives-windows.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-openal-natives-windows.jar;D:\OneDrive\workspace_intellij\3dgame\lib\lwjgl-opengl-natives-windows.jar -m yt.hydrozoa.threedgame/yt.hydrozoa.threedgame.Main
LWJGL v3.2.3 build 13
[LWJGL] Version: 3.2.3 build 13
[LWJGL] OS: Windows 10 v10.0
[LWJGL] JRE: 13.0.2 amd64
[LWJGL] JVM: OpenJDK 64-Bit Server VM v13.0.2+8 by Oracle Corporation
[LWJGL] Loading JNI library: lwjgl
[LWJGL] Module: org.lwjgl
[LWJGL] windows/x64/org/lwjgl/lwjgl.dll not found in java.library.path=C:\Program Files\Java\jdk-13.0.2\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;D:\Programmer\mysql-8.0.13-winx64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Git\cmd;C:\Program Files\Geth;C:\Program Files\ethminer-0.15.0.dev7-Windows\bin;C:\Program Files\Java\jdk-10.0.1\bin;D:\Programmer\Quicktime\QTSystem\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\Programmer\WinSCP\;C:\Program Files\kotlinc\bin;C:\Program Files (x86)\ClockworkMod\Universal Adb Driver;C:\Go\bin;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;D:\Programmer\caddy_v0.11.1_windows_amd64_personal;C:\Program Files\PuTTY\;D:\Programmer\7-Zip;C:\Program Files\Java\jdk1.8.0_171\bin;;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\madsh\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Users\madsh\gocode\bin;D:\cygwin64\bin;;.
[LWJGL] lwjgl.dll not found in java.library.path
[LWJGL] Failed to load a library. Possible solutions:
a) Add the directory that contains the shared library to -Djava.library.path or -Dorg.lwjgl.librarypath.
b) Add the JAR that contains the shared library to the classpath.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to locate library: lwjgl.dll
at org.lwjgl/org.lwjgl.system.Library.loadSystem(Library.java:162)
at org.lwjgl/org.lwjgl.system.Library.loadSystem(Library.java:62)
at org.lwjgl/org.lwjgl.system.Library.<clinit>(Library.java:50)
at org.lwjgl/org.lwjgl.system.MemoryUtil.<clinit>(MemoryUtil.java:97)
at org.lwjgl/org.lwjgl.system.Pointer$Default.<clinit>(Pointer.java:67)
at org.lwjgl/org.lwjgl.system.Callback.<clinit>(Callback.java:41)
at yt.hydrozoa.threedgame/yt.hydrozoa.threedgame.Main.init(Main.java:94)
at yt.hydrozoa.threedgame/yt.hydrozoa.threedgame.Main.run(Main.java:78)
at yt.hydrozoa.threedgame/yt.hydrozoa.threedgame.Main.main(Main.java:225)

Process finished with exit code 1

I fixed this by adding a new folder "natives/" to the root of my intelliJ IDEA project, and extracting the natives in there manually. Then I added -Dorg.lwjgl.librarypath="../natives/" to my run configuration for my java module. The reason it jumps up one level before going to the natives-directory is because I make the module path the root when running.
98
Lightweight Java Gaming Library / Re: Can't launch glfw
« Last post by KaiHH on January 29, 2020, 11:14:10 »
https://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java

How to solve this entirely depends on how you invoke the java command, whether you use an IDE and which one you use, whether you use the Java 9+ Module System or the classpath and whether you use a Java build system (like Maven, Gradle, Ant+Ivy).
99
Lightweight Java Gaming Library / Can't launch glfw
« Last post by Ryan48 on January 29, 2020, 04:07:33 »
I'm new to lwjgl. I was trying to simply create a window. However I do not understand how to resolve this exception

here is the message
Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/glfw/GLFW
   at com.tianyuan.flappy.Main.main(Main.java:9)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.glfw.GLFW
   at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
   at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
   at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
   ... 1 more

can anyone help me?
100
OpenGL / Re: Shader fails to validate on MacOS with no error log
« Last post by Danjb on January 26, 2020, 08:50:25 »
Well, according to the specification of glValidateProgram:
Quote
This function mimics the validation operation that OpenGL implementations must perform when rendering commands are issued while programmable shaders are part of current state.
So, the validation being performed is essentially the same as the one when a glDraw... call is being invoked. So, in your case, ensure that at the point where you call glValidateProgram you could also have made a draw call with the current state of the pipeline, and that draw call would have succeeded. This in particular means:
- the texture unit of the sampler in your fragment shader is bound to a valid texture object
- a valid Vertex Array Object is currently bound
- all of the three vertex attributes are enabled and bound to a vertex source (such as a buffer object)

Thanks a lot, that sounds like the problem!

I have just found a very similar answer here:
https://stackoverflow.com/a/27629868/1624459

I was validating the program immediately after compiling, which now I understand is not the correct thing to do.
Pages: 1 ... 8 9 [10]