Skip to main content
GameDev.net gamedev.net
🔒 Locked

Creating GLSL objects fails

Started by Koetje Sep 3, 2007 at 3:10 AM 4 replies 1k views
Original Post
Koetje
Koetje
Hey there, When I wanted to pick up a sleeping project I ran into some problems. I'm making a simple multithreaded engine in C# using Tao for the OpenGL magic. The development PC runs Ubuntu with up to date NVIDIA drivers supporting Opengl2.0 etcetera. Loading the extensions also works, using:

if(GlExtensionLoader.IsExtensionSupported("GL_VERSION_2_0"))
			{
				System.Console.WriteLine("\tOpenGL 2.0");
				GlExtensionLoader.LoadExtension("GL_VERSION_2_0");
			}
			else
				throw new System.NotSupportedException("No opengl 2.0 support");
This shows the message I would like to see, namely "OpenGL 2.0" If everything is initialized the render thread starts its draw main loop, which calls a particle emitter, which checks if it has an initialized shader and if not, tries to make a shader object:

			program = Gl.glCreateProgram();
			
			if(program == 0)
				throw new System.NotSupportedException("Seems like shaders are not supported, failed creating shader program ("+Gl.glGetError()+")");
And this Exception does get thrown and if I switch some orders so glCreateShader is called first, that also failed. Things I've checked: - The same problem occurs if I use the ARB variant - This code is run in the renderer thread - I'm pretty sure opengl has initialized correctly, IE, I already see a window popping up and if I disable the exceptions the program runs but without the shaders. Any ideas I could try?
Lord_Evil
Lord_Evil
Sure you have the OpenGL context ready before calling glCreateProgram ?
If the context is set up later on the program might work but without the shader.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
Koetje
Koetje
Yeah, pretty sure. Anything I can query to see if it is ready? Basicly the threads wait on each other to initialize before really starting their main loops.

			Init();						System.Console.WriteLine("Waiting for gameobject...");						while(GameObject.initialized == false)				;			System.Console.WriteLine("All systems online!");			while(isRunning)			{


etcetera

Lord_Evil
Lord_Evil
Well I don't know Tao but you might try and load the shader after the window is initialized (and visible?). The context might not be created until then.

Or are you able to load some other data to OpenGL like vertices, textures etc. before creating the program?
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
Koetje
Koetje
I am able to run this code:

			Gl.glBegin(Gl.GL_QUADS);			Gl.glTexCoord2f(0.0f,0.0f);			Gl.glVertex3f(0.0f, 1.0f, 0.0f);			Gl.glTexCoord2f(0.0f,1.0f);			Gl.glVertex3f(1.0f, 1.0f, 0.0f);			Gl.glTexCoord2f(1.0f,1.0f);			Gl.glVertex3f(1.0f, 0.0f, 0.0f);			Gl.glTexCoord2f(1.0f,0.0f);			Gl.glVertex3f(0.0f, 0.0f, 0.0f);			Gl.glEnd();	


Atleast, it doesn't crash. If I put this in one of the other threads a crash occurs.

And the window is visible before I try to create the shader
Lord_Evil
Lord_Evil
Do you create the shader before you execute that code?

Is that code in a loop and always executed? If it is in a loop it might work after the context is available but fail before and you might not even notice that. Query OpenGL for errors after calling the draw code and write some message to the console if there's an error. This way you'll be able to see if the draw code runs into some errors at startup.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.