From: Tim R. <ti...@us...> - 2004-07-15 17:35:55
|
Update of /cvsroot/csdopenglnet/tutorials/lesson05 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16099/lesson05 Added Files: Makefile lesson05.cs Log Message: new example --- NEW FILE: Makefile --- CC=mcs DEBUG=/d:DEBUG DEBUG= OPTS=$(DEBUG) LIBS=csdGL.dll MCS=$(CC) $(OPTS) -lib:/usr/lib/mono/csDragons -lib:/usr/lib/mono/gtk-sharp FILES = lesson05.exe all: $(FILES) %.exe:%.cs $(MCS) -r:csdGL.dll $^ -o $@ run: $(FILES) ./lesson05.exe clean: rm -f $(FILES) .IGNORE: clean .EXPORT_ALL_VARIABLES: .PHONY: clean --- NEW FILE: lesson05.cs --- using csDragons.OpenGL; using System; public class Lesson05 : csdGL { protected float rotTri = 0.0f; protected float rotQua = 0.0f; public Lesson05() { glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutInitWindowSize( 640, 480 ); glutCreateWindow("Lesson 05"); initGL(); glutDisplayFunc( new cb0_glutDisplayFunc( draw ) ); glutKeyboardFunc( new cb0_glutKeyboardFunc(keyboard) ); glutReshapeFunc( new cb0_glutReshapeFunc( reshape ) ); glutVisibilityFunc( new cb0_glutVisibilityFunc( visible ) ); glutMainLoop(); } protected void visible( int state ) { if ( state==GLUT_VISIBLE ) { glutIdleFunc( new cb0_glutIdleFunc( redraw ) ); } else { glutIdleFunc( null ); } } protected void redraw() { glutPostRedisplay(); rotTri += 0.20f; rotQua -= 0.15f; } protected void initGL() { glShadeModel( GL_SMOOTH ); glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); glClearDepth( 1.0f ); glEnable( GL_DEPTH_TEST ); glDepthFunc( GL_LEQUAL ); glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); } protected void reshape( int width, int height ) { if (height==0) height = 1; float h = ((float)width) / ((float)height); glViewport (0, 0, width, height); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 45.0f, h, 0.1f, 150.0f ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); } protected void draw() { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glLoadIdentity(); glTranslatef( -1.5f, 0.0f, -6.0f ); glRotatef( rotTri, 0.0f, 1.0f, 0.0f ); glBegin( GL_TRIANGLES ); glColor3f( 1.0f, 0.0f, 0.0f ); glVertex3f( 0.0f, 1.0f, 0.0f ); glColor3f( 0.0f, 1.0f, 0.0f ); glVertex3f(-1.0f,-1.0f, 1.0f ); glColor3f( 0.0f, 0.0f, 1.0f ); glVertex3f( 1.0f,-1.0f, 1.0f ); glColor3f( 1.0f, 0.0f, 0.0f ); glVertex3f( 0.0f, 1.0f, 0.0f ); glColor3f( 0.0f, 0.0f, 1.0f ); glVertex3f( 1.0f,-1.0f, 1.0f ); glColor3f( 0.0f, 1.0f, 0.0f ); glVertex3f( 1.0f,-1.0f,-1.0f ); glColor3f( 1.0f, 0.0f, 0.0f ); glVertex3f( 0.0f, 1.0f, 0.0f ); glColor3f( 0.0f, 1.0f, 0.0f ); glVertex3f( 1.0f,-1.0f,-1.0f ); glColor3f( 0.0f, 0.0f, 1.0f ); glVertex3f(-1.0f,-1.0f,-1.0f ); glColor3f( 1.0f, 0.0f, 0.0f ); glVertex3f( 0.0f, 1.0f, 0.0f ); glColor3f( 0.0f, 0.0f, 1.0f ); glVertex3f(-1.0f,-1.0f,-1.0f ); glColor3f( 0.0f, 1.0f, 0.0f ); glVertex3f(-1.0f,-1.0f, 1.0f ); glEnd(); glLoadIdentity(); glTranslatef( 1.5f, 0.0f, -7.0f ); glRotatef( rotQua, 1.0f, 1.0f, 1.0f ); glBegin( GL_QUADS ); glColor3f( 0.0f, 1.0f, 0.0f ); // Top 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 ); glColor3f( 1.0f, 0.5f, 0.0f ); // Bottom 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 ); glColor3f( 1.0f, 0.0f, 0.0f ); // Front 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 ); glColor3f( 1.0f, 1.0f, 0.0f ); // Back 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 ); glColor3f( 0.0f, 0.0f, 1.0f ); // Left 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 ); glColor3f( 1.0f, 0.0f, 1.0f ); // Right 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(); } protected void keyboard( byte key, int x, int y ) { if (key==27) System.Environment.Exit(0); } public static void Main( string[] args) { new Lesson05(); } } |