PDA

View Full Version : glTexImage3DEXT crashed



renaissance
11-12-2008, 01:43 PM
I am trying to use glTexImage3DEXT for volume rendering. In fact, I am using the code from the following link.
http://www.opengl.org/resources/code/samples/advanced/advanced97/programs/programs.html

However, after successful compilation, the program crashed when it entered glTexImage3DEXT function. I used
glewIsSupported("GL_EXT_texture3D");
to make diagnosis and I found the reture value is 0.

Can anyone give me some hints?

Thanks a lot.

ZbuffeR
11-12-2008, 02:04 PM
Don't use it, if it is not available :)

renaissance
11-12-2008, 02:49 PM
my system has the following config. Should the glTexImage3DEXT be supported and available?


GLEW version 1.5.1
Reporting capabilities of pixelformat 1
Running on a GeForce 8600 GT/PCI/SSE2 from NVIDIA Corporation
OpenGL version 2.1.1 is supported

Korval
11-12-2008, 03:31 PM
OpenGL version 2.1.1 is supported

The implementation probably stopped exposing texture3D as an extension, as it supports a version of OpenGL that requires 3D textures. Just use the core function pointers.

renaissance
11-12-2008, 03:42 PM
Hi Korval:

I do not quite understand what you posted. Can you give a little bit more explanationS?

Thanks a lot.

Korval
11-12-2008, 04:08 PM
I do not quite understand what you posted. Can you give a little bit more explanationS?

OpenGL version 2.1 requires that implementations support 3D textures. The API to do this is part of the core OpenGL 2.1 specification.

However, support for 3D textures can also be exposed by an extension called "GL_EXT_texture3D". Because it is an extension, all of the function pointers for it end in "EXT" as do all of the #define enumerations.

OpenGL version 2.1 defines a function called "glTexImage3D" (note the lack of EXT at the end). The extension "GL_EXT_texture3D" defines a function called "glTexImage3DEXT". If an OpenGL version returns 2.1, it must expose "glTexImage3D" as a function. If an OpenGL implementation advertises the extension "GL_EXT_texture3D", then it must expose "glTexImage3DEXT".

Your GL implementation says that it does not support the "GL_EXT_texture3D" extension. However, your OpenGL version is 2.1, which means that it does expose "glTexImage3D". Therefore, you should stop looking for the extension and start looking for the core feature.

Jan
11-12-2008, 04:09 PM
1) Did you call glewInit _after_ context creation?
2) Korval suggests to use glTexImage3D instead of glTexImage3DEXT.

Jan
11-12-2008, 04:10 PM
Argh, too slow ;)

renaissance
11-12-2008, 04:18 PM
I tried using glTexImage3D before and it had the similar crashing result.

renaissance
11-12-2008, 04:21 PM
Thank you for you advice, Jan and Korval.

For Jan, I do not understand the glewInit _after_ context suggestion. Can you come up with more details?

yooyo
11-12-2008, 05:40 PM
You cannot initialise extensions entry points before you create GL context.

renaissance
11-13-2008, 05:18 PM
As you suggested, yooyo, I inserted the following code:

...
GLenum err = glewInit();
if (GLEW_OK != err)
{
fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
}
...

I got the following output "Missing GL version"

But my system is supposed to support opengGL
GLEW version 1.5.1
Reporting capabilities of pixelformat 1
Running on a GeForce 8600 GT/PCI/SSE2 from NVIDIA Corporation
OpenGL version 2.1.1 is supported
....

What happened?

Jan
11-14-2008, 12:58 AM
I assume that you are doing this, before you have created your OpenGL context, thus glew cannot initialize itself. Try moving that glewInit to a later point in your code, where you definitely have initialized OpenGL.

Jan.

yooyo
11-14-2008, 08:30 AM
@renaissance:
Try to call glewInit(); AFTER you create gl context. Im not sure which OS & framework you use, but in case of Windows, find the wglCreateContext and wglMakeCurrent calls and add glewInit after that.

renaissance
11-14-2008, 09:57 AM
Thanks a lot to all you guys for your help.
My program works when I moved that glewInit to a later point in my code, as Jan suggested.

Thank you all again.

renaissance
11-14-2008, 10:01 AM
To yooyo:
My program does not use wgl function to create any context. I just used glut to initialize window, displaymode and createwindow for dispalying. But I am a newbie to use OpenGL, I am just curious if what you suggested is another approach to achieve the same goal. Can you make a brief comparsion between your approach and mine?

THank you very much.

yooyo
11-14-2008, 04:05 PM
Glut is rendering context and basic OS stuff wrapper for simple OpenGL programs. Using glut you dont have to bother to create window, handle messages, etc.. glut will do it for you. But If you want to create modern app with menus, toolbars, multiple 3d views, you have to write your own OpenGL initialisation code.
In windows.. all you have to do is:


// assume that window is already created
bool CreateOpenGL(HWND hWnd)
{
PIXELFORMATDESCRIPTOR pfd;
int format;

// get the device context (DC)
m_hDC = GetDC( hWnd );
if (m_hDC == NULL)
{
return false;
}

// set the pixel format for the DC
ZeroMemory( &pfd, sizeof( pfd ) );
pfd.nSize = sizeof( pfd );
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32;
pfd.cDepthBits = 24;
pfd.iLayerType = PFD_MAIN_PLANE;
format = ChoosePixelFormat( m_hDC, &pfd );

if (FALSE==SetPixelFormat( m_hDC, format, &pfd ))
{
ReleaseDC(m_hDC);
return false;
}

// create and enable the render context (RC)
m_hRC = wglCreateContext( m_hDC );
if (m_hRC == NULL)
{
ReleaseDC(m_hDC);
return false;
}

wglMakeCurrent( m_hDC, m_hRC );
InitOpenGLExtensions(); // or call glewInit

return true;
}



Then handle WM_PAINT messages to redraw your 3d scene, or use maeesage loop to update 3d content all the time.

More details & tutorials for beginners you can find on http://nehe.gamedev.net/