Results 1 to 3 of 3

Thread: Newb Question - OpenGL

  1. #1
    theduck
    Guest

    Newb Question - OpenGL

    Hello,

    I (FreePascal+OGL noob) can't get this tutorial to work!!!!!
    Can anybody help me? The rotating doesn't work!!!!!!!

    http://nehe.gamedev.net/data/lessons....asp?lesson=04

    I have translated it into Pascal, and I can't get it to work...

    I am using the FPC (FreePascal Compiler) and OpenGL for this.

    I have been using this as a basic Template:
    So it would be appreciated greatly if you could tell me where to put the rotating code in with my template.
    (Nothing else compiles right for OpenGL templates... ....)

    [pascal]//OPEN-GL TEMPLATE///////
    //DUCK ENTERPRISES 2005/
    //COLIN DRAKE//////////
    //////////////////////
    Program Tutor02;/////
    ////////////////////
    Uses GL, GLUT;/////
    //////////////////
    //declaration of constants and variables


    //program initialization



    //misc



    //list creation



    //drawing
    //
    //
    //callback
    Procedure reshape(width, height : LongInt); stdcall;
    Var aspect : glFloat;
    Begin
    aspect := width/height;
    //setup new projection matrix which depends on window size
    glMatrixMode(GL_PROJECTION); //switch to projection-matrix
    glLoadIdentity; //setup standard matrix
    glFrustum(-1.0*aspect, 1.0*aspect, 1.0, -1.0, 1.0, 20.0);//setup viewing matrix

    glMatrixMode(GL_MODELVIEW); //switch back to the modelview-matrix
    glLoadIdentity; //setup standard matrix
    End;


    //CREATE EVERYTHING
    Procedure draw; stdcall;
    Begin


    //clear the color buffer
    glClear(GL_COLOR_BUFFER_BIT);

    //do some drawing
    glBegin(GL_QUADS); //draw something with 4 vertexes

    glColor3f(1.0,0.0,0.0); //color
    glVertex3f(-0.8, -0.5, -2.0); //first vertex

    glColor3f(0.0,1.0,0.0); //color
    glVertex3f(-0.0, 0.5, -2.0); //second vertex

    glColor3f(0.0,0.0,1.0); //color
    glVertex3f( 0.0, 0.5, -2.0); //...

    glColor3f(0.0,1.0,0.0); //color
    glVertex3f( 0.8, -0.5, -2.0);

    glEnd; //thats four vertexes, so it draws it!!

    glFlush; //tell OpenGL to flush internal buffers
    //glSwapBuffers; //we actually don't use the double-buffer
    End;


    //START UP CODE
    Begin
    //OpenGL and GLUT initialization
    glutInit(@argc, argv);
    glutCreateWindow('My First OpenGL Application');

    //callback registration
    glutDisplayFunc(@draw);
    glutReshapeFunc(@reshape);


    //MAIN LOOP
    //glutMainLoop
    glutMainLoop;



    End.

    [/pascal]

    Thanks!

  2. #2

    Newb Question - OpenGL

    Every vertex you pass first gets transformed (multiplied) by the current modelview matrix. It is illegal to modify any OpenGl matrix inside a glbegin glend block, other then that you can put it wherever you want before passing verticies you want transformed as long as modelview matrix is selected.

  3. #3
    theduck
    Guest

    Thanks!

    Thanks a lot! I got it now!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •