Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (803)
Games in Android Showcase (237)
games submitted by our members
Games in WIP (867)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [FIXED] LWJGL3 Engine Crashes rendering "Stanford Bunny"  (Read 5712 times)
0 Members and 1 Guest are viewing this topic.
Offline stuart6854

Junior Devvie


Medals: 2
Exp: 3 years



« Posted 2015-12-13 22:38:53 »

As the title says. It doesn't crash when i get it to load and render a basic cube(although the cube's height is halved). I cant find out what is wrong but i did try placing a couple of sysout's and have narrowed it down the rendering phase. The thing that is strange is that (according to console output) it does manage to render a couple of times before crashing. If anyone knows any ways to further debug/detect the problem please tell me.

SideNote: Could it be caused by shaders?

EDIT: Uploaded Source: https://github.com/stuart6854/Engine_Source

Project starts at "/VoxelGame_BearEngine/src/org/voxelgame/core/Game.java".
From their you should be able to see the paths the programs takes.


Relevant Source Below(if want to see more please ask).

OBJLoader.java
http://pastebin.com/Siu5Abn5

Mesh.java
http://pastebin.com/0h2quxkh

Render Method that calls mesh.render
http://pastebin.com/DHjgp9JK
Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #1 - Posted 2015-12-13 22:41:07 »

Can we get the console output?

EDIT: We also need the source of the model, or just a few blocks of it, some OBJ models use indices which you don't have programmed.

Offline stuart6854

Junior Devvie


Medals: 2
Exp: 3 years



« Reply #2 - Posted 2015-12-13 22:59:56 »

OBJ Source: https://graphics.stanford.edu/~mdfisher/Data/Meshes/bunny.obj

Note: the crash is the standard window goes white and popup appears saying it is not responding.

Output:

1  
2  
3  
4  
5  
6  
7  
8  
1
2
3
4
1
2
3
4
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #3 - Posted 2015-12-13 23:02:51 »

That's an OpenGL Error

https://www.youtube.com/watch?v=4_ZMu8qiShw

EDIT:

1  
2  
3  
4  
5  
6  
        int errorFlag = GL11.glGetError();
        // If an error has occurred...
        if (errorFlag != GL11.GL_NO_ERROR) {
            // Print the error to System.err.
            System.err.println(GLU.gluErrorString(errorFlag));
        }


Try putting that right after you render everything.

Offline stuart6854

Junior Devvie


Medals: 2
Exp: 3 years



« Reply #4 - Posted 2015-12-13 23:15:53 »

Not getting any output from it, just: 1 2 3

note: i put it before the sysout "4" and after the drawelements
Offline stuart6854

Junior Devvie


Medals: 2
Exp: 3 years



« Reply #5 - Posted 2015-12-13 23:30:23 »

Just tried to print something after the glgetError() and before if check but it doesnt. The output that was : 1 2 3 4
Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #6 - Posted 2015-12-13 23:48:12 »

If the window doesn't respond then "Display.update()" isn't being called. (In LWJGL3 this is "glfwPollEvents() and glfwSwapBuffers(window)") I looked at your render method, looks like you don't have a 'Display.update()' there.

If you're calling it in the update method or something, then there's a bad patch of code that's taking a long time and is blocking the Display.update call. Try putting a few more syso calls further down the line, the last number outputted should tell you which line of code is slowing/stopping the program.

Offline stuart6854

Junior Devvie


Medals: 2
Exp: 3 years



« Reply #7 - Posted 2015-12-14 00:03:51 »

It gets all the way through a render pass and hits all my sysout's. i put the display updates methods in render function
Offline stuart6854

Junior Devvie


Medals: 2
Exp: 3 years



« Reply #8 - Posted 2015-12-14 09:33:18 »

After having slept to refresh myself, i have tried to find the problem again. Now after piling sysout's into my engine core code after every function and the start and end of a fucntions call, i have found the source which seems to be when glfwSwapBuffers is called. What could be causing this?
Offline stuart6854

Junior Devvie


Medals: 2
Exp: 3 years



« Reply #9 - Posted 2015-12-14 09:56:03 »

Would it be useful toe post the whole project?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline stuart6854

Junior Devvie


Medals: 2
Exp: 3 years



« Reply #10 - Posted 2015-12-14 11:03:44 »

Uploaded Source: https://github.com/stuart6854/Engine_Source

Project starts at "/VoxelGame_BearEngine/src/org/voxelgame/core/Game.java".

From their you should be able to see the paths the programs takes.
Offline stuart6854

Junior Devvie


Medals: 2
Exp: 3 years



« Reply #11 - Posted 2015-12-14 12:28:59 »

Other thought is that it has something to do with a simple cube.obj being rendered with a squashed height as well as texture coords being off: http://puu.sh/lV8k1/f8191546da.png

Gonna see if it could be the objreader...

EDIT: Smiley YES! Looks like i have solved it. The problem was in the ObjLoader i was doing some unneccesarry operations on arrays and lists doing conversions which in a way must have muddled the data.

Gonna keep testing make sure it is fine.

Edit: Although not related to crashes, models are definatlybeing squashed height wise: http://puu.sh/lV97C/c8315194e4.png and also the cube image linked before
Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #12 - Posted 2015-12-14 13:46:19 »

Have you tried resizing the window? Does it remain a fixed size and squish or does it change interactively with the window.

This could be because your main projection matrix has the wrong aspect ratio. Show me where you set up your primary projection matrix

Offline stuart6854

Junior Devvie


Medals: 2
Exp: 3 years



« Reply #13 - Posted 2015-12-14 14:09:26 »

The cube stays squished height wise when resizing window height.

Window.java(where projection is set in init() method)
1  
Projection.updatePerspective(FOV, getWidth() / getHeight(), Z_NEAR, Z_FAR);


Projection.java(Note: Matrix4f class is from JOML Library)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
public class Projection {
   
   public static Matrix4f perspective;
   public static Matrix4f orthogonal;
   
   public static void updatePerspective(float fov, float aspect, float zNear, float zFar){
      Matrix4f matrix = new Matrix4f();

      matrix.identity();
      matrix.perspective(fov, aspect, zNear, zFar);
     
       perspective = matrix;
   }
   
   public static void updateOrthogonal(float left,float right,float bottom,float top,float near,float far){
      Matrix4f matrix = new Matrix4f().identity();

      matrix.m00 = 2/(right - left);
      matrix.m11 = 2/(top - bottom);
      matrix.m22 = -2/(far - near);
      matrix.m32 = (far+near)/(far - near);
      matrix.m30 = (right+left)/(right -left);
      matrix.m31 = (top + bottom)/(top-bottom);

      orthogonal = matrix;
    }
   
}


Then every render iteration projection is sent to shader:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
public void render(Window window, Camera camera, List<GameObject> renderList) {
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);// LEAVE
     
      //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
     
      Matrix4f viewMatrix = MatrixUtils.getViewMatrix(camera);
     
      shaderProgram.bind();
      shaderProgram.setUniform("projectionMatrix", Projection.perspective);
      //shaderProgram.setUniform("camera_pos", camera.getPosition());

      System.out.println("0");
      shaderProgram.setUniform("texture_sampler", 0);
      for(GameObject gameObject : renderList){
         Matrix4f modelViewMatrix = MatrixUtils.getModelViewMatrix(gameObject.getTransform(), viewMatrix);
         shaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
         shaderProgram.setUniform("material", gameObject.getMesh().getMaterial());
         gameObject.getMesh().render();
      }

      System.out.println("6");
      shaderProgram.unbind();
     

      System.out.println("7");
   }
Offline theagentd
« Reply #14 - Posted 2015-12-14 14:17:43 »

getWidth()/getHeight() is done.at integer precision. Cast to float before the division.

Myomyomyo.
Offline stuart6854

Junior Devvie


Medals: 2
Exp: 3 years



« Reply #15 - Posted 2015-12-14 14:32:23 »

getWidth()/getHeight() is done.at integer precision. Cast to float before the division.


That fixed it, thanks.
Pages: [1]
  ignore  |  Print  
 
 

 
Riven (397 views)
2019-09-04 15:33:17

hadezbladez (5280 views)
2018-11-16 13:46:03

hadezbladez (2204 views)
2018-11-16 13:41:33

hadezbladez (5544 views)
2018-11-16 13:35:35

hadezbladez (1150 views)
2018-11-16 13:32:03

EgonOlsen (4584 views)
2018-06-10 19:43:48

EgonOlsen (5462 views)
2018-06-10 19:43:44

EgonOlsen (3119 views)
2018-06-10 19:43:20

DesertCoockie (4015 views)
2018-05-13 18:23:11

nelsongames (4708 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!