From: Tim R. <ti...@us...> - 2004-07-13 19:52:08
|
Update of /cvsroot/csdopenglnet/tutorials/lesson04 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26810/lesson04 Added Files: Makefile lesson04.cs Log Message: new lessons --- NEW FILE: lesson04.cs --- using csDragons.OpenGL; using System; public class Lesson03 : csdGL { protected float rotTri = 0.0f; protected float rotQua = 0.0f; public Lesson03() { glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH ); glutInitWindowSize( 640, 480 ); glutCreateWindow("Lesson 03"); initGL(); glutDisplayFunc( new cb0_glutDisplayFunc( draw ) ); glutKeyboardFunc( new cb0_glutKeyboardFunc(keyboard) ); glutReshapeFunc( new cb0_glutReshapeFunc( reshape ) ); glutVisibilityFunc( new cb0_glutVisibilityFunc( visibility ) ); glutMainLoop(); } protected void visibility( int status ) { if ( status == GLUT_VISIBLE ) { glutIdleFunc( new cb0_glutIdleFunc( draw ) ); } else { glutIdleFunc( null ); } } 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 reshape2( int width, int height ) { float h = ((float)height) / ((float)width); glViewport (0, 0, width, height); glMatrixMode (GL_PROJECTION); glLoadIdentity (); glFrustum (-1.0, 1.0, -h, h, 5.0, 5.0); glMatrixMode (GL_MODELVIEW); glLoadIdentity (); // glTranslatef (0.0f, 0.0f, -40.0f); } 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 ); glPushMatrix(); 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, 0.0f); glColor3f( 0.0f, 0.0f, 1.0f); glVertex3f( 1.0f,-1.0f, 0.0f); glEnd(); glLoadIdentity(); glTranslatef( 1.5f, 0.0f, -6.0f ); glRotatef( rotQua, 1.0f, 0.0f, 0.0f ); glColor3f(0.5f,0.5f,1.0f); glBegin(GL_QUADS); glVertex3f(-1.0f, 1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 0.0f); glVertex3f( 1.0f,-1.0f, 0.0f); glVertex3f(-1.0f,-1.0f, 0.0f); glEnd(); glPopMatrix(); glutSwapBuffers(); rotTri += 0.2f; rotQua -= 0.15f; } protected void keyboard( byte key, int x, int y ) { if (key==27) System.Environment.Exit(0); } public static void Main( string[] args) { new Lesson03(); } } --- 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 = lesson04.exe all: $(FILES) %.exe:%.cs $(MCS) -r:csdGL.dll $^ -o $@ clean: rm -f $(FILES) .IGNORE: clean .EXPORT_ALL_VARIABLES: .PHONY: clean |