LWJGL Forum

Please login or register.

Login with username, password and session length
Pages: 1 2 [3] 4 5 ... 10
 21 
 on: October 05, 2017, 22:39:39 
Started by sourceskyboxer - Last post by sourceskyboxer
Hello everyone,

I am here now:

I tried just clean HelloWorld.java from Get Started.

Code: [Select]
public class HelloWorld {

// The window handle
private long window;
private GLFWVidMode vid;
private int width;
private int height;

public void run(String[] args) {
System.out.println("Hello LWJGL " + Version.getVersion() + "!");
for(int i = 0; i < args.length; i++)
{
switch(args[i])
{
case "-w":
case "-width":
width = Integer.parseInt(args[i+1]);

System.out.println("argument is for w/width "+args[i+1]+"\n");
break;
case "-h":
case "-height":
height = Integer.parseInt(args[i+1]);
System.out.println("argument is for h/height "+args[i+1]+"\n");
break;
case "-windowed":
vid = glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
glfwSetWindowMonitor(window, glfwGetWindowMonitor(window), (vid.width()-width)/2, (vid.height()-height)/2, width, height, 60);
System.out.println("argument is for windowed = false \n");
break;
default:
break;
}
}

init();
loop();

// Free the window callbacks and destroy the window
glfwFreeCallbacks(window);
glfwDestroyWindow(window);

// Terminate GLFW and free the error callback
glfwTerminate();
glfwSetErrorCallback(null).free();
}

private void init() {
// Setup an error callback. The default implementation
// will print the error message in System.err.
GLFWErrorCallback.createPrint(System.err).set();

// Initialize GLFW. Most GLFW functions will not work before doing this.
if ( !glfwInit() )
throw new IllegalStateException("Unable to initialize GLFW");

// Configure GLFW
glfwDefaultWindowHints(); // optional, the current window hints are already the default
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // the window will stay hidden after creation
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); // the window will be resizable
glfwWindowHint(GLFW_MAXIMIZED, GLFW_FALSE);

// Create the window
window = glfwCreateWindow(640, 480, "Hello World!", glfwGetPrimaryMonitor(), NULL);
if ( window == NULL )
throw new RuntimeException("Failed to create the GLFW window");

// Setup a key callback. It will be called every time a key is pressed, repeated or released.
glfwSetKeyCallback(window, (window, key, scancode, action, mods) -> {
if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE )
glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop
});

// Make the OpenGL context current
glfwMakeContextCurrent(window);
// Enable v-sync
glfwSwapInterval(1);

// Make the window visible
glfwShowWindow(window);
}

private void loop() {
// This line is critical for LWJGL's interoperation with GLFW's
// OpenGL context, or any context that is managed externally.
// LWJGL detects the context that is current in the current thread,
// creates the GLCapabilities instance and makes the OpenGL
// bindings available for use.
GL.createCapabilities();

// Set the clear color
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);

// Run the rendering loop until the user has attempted to close
// the window or has pressed the ESCAPE key.
while ( !glfwWindowShouldClose(window) ) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the framebuffer

glfwSwapBuffers(window); // swap the color buffers

// Poll for window events. The key callback above will only be
// invoked during this call.
glfwPollEvents();
}
}

public static void main(String[] args) {
new HelloWorld().run(args);
}

}
Is it correct? But I understand like glfw forum I always tried glfwSetWindowMonitor()

But it crashed now:
Code: [Select]
Hello LWJGL 3.1.4 SNAPSHOT!
argument is for w/width 1200

argument is for h/height 720

Exception in thread "main" java.lang.NullPointerException
at org.lwjgl.system.Checks.check(Checks.java:96)
at org.lwjgl.glfw.GLFW.nglfwGetVideoMode(GLFW.java:1284)
at org.lwjgl.glfw.GLFW.glfwGetVideoMode(GLFW.java:1306)
at HelloWorld.run(HelloWorld.java:35)
at HelloWorld.main(HelloWorld.java:116)

If I use -windowed than glfwSetWindowMonitor will change to width and height. But it won't work. How do I fix?

 22 
 on: October 05, 2017, 19:49:35 
Started by LapisSea - Last post by LapisSea
Thanks for the info!  :)
This is means green light for option 2. (however i'd not recommend this as a final solution to anyone with similar problem...)
Hoping that it becomes a reality in next year or so.

 23 
 on: October 05, 2017, 19:39:49 
Started by LapisSea - Last post by KaiHH
There are no bindings to GLSL/SPIR-V compilers currently in LWJGL3 to support option 1.
It'd sure be a nice opportunity to add one, though.
See: https://github.com/LWJGL/lwjgl3/issues/77#issuecomment-137675918
Google's shaderc/libshaderc, integrating glslang and SPIR-V Tools, has a particularly simple C API, which I wrote a custom JNI binding to a while ago.
So, it should be very easy to port this to LWJGL3's binding approach with a Kotlin template.

 24 
 on: October 05, 2017, 18:41:11 
Started by LapisSea - Last post by LapisSea
Hi I recently started porting my game from opengl to Vulkan.
Now I got stuck on shaders. I have this system where I generate many shaders from "modules" depending on what a model needs. (if some face need to be glowing then add glowing module to shader source)
Now this was no issue in opengl as I could simply give the generated source to opengl and it would compile it. So I can't just include some compiled shaders in the game as I allow for user created content. (mods and similar)

Solutions:
  • Compile source to spv from glsl directly in game
  • Force user to have vulkan sdk installed and use command line to call glslangValidator.exe
  • Drop the whole system and lose on performance

Sooo.... first option is by far the best one. I know you can do it in c++ but I am really not sure how I would go about this in LWJGL3.

 25 
 on: October 05, 2017, 17:54:55 
Started by matan45 - Last post by KaiHH
With standard filtering, OpenGL is interpolating beyond the edges of the texture at the coordinates around 0.0 and 1.0 and uses the texture's border color wraps around/repeats at the other side of the texture.
Use CLAMP_TO_EDGE wrap mode to fix this:
Code: [Select]
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

 26 
 on: October 05, 2017, 10:32:22 
Started by matan45 - Last post by matan45
why i have this bug when i texture ball?


https://imgur.com/boaIvDr

 27 
 on: October 05, 2017, 04:40:25 
Started by matan45 - Last post by matan45
what decoder you use for mp4?

 28 
 on: October 05, 2017, 03:17:16 
Started by gudenau - Last post by gudenau
nullable.. should remove the check.

edit: btw, you can do Check(1) instead of Check("1").

I'll double check that I did not mess that up then, and I will change all of those Check statements.

Edit:
Seems that it was just me being stupid like normal. Go figure.

 29 
 on: October 04, 2017, 20:26:49 
Started by gudenau - Last post by spasi
nullable.. should remove the check.

edit: btw, you can do Check(1) instead of Check("1").

 30 
 on: October 04, 2017, 20:12:03 
Started by gudenau - Last post by gudenau
Odd problem, checks are happening where they should not be for a function.

I have tried this:
Code: [Select]
    size_t(
        "libusb_get_device_list", "",

        optional..libusb_context_p.IN("ctx", ""),
        Check("1")..libusb_device_p.p.p.OUT("list", "")
    )

and this

Code: [Select]
    size_t(
        "libusb_get_device_list", "",

        nullable..libusb_context_p.IN("ctx", ""),
        Check("1")..libusb_device_p.p.p.OUT("list", "")
    )

A null ctx tells the library to use the default one.

Pages: 1 2 [3] 4 5 ... 10