VoyForums
[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: [1] ]


[ Next Thread | Previous Thread | Next Message | Previous Message ]

Date Posted: 03:08:51 01/10/03 Fri
Author: Vuong Anh Tuan
Subject: Re: SOURECODE Here
In reply to: Numez 's message, "SOURECODE Here" on 12:27:05 01/16/02 Wed

>#include
>#include
>#include
>void init(void);
>void display(void);
>void idle_func(void);
>
>GLfloat angle;
>
>int main(int argc, char *argv[])
>{
> glutInit(&argc,argv);
> glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
> glutInitWindowSize(250,250);
> glutInitWindowPosition(100,200);
> glutCreateWindow("Drehung");
> glutDisplayFunc(display);
> glutIdleFunc(idle_func);
> init();
> glutMainLoop();
> return 0;
>}
>void init(void)
>{
> glClearColor(0.0f ,0.0f ,0.0f ,0.0f);
> glClearDepth(1.0f);
> glEnable(GL_CULL_FACE);
> glMatrixMode(GL_PROJECTION);
> glLoadIdentity();
> gluPerspective(45.0f,(GLfloat)250/(GLfloat250,0.1f,100
>.0f);
> glMatrixMode(GL_MODELVIEW);
> glLoadIdentity();
>}
>void idle_func (void)
>{
> angle+=0.05f;
> if (angle>360) angle=0.0f; // Kann verändert werden
> glutPostRedisplay ();
>}
>void display(void){glClear(GL_COLOR_BUFFER_BIT);
> glLoadIdentity();
> glTranslatef(0,0,-5.0f);
> glRotatef(angle,0.0f,1.0f,0.0f);
> glBegin(GL_QUADS);
> glColor3f(1.0f,0.0f,0.0f);
> glVertex3f( -1.0f, 1.0f, -1.0f);
> glVertex3f(1.0f, 1.0f, -1.0f);
> glVertex3f(1.0f,-1.0f, -1.0f);
> glVertex3f( -1.0f,-1.0f, -1.0f);
> glEnd();
>glutSwapBuffers();
>}
>Sorry, ist nur ein Quadrat, kein Würfel.(und das Ganze
>noch mit GLUT).
>ähhhmm wichtig ist die Idle Funktion. Wir haben ne
>Variable
>angle , vom typ float. In jedem Refresh (des displays)
>wird das Quadrat um 0.05 Grad verschoben. (den wert
>kannst du anpassen, aber es wichtig eine float
>variable zu nehmen, da mit kleineren werten eine
>flüssigere darstellung gewährleistet ist). Wenn angle
>über 360 geht, wird die variable auf Null gesetzt.
>glutPostRedisplay sorgt dafür, dass das fenster
>erneuert wird. (refresh).
>Der Rest ist Basic Glut. Sollte keine Probleme
>darstellen.
>
>
>Numez

[ Next Thread | Previous Thread | Next Message | Previous Message ]

[ Contact Forum Admin ]


Forum timezone: GMT-8
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.