Java-Gaming.org Hi !
Featured games (87)
games approved by the League of Dukes
Games in Showcase (670)
Games in Android Showcase (194)
games submitted by our members
Games in WIP (727)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2 3 4
1  Game Development / Newbie & Debugging Questions / Re: Crash but no crash log! on: 2016-01-26 22:44:41
Try replacing

1  
2  
3  
4  
                glVertexAttribPointer(0, 3, GL_FLOAT, false, 20, 0);
      glVertexAttribPointer(1, 2, GL_FLOAT, false, 20, 12);

      glBindBuffer(GL_ARRAY_BUFFER, this.vbo);


to

1  
2  
3  
                glBindBuffer(GL_ARRAY_BUFFER, this.vbo);
                glVertexAttribPointer(0, 3, GL_FLOAT, false, 20, 0);
      glVertexAttribPointer(1, 2, GL_FLOAT, false, 20, 12);


Not sure if its your issue but it is wrong

Oh my god I think that fixed it! (It isn't rendering right yet but that's gotta be my fault somewhere else in the code). It isn't crashing! Cheesy

Thank you so much!!!
2  Game Development / Newbie & Debugging Questions / Re: Crash but no crash log! on: 2016-01-25 23:43:48
Use break points and step through the code, you will then find what line causes the crash, and you can work it out from there.

It crashes when glDrawArrays is called. But a few draw() calls succeed before it crashes... so... what? Tongue

Really not sure what's going on. Will keep looking but... idk if I'll find it.
3  Game Development / Newbie & Debugging Questions / Crash but no crash log! on: 2016-01-23 22:45:41
So I am at a point where my game simply exits with some strange error code:

1  
Java Result: -1073741819


There is no Java stack trace, no OpenGL error, and no JVM crash log.

Really not sure what to do here. How do I debug this?

I have a rough idea of what code is causing this, but I guess I'm wondering if I can get more information... Otherwise this will be quite difficult to debug.

EDIT: As far as I can tell, calling render() and/or draw() in this class: https://github.com/sci4me/SciCraft/blob/sgl/src/main/java/com/sci/craft/client/render/world/RenderChunk.java causes this to happen.
4  Game Development / Newbie & Debugging Questions / Re: glDrawArrays VM Crash on: 2016-01-23 21:57:38
The bug is exactly here. Smiley
The first argument to that method call should be 1.

You did not specify the vertex pointer for attribute index 1, so you ended up with asking OpenGL to source from an unspecified VBO/buffer for the enabled attribute index 1.

Doh! I'm such an idiot.
Thanks a lot!

EDIT: With the way I'm doing things, do I have to do the glVertexAttribPointer calls every frame or just on init?
5  Game Development / Newbie & Debugging Questions / glDrawArrays VM Crash on: 2016-01-23 21:49:49
I am using LWJGL 3. I am working on replacing all the deprecated GL code I was using with the modern stuff. Shaders and the like.

So I am getting this VM crash when I call glDrawArrays: http://www.java-gaming.org/?action=pastebin&id=1403

As far as I can tell, there is no GL error from glGetError.

Here is the actual call to glDrawArrays: https://github.com/sci4me/SciCraft/blob/sgl/src/main/java/com/sci/craft/client/render/renderer/RenderSkybox.java#L87

I'll keep looking, but so far I haven't really found much. The one hint I found was relating to VAOs. Could they be related to this?
6  Game Development / Newbie & Debugging Questions / Re: Modern OpenGL & Shaders on: 2016-01-23 09:59:18
Alrighty, good to know.
7  Game Development / Newbie & Debugging Questions / Modern OpenGL & Shaders on: 2016-01-23 09:49:15
So, I think I understand how modern GL code is supposed to be written and I want to make sure I'm right.
I am supposed to manage my own matrix/matrices instead of using glXXX (glPush/PopMatrix, glTranslate, glScale, etc.).
Then, I am supposed to use a shader that takes that matrix (and whatever else is needed) to do the rendering.

Am I right so far?

So if I have to manage matrices myself, can I just write my own implementation of glPushMatrix, glPopMatrix, glTranslate, etc. myself? Is this a good idea?
8  Game Development / Newbie & Debugging Questions / Re: Screenshots Stop Working on Window Resize on: 2016-01-23 08:53:20
So after a bit more searching, I found this:

1  
glPixelStorei(GL_PACK_ALIGNMENT, 1);


and that seems to fix it. "prevents the images getting padded when the width multiplied by 3 is not a multiple of 4"

9  Game Development / Newbie & Debugging Questions / Screenshots Stop Working on Window Resize on: 2016-01-23 07:54:51
So I added screenshots to my game. They work great. The problem is, when I change the window size from the default, they stop working. Instead of capturing the scene being rendered, they simply draw all black.

So for example, if I open the game and press the maximize button, the screenshots won't work. But if I then re-press the maximize button to make the window go back to its original size, they start working again!

Here's the code:

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  
29  
30  
31  
32  
33  
34  
35  
36  
37  
private void doTakeScreenshot() {
      final int width = Window.instance().getWidth();
      final int height = Window.instance().getHeight();

      final int pbo = glGenBuffers();

      glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo);
      glBufferData(GL_PIXEL_PACK_BUFFER, width * height * 3, GL_STREAM_READ);
      glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, 0);
     
      final ByteBuffer buffer = glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY, width * height * 3, null);
     
      final int[] pixels = new int[width * height];
      for(int y = height - 1; y >= 0; y--) {
         for(int x = 0; x < width; x++)  {
            pixels[x + y * width] = (0xFF << 24) |
                              ((buffer.get() & 0xFF) << 16) |
                              ((buffer.get() & 0xFF) << 8) |
                              (buffer.get() & 0xFF);
         }
      }
   
      glDeleteBuffers(pbo);

      new Thread() {
         @Override
         public void run() {
            try {
               final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
               image.setRGB(0, 0, width, height, pixels, 0, width);
               ImageIO.write(image, "png", new File("screenshot_" + System.nanoTime() + ".png"));
            } catch(final Throwable t) {
               Log.s("Failed to save screenshot!", t);
            }
         }
      }.start();
   }


When the window is resized, I do glViewport and my projection matrix also ends up getting re-created.

I really don't know what's going on here.
10  Game Development / Newbie & Debugging Questions / Re: Artifact between blocks on: 2016-01-20 22:13:17
That's alright. Thanks for trying.

Honestly, I might just have to declare this as an AMD fail and move on. Maybe at least for now.
11  Game Development / Newbie & Debugging Questions / Re: 3D AABB Collision on: 2016-01-20 22:12:33
Well, I want Minecraft-like collisions.
12  Game Development / Newbie & Debugging Questions / Re: Artifact between blocks on: 2016-01-20 07:56:23
So I tried this:
1  
glDisable(GL13.GL_MULTISAMPLE);


Unless that's the wrong way to do it, it doesn't fix the problem.

Hmmh...
13  Game Development / Newbie & Debugging Questions / 3D AABB Collision on: 2016-01-20 05:57:56
So I am making a cube-based game. I intend all in-world objects to be box-shaped. So, I ought to use AABBs for collision right?

My question is, once I detect a collision, how do I actually respond to it?
14  Game Development / Newbie & Debugging Questions / Re: Artifact between blocks on: 2016-01-20 05:52:05
I am almost certain it's not a rounding error. I am getting the exact same values for all the vertices as far as I can see.

Using GL_LINEAR doesn't help. Not only does it ruin my textures, but it also makes this issue even worse. But it also makes me think that it might be some sort of issue like you have described. I don't know that is's a rounding issue, but... look at this:\

15  Game Development / Newbie & Debugging Questions / Re: Artifact between blocks on: 2016-01-19 01:37:02
I am almost certain this is a texture bug. I really don't see where any floating point error could be getting in there, but then again, I'm no pro.
I am not using mipmapping.

The code is available, if anyone wants to try and look.
Texture atlas: https://github.com/sci4me/SciCraft/blob/master/src/main/java/com/sci/craft/client/texture/BlockTextures.java
Block rendering: https://github.com/sci4me/SciCraft/blob/master/src/main/java/com/sci/craft/client/render/RenderChunk.java

I don't understand how it would be a floating point error if it only happens on the AMD card... but like I said, I am a n00b at rendering.
16  Game Development / Newbie & Debugging Questions / Re: Artifact between blocks on: 2016-01-18 08:05:36
Update: it turns out, this only happens on my laptop. On my desktop it works flawlessly.
I don't know for sure but I THINK my laptop has an AMD card... and my desktop has an NVidia card... so...
17  Game Development / Newbie & Debugging Questions / Artifact between blocks on: 2016-01-18 05:59:50
So I'm rendering blocks next to each other, and I'm getting a strange artifact between the blocks. It started happening when I started using a texture atlas.



Things I've already tried to fix it: using GL_CLAMP, GL_CLAMP_TO_EDGE, and GL_NEAREST for my texture parameters.

Anyone know what's causing this and how to fix it? Or, any guesses?
18  Game Development / Newbie & Debugging Questions / Re: How to rerender a VBO? on: 2016-01-18 02:00:22
Ok and a quick related question: when I want to draw my VBO I am doing glEnableClientState, drawing it, and doing glDisableClientState. Is there any reason to do it this way or can I just do glEnableClientState at the start of my program and leave it enabled?
19  Game Development / Newbie & Debugging Questions / Re: How to rerender a VBO? on: 2016-01-18 01:13:02
I appreciate the tutorials and am sure they'll be helpful, but I still need to know how to rerender a VBO...
20  Game Development / Newbie & Debugging Questions / How to rerender a VBO? on: 2016-01-17 21:06:16
So I'm writing a voxel game. So, if a block changes in a chunk, I need to rerender that chunk's VBO with the new data. How do I do this?
21  Game Development / Newbie & Debugging Questions / Re: Can't get a simple Vertex Array to work! on: 2016-01-17 19:01:46
Oh, I thought the first parameter was the number of vertices. Doh.

EDIT: nevermind it works, I'm just dumb.
22  Game Development / Newbie & Debugging Questions / Can't get a simple Vertex Array to work! on: 2016-01-17 09:32:23
So I have a very simple renderer that uses a display list. I am trying to convert it to use a VBO. The step before a VBO is doing a vertex array (upload every frame). I can not get that to work. I've been trying everything I can think of for like an hour and got nowhere.

Here's the old displaylist code:
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  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
public final class RenderReticle<Void> extends Renderer<Void> {
   public static final RenderReticle INSTANCE = new RenderReticle();
   
   private static final float size = 25f;
   private static final float halfSize = size / 2;
   
   private DisplayList displayList;
   private Texture texture;
   
   private RenderReticle() {
     
   }
   
   @Override
   public void init() {
      this.displayList = new DisplayList();
      this.displayList.startDrawing();
     
      glBegin(GL_QUADS);
      glTexCoord2f(0f, 0f); glVertex2f(0.0f, 0.0f);
      glTexCoord2f(0f, 1f); glVertex2f(0.0f, size);
      glTexCoord2f(1f, 1f); glVertex2f(size, size);
      glTexCoord2f(1f, 0f); glVertex2f(size, 0.0f);
      glEnd();

      this.displayList.stopDrawing();
     
      this.texture = Texture.get("reticle");
   }
   
   @Override
   public void render(final Void object) {
      gluSet2D();
     
      glTranslatef(Window.instance().getWidth() / 2 - halfSize, Window.instance().getHeight() / 2 - halfSize, 0);
     
      this.texture.bind();
      this.displayList.call();
     
      gluSet3D();
   }
}


And here's the new vertex array code:
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  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
public final class RenderReticle<Void> extends Renderer<Void> {
   public static final RenderReticle INSTANCE = new RenderReticle();
   
   private static final float size = 1f;
   private static final float halfSize = size / 2;
   
   private Texture texture;
   
   private FloatBuffer vBuffer;
   private FloatBuffer tBuffer;

   private RenderReticle() {
     
   }
   
   @Override
   public void init() {
      this.vBuffer = BufferUtils.createFloatBuffer(8);
      this.vBuffer.put(0).put(0);
      this.vBuffer.put(0).put(size);
      this.vBuffer.put(size).put(size);
      this.vBuffer.put(size).put(0);
      this.vBuffer.flip();
     
      this.tBuffer = BufferUtils.createFloatBuffer(8);
      this.tBuffer.put(0).put(0);
      this.tBuffer.put(0).put(1);
      this.tBuffer.put(1).put(1);
      this.tBuffer.put(1).put(0);
      this.tBuffer.flip();
     
      this.texture = Texture.get("reticle");
   }
   
   @Override
   public void render(final Void object) {
      gluSet2D();
     
      glTranslatef(Window.instance().getWidth() / 2 - halfSize, Window.instance().getHeight() / 2 - halfSize, 0);
     
      this.texture.bind();

      glEnableClientState(GL_VERTEX_ARRAY);
      glEnableClientState(GL_TEXTURE_COORD_ARRAY);
   
      glVertexPointer(4, GL_FLOAT, 2 << 2, this.vBuffer);
      glTexCoordPointer(4, GL_FLOAT, 2 << 2, this.tBuffer);
      glDrawArrays(GL_QUADS, 0, 4);
     
      glDisableClientState(GL_VERTEX_ARRAY);
      glDisableClientState(GL_TEXTURE_COORD_ARRAY);
     
      gluSet3D();
   }
}


"gluSet2D" and "gluSet3D" are functions I wrote. They basically just do glOrtho and the perspective matrix respectively.

So, how come the first one works but the second one doesn't? (It just displays nothing on the screen).
23  Game Development / Newbie & Debugging Questions / Re: What type of rendering should I use? on: 2016-01-17 05:20:42
Okay so, even if I want the simple functionality like I mentioned, I should use a shader of my own?
24  Game Development / Newbie & Debugging Questions / Re: What type of rendering should I use? on: 2016-01-17 03:51:50
Why are shaders preferred? I mean, at the moment I have no desire for any fancy rendering. I just want to draw some geometry with textures.
25  Game Development / Newbie & Debugging Questions / What type of rendering should I use? on: 2016-01-17 02:55:36
By type, I mean immediate mode vs display lists vs VBOs vs whatever else there is.

I am trying to get an intuition for what I should be doing and when.

So, for example, what if I am trying to render a reticle on my screen. That will NEVER change EVER. How should I render it?
Another example: I'm making a voxel game. Blocks change relative infrequently (in the scope of computer speeds...) so how should I render those? I know Minecraft has been using display lists (and recently added VBO support).

So what type of rendering should I use? Are there times where I should use different types of rendering?
26  Game Development / Newbie & Debugging Questions / Should I use LWJGL 2 or 3? on: 2016-01-16 02:47:10
Unless there's any problem with LWJGL 3, the only reason I can think of to use LWJGL 2 would be that it has a lot more resources available for it... but that may not be such an issue really.

So should I use LWJGL 2 or 3 for my new game?
27  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 07:03:04
Best I have: it seems removing the if(value != 0) allows removal of zeroing as well.
Reaches the same fixpoint in my random board test at least, so it appears valid, and is about 1.75x faster than with fill().

I'm done for the night.

Cool cool. Thanks a lot for the help! This has been fun.
28  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 06:57:47
Does this help?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
private static void fill(final byte[] array, final byte value)
        {
            final int len = array.length;

            if (len > 0)
                array[0] = value;

            for (int i = 1; i < len; i += i)
            {
                System.arraycopy(array, 0, array, i, ((len - i) < i) ? (len - i) : i);
            }
        }


Doesn't seem to make much difference for me... er... maybe it's a bit slower actually... probably due to the JNI calls from arraycopy...

Anyway, I found that online and thought I would give it a shot...
29  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 06:47:09
I figured it out too, but fill() slows it down a good bit, trying to find a better way.

What about that memory usage though? Can't go around churning >1Gb heaps for no reason.  Pointing

This is true...

So we've made little progress overall really... I mean, better memory use is good but it's basically the same speed still Tongue

Progress is progress I suppose.
30  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 06:38:54
I figured it out.

you can't do this:

1  
newGrid[idx] = 0;


in the loop. I put Arrays.fill and it works.

BUT: 512x512? pfft. Try 1600x900!

At that size, this doesn't seem much different than my original code...

EDIT: with a little testing, comparing your code to mine, with a grid size of 2000x2000, it seems that they perform NEARLY the same..
Pages: [1] 2 3 4
 
IanParcs (36 views)
2016-04-18 14:18:53

KaiHH (36 views)
2016-04-18 08:35:41

KaiHH (67 views)
2016-04-15 12:43:58

theagentd (68 views)
2016-04-14 02:16:17

theagentd (76 views)
2016-04-14 02:15:43

IanParcs (92 views)
2016-04-12 03:51:16

IanParcs (37 views)
2016-04-12 03:50:03

IanParcs (33 views)
2016-04-12 03:49:54

IanParcs (30 views)
2016-04-12 03:49:52

IanParcs (39 views)
2016-04-12 03:49:52
Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17

List of Learning Resources
by SilverTiger
2016-02-05 09:39:47

List of Learning Resources
by SilverTiger
2016-02-05 09:38:38

List of Learning Resources
by SilverTiger
2016-02-05 09:35:50

Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30
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!