LWJGL glCallLists OpenGL error 1282?

Hey guys! So, basically when I call glCallLists and pass my IntBuffer of lists to render, it gives OpenGL error 1282… and I can’t figure out why. I am fairly certain that this is a texture issue… I am using slick 2d’s texture loader. If I remove the Util.checkGLError(), I can get it to render, but the textures aren’t correct… which is the main reason I think it’s a texture issue… any ideas? I know that I am not calling any glBegin()/glEnd() pairs during the glCallLists… so… don’t know what else it could be.

You need to remove any translate/scale/rotate functions out of between your glCreateList and glEndList

But… how could that work… how can the blocks be at the right position in the list…

Call translate after your display lists are generated. You’re not going to get around it, so just do it. Display lists only allow certain functions to be called when creating a new list. glTranslate is not one of them. So, loop through all your objects and call glTranslate on them in between glPushMatrix and glPopMatrix calls to preserve the matrices.

I still don’t understand how to do that…


GL11.glNewList(listID, GL11.GL_COMPILE);
		for(int xx = x; xx < x + 16; xx++)
		{
			for(int yy = y; yy < y + 256; yy++)
			{
				for(int zz = z; zz < z + 16; zz++)
				{
					cube(xx * 2, yy * 2, zz * 2);
				}
			}
		}
		GL11.glEndList();

in the cube method, i do translations and drawing… so… I don’t see how that could be done outside of the list…

Like I said, after you create the list, loop through your objects and translate them to the correct position. Since you seem to be creating a voxel engine, I would recommend not using glTranslate for translating your geometry, its a terrible resource hog. In your cube method, for your glVertexCalls, just use the coordinates you want to render the cubes at, don’t use glTranslate. Your code seems like it would be fine without glTranslate though.

hmm… that will be a lot of changing but that will work. :stuck_out_tongue: didnt think of that… thx, ill try.

I removed the translates but I still get the error… check the cube method?


private void cube(int x, int y, int z)
	{
		Block b = Block.blockList[blocks[(x / 2) - this.x][(y / 2) - this.y][(z / 2) - this.z]];
		if(b == null)
			return;

		GL11.glBegin(GL11.GL_QUADS);
		{
			Texture t = b.getTexture(Side.TOP);
			if(t != null)
				t.bind();
			else
				GL11.glColor3f(1, 1, 1);
			GL11.glTexCoord2f(0, 0);
			GL11.glVertex3f(1+x, 1+y, -1+z);
			GL11.glTexCoord2f(1, 0);
			GL11.glVertex3f(-1+x, 1+y, -1+z);
			GL11.glTexCoord2f(1, 1);
			GL11.glVertex3f(-1+x, 1+y, 1+z);
			GL11.glTexCoord2f(0, 1);
			GL11.glVertex3f(1+x, 1+y, 1+z);

			t = b.getTexture(Side.BOTTOM);
			if(t != null)
				t.bind();
			else
				GL11.glColor3f(1, 1, 1);
			GL11.glTexCoord2f(0, 0);
			GL11.glVertex3f(1+x, -1+y, 1+z);
			GL11.glTexCoord2f(1, 0);
			GL11.glVertex3f(-1+x, -1+y, 1+z);
			GL11.glTexCoord2f(1, 1);
			GL11.glVertex3f(-1+x, -1+y, -1+z);
			GL11.glTexCoord2f(0, 1);
			GL11.glVertex3f(1+x, -1+y, -1+z);

			t = b.getTexture(Side.NORTH);
			if(t != null)
				t.bind();
			else
				GL11.glColor3f(1, 1, 1);
			GL11.glTexCoord2f(0, 0);
			GL11.glVertex3f(1+x, 1+y, 1+z);
			GL11.glTexCoord2f(1, 0);
			GL11.glVertex3f(-1+x, 1+y, 1+z);
			GL11.glTexCoord2f(1, 1);
			GL11.glVertex3f(-1+x, -1+y, 1+z);
			GL11.glTexCoord2f(0, 1);
			GL11.glVertex3f(1+x, -1+y, 1+z);

			t = b.getTexture(Side.SOUTH);
			if(t != null)
				t.bind();
			else
				GL11.glColor3f(1, 1, 1);
			GL11.glTexCoord2f(1, 1);
			GL11.glVertex3f(1+x, -1+y, -1+z);
			GL11.glTexCoord2f(0, 1);
			GL11.glVertex3f(-1+x, -1+y, -1+z);
			GL11.glTexCoord2f(0, 0);
			GL11.glVertex3f(-1+x, 1+y, -1+z);
			GL11.glTexCoord2f(1, 0);
			GL11.glVertex3f(1+x, 1+y, -1+z);

			t = b.getTexture(Side.EAST);
			if(t != null)
				t.bind();
			else
				GL11.glColor3f(1, 1, 1);
			GL11.glTexCoord2f(0, 0);
			GL11.glVertex3f(-1+x, 1+y, 1+z);
			GL11.glTexCoord2f(1, 0);
			GL11.glVertex3f(-1+x, 1+y, -1+z);
			GL11.glTexCoord2f(1, 1);
			GL11.glVertex3f(-1+x, -1+y, -1+z);
			GL11.glTexCoord2f(0, 1);
			GL11.glVertex3f(-1+x, -1+y, 1+z);

			t = b.getTexture(Side.WEST);
			if(t != null)
				t.bind();
			else
				GL11.glColor3f(1, 1, 1);
			GL11.glTexCoord2f(0, 0);
			GL11.glVertex3f(1+x, 1+y, -1+z);
			GL11.glTexCoord2f(1, 0);
			GL11.glVertex3f(1+x, 1+y, 1+z);
			GL11.glTexCoord2f(1, 1);
			GL11.glVertex3f(1+x, -1+y, 1+z);
			GL11.glTexCoord2f(0, 1);
			GL11.glVertex3f(1+x, -1+y, -1+z);
		}
		GL11.glEnd();
	}

You can’t bind textures whilst creating a display list I believe either. It also will destroy your FPS for very technical reasons. Try removing the bind calls. When you need to render your textures, use a sprite sheet and store your texture coordinates in your block class. Each block type will have different coordinates. Bind the spritesheet right before you render your display list. Trust me, it’ll be ridiculously faster than what you’re doing now.

Okay, how do I do the coordinates? Still haven’t figured that out…

Okay, I got it working… but my textures are 16x16 and i have it in a 512x512 sheet, so i use 0.03125 for my tex coords, but that doesnt correctly line up… its VERY close… but its a tiny bit off, and i cant seem to make it any better… ideas?

See how they dont line up? Hmm…

You can bind textures and use glTranslate/glRotate/glScale while creating display lists without problems, but binding textures inside display list is rather bad practice. :slight_smile:

I removed all those… the issue is now with my texture coords or the sprite sheet…