• Advertisement
Sign in to follow this  

newbie opengl question

This topic is 4618 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there. I’m trying to get back to doing some openGL programming but have come across a rather annoying and confusing problem After I compile a program I’ve written (Borland bcc32 if that’s important) and try to run the .exe, I get a ' test1.exe has encountered a problem and needs to close. We are sorry for the inconvenience' error with windows asking if I want to send an error report (to who… me?). I assumed it was my programming ineptitude so I tired opening a simple exe (just opens a blank window) and the same error pops up. I don’t know what to do. Any help you guys could give would be great. Cheers.

Share this post


Link to post
Share on other sites
Advertisement
Wow. That was quick

#include <windows.h>
#include <GL/glut.h>
#include <stdio.h>
#include <stdlib.h>

void init ( void ) {
glEnable ( GL_DEPTH_TEST );
glClearColor ( 0.0, 0.0, 0.0, 0.0 );
}

void display ( void ) {
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glPushMatrix ( );
glPopMatrix ( );
glutSwapBuffers ( );
}

void reshape(int w, int h) {
glViewport ( 0, 0, w, h );
glMatrixMode ( GL_PROJECTION );
glLoadIdentity ( );
if ( h==0 )
gluPerspective ( 80, ( float ) w, 1.0, 5000.0 );
else
gluPerspective ( 80, ( float ) w / ( float ) h, 1.0, 5000.0 );
glMatrixMode ( GL_MODELVIEW );
glLoadIdentity ( );

}

void keyboard ( unsigned char key, int x, int y ) {
switch ( key ) {
case 27: /* Escape key */
exit ( 0 );
break;
case 'f':
glutFullScreen ( );
break;
case 'w':
glutReshapeWindow ( 250,250 );
break;
default:
break;
}
}

int main ( int argc, char** argv ) {
glutInit ( &argc, argv );
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE );
glutInitWindowSize ( 250, 250 );
glutCreateWindow ( argv[0] );
init ( );
glutReshapeFunc ( reshape );
glutKeyboardFunc ( keyboard );
glutDisplayFunc ( display );
glutMainLoop ( );
return 0;
}

It's as simple a program as I could make. I even got a mate to compile and run it and he had no problems.

Share this post


Link to post
Share on other sites
Well, if your mate could compile and run it without problems, have you tried to do a clean and then build it from scratch? Probably under "Build" menu.

Also, I can't see any point to having these two lines called one after the other:

glPushMatrix ( );
glPopMatrix ( );

Share this post


Link to post
Share on other sites
Cheers all. First off, the glPushMatrix() and glPopMatrix() were left behind from hacking my code down to see what was wrong with it, well spotted. I have tried cleaning and building from scratch repeatedly without much luck.

I've also changed to the latest glut32 files... nothin’.

Share this post


Link to post
Share on other sites
Wait a minute. I've just tired linking the compiled file and got loads of these error messages

Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external 'glutInit' referenced from C:\DOCUMENTS AND SETTINGS\MY DOCUMENTS\CPROJECTS\TESTER\TEST1.OBJ
Error: Unresolved external 'glutInitDisplayMode' referenced from C:\DOCUMENTS AND SETTINGS\MY DOCUMENTS\CPROJECTS\TESTER\TEST1.OBJ
***
***
***
Error: Unresolved external 'glutInitWindowSize' referenced from C:\DOCUMENTS AND SETTINGS\MY DOCUMENTS\CPROJECTS\TESTER\TEST1.OBJ
Error: Unresolved external 'glutCreateWindow' referenced from C:\DOCUMENTS AND SETTINGS\MY DOCUMENTS\CPROJECTS\TESTER\TEST1.OBJ

I think why this didn’t come up before was because my clean tool's settings were wrong. Sorry if this has wasted any of your time, but how do I sort this out?

Share this post


Link to post
Share on other sites
I’ve linked to glut.lib now, and it crates an exe. Which is nice. But now it gives me a new runtime error message:

test1.exe - Unable to Locate Component
This application has failed to start because OPENGL.dll was not found. Re-initialising the application may fix this problem.

Any ideas?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement