GLViewportMorph subclass: #GLStef	instanceVariableNames: 'rotationAngle'	classVariableNames: ''	poolDictionaries: ''	category: 'NBOpenGL-Stef'!!GLStef methodsFor: 'initialize' stamp: 'sd 2/22/2012 18:29'!initialize	super initialize.	rotationAngle := 0! !!GLStef methodsFor: 'initialize' stamp: 'sd 2/22/2012 18:28'!openInWorld	super openInWorld.		self startStepping.! !!GLStef methodsFor: 'as yet unclassified' stamp: 'sd 2/22/2012 19:20'!drawCube	| gl |	gl := display gl.		gl translatef_x: -1.5 y: 0 z: -60. 	gl rotatef_angle: rotationAngle x: 0 y: 1  z: 0. 							gl 		begin: GL_TRIANGLES;															color3f_red: 1 green: 0  blue: 0;		vertex3f_x: 0 y: 1 z: 0;  		color3f_red: 0 green: 1  blue: 0;		vertex3f_x: -1  y: -1 z: 1;  		color3f_red: 0 green: 0  blue: 1;		vertex3f_x: 1  y: -1 z: 1;  				color3f_red: 1 green: 0  blue: 0;		vertex3f_x: 0  y: 1 z: 0;  		color3f_red: 0 green: 0  blue: 1;		vertex3f_x: 1  y: -1 z: 1;  		color3f_red: 0 green: 1  blue: 0;		vertex3f_x: 1 y: -1 z:  -1;  				color3f_red: 1 green: 0  blue: 0;		vertex3f_x: 0 y: 1 z:  0;  		color3f_red: 0 green: 1  blue: 0;		vertex3f_x: 1 y: -1 z: -1;  		color3f_red: 0 green: 0  blue: 1;		vertex3f_x: -1 y: -1 z: -1;  		color3f_red: 1 green: 0  blue: 0;		vertex3f_x: 0 y: 1 z:  0;  		color3f_red: 0 green: 0  blue: 1;		vertex3f_x: -1 y: -1 z: -1;  		color3f_red: 0 green: 1  blue: 0;		vertex3f_x: -1 y: -1 z: 1;  		end.			"		color3f (0.0f,0.0f,1.0f);						// Blue		vertex3f -1.0f,-1.0f,-1.0f);					// Left Of Triangle (Left)		color3f (0.0f,1.0f,0.0f);						// Green		vertex3f -1.0f,-1.0f, 1.0f);					// Right Of Triangle (Left)	glEnd();											// Done Drawing The Pyramid	glLoadIdentity();									// Reset The Current Modelview Matrix	glTranslatef(1.5f,0.0f,-7.0f);						// Move Right 1.5 Units And Into The Screen 7.0	glRotatef(rquad,1.0f,1.0f,1.0f);					// Rotate The Quad On The X axis ( NEW )	glBegin(GL_QUADS);									// Draw A Quad		color3f (0.0f,1.0f,0.0f);						// Set The Color To Green		vertex3f  1.0f, 1.0f,-1.0f);					// Top Right Of The Quad (Top)		vertex3f -1.0f, 1.0f,-1.0f);					// Top Left Of The Quad (Top)		vertex3f -1.0f, 1.0f, 1.0f);					// Bottom Left Of The Quad (Top)		vertex3f  1.0f, 1.0f, 1.0f);					// Bottom Right Of The Quad (Top)		color3f (1.0f,0.5f,0.0f);						// Set The Color To Orange		vertex3f  1.0f,-1.0f, 1.0f);					// Top Right Of The Quad (Bottom)		vertex3f -1.0f,-1.0f, 1.0f);					// Top Left Of The Quad (Bottom)		vertex3f -1.0f,-1.0f,-1.0f);					// Bottom Left Of The Quad (Bottom)		vertex3f  1.0f,-1.0f,-1.0f);					// Bottom Right Of The Quad (Bottom)		color3f (1.0f,0.0f,0.0f);						// Set The Color To Red		vertex3f  1.0f, 1.0f, 1.0f);					// Top Right Of The Quad (Front)		vertex3f -1.0f, 1.0f, 1.0f);					// Top Left Of The Quad (Front)		vertex3f -1.0f,-1.0f, 1.0f);					// Bottom Left Of The Quad (Front)		vertex3f  1.0f,-1.0f, 1.0f);					// Bottom Right Of The Quad (Front)		color3f (1.0f,1.0f,0.0f);						// Set The Color To Yellow		vertex3f  1.0f,-1.0f,-1.0f);					// Top Right Of The Quad (Back)		vertex3f -1.0f,-1.0f,-1.0f);					// Top Left Of The Quad (Back)		vertex3f -1.0f, 1.0f,-1.0f);					// Bottom Left Of The Quad (Back)		vertex3f  1.0f, 1.0f,-1.0f);					// Bottom Right Of The Quad (Back)		color3f (0.0f,0.0f,1.0f);						// Set The Color To Blue		vertex3f -1.0f, 1.0f, 1.0f);					// Top Right Of The Quad (Left)		vertex3f -1.0f, 1.0f,-1.0f);					// Top Left Of The Quad (Left)		vertex3f -1.0f,-1.0f,-1.0f);					// Bottom Left Of The Quad (Left)		vertex3f -1.0f,-1.0f, 1.0f);					// Bottom Right Of The Quad (Left)		color3f (1.0f,0.0f,1.0f);						// Set The Color To Violet		vertex3f  1.0f, 1.0f,-1.0f);					// Top Right Of The Quad (Right)		vertex3f  1.0f, 1.0f, 1.0f);					// Top Left Of The Quad (Right)		vertex3f  1.0f,-1.0f, 1.0f);					// Bottom Left Of The Quad (Right)		vertex3f  1.0f,-1.0f,-1.0f);					// Bottom Right Of The Quad (Right)	glEnd();											// Done Drawing The Quad	rtri+=0.2f;											// Increase The Rotation Variable For The Triangle ( NEW )	rquad-=0.15f;										// Decrease The Rotation Variable For The Quad ( NEW )	return TRUE;										// Keep Going"! !!GLStef methodsFor: 'as yet unclassified' stamp: 'sd 2/22/2012 18:05'!perspectiveFovY: fovY aspect: aspect zNear: zNear zFar: zFar"Replaces gluPerspective. Sets the frustum to perspective mode.// fovY     - Field of vision in degrees in the y direction// aspect   - Aspect ratio of the viewport// zNear    - The near clipping distance// zFar     - The far clipping distance "	| fW fH |	fH := (fovY / (360 * Float pi)) tan * zNear.	"fH = tan( fovY / 360 * pi ) * zNear;"	fW := fH * aspect.	display gl frustum_left: fW negated  right:  fW bottom: fH negated top: fH  zNear:  zNear zFar:   zFar! !!GLStef methodsFor: 'as yet unclassified' stamp: 'sd 2/22/2012 19:11'!render	| gl |	self checkSession.	gl := display gl.	gl 		shadeModel: GL_SMOOTH;								clearDepth: 1; 	 	enable: GL_DEPTH_TEST;		depthFunc: GL_LEQUAL;		depthMask: true.									gl 		clearColor_red: 0.3 green:  0.3 blue:  0.3 alpha: 0;		clear: GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT.		gl matrixMode: GL_PROJECTION; 								loadIdentity.														self perspectiveFovY: 45.0 			aspect: (self width /self height) asFloat 			zNear:  0.1 zFar: 100.0.		gl matrixMode: GL_MODELVIEW. 							gl loadIdentity.		self drawCube.					gl flush"	self drawCube."! !!GLStef methodsFor: 'as yet unclassified' stamp: 'sd 2/22/2012 19:07'!step		rotationAngle := rotationAngle + 2.	self changed ! !!GLStef methodsFor: 'as yet unclassified' stamp: 'sd 2/22/2012 18:26'!stepTime	^ 5! !