// Get texture for what player is holding - we use the TextureManager singleton for thisTextureBuffertexture = TextureManager.getInstance().getTexture(t);GL11.glBindTexture(GL_TEXTURE_2D, texture.textureId);

GL11.glTexCoord2f(0.0f, 0.0f);off_glVertex3f(-0.5f, -0.5f, 0.5f); // Bottom Left Of The Texture and QuadGL11.glTexCoord2f(1.0f, 0.0f);off_glVertex3f( 0.5f, -0.5f, 0.5f); // Bottom Right Of The Texture and QuadGL11.glTexCoord2f(1.0f, 1.0f);off_glVertex3f( 0.5f, 0.5f, 0.5f); // Top Right Of The Texture and QuadGL11.glTexCoord2f(0.0f, 1.0f);off_glVertex3f(-0.5f, 0.5f, 0.5f); // Top Left Of The Texture and Quad// Back FaceGL11.glTexCoord2f(1.0f, 0.0f);off_glVertex3f(-0.5f, -0.5f, -0.5f); // Bottom Right Of The Texture and QuadGL11.glTexCoord2f(1.0f, 1.0f);off_glVertex3f(-0.5f, 0.5f, -0.5f); // Top Right Of The Texture and QuadGL11.glTexCoord2f(0.0f, 1.0f);off_glVertex3f( 0.5f, 0.5f, -0.5f); // Top Left Of The Texture and QuadGL11.glTexCoord2f(0.0f, 0.0f);off_glVertex3f( 0.5f, -0.5f, -0.5f); // Bottom Left Of The Texture and Quad// Top FaceGL11.glTexCoord2f(0.0f, 1.0f);off_glVertex3f(-0.5f, 0.5f, -0.5f); // Top Left Of The Texture and QuadGL11.glTexCoord2f(0.0f, 0.0f);off_glVertex3f(-0.5f, 0.5f, 0.5f); // Bottom Left Of The Texture and QuadGL11.glTexCoord2f(1.0f, 0.0f);off_glVertex3f( 0.5f, 0.5f, 0.5f); // Bottom Right Of The Texture and QuadGL11.glTexCoord2f(1.0f, 1.0f);off_glVertex3f( 0.5f, 0.5f, -0.5f); // Top Right Of The Texture and Quad// Bottom FaceGL11.glTexCoord2f(1.0f, 1.0f);off_glVertex3f(-0.5f, -0.5f, -0.5f); // Top Right Of The Texture and QuadGL11.glTexCoord2f(0.0f, 1.0f);off_glVertex3f( 0.5f, -0.5f, -0.5f); // Top Left Of The Texture and QuadGL11.glTexCoord2f(0.0f, 0.0f);off_glVertex3f( 0.5f, -0.5f, 0.5f); // Bottom Left Of The Texture and QuadGL11.glTexCoord2f(1.0f, 0.0f);off_glVertex3f(-0.5f, -0.5f, 0.5f); // Bottom Right Of The Texture and Quad// Right faceGL11.glTexCoord2f(1.0f, 0.0f);off_glVertex3f( 0.5f, -0.5f, -0.5f); // Bottom Right Of The Texture and QuadGL11.glTexCoord2f(1.0f, 1.0f);off_glVertex3f( 0.5f, 0.5f, -0.5f); // Top Right Of The Texture and QuadGL11.glTexCoord2f(0.0f, 1.0f);off_glVertex3f( 0.5f, 0.5f, 0.5f); // Top Left Of The Texture and QuadGL11.glTexCoord2f(0.0f, 0.0f);off_glVertex3f( 0.5f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad// Left FaceGL11.glTexCoord2f(0.0f, 0.0f);off_glVertex3f(-0.5f, -0.5f, -0.5f); // Bottom Left Of The Texture and QuadGL11.glTexCoord2f(1.0f, 0.0f);off_glVertex3f(-0.5f, -0.5f, 0.5f); // Bottom Right Of The Texture and QuadGL11.glTexCoord2f(1.0f, 1.0f);off_glVertex3f(-0.5f, 0.5f, 0.5f); // Top Right Of The Texture and QuadGL11.glTexCoord2f(0.0f, 1.0f);off_glVertex3f(-0.5f, 0.5f, -0.5f); // Top Left Of The Texture and Quad GL11.glEnd();glColor3f(1,1,1);GL11.glPopMatrix(); }

But I don't know what t is and where it comes from. Maybe this is important.

Anyway, it seems you are binding a texture with every call of renderBlock. This means, every rendered block gets it's own call to bind(). This is a waste of ressources, because bind() is very expensive. When you have a TextureManager, you should use it to bind a texture when it is not currently bound. Like this:

in your code, but there is no transformation. At least I can't find one... Maybe this is a relict of previous versions of your code? But this can also be a source of problems, if your translation isn't done right at other places in your code.Maybe all your blocks are rendered at the same position?

I once had 884 textures with dimensions 20*20 pixel rendered in one frame. Every single one with a call to bind(). And the FPS were down to 7 on my Intel Core i3 M330 with Radeon HD5650. Having many bind() calls is not good.

Yeah I have something similiar to that with my TextureManager, but where does Texture object come from? I'm trying to instantiate one like you but getting an error saying I cannot instantiate this object? Which are you using, the slick util one?

I have to add, that I am confusing a few things here, because I was usually working in 2D environments:At the moment I am not using any batch class for textures. I am manually binding them with my TextureManager.

GL11.glTexCoord2f(0.0f, 0.0f);off_glVertex3f(-0.5f, -0.5f, 0.5f); // Bottom Left Of The Texture and QuadGL11.glTexCoord2f(1.0f, 0.0f);off_glVertex3f( 0.5f, -0.5f, 0.5f); // Bottom Right Of The Texture and QuadGL11.glTexCoord2f(1.0f, 1.0f);off_glVertex3f( 0.5f, 0.5f, 0.5f); // Top Right Of The Texture and QuadGL11.glTexCoord2f(0.0f, 1.0f);off_glVertex3f(-0.5f, 0.5f, 0.5f); // Top Left Of The Texture and Quad// Back FaceGL11.glTexCoord2f(1.0f, 0.0f);off_glVertex3f(-0.5f, -0.5f, -0.5f); // Bottom Right Of The Texture and QuadGL11.glTexCoord2f(1.0f, 1.0f);off_glVertex3f(-0.5f, 0.5f, -0.5f); // Top Right Of The Texture and QuadGL11.glTexCoord2f(0.0f, 1.0f);off_glVertex3f( 0.5f, 0.5f, -0.5f); // Top Left Of The Texture and QuadGL11.glTexCoord2f(0.0f, 0.0f);off_glVertex3f( 0.5f, -0.5f, -0.5f); // Bottom Left Of The Texture and Quad// Top FaceGL11.glTexCoord2f(0.0f, 1.0f);off_glVertex3f(-0.5f, 0.5f, -0.5f); // Top Left Of The Texture and QuadGL11.glTexCoord2f(0.0f, 0.0f);off_glVertex3f(-0.5f, 0.5f, 0.5f); // Bottom Left Of The Texture and QuadGL11.glTexCoord2f(1.0f, 0.0f);off_glVertex3f( 0.5f, 0.5f, 0.5f); // Bottom Right Of The Texture and QuadGL11.glTexCoord2f(1.0f, 1.0f);off_glVertex3f( 0.5f, 0.5f, -0.5f); // Top Right Of The Texture and Quad// Bottom FaceGL11.glTexCoord2f(1.0f, 1.0f);off_glVertex3f(-0.5f, -0.5f, -0.5f); // Top Right Of The Texture and QuadGL11.glTexCoord2f(0.0f, 1.0f);off_glVertex3f( 0.5f, -0.5f, -0.5f); // Top Left Of The Texture and QuadGL11.glTexCoord2f(0.0f, 0.0f);off_glVertex3f( 0.5f, -0.5f, 0.5f); // Bottom Left Of The Texture and QuadGL11.glTexCoord2f(1.0f, 0.0f);off_glVertex3f(-0.5f, -0.5f, 0.5f); // Bottom Right Of The Texture and Quad// Right faceGL11.glTexCoord2f(1.0f, 0.0f);off_glVertex3f( 0.5f, -0.5f, -0.5f); // Bottom Right Of The Texture and QuadGL11.glTexCoord2f(1.0f, 1.0f);off_glVertex3f( 0.5f, 0.5f, -0.5f); // Top Right Of The Texture and QuadGL11.glTexCoord2f(0.0f, 1.0f);off_glVertex3f( 0.5f, 0.5f, 0.5f); // Top Left Of The Texture and QuadGL11.glTexCoord2f(0.0f, 0.0f);off_glVertex3f( 0.5f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad// Left FaceGL11.glTexCoord2f(0.0f, 0.0f);off_glVertex3f(-0.5f, -0.5f, -0.5f); // Bottom Left Of The Texture and QuadGL11.glTexCoord2f(1.0f, 0.0f);off_glVertex3f(-0.5f, -0.5f, 0.5f); // Bottom Right Of The Texture and QuadGL11.glTexCoord2f(1.0f, 1.0f);off_glVertex3f(-0.5f, 0.5f, 0.5f); // Top Right Of The Texture and QuadGL11.glTexCoord2f(0.0f, 1.0f);off_glVertex3f(-0.5f, 0.5f, -0.5f); // Top Left Of The Texture and Quad GL11.glEnd();glColor3f(1,1,1); }

Many thanks for the help, and your raycasting looks cool on picking the blocks. How did you do your collision checks with the blocks? AABB's?

Thanks

I have no collision testing in my released alpha. I am currently fixing some issues with it. Then I will update my thread. But it will be AABB/AABB collision testing.Glad you like the raycasting. I am fascinated by it too. I guess you found the source for it in my thread. It may be helpful.

BTW: In your posted source you are still calling glEnd() after every rendered cube. Doesn't it work without this at this position?

You are making three major mistakes:1. The off_vertex method never get's it's tx/ty/tz values.2. You are not using a single texture for the block textures.3. You are using glBegin/glEnd wrong (Wrong placed).

You mean the glEnd in my createChunkList code? All works with it where it is?

No, like Riven said:

1 2 3 4 5 6 7 8 9 10 11

privatevoidrenderBlock(Block.BlockTypetype) {

GL11.glTexCoord2f(0.0f, 0.0f);off_glVertex3f(-0.5f, -0.5f, 0.5f); // Bottom Left Of The Texture and QuadGL11.glTexCoord2f(1.0f, 0.0f);off_glVertex3f( 0.5f, -0.5f, 0.5f); // Bottom Right Of The Texture and Quad [...]off_glVertex3f(-0.5f, 0.5f, -0.5f); // Top Left Of The Texture and Quad GL11.glEnd(); // this one here ########################glColor3f(1,1,1); }

Quote

Yep, raycasting looks cool, how do you get the direction the player is facing, this somesimple trig?

I have made my own Ray class and it takes an origin of Vector3 and a uniform delta of Vector3. Then the uniform vector gets scaled by scalarProduct.

2. Single texture for the block textures - you mean I'm binding them again?? Or have one big texture which has multiple textures in it?

3. glBegin / glEnd - in my createChunkList method?

I appreciate your advice @Longor1996

1. Where? I can't see any getter/setter that sets the values for the method.2. Yep. Multiple textures in a single Texture. This is the way to go. (Google: Tile Atlas/Map)3. Yep. You are using them wrong. You only need one at the beginning of the nested loop that draws the blocks, and at the end of the nested loop.

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