Sending Textures to Fragment Shaders - solved

Started by Super_Llama, June 08, 2010, 23:47:10

Previous topic - Next topic

Ciardhubh

Yea ... that 4 was probably ok *cough*

Do you have a Vertex shader (not sure if one is mandatory if you have a fragment program)? Do you set gl_TexCoord[0] = gl_MultiTexCoord0; in it to pass it to the fragment shader?

Do you still get exceptions with the debug build? Can't really see something right now - guess it's late - without running it myself.

Super_Llama

The texture coordinates are being accessed perfectly, I can pass UVW as RGB and it renders as expected. I'm not using a vertex shader since the default one (or lack thereof) is sufficient for what I"m trying to do. The only problem is that it's not sending the buffer. I might try using a FloatBuffer instead. And yes, the debug build is still pumping out exceptions regarding MatrixMode, which is weird because there's nothing wrong with the matrices.

Ciardhubh

Well, an exception means something's wrong. I'd say, find the call responsible and check the OpenGL spec (http://www.opengl.org/sdk/docs/man/) for cases in which this error is thrown.

Super_Llama

I'm fixing them one by one-- seems like all of them are in the matrix code I copy-pasted from a sample, rofl. I'll post back if I find the culprit, or if the error river runs dry...

EDIT: I found it!
Exception in thread "AWT-EventQueue-2" org.lwjgl.opengl.OpenGLException: Invalid operation (1282)
	at org.lwjgl.opengl.Util.checkGLError(Util.java:56)
	at org.lwjgl.opengl.ARBShaderObjects.glUniform1iARB(ARBShaderObjects.java:231)


Unfortunately I have no idea how to fix it, since I'm doing exactly what Matthias said on page 1... it seems to think that a Uniform1i can't be used to set a sampler2D.

EDIT 2:
Quote
GL_INVALID_OPERATION is generated if a   sampler is loaded using a command other than glUniform1i and glUniform1iv.
I wonder if glUniform1iARB is different than glUniform1i...? I guess I'll try iv...

Ciardhubh

Invalid operation is also thrown if:
GL_INVALID_OPERATION is generated if glUniform is executed between the execution of glBegin and the corresponding execution of glEnd. (called between begin and end?)
GL_INVALID_OPERATION is generated if there is no current program object. (no call to glUseProgram?)
GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1. (did glGetUniformLocation run ok?)

Super_Llama

Quote from: Ciardhubh on June 11, 2010, 06:58:30
GL_INVALID_OPERATION is generated if there is no current program object. (no call to glUseProgram?)
That's what it was. I reordered the calls and the exception went away, but the quad still renders without a texture >_<

EDIT:
The river of errors has run dry, and there's still no solution... linking to debug makes absolutely no difference now, and the quad still shows up black. I tried using a FloatBuffer instead of a ByteBuffer and it didn't help.

EDIT 2: Still waiting for help, changed title to make sure people notice :-\

Rene

The default OpenGL minification filter uses mipmaps. You can easily generate mipmaps with
EXTFramebufferObject.glGenerateMipmapEXT(GL11.GL_TEXTURE_2D);


Or change the minification filter, depending on your needs.
When I am king, they shall not have bread and shelter only, but also teachings out of books, for a full belly is little worth where the mind is starved - Mark Twain

Super_Llama

I had a hunch that it had something to do with mipmaps, but I didn't know where to start. Thanks for the advice, I really hope this works!

EDIT: YES!!! IT WORKED! Thanks a lot, I was just about ready to give up. I'd +rep if the forum had such a feature :P