PDA

View Full Version : why my little program of mipmapping don't work (a strange error)



airseb
05-08-2003, 06:54 AM
i have this at the compilation :
--------------------Configuration: premiere_texture - Win32 Debug--------------------
Compiling...
premiere_texture.cpp
D:\programmation\[Mes programmes Open GL]\premiere_texture.cpp(19) : error C2065: 'GL_TEXTURE_BASE_LEVEL' : undeclared identifier
D:\programmation\[Mes programmes Open GL]\premiere_texture.cpp(20) : error C2065: 'GL_TEXTURE_MAX_LEVEL' : undeclared identifier
Error executing cl.exe.

premiere_texture.exe - 2 error(s), 0 warning(s)
what do i have forgotten ?
my headers are :
#include <gl\GLAUX.h>
#include <gl\glut.h>
#include <gl\gl.h>
can you tell me too if my program is correct ? because it don't displays the textures of mipmap.:-/



void init ()
{
AUX_RGBImageRec *texture1;
texture1 = auxDIBImageLoad("herbe256.bmp");
AUX_RGBImageRec *texture2;
texture2 = auxDIBImageLoad("bois.bmp");
glGenTextures (1, texname) ;
glBindTexture (GL_TEXTURE_2D, texname[0]) ;
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);

glTexImage2D(GL_TEXTURE_2D, 0, 3, (texture1)->sizeX, (texture1)->sizeY,
0, GL_RGB, GL_UNSIGNED_BYTE, (texture1)->data);
glTexImage2D(GL_TEXTURE_2D, 1, 3, (texture2)->sizeX, (texture2)->sizeY,
0, GL_RGB, GL_UNSIGNED_BYTE, (texture2)->data);
glEnable(GL_TEXTURE_2D) ;
}




[This message has been edited by airseb (edited 05-08-2003).]

[This message has been edited by airseb (edited 05-08-2003).]

Vlasko
05-08-2003, 08:27 AM
I looked into MSDN for glTexParameteri and it doesn't use GL_TEXTURE_BASE_LEVEL and GL_TEXTURE_MAX_LEVEL.Are you sure that those are what you want to use in glTexParameteri?

airseb
05-08-2003, 08:31 AM
yes i have seen it in a version of the redbook in french...
it's strange !
otherwise can you tell me what's wrong with the function above ? (it doen't display the textures)

[This message has been edited by airseb (edited 05-08-2003).]

Brian Jones
05-08-2003, 08:31 AM
You need the glext.h header to use GL_TEXTURE_MIN/MAX_LEVEL since it is a part of the OpenGL 1.2 spec. Not 1.1 which you're using. You can get it here: http://oss.sgi.com/projects/ogl-sample/ABI/glext.h

airseb
05-08-2003, 08:32 AM
Originally posted by Brian Jones:
You need the glext.h header to use GL_TEXTURE_MIN/MAX_LEVEL since it is a part of the OpenGL 1.2 spec. Not 1.1 which you're using. You can get it here: http://oss.sgi.com/projects/ogl-sample/ABI/glext.h


thanks, but how can i be sure of working with open gl 1.2 ?


[This message has been edited by airseb (edited 05-08-2003).]

[This message has been edited by airseb (edited 05-08-2003).]

Brian Jones
05-08-2003, 08:33 AM
Also, you might want wglext.h for the Microsoft Windows windowing extension system.

Microsoft hasn't updated their library after 1.1. The only way you can use new features on windows is if you have glext.h, or/and wglext.h

airseb
05-08-2003, 08:36 AM
Originally posted by Brian Jones:
Also, you might want wglext.h for the Microsoft Windows windowing extension system.

Microsoft hasn't updated their library after 1.1. The only way you can use new features on windows is if you have glext.h, or/and wglext.h

ok, thank you http://www.opengl.org/discussion_boards/ubb/biggrin.gif
now somebody can tell me why the function below doen't displays the textures ? (it's to make mipmapping)

Brian Jones
05-08-2003, 08:37 AM
Call glGetString(GL_VERSION). If it reports a version higher than 1.1, like 1.4(if you have downloaded the lastest drivers for your video card) then know you can use 1.2 OpenGL features

airseb
05-08-2003, 08:40 AM
and my program above, pleeeeeeeasee ! http://www.opengl.org/discussion_boards/ubb/biggrin.gif

Brian Jones
05-08-2003, 08:41 AM
Everything looks ok. Is the dimensions of the second image half the dimensions of the first? Like if the first is 64 x 32, the second would be 32 x 16

airseb
05-08-2003, 08:44 AM
Originally posted by Brian Jones:
Everything looks ok. Is the dimensions of the second image half the dimensions of the first? Like if the first is 64 x 32, the second would be 32 x 16

yes the first is 256x256 and the other is 128x128.
i don't understand why it doen't work (a problem of opengl version ?)
but it work with gluBuild2DMipmaps and not without :-/

Brian Jones
05-08-2003, 08:57 AM
It's a very odd error indeed. glGetError() doesn't return anything? Try changing the base level and all subsequent levels to something else. Maybe you need to add more mipmap? Sorry I'm not of much help.

airseb
05-08-2003, 09:03 AM
Originally posted by Brian Jones:
It's a very odd error indeed. glGetError() doesn't return anything? Try changing the base level and all subsequent levels to something else. Maybe you need to add more mipmap? Sorry I'm not of much help.

it doen't work :-(

Brian Jones
05-08-2003, 09:08 AM
I just read the whole section of BASE/MAX_LEVEL mipmapping in OpenGL Programming Guide. I honestly don't know what it can be. Your code looks right. Did you call glGetString(GL_VERSION) and make sure your card supports the 1.2 spec (at least)?

airseb
05-08-2003, 09:16 AM
Originally posted by Brian Jones:
I just read the whole section of BASE/MAX_LEVEL mipmapping in OpenGL Programming Guide. I honestly don't know what it can be. Your code looks right. Did you call glGetString(GL_VERSION) and make sure your card supports the 1.2 spec (at least)?

my video card is a geforce 1.
can you tell me how use glGetString(GL_VERSION), i have tried but i don't manage.

Brian Jones
05-08-2003, 09:18 AM
Uh, geForce 1. WOW!!! heh, anyways...
The code:

const char *glver = glGetString(GL_VERSION);
cout << glver << endl;
or
MessageBox(NULL, glver, "Version", MB_OK);

airseb
05-08-2003, 09:26 AM
i have that :

Compiling...
premiere_texture.cpp
D:\programmation\[Mes programmes Open GL]\premiere_texture.cpp(97) : error C2440: 'initializing' : cannot convert from 'const unsigned char *' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

premiere_texture.exe - 1 error(s), 0 warning(s)

:-(
i don't understand

Brian Jones
05-08-2003, 09:30 AM
Sorry, try this
const unsigned char *glver = glGetStrign(GL_VERSION);

Or you could have just typecasted the returning string to (const char*)

airseb
05-08-2003, 09:39 AM
i have done :
const unsigned char *glver = glGetString(GL_VERSION);
cout << glver << endl;

and :
const unsigned char *glver = glGetString(GL_VERSION);
cout << *glver << endl;

and windows gives me an error message, sorry but i'm not very advanced in c++

[This message has been edited by airseb (edited 05-08-2003).]

airseb
05-08-2003, 09:44 AM
it works !
i have put the glext.h and changed the values of the glFrustum and it works !
but i haven't managed to use what we tried (GL_VERSION)

Brian Jones
05-08-2003, 09:44 AM
What was the error message Windows gave you?

Brian Jones
05-08-2003, 09:46 AM
Great!

airseb
05-08-2003, 09:59 AM
the message is :
"the program has "met" an error and have to close" or something like that (windows is in french).

[This message has been edited by airseb (edited 05-08-2003).]