Skip to main content
GameDev.net gamedev.net
🔒 Locked

glRotatef

Started by Monty Python Jul 13, 2003 at 1:52 PM 2 replies 850+ views
Original Post
Monty Python
Monty Python
Can anybody spot a problem with the following code: * The quad is displayed correctly on the scene * The variable thetaQuad is definitely a float * The Python interpreter reports no errors
import sys

from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *


thetaQuad = 0.1


def renderScene():
    global thetaQuad

    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
    glLoadIdentity()

    glRotatef( thetaQuad, 0.0, 1.0, 0.0 )
    glBegin( GL_QUADS )
    glVertex3f( -0.5, -0.5, 0.0 )
    glVertex3f( -0.5, 0.5, 0.0 )
    glVertex3f( 0.5, 0.5, 0.0 )
    glVertex3f( 0.5, -0.5, 0.0 )
    glEnd()

    glutSwapBuffers()
    thetaQuad += 0.2


def initScene():
    glClearColor( 0.3, 0.3, 0.3, 1.0 )
    glShadeModel( GL_SMOOTH )


def idleScene():
    pass


def main():
    glutInit( sys.argv )
    glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE )
    glutInitWindowPosition( 200, 200 )
    glutInitWindowSize( 800, 600 )
    glutCreateWindow( "OpenGL" )

    initScene()
    glutDisplayFunc( renderScene )
    glutIdleFunc( idleScene )
    glutMainLoop()


main()
GSACP: GameDev Society Against Crap Posting
To join: Put these lines in your signature and don't post crap!
Daivuk
Daivuk
before you make glRotatef, write : glPushMatrix();
And after drawing your quads, write glPopMatrix();

If you always use that, you will never get problem with Transformation.

All transformations you make between Push and Pop will not affect the rest of the drawing.

thats the way to draw an object :

glPushMatrix();
.. Do Transformation.. (Translate, Rotate, Scale)
.. Draw Your object..
glPopMatrix();
Trienco
Trienco
quote:
Original post by Daivuk
before you make glRotatef, write : glPushMatrix();
And after drawing your quads, write glPopMatrix();



what for? he''s doing nothing else and pushing the identity seems quite pointless, too.

quote:

If you always use that, you will never get problem with Transformation.



and if youre always doing that without understanding why and what it does you start pushing and popping for a single triangle where its extremely useless.


btw. what exactly is the problem? if there are no errors and its displayed correctly, why looking for errors? if you DONT see anything then thats most likely because the quad is exactly around the same position as your point of view or because you never set a color. do that and for example translate it a few units along the negative z-axis before rotating. or tell us what exactly is the problem?
f@dzhttp://festini.device-zero.de
Fruny
Fruny
You need to refresh your image as an idle task.

def idleScene():
glutPostRedisplay()




[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.