View Full Version : Problems making triangles

06-03-2004, 04:46 PM
I'm coding a program that doesn't give me any problem on building however when I try to start it a strange error appears Unhandled exception at 0x77f8e4b4 in triangle.exe: 0xC0000005: Access violation. I used the Visual Studio .NET enterprise edition. The code without the triangle draw seems to work correcly.

#include <windows.h>
#include <gl/gl.h> // Header File For The OpenGL32 Library
#include <gl/glu.h> // Header File For The GLu32 Library
#include <gl/glut.h> // Header File For The GLut Library

#define kWindowWidth 400
#define kWindowHeight 300

GLvoid InitGL(GLvoid){};
GLvoid DrawGLScene(GLvoid)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units

glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
GLvoid ReSizeGLScene(int Width, int Height){};

int main(int argc, char** argv)
glutInit(&amp;argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (kWindowWidth, kWindowHeight);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);




return 0;


06-03-2004, 05:04 PM
I compiled and ran your code fine. I couldn't tell you what's wrong.

sorry I know that doesn't help. got the latest drivers? what about glut?


06-04-2004, 10:32 AM
i'm no c++ guru, but I think that you arn't supposed to have the semi-colons at the end of the functions after the '}' if you are, then they are treated as prototypes and not functions. I may be wrong, but try taking them out.