Sign in to follow this  

Need help getting OpenGL to work

This topic is 4856 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

I just started OpenGL. I have the impression that I don't need to download anything since my video card supports it. So I tried the following, and some errors resulted. Any idea why?
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glx.h>
#include "aux.h"

static GLfloat spin = 0.0;

void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
    glRotatef(spin, 0.0, 0.0, 1.0);
    glRectf(-25.0, -25.0, 25.0, 25.0);
    glPopMatrix();

    glFlush();
    glXSwapBuffers(auxXDisplay(), auxXWindow());
}

void spinDisplay(void)
{
    spin = spin + 2.0;
    if (spin > 360.0)
        spin = spin - 360.0;
    display();
}

void startIdleFunc(AUX_EVENTREC *event)
{
    auxIdleFunc(spinDisplay);
}

void stopIdleFunc(AUX_EVENTREC *event)
{
    auxIdleFunc(0);
}

void myinit(void)
{
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glColor3f(1.0, 1.0, 1.0);
    glShadeModel(GL_FLAT);
}

void myReshape(GLsizei w, GLsizei h)
{
    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    if (w <= h) 
        glOrtho (-50.0, 50.0, -50.0*(GLfloat)h/(GLfloat)w, 
            50.0*(GLfloat)h/(GLfloat)w, -1.0, 1.0);
    else 
        glOrtho (-50.0*(GLfloat)w/(GLfloat)h, 
            50.0*(GLfloat)w/(GLfloat)h, -50.0, 50.0, -1.0, 1.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity ();
}


int main(int argc, char** argv)
{
    auxInitDisplayMode(AUX_DOUBLE | AUX_RGBA);
    auxInitPosition(0, 0, 500, 500);
    auxInitWindow(argv[0]);
    myinit();
    auxReshapeFunc(myReshape);
    auxIdleFunc(spinDisplay);
    auxMouseFunc(AUX_LEFTBUTTON, AUX_MOUSEDOWN, startIdleFunc);
    auxMouseFunc(AUX_MIDDLEBUTTON, AUX_MOUSEDOWN, stopIdleFunc);
    auxMainLoop(display);
}

I get these errors...
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2144: syntax error : missing ';' before type 'void'
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

Share this post


Link to post
Share on other sites
That piece of code you have seems to be written for X Windows. Although OpenGL is portable, it doesn't take care of opening windows and such things, so you'll have to use something else. What's used in your case is GLX, which is for X Windows only.

I suggest you find an example that uses GLUT or the Win32 API instead. Nehe's site might be a good place to start.

EDIT: The code also uses the AUX library, which is very old and shouldn't be used. You'd be better off learning something else (like GLUT or GLFW.)

Share this post


Link to post
Share on other sites
Ok... I downloaded it and the documentation says this...

COMPILING/INSTALLATION:

o Precompiled versions of the DLL and import library can be
found on the GLUT for Win32 web page mentioned above.

o Microsoft Developer Studio 6 workspace and project files have
been included in the source code distribution.

To build the glut dll:
First, open Microsoft Developer Studio.
Then, select File -> Open Workspace and find the glut.dsw file
in the file dialog and double-click on it.
Finally, select Build -> Build glut32.dll.
When the build is finished, it will copy:
glut32.dll to %WinDir%\System,
glut32.lib to $(MSDevDir)\..\..\VC98\lib, and
glut.h to $(MSDevDir)\..\..\VC98\include\GL.

Additional workspace files have been included in the progs, test
and lib directories to build the progs, tests and libs respectively.


----

I tried this but there's no glut.dsw file when I open a workspace. It can't find glx.h either. I'm really lost.

Share this post


Link to post
Share on other sites

This topic is 4856 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this