Пример #1
0
void DaoxCanvas_glutDisplay(void)
{
	if( daox_current_painter && daox_current_canvas ){
		DaoxCanvas_UpdateScene( daox_current_canvas );
		DaoxPainter_Paint( daox_current_painter, daox_current_canvas, daox_current_canvas->viewport );
	}
	if( daox_current_renderer && daox_current_scene ){
		DaoxCamera *camera = DaoxRenderer_GetCurrentCamera( daox_current_renderer );
		camera->aspectRatio = window_width / (float) window_height;
		DaoCstruct_CallMethod( (DaoCstruct*) daox_current_scene, "Update" );
		DaoxRenderer_Render( daox_current_renderer, daox_current_scene, NULL );
	}

	glutSwapBuffers();

	DaoxCanvas_ApplyMaxFPS( fps_limit );

	if( test_fps ) DaoxCanvas_TestFPS();
}
Пример #2
0
void DaoxCanvas_glutSpecialKeyboard( int key, int x, int y )
{
	if( daox_current_renderer ){
		DaoxCamera *camera = DaoxRenderer_GetCurrentCamera( daox_current_renderer );
		float dx = 0.0;
		float dy = 0.0;
		float dz = 0.0;
		float delta = 10*camera->nearPlane;
		switch( key ){
		case GLUT_KEY_UP    : dz = - delta; break;
		case GLUT_KEY_DOWN  : dz = + delta; break;
		case GLUT_KEY_LEFT  : dx = - delta; break;
		case GLUT_KEY_RIGHT : dx = + delta; break;
		}
		DaoxCamera_MoveByXYZ( camera, dx, dy, dz );
	}
	if( daox_current_canvas == NULL ) return;
	DaoCstruct_CallKeyboardMethod( (DaoCstruct*) daox_current_canvas, "OnKeyboard", key, x, y );
}
Пример #3
0
static void GLUT_Render( DaoProcess *proc, DaoValue *p[], int N )
{
	daox_current_renderer = (DaoxRenderer*) p[0];
	daox_current_scene = (DaoxScene*) p[1];
	if( daox_current_renderer->buffer.vertexOffset == 0 ){
		DaoxModel *model = DaoxModel_New();
		DaoxMesh *mesh = DaoxMesh_New();
		DaoxCamera *cam = DaoxRenderer_GetCurrentCamera( daox_current_renderer );
		cam->aspectRatio = window_width / (float) window_height;
		DaoxMesh_MakeViewFrustumCorners( mesh, cam->fovAngle, cam->aspectRatio, cam->nearPlane );
		//DaoxMesh_MakeBoxObject( mesh );
		DaoxMesh_UpdateTree( mesh, 0 );
		DaoxModel_SetMesh( model, mesh );
		DaoxSceneNode_AddChild( (DaoxSceneNode*) cam, (DaoxSceneNode*) model );

		DaoxRenderer_InitShaders( daox_current_renderer );
		DaoxRenderer_InitBuffers( daox_current_renderer );
	}
	glutMainLoop();
}
Пример #4
0
static void RENDR_GetCurrentCamera( DaoProcess *proc, DaoValue *p[], int N )
{
	DaoxRenderer *self = (DaoxRenderer*) p[0];
	DaoxCamera *cam = DaoxRenderer_GetCurrentCamera( self );
	DaoProcess_PutValue( proc, (DaoValue*) cam );
}