• Create Account

## GL_TEXTURE_3D

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

10 replies to this topic

### #1mike74  Members

Posted 02 August 2005 - 08:19 AM

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

### #2The Rug  Members

Posted 02 August 2005 - 08:34 AM

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.

### #3mike74  Members

Posted 02 August 2005 - 08:39 AM

Hmmm... So Unix would support this without any fuss?

What version of OpenGL does Unix support?

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

Posted 02 August 2005 - 10:24 AM

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");

### #5mike74  Members

Posted 02 August 2005 - 01:22 PM

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

### #6Mantear  Members

Posted 02 August 2005 - 02:12 PM

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.

### #7mike74  Members

Posted 02 August 2005 - 03:01 PM

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

### #8mike74  Members

Posted 02 August 2005 - 03:17 PM

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/

### #9phantom  Members

Posted 02 August 2005 - 03:27 PM

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.

### #10mike74  Members

Posted 02 August 2005 - 03:42 PM

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

### #11phantom  Members

Posted 02 August 2005 - 03:57 PM

if you are using GLee just do;

if(!GLEE_EXT_texture3D){   std::cout << "no 3d texture support found" << std::endl;}`

might want to check that GLEE_EXT_texture3D line, might need to be all caps if it doest work.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.