The GINI the M: Dogs

OK. I have a problem, and I need help. I don’t seem to understand how to write OpenGL code. Here’s what I did (using lwJGL):
a) implemented an interface which offers a storeTexture and a drawSprite method (storeTexture copies a colormap and a normalmap to VRAM in my LWJGL class)
b) write shaders (that part is fun and I think I got it right - except for my previous question, but that’s low priority)
c) I think the storeTexture part is good. But I have problems with the drawSprite method.

Currently this method does the following:
Use my cool shader:
GL20.glUseProgram(BumpmapProgram);
Pump the sampler2d uniforms to the fragment shader:
GL20.glUniform1i(maTextureHandle, spriteTexture[0]);
GL20.glUniform1i(maNormalsHandle, spriteTexture[1]);
Make one Quad into a buffer:
IntBuffer vert=makeBuffer(new int[]{0,0,0,0,spriteDimensions[1],0,spriteDimensions[0],spriteDimensions[1],0,spriteDimensions[0],0,0});
Pump the buffer to VRAM
GL20.glVertexAttribPointer(maPositionHandle, 4, false, false, 3INT_SIZE_BYTES, vert);
Let the shader know that he can count on the vertices:
GL20.glEnableVertexAttribArray(maPositionHandle);
Pump the texture UV thingies to the shader:
GL20.glVertexAttribPointer(maTexturePosHandle, 4, false, false, 3
INT_SIZE_BYTES, vert);
Let the shader know that he can count on the UV coords:
GL20.glEnableVertexAttribArray(maTexturePosHandle);
Now, up to here I think that I’ve got things right. Now I need to pump the index buffers to VRAM. Let’s first reserve a buffer ID:
int primitiveID=GL15.glGenBuffers();
Now create the buffer in normal RAM:
IntBuffer Primitives=makeBuffer(new int[]{0,1,2,3});
Tell my ol’ NVidia to point to that buffer:
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, primitiveID);
…and upload the index data to VRAM:
GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, Primitives, GL15.GL_STREAM_DRAW);
Again, let the GPU know which buffer to work with:
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, primitiveID);
and tell it to draw elements:
GL11.glDrawElements(GL11.GL_QUADS, 4, GL11.GL_INT, 0);

I can explain every line of my code, but still I think it’s amazingly wrong. Assistance would be appreciated a lot!

Cheers, J

I suggest you to post your question in the LWJGL forum with a meaningful title .
First because many people who could help you will not see your message because they might not be interested in your projects or any projects at all.
Second, it will make your question clearly available to all people who might face similar problems, avoiding them to do the same question .



/*  and don't forget to use the code tag */


Ok, I did that, thanks for the hint.
http://www.java-gaming.org/index.php/topic,23813.0.html

Hopefully my question is not too n00bish to answer :-\

You dont really get these problems with Slick… ::slight_smile:

Hehehe. I wouldn’t get this kind of problem with “Greenfoot” either :wink:

I would really like to have full control & / | understanding of how my code works. I will swap to Slick once I understand what it does. But first I have to / want to understand LWJGL.

Sorry, I meant “Let us know whether you have any problem with JOGL 2.0”.

Are you French-speaking?

Anyway I gave you a pointer in another thread…

Thanks to everyone helping me out with LWJGL / openGL. The prerelease can be found as a webstart at
http://www.nope.tv/dogs/LWDogs.jnlp
Still somewhat buggy, but hey. See you in space!

I got this… Not sure if it’s important at all:



JNLP JREDesc in Component ignored: http://lwjgl.org/webstart/2.7.1/extension.jnlp
Shader errors: Vertex shader was successfully compiled to run on hardware.
Shader errors: Fragment shader was successfully compiled to run on hardware.
Program errors:Fragment shader(s) linked, vertex shader(s) linked.
Shader errors: Vertex shader was successfully compiled to run on hardware.
Shader errors: Fragment shader was successfully compiled to run on hardware.
Program errors:Fragment shader(s) linked, vertex shader(s) linked.
Shader errors: Vertex shader was successfully compiled to run on hardware.
Shader errors: Fragment shader was successfully compiled to run on hardware.
Program errors:Fragment shader(s) linked, vertex shader(s) linked.
Shader errors: Vertex shader was successfully compiled to run on hardware.
Shader errors: Fragment shader was successfully compiled to run on hardware.
Program errors:Fragment shader(s) linked, vertex shader(s) linked.
Shader errors: Vertex shader was successfully compiled to run on hardware.
Shader errors: Fragment shader was successfully compiled to run on hardware.
Program errors:Fragment shader(s) linked, vertex shader(s) linked.

It closes sometimes if I wait too long in the title-screen. I also can’t seem to make a new account. Nothing happens when I press OK. :clue:

Hi Mads,
sounds bad. The debug output you attached is not from my game.

But there’s another client. If you start this:
http://www.nope.tv/dogs/LWDogsDebug.jnlp
there will be a window with messages that might help me find your problem…

Tried it. Looks interesting but very buggy still.

First time it crashed when I selected to create account, second time when I started game, third when I was Entering shop, then I gave up. Console froze at first crash and no info on the rest of the crashes. The input was too sluggish to be able to control the ship, and didn’t take my backspace command at all. Probably living too far away from server. What little I saw of the game, it looks like it could be great fun.

Yes. I found a memory-leak. Apparently the GC will not free unused FloatBuffer’s… At least not in every JVM/GC implementation - I (OSX) don’t have that problem… Will repair tonight.

I’ve tried again and couldn’t control the ship very well. :clue: It nearly didn’t respond to keys and the controls were horrible. Very jumpy.
This time I’ve brought a new laptop with a quad-core 2 GHz so I don’t believe the problem is my hardware.

The memory leak thing is not solved yet. Still working on that…

I think that there are still some “lag” issues - eventhough I implemented a compression for my streams and disabled Nagle. I’ll see what I can do about that, after I solved the leak problem…

EDIT: Memory leak is solved now. It seams to be a bad idea to create multiple FloatBuffers every Frame…

This new version does not require a fast CPU anymore. If the game is jumpy, the problem is probably the ping to the server. Sorry 'bout that!