OpenGL GL_TEXTURE_3D

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

Recommended Posts

When I do glEnable(GL_TEXTURE_3D); Dev-C++ says 52 C:\Dev-Cpp\main.cpp GL_TEXTURE_3D' undeclared (first use this function) Does anyone know how to get this to work? Do I have to get a whole new version of OpenGL or something? Mike http://www.coolgroups.com/forum

Share on other sites
I'm guessing you're on Windows?

GL_TEXTURE_3D is part of OpenGL 1.2, and unfortunately Windows only has support for OpenGL 1.1. The way you get around this is using extensions- there are libraries such as GLee that make this much easier.

Share on other sites
Hmmm... So Unix would support this without any fuss?

What version of OpenGL does Unix support?

Mike
http://www.coolgroups.com/forum

Share on other sites
I just got this going recently, here's what you need. Google for the glext.h header. I found two, one is less than 20k and the other is over 300k. 3d textures are not defined in the smaller file. Include it in the project and then add this in your globals:

PFNGLTEXIMAGE3DPROC glTexImage3D;

and then paste this in main before your GL loop starts:

PFNGLTEXIMAGE3DPROC glTexImage3D = (PFNGLTEXIMAGE3DPROC) wglGetProcAddress("glTexImage3D");

Share on other sites
Here's my code:

unsigned char *texturemem = new unsigned char[24];
GLuint textureID;
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_3D, textureID);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 2, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, texturemem);

However, it crashes when it gets to glTexImage3D. Any ideas why?

Mike
http://www.coolgroups.com/forum

Share on other sites
I highly recommend using GLee. It makes using any OGL features beyond 1.1 a breeze. You could also look at the GLee source if you get curious as to how it's done.

Share on other sites
I tried glee and linked in glee.lib, but now I'm getting compilation errors:

.drectve /DEFAULTLIB:"LIBC" /DEFAULTLIB:"OLDNAMES" ' unrecognized
[Linker error] undefined reference to _imp__wglGetProcAddress@4'
[Linker error] undefined reference to _imp__wglGetCurrentDC@0'
[Linker error] undefined reference to _imp__glGetString@4'
[Linker error] undefined reference to _imp__glGetString@4'
[Linker error] undefined reference to _imp__glGetString@4'

any ideas?

Mike
http://www.coolgroups.com/forum

Share on other sites
Ok, apparently I didn't have the Windows version.

Anyway, now I do, and it still doesn't work.

Here's what the guy says in the readme file:

---------------------------------------------------------------

1) Put the GLee.lib in the lib folder (ie C:\dmd\lib)
2) Put glee.d and glConstants.d in the include folder (ie create c:\glee and use the -IC:\glee on the compiler.)
3) The D code is pretty much the same as the C code but you need to specify:

import glee; //Instead of #include "glee.h"

---------------------------------------------------------------

Anyway, when I do "import glee" Dev-C++ gets mad and says:

5 C:\Dev-Cpp\main.cpp `import' does not name a type

Anyone know what the deal is?

Mike
http://www.coolgroups.com/forum/

Share on other sites
You are using C++, not D which is why it didnt work [smile]
Just include the .c and .h file in your project, so that it compiles the .c file, I find it much easier to work with it like that than to use the lib.

Share on other sites
Well, it compiles now using glee. I tried this:

glEnable(GL_TEXTURE_3D);
unsigned char *texturemem = new unsigned char[24];
GLuint textureID;
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_3D, textureID);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, 2, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, texturemem);

Still, it crashes. I'm guessing the graphics card doesn't support 3d textures?

That's strange because I'm at a library, and the computers here are top-notch.

I tried this before to check support:

int sup = isExtensionSupported("GL_EXT_texture3D");

int isExtensionSupported(const char *extension)
{
const GLubyte *extensions = NULL;
const GLubyte *start;
GLubyte *where, *terminator;

/* Extension names should not have spaces. */
where = (GLubyte *) strchr(extension, ' ');
if (where || *extension == '\0')
return 0;
extensions = glGetString(GL_EXTENSIONS);
/* It takes a bit of care to be fool-proof about parsing the
OpenGL extensions string. Don't be fooled by sub-strings,
etc. */
start = extensions;
for (;;) {
where = (GLubyte *) strstr((const char *) start, extension);
if (!where)
break;
terminator = where + strlen(extension);
if (where == start || *(where - 1) == ' ')
if (*terminator == ' ' || *terminator == '\0')
return 1;
start = terminator;
}
return 0;
}

Is that the proper way to check for support for 3d textures?

Mike
http://www.coolgroups.com/forum

1. 1
Rutin
23
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 29
• 40
• 23
• 13
• 13
• Forum Statistics

• Total Topics
631740
• Total Posts
3001966
×