GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D, o); not working?

Started by lainmaster, March 10, 2010, 05:27:57

Previous topic - Next topic

lainmaster

GL11.glBindTexture(GL11.GL_TEXTURE_2D, 30); // testing line

IntBuffer o = ByteBuffer.allocateDirect(64).order(ByteOrder.nativeOrder()).asIntBuffer();
GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D, o);
int iBoundTexture = o.get();
System.out.println("tex " + iBoundTexture);


Always outputs 0 (zero).
Also outputs 0 without the testing line (should be another texture bound)

is GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D, o); not working, or am I doing anything wrong?

BTW it's lwjgl 2.3 Windows 7 64 bits if it matters

Matthias

Why do you ask OpenGL for things you set a few lines ago? You should just remember which texture you have bound - esp since glGet* can force synchronization which will hurt performance when you have a multithreaded OpenGL driver.

lainmaster

Well I guess the question has become irrelevant now, since it's rather easy and faster to keep track of the bound texture.

The real matter was to check whether or not my method was inside a glBegin-glEnd block, but that, too, won't matter anymore.

Still, the method is there, so it should work.

Kai

QuoteStill, the method is there, so it should work.

The method sure works, but not inside a glBegin/glEnd-Block (if you were trying that), as stated by the specification, which also makes no sense since you cannot change state in a glBegin/glEnd-Block.

QuoteGL_INVALID_OPERATION is generated if glGet is executed between the execution of glBegin and the corresponding execution of glEnd.

lainmaster

Quote from: Kai on March 10, 2010, 20:12:44
QuoteStill, the method is there, so it should work.

The method sure works, but not inside a glBegin/glEnd-Block (if you were trying that), as stated by the specification, which also makes no sense since you cannot change state in a glBegin/glEnd-Block.

QuoteGL_INVALID_OPERATION is generated if glGet is executed between the execution of glBegin and the corresponding execution of glEnd.


Thanks, I had been searching for that but could not find.