Sign in to follow this  

glGenTextures prob

This topic is 4108 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm following nehe's tutorial on scisors test, found here: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=24 I changed the code for loadTga, and buildFont slightly so that it can fit into my framework. But the meat and potatoes is the same. In the function loadTGA, I think I'm having problems here: glGenTextures(1, &texture[0].texID); I don't think texID is being set properly. If I do this: GLuint i = 7; glGenTextures(1,&i); printf("I is: %d\n",i); // i is 7 it doesn't seem to be generating texture numbers. It keeps the one that I passed. Basically, the end result is that I can't see the writing on the screen. thanks P.S. I'm running Fedora Core 5, using glut and mesa drivers.

Share this post


Link to post
Share on other sites
Your code is correct, opengl should assign a free texture id to variable i.
Did you try to set i to another value (i.e. 4711) before doing the call to glGenTextures() ?
Which version of opengl do you use (must be >= 1.1).
Did you check the error state of opengl ?

[Edited by - nmi on September 18, 2006 2:07:07 AM]

Share this post


Link to post
Share on other sites
"Did you try to set i to another value (i.e. 4711) before doing the call to glGenTextures() ?"

Yeah. It just keeps the whatever value it had before the call to glGenTextures().

" Try some debuging; call glGetError() before and after the glGenTextures() call. What codes are returned?"

I have. They return no error.

' Do you have a valid OpenGL context before calling glGenTextures?"

I don't know what you mean by this. Before following the scissor tutorial, I was able to display a rotating box on screen.


AFAIK, that could be the normal behavior of glGenTexture (to keep whatever number you called it with, if it's not taken). I'm can't get the font to display, so I'm looking for the source of the problem

Share this post


Link to post
Share on other sites
Quote:
Original post by supervlad
"Do you have a valid OpenGL context before calling glGenTextures?"

I don't know what you mean by this. Before following the scissor tutorial, I was able to display a rotating box on screen.


An OpenGL context is created when you create an OpenGL enabled window, and is used to store the OpenGL state. What toolkit are you using to create your window (e.g. glut, SDL)?

Share this post


Link to post
Share on other sites
Quote:
Original post by supervlad
AFAIK, that could be the normal behavior of glGenTexture (to keep whatever number you called it with, if it's not taken). I'm can't get the font to display, so I'm looking for the source of the problem


Call it twice with the same number. Then second call has to change the value you passed in.

Call it so that it generates more than one id and check the result.

Share this post


Link to post
Share on other sites
glut. Like I mentioned. I was able to have a rotating cube on screen before. So I believe that I do have an OpenGL rendering context.

I don't know if you guys have seen nehe's tutorial on scissors, at:
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=24

What could be other reasons why the text is not displaying on screen, assuming the texture was loaded, and the font built from it. Maybe something with the matrix positions?

Share this post


Link to post
Share on other sites
Quote:
Original post by supervlad
glut. Like I mentioned. I was able to have a rotating cube on screen before. So I believe that I do have an OpenGL rendering context.


You have a rendering context when you are rendering but do you have one when you call glGenTextures? i.e., is your call to glGenTextures after your call to glutCreateWindow?

Share this post


Link to post
Share on other sites
Awesome!

bakery2k1, it was as you predicted. I was trying to bind the textures before having a rendering context. I changed it and then called glGenTexture twice with the same number, like nmi said. I noticed that OpenGL was returning 1 now. I changed the text coords, and It works!

thanks, guys.

I'm gonna be spending alot more time in these forums.

Share this post


Link to post
Share on other sites

This topic is 4108 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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