Sign in to follow this  
obi-wan shinobi

Problem with SDL.NET 6.1 and glGenTextures

Recommended Posts

Using SDL.NET's OpenGL functions, I try to generate several textures like this:
int[] textures = new int[5];    //array space for five unique textures
Gl.glGenTextures(5, textures);  //attempt to generate 5 texture names
foreach(int i in textures)
    Console.WriteLine(i);       //print out the integers

The problem here is that when I print out the integers, they are all the same number and it becomes impossible to use more than one texture at a time without constant overwriting and the performance loss that causes. In SDL.NET, the output would be 0 0 0 0 0, whereas in Pygame or SDL, it would be 0 1 2 3 4. Even using the overloaded version of glGenTextures that takes an IntPtr type instead of int[], the only output given is 0. What could be causing this?

Share this post


Link to post
Share on other sites
I didn't think I'd have to explicitly create an OpenGL context -- doesn't the SetVideoMode constuctor do that automatically when the opengl argument is set to true?. Besides, as my code is now, everything in GL works (that is: glBegin, glEnd, glVertex, glTexCoord, etc). The problem here is that I only get one texture name when there should be more. Similar code in either SDL or Pygame produces the correct effect so I don't know why it does something else with SDL.NET in use. As far as I can tell from cs-sdl.sourceforge.net, there's no bug report on it.

Share this post


Link to post
Share on other sites
Kambiz    758
Do you call SetVideoMode before glGenTextures? Also is your application multithreaded?
Do you have a minimal program that demonstrated the problem?

Share this post


Link to post
Share on other sites
All calls to OpenGL come after SetVideoMode returns the video surface. The code itself is mostly taken from the NeHe texture loading code that comes with the SDL.NET SDK (tutorial #6 or 8). The application currently only uses one thread and I've never even considered multithreading.

Share this post


Link to post
Share on other sites
Apparently, the GL calls were going before SetVideoMode was called...using static classes means the objects were being created when the first function of the static class was called rather than at some earlier time as I had thought. The problem was really that I didn't know how static classes work compared to non-static classes (and that it's just being brought up now). Thanks for helping!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this