Latest

Archive

Community news

C++

Communities and Content

Databases

Editorials

Emacs

General

HTML

Java

Notices

PHP

XML

Apache

C++

Database

General

HTML

Java

Javascript

Linux

Object oriented programming

Open source

Perl

PHP

Python

Ruby

SOAP

XML

Suggest a link

Advertise on zez

Contribute

Contact us

About zez


Building 3D worlds with OpenGL




resizeGL()


This function sets up the viewport for my scene. It is pretty standard stuff, in many cases you can simply copy this into your own program.


void GameWidget::resizeGL( int width, int height )
{
    GLfloat w = (float) width / (float) height;
    GLfloat h = 1.0;

    glViewport( 0, 0, width, height );
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glFrustum( -w, w, -h, h, 5.0, 60.0 );
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef( 0.0, 0.0, -40.0 );
}


paintGL()


This function draws the scene whenever necessary. It also does the rotation. As you can see, it calls the display list I made in initializeGL().


void GameWidget::paintGL()
{
    if ( Animate )
        Angle += 2.0;

    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    glPushMatrix();
    glTranslatef( 0.0, -5.0, 0.0 );
    glRotatef( Angle, 0.0, 1.0, 0.0 );
    glCallList( Landscape );             // call display list
    glPopMatrix();
}



<< Previous page | 1 | 2 | 3 | 4 | < 5 > | 6 | Next page >> | Printer-friendly page |

Comment List


Topic: Author:
Time:
Beginner's tutorials Johann Fuchs 13.02.2001 17:04

if you want to learn opengl programming from the scratch
to high level you should look at

http://nehe.gamedev.net

which is quite an excellent site IMHO.




Forgot your password?

Register a new user

Results

Polls