Discussion:
(OpenGL) Crashing in glGetIntegerv?
(too old to reply)
Reed Hedges
2003-11-10 01:26:36 UTC
Permalink
Hello, I am having a strange crash in the OpenGL function
glGetIntegerv. AFAIK the following program should work, but I get "Bus
error" inside the first call to glGetIntegerv. (I am a complete
OpenGL newbie, just trying to port some software).


#include <stdio.h>
#include <OpenGL/gl.h>

int main() {
GLint max_mv_depth;
GLint max_tex;
glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_tex);
printf("Max texture is %d\n", (int)max_tex);
glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &max_mv_depth);
printf("Max mv stack depth is %d\n", (int)max_mv_depth);
}


I built it with "-framework OpenGL"

I am using 10.2.8 on an iBook G3 (ATI Rage 128 Pro).
Other applications using OpenGL work fine.

Thanks for any help or suggestions!

reed
Miro Jurisic
2003-11-10 06:12:54 UTC
Permalink
Post by Reed Hedges
Hello, I am having a strange crash in the OpenGL function
glGetIntegerv. AFAIK the following program should work, but I get "Bus
error" inside the first call to glGetIntegerv. (I am a complete
OpenGL newbie, just trying to port some software).
#include <stdio.h>
#include <OpenGL/gl.h>
int main() {
GLint max_mv_depth;
GLint max_tex;
glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_tex);
printf("Max texture is %d\n", (int)max_tex);
glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &max_mv_depth);
printf("Max mv stack depth is %d\n", (int)max_mv_depth);
}
You don't have a valid OGL context. You need to create one using the
platform-specific API (in your case AGL) before you can make any GL calls.

hth

meeroh
--
If this message helped you, consider buying an item
from my wish list: <http://web.meeroh.org/wishlist>
C Lund
2003-11-10 10:07:15 UTC
Permalink
Post by Reed Hedges
Hello, I am having a strange crash in the OpenGL function
glGetIntegerv. AFAIK the following program should work, but I get "Bus
error" inside the first call to glGetIntegerv. (I am a complete
OpenGL newbie, just trying to port some software).
Do you have a working openGL view when those calls are made? It seems
as if you do not. I suggest going to http://nehe.gamedev.net/ and
downloading some of the early tutorials (column to the left of the
main text). The tutorials are written for Windows, but if you scroll
to the bottom of a given tutorial, you'll find links to various ports
of the code - including for OS X/Cocoa. NeHe is a very good place for
learning openGL.
--
C Lund, www.notam02.no/~clund
Reed Hedges
2003-11-12 18:57:55 UTC
Permalink
Thanks C. Lund and Miro, I had no GL context. In the software I was
working with, glGetIntegerv was being called from the constructor of a
static C++ class instance.

I guess it works on Linux, but not Mac.

Loading...