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

glGenTextures prob

Started by supervlad Sep 18, 2006 at 1:12 AM 9 replies 1.4k views
Original Post
supervlad
supervlad
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.
supervlad
supervlad
I'm passing the address of the int purposedly.
nmi
nmi
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]
Kalasjniekof
Kalasjniekof
Try some debuging; call glGetError() before and after the glGenTextures() call. What codes are returned?
bakery2k1
bakery2k1
Do you have a valid OpenGL context before calling glGenTextures?
supervlad
supervlad
"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
bakery2k1
bakery2k1
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)?
nmi
nmi
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.
supervlad
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.

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?
bakery2k1
bakery2k1
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?
supervlad
supervlad
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.

Topic Locked

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

Sign in to reply to this topic.