Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

OpenGL crash with glGetIntegerv

309 views
Skip to first unread message

robe...@my-dejanews.com

unread,
Aug 2, 1998, 3:00:00 AM8/2/98
to
I wanted to get the current state of the glPolygonMode in a function, so I
tried:

GLint mode;
glGetIntegerv(GL_POLYGON_MODE, &mode);

This works okay if I call it in my main display routine, but if I put it in
a separate function it crashes with a memory access error. I am using glut
to do my windowing, so I thought that might be the problem, but then I tried
similar things using an MFC app demo and I get the same crash. Here's a
small program that crashes my machine every time (BTW I'm running NT4).

#include "GL/glut.h"

void f(){
GLint mode;
glGetIntegerv(GL_POLYGON_MODE, &mode);
}

void Display(void){

int a;

glClear(GL_COLOR_BUFFER_BIT);// | GL_DEPTH_BUFFER_BIT | GL_RGB_BUFFER_BIT);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

f();
glColor3d(1,1,1);
glutWireSphere(1,50,50);

glFlush();
}

void main(int argc, char *argv[]){
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE);
glutInitWindowSize (600, 600); glutInitWindowPosition (400,50);
glutCreateWindow("Window");
glutDisplayFunc(Display);
glutMainLoop();
}

Now, as if this weren't already enough fun, if I comment out the int a;
(which is an unreferenced variable) it runs fine.

function f(), will cause just about anything to crash (as long as some
memory allocation is happening in the display routine, such as that int a;).

Does glGetIntegerv() actually grab hold of the pointer it's passed and then
try to use it later? That seems incredibly odd, but that's the only thing I
can think of that would cause this behavior.

Is this an OpenGL problem, or is it mine?

-Rob

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum

David Blythe

unread,
Aug 2, 1998, 3:00:00 AM8/2/98
to
In article <6q0oel$vva$1...@nnrp1.dejanews.com> robe...@my-dejanews.com writes:
>I wanted to get the current state of the glPolygonMode in a function, so I
>tried:
>
>GLint mode;
>glGetIntegerv(GL_POLYGON_MODE, &mode);
>
>This works okay if I call it in my main display routine, but if I put it in
>a separate function it crashes with a memory access error. I am using glut
>to do my windowing, so I thought that might be the problem, but then I tried
>similar things using an MFC app demo and I get the same crash. Here's a
>small program that crashes my machine every time (BTW I'm running NT4).

glPolygonMode returns two values, one for front facing polygons and one
for back. You need GLint mode[2];
-db

0 new messages