I have been trying to incorporate NeHe’s texture mapping code into some old code of mine that uses fltk for windowing instead of the one NeHe uses (GLUT? I forget). Anyway, I am trying to compile in MS Visual C++ and I am getting this error:
: excube\graphics.cxx(91) : error C2065: ‘texture’ : undeclared identifier
c: excube\graphics.cxx(94) : error C2109: subscript requires array or pointer type
Here are the two lines that it is complaining about:
glGenTextures(1, texture); //line 91 - Create The Texture
glBindTexture(GL_TEXTURE_2D, texture); //line 94
I declare my texture variable in my graphics.h file as public with this line:
And initialize the memory like this in the init part of my graphics.cxx file:
texture = new GLuint;
I am using the same functions from NeHe’s example to load the bmp, except I have changed where my bmp is located.
Why is the variable ‘texture’ causing these errors?
Thanks in advance,
The errors indicate that you are using the texture variable outside of the scope in which it was declared. Without more details of how your code is arranged, I can’t help you much.
You said you declare texture as public. That infers that it is part of a class? Is the function you try to use it part of the same class? Is it a non-static method?
Basically, what is the scope of the variable, and what is the scope of the method in which you try to use that variable.
[This message has been edited by Deiussum (edited 10-28-2003).]
I have included the functions that load the bmp file in the graphics.h file, but I am not sure if I actually declared the functions as belonging to the class. I dont have access to the code right now, I’ll check up on it later tonight…
Ah hah! You were right. I did not make the functions I added part of my class. So, it looks like this thing will compile, except I am getting a weird MS Visual C++ error upon trying to compile:
LINK : warning LNK4098: defaultlib “MSVCRTD” conflicts with use of other libs; use /NODEFAULTLIB:library
graphics.obj : error LNK2001: unresolved external symbol _auxDIBImageLoadA@4
Debug/startup.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
I know this isnt really an OpenGL question, but I would appreciate some help on resolving this one.
That’s a linker error indicating you didn’t include the library which contains the code for auxDIBImageLoad. If you are using VC++, go to the project settings, then to the linker settings, and add glaux32.lib as one of the libraries.
looks like I don’t have glaux on my computer. I did a search for glaux.dll, glaux.h and glaux32.lib with no results. I have read that glaux is obsolete and I should use glu or glut instead. Does anyone know where I cant find good tutorials for using this method?
Thanks for your help so far guys, I really appreciate it!
You likely won’t find a glaux.dll on your system. It comes with VC++ as a static library, not as a dynamically-linked library.
You are correct that glaux is an outdated library. If you were using it for windowing functions, I’d recommend something like glut. glut doesn’t have any image loading routines, however, and it appears that is what you were using glaux for. There are a number of different libraries available for loading images. I can’t really recommend any because I usually use my own TGA loading code and haven’t used any of them.