Show Posts
|
Pages: [1] 2 3 4
|
2
|
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!  Thank you so much!!!
|
|
|
3
|
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?  Really not sure what's going on. Will keep looking but... idk if I'll find it.
|
|
|
5
|
Game Development / Newbie & Debugging Questions / Re: glDrawArrays VM Crash
|
on: 2016-01-23 21:57:38
|
The bug is exactly here.  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?
|
|
|
8
|
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?
|
|
|
10
|
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.
|
|
|
15
|
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:\ 
|
|
|
18
|
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?
|
|
|
19
|
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?
|
|
|
23
|
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).
|
|
|
26
|
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?
|
|
|
28
|
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.
|
|
|
29
|
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...
|
|
|
30
|
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.  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  Progress is progress I suppose.
|
|
|
|
|
nelsongames
(19 views)
2018-04-24 18:15:36
nelsongames
(17 views)
2018-04-24 18:14:32
ivj94
(608 views)
2018-03-24 14:47:39
ivj94
(53 views)
2018-03-24 14:46:31
ivj94
(401 views)
2018-03-24 14:43:53
Solater
(66 views)
2018-03-17 05:04:08
nelsongames
(111 views)
2018-03-05 17:56:34
Gornova
(176 views)
2018-03-02 22:15:33
buddyBro
(747 views)
2018-02-28 16:59:18
buddyBro
(94 views)
2018-02-28 16:45:17
|
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
|
|