Ejemplo n.º 1
0
// Fonction d'interaction : choix de l'opération à faire (cinématique directe / inverse)
void processMouseActiveMotion(int x, int y)
{
			
  switch (m_boutton)
    {

      // Cinématique inverse
    case GLUT_LEFT_BUTTON : // Manipulation par cinématique inverse

      //..

      break;





      // Cinématique directe
    case GLUT_MIDDLE_BUTTON : // Manipulation directe du segment UpArm

      //..

      break;

    case GLUT_RIGHT_BUTTON : // Manipulation durecte du segment LowArm
      
      m_LowArm.rot.z = m_Grab_LowArm_Rot_Z + ROTATE_SPEED  * (m_mousepos_x - x);
      DrawGLScene();
      
      break;
    }


}
Ejemplo n.º 2
0
void update(int value){
	


	DrawGLScene();
	glutPostRedisplay();		
	
//	block_left =block_left +  0.1f;		
//	robot_rot ++ ;
	//	printf("%f\n",Scale);
	_model->advance(0.025f);
	if(flag_scale==0){
		Scale = Scale + 0.1;
		block_left = block_left + 0.1f;
	}
	else{
		block_left = block_left - 0.1f;
		Scale = Scale - 0.1;
	}
	if(Scale >= 2.0 || Scale <= 0.0)
		flag_scale = !flag_scale ;
/*	if(w_flag!=1){
		_model->setAnimation("stand");
		w_flag=0;
	}*/

	glutTimerFunc(100,update,0);
}
Ejemplo n.º 3
0
void OnPaint(HWND hwnd)
{
	DrawGLScene();
	SwapBuffers(hDC);
	DrawPicture(hwnd);
	DrawFigure();
}
Ejemplo n.º 4
0
int main(void) {
//---------------------------------------------------------------------------------
	
        tblu = bluCreate();
	initRes();
	bsp = *((bluSprite*)tblu->System_ResourceFactory());
	tblu->Input_Init();
	tblu->GFX_Initiate();	
	tblu->GFX_LDSprite(&bsp);
	tblu->GFX_InitAnimationFrames(&tban, 2);
	tblu->GFX_AddAnimationFrame(&tban, 0, sgunTiles, sgunPal, sgunTilesLen, sgunPalLen);
	tblu->GFX_AddAnimationFrame(&tban, 1, sgunTiles+512, sgunPal, sgunTilesLen, sgunPalLen);
	tblu->System_SetFunc(FrameProc, BLUFRAMFUNC);
	consoleDemoInit();  //setup the sub screen for printing
	tblu->System_Start();

	tblu->GFX_Init3DDevice();
	while(1){
	DrawGLScene();
	glFlush(0);	

	}

/*	tblu->Release();
	while(1) {

		touchRead(&touch);
		iprintf("Touch y = %04i, %04i\n", touch.rawy, touch.py);

		swiWaitForVBlank();
	}

*/	return 0;
}
Ejemplo n.º 5
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
	MSG		msg;								
	BOOL	done=FALSE;						

	init("window",640,480);

	if (CreateGLWindow() == FALSE){
		return 0;									
	}
	elemInit();
	while(!done){
		if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)){
			if (msg.message==WM_QUIT){
				done=TRUE;
			}else{
				TranslateMessage(&msg);				
				DispatchMessage(&msg);				
			}
		}else{
			if (keys[VK_ESCAPE]){
				done=TRUE;						
			}else{
				DrawGLScene();					
				SwapBuffers(hDC);			
			}
		}
	}

	KillGLWindow();									
	return (msg.wParam);							
}
Ejemplo n.º 6
0
void keyPressed(unsigned char key, int x, int y) 
{
  switch(key) {
    case 27:
      glutDestroyWindow(window); 
      exit(0);                   
    case 'r':
      doRotate = !doRotate;
      break;
    case 't':
      doTranslate = !doTranslate;
      break;
    case 's':
      doScale = !doScale;
      break;
    case '+':
      speed *= 1.1;
      frame = 0;
      break;
    case '-':
      speed /= 1.1;
      frame = 0;
      break;
    default:
      useMyOrtho = !useMyOrtho;
      ReSizeGLScene(windowWidth,windowHeight);
  }      
  DrawGLScene();
}
/***************************************************************************
 callback_display
 ****************************************************************************/
void callback_display(void)
{
    //GLint viewport[4];
    //glGetIntegerv(GL_VIEWPORT, viewport);
    
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
	
    //gluPerspective(15.0, aspect, zNear, zFar);
	
    //glOrtho(-1/sdepth*kWindowWidth, 1/sdepth*kWindowWidth, -1/sdepth*kWindowHeight, 1/sdepth*kWindowHeight, zNear, zFar);
    glTranslatef(0.0,0.0,-100);
	
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity(); 
    //glTranslatef(0.0,0.0,-sdepth);
    glRotatef(-stheta, 1.0, 0.0, 0.0);
    glRotatef(sphi, 0.0, 0.0, 1.0);
    
	
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    DrawGLScene();
    
    //glTranslatef(0.0,0.0, sdepth);
    glutSwapBuffers();
}
Ejemplo n.º 8
0
static gboolean
update_sdl_scene (void *fk)
{
  GstElement *fakesink = (GstElement *) fk;
  GMainLoop *loop =
      (GMainLoop *) g_object_get_data (G_OBJECT (fakesink), "loop");
  GAsyncQueue *queue_input_buf =
      (GAsyncQueue *) g_object_get_data (G_OBJECT (fakesink),
      "queue_input_buf");
  GAsyncQueue *queue_output_buf =
      (GAsyncQueue *) g_object_get_data (G_OBJECT (fakesink),
      "queue_output_buf");
  GstBuffer *buf = (GstBuffer *) g_async_queue_pop (queue_input_buf);

  SDL_Event event;
  while (SDL_PollEvent (&event)) {
    if (event.type == SDL_QUIT) {
      g_main_loop_quit (loop);
    }
    if (event.type == SDL_KEYDOWN) {
      if (event.key.keysym.sym == SDLK_ESCAPE) {
        g_main_loop_quit (loop);
      }
    }
  }

  DrawGLScene (buf);

  /* push buffer so it can be unref later */
  g_async_queue_push (queue_output_buf, buf);

  return FALSE;
}
Ejemplo n.º 9
0
LRESULT CGLLogoView::OnSize(UINT, WPARAM, LPARAM lParam, BOOL&)
{
	ResizeScene(LOWORD(lParam),HIWORD(lParam));  // LoWord=width, HiWord=height
	DrawGLScene();
	SwapBuffers(hDC);
	return TRUE;								
}
Ejemplo n.º 10
0
int WINAPI WinMain(	HINSTANCE	hInstance,			// Instance
					HINSTANCE	hPrevInstance,		// Previous Instance
					LPSTR		lpCmdLine,			// Command Line Parameters
					int			nCmdShow)			// Window Show State
{
	MSG		msg;									// Windows Message Structure
	BOOL	done=FALSE;								// Bool Variable To Exit Loop

	// Ask The User Which Screen Mode They Prefer
	if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)
	{
		fullscreen=FALSE;							// Windowed Mode
	}

	InitVars();                                     // Initialize Variables

	// Create Our OpenGL Window
	if (!CreateGLWindow("Magic Room",640,480,16,fullscreen))
	{
		return 0;									// Quit If Window Was Not Created
	}

	while(!done)									// Loop That Runs While done=FALSE
	{
		if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))	// Is There A Message Waiting?
		{
			if (msg.message==WM_QUIT)				// Have We Received A Quit Message?
			{
				done=TRUE;							// If So done=TRUE
			}
			else									// If Not, Deal With Window Messages
			{
				TranslateMessage(&msg);				// Translate The Message
				DispatchMessage(&msg);				// Dispatch The Message
			}
		}
		else										// If There Are No Messages
		    if (active)
			{
				// Draw The Scene.  Watch For ESC Key And Quit Messages From DrawGLScene()
				if (keys[VK_ESCAPE])	// Active?  Was There A Quit Received?
				{
					done=TRUE;							// ESC or DrawGLScene Signalled A Quit
				}
				else									// Not Time To Quit, Update Screen
				{
					idle();                             // Advance Simulation
					DrawGLScene();                      // Draw Scene
					SwapBuffers(hDC);					// Swap Buffers (Double Buffering)
				}
	
				if (!ProcessKeys()) return 0;
			}
	}

	// Shutdown
	KillGLWindow();									// Kill The Window
    glDeleteTextures(4,texture);
	return (msg.wParam);							// Exit The Program
}
Ejemplo n.º 11
0
void keyPressed(unsigned char key, int x, int y)
{
    switch(key) {
    case 27:
      glutDestroyWindow(window);
      exit(0);
    case 'r':
      x_rotation = 0.0f;
      z_rotation = 0.0f;
      rotation_mode = ROTATE_X_AND_Z;
      printf("X and Z rotation reset to 0 degrees\n");
      printf("Mouse rotates around both X and Z axes\n");
      break;
    case 'x':
      rotation_mode = ROTATE_ONLY_X;
      printf("Mouse rotates only around X axis\n");
      break;
    case 'z':
      rotation_mode = ROTATE_ONLY_Z;
      printf("Mouse rotates only around Z axis\n");
      break;
    }

    DrawGLScene();
}
Ejemplo n.º 12
0
LONG WINAPI ScreenSaverProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam){
    // Handles screen saver messages
    switch(message)
    {
    case WM_CREATE:
        // Creation of the screen saver window
		hWnd = hwnd;
		SetupOpenGL();
		// Set Timer (Target 60 fps ish (1000/60 = 16)
		uTimer = SetTimer(hwnd, 1, 16, NULL);
        return 0;

    case WM_ERASEBKGND:
        // Erases the screen saver background
		// Not needed with OpenGL
        return 0;

    case WM_TIMER:
        // Handles the timer
		DrawGLScene();
        return 0;

    case WM_DESTROY:
        // Cleans up the screen saver window
		KillTimer(hwnd, uTimer);
		KillGL();
        PostQuitMessage(0);
        return 0;
    }
    return DefScreenSaverProc(hwnd,message,wparam,lparam);
}
Ejemplo n.º 13
0
Archivo: main.cpp Proyecto: GGBone/Nehe
int WINAPI WinMain(HINSTANCE hInstance,
	HINSTANCE hPreInstance,
	LPSTR lpCmdLine,
	int cmdShow)
{
	MSG msg;
	BOOL done = false;

	CreateGLWindow("openGL", 640, 480, 32, true);


	while (!done)
	{
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			if (msg.message == WM_QUIT)
			{
				done = TRUE;
			}
			else
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
		else
		{
			if (active)
			{
				if (keys[VK_ESCAPE])
				{
					done = TRUE;
				}
				else
				{
					DrawGLScene();
					SwapBuffers(hDC);
				}
			}
			if (keys[VK_F1])
			{
				keys[VK_F1] = FALSE;
				KillGLWindow();
				fullscreen = !fullscreen;
				if (!CreateGLWindow("NeHe's OpenGL Framework", 640, 480, 16, fullscreen))
				{
					return 0;
				}
			}
		}
	}
	//注册窗口类

	//程序初始化

	//消息循环
	return (msg.wParam);
}
Ejemplo n.º 14
0
int main() {
		
	// Setup the Main screen for 3D 
	videoSetMode(MODE_0_3D);
		
	// initialize the geometry engine
	glInit();
	
	// enable antialiasing
	glEnable(GL_ANTIALIAS);
	
	// setup the rear plane
	glClearColor(0,0,0,31); // BG must be opaque for AA to work
	glClearPolyID(63); // BG must have a unique polygon ID for AA to work
	glClearDepth(0x7FFF);
	
	// Set our viewport to be the same size as the screen
	glViewport(0,0,255,191);
	
	// setup the view
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(70, 256.0 / 192.0, 0.1, 100);
	
	
	//ds specific, several attributes can be set here	
	glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE);
	
	while (1) 
	{
		// Set the current matrix to be the model matrix
		glMatrixMode(GL_MODELVIEW);
		
		glColor3f(1, 1, 1);									// Set the color..not in nehe source...ds gl default will be black
		
		//Push our original Matrix onto the stack (save state)
		glPushMatrix();	

		DrawGLScene();
		
		// Pop our Matrix from the stack (restore state)
		glPopMatrix(1);

		//a handy little built in function to wait for a screen refresh
		swiWaitForVBlank();

		// flush to screen	
		glFlush(0);

		scanKeys();

		int pressed = keysDown();

		if(pressed & KEY_START) break;	
	}
	
	return 0;
}
Ejemplo n.º 15
0
void
specialKeyPressed(int key, int x, int y)
{
    (void)x;
    (void)y;
    (void)key;

    DrawGLScene();
}
Ejemplo n.º 16
0
LRESULT CGLLogoView::OnTimer(UINT, WPARAM wParam, LPARAM, BOOL&)
{
	if (wParam = m_Timer)
	{
		DrawGLScene();
		SwapBuffers(hDC);
	}
	return TRUE;
}
Ejemplo n.º 17
0
//
// Run_Anim
// - combine animation and draw scene
void Run_Anim(void)
{

	if (ant_globals->paused == 0)
		AnimateScene();		// do all the processing 

	DrawGLScene();		// render to window

} // end of the function
void CHOpenGLView::OnDraw(CDC* /*pDC*/)
{
	CHOpenGLDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	// TODO: 여기에 원시 데이터에 대한 그리기 코드를 추가합니다.
	DrawGLScene();
}
Ejemplo n.º 19
0
int Game::Run()
{
    srand( timeGetTime() );
    map.PopulateMap();
    MSG msg;
    while(!done)									// Loop That Runs While done=FALSE
    {
        if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))	// Is There A Message Waiting?
        {
            if (msg.message==WM_QUIT)				// Have We Received A Quit Message?
            {
                done=TRUE;							// If So done=TRUE
            }
            else									// If Not, Deal With Window Messages
            {
                TranslateMessage(&msg);				// Translate The Message
                DispatchMessage(&msg);				// Dispatch The Message
            }
        }
        else										// If There Are No Messages
        {
            // Draw The Scene.  Watch For ESC Key And Quit Messages From DrawGLScene()
            if (active)								// Program Active?
            {
                if (keys[VK_ESCAPE])				// Was ESC Pressed?
                {
                    done=TRUE;						// ESC Signalled A Quit
                }
                else								// Not Time To Quit, Update Screen
                {
                    DWORD time = timeGetTime();
                    DWORD lapse = time - currentTime;
                    currentTime = time;
                    Update(lapse);
                    DrawGLScene();					// Draw The Scene
                    SwapBuffers(hDC);				// Swap Buffers (Double Buffering)
                }
            }

            if (keys[VK_F1])						// Is F1 Being Pressed?
            {
                keys[VK_F1]=FALSE;					// If So Make Key FALSE
                KillGLWindow();						// Kill Our Current Window
                fullscreen=!fullscreen;				// Toggle Fullscreen / Windowed Mode
                // Recreate Our OpenGL Window
                if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen))
                {
                    return 0;						// Quit If Window Was Not Created
                }
            }
        }
    }

    return 0;
}
Ejemplo n.º 20
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
	LPSTR lpCmdLine, int nCmdShow)
{
	MSG		msg;	// Структура сообщения Windows
	WNDCLASS	wc; // Структура класса Windows для установки типа окна
	HWND		hWnd;	// Сохранение дескриптора окна
	wc.style		 = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
	wc.lpfnWndProc	 = (WNDPROC) WndProc;
	wc.cbClsExtra	 = 0;
	wc.cbWndExtra	 = 0;
	wc.hInstance	 = hInstance;
	wc.hIcon		 = NULL;
	wc.hCursor		 = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground	 = NULL;
	wc.lpszMenuName	 = NULL;
	wc.lpszClassName	 = "OpenGL WinClass";
	if(!RegisterClass(&wc)){
		MessageBox(0, 
			"Failed To Register The WindowClass.", 
			"Error", MB_OK|MB_ICONERROR);
		return FALSE;
	}
	hWnd = CreateWindow("OpenGL WinClass", 
		"OpenGL | Lab #5 | Quadric objects", 	// Заголовок вверху окна
		WS_OVERLAPPEDWINDOW, 
		CW_USEDEFAULT, CW_USEDEFAULT, 			// Позиция окна на экране
		1024, 768, 		// Ширина и высота окна
		NULL, 
		NULL, 
		hInstance, 
		NULL);
	if(!hWnd){
		MessageBox(0, "Window Creation Error.", "Error", MB_OK|MB_ICONERROR);
		return FALSE;
	}
	if(!hWnd){
		MessageBox(0, "Window Creation Error.", "Error", MB_OK|MB_ICONERROR);
		return FALSE;
	}
	ShowWindow(hWnd, SW_SHOW);
	UpdateWindow(hWnd);
	SetFocus(hWnd);
	while (1){		// Обработка всех сообщений
		while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)){
			if (GetMessage(&msg, NULL, 0, 0)){
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
			else
				return TRUE;
		}
		DrawGLScene();				// Нарисовать сцену
		SwapBuffers(hDC);		// Переключить буфер экрана
	}
}
Ejemplo n.º 21
0
bool SetKeyPress(int musicNum)
{
    if((musicNum >= MAX_KEY_NUM) || (musicNum < 0))
    {
        return false;
    }
    g_PressWhichKey = musicNum;
    EnterCriticalSection(&g_csPiano);
    g_pianoMelody->Play(musicNum);
    LeaveCriticalSection(&g_csPiano);
    DrawGLScene();
    return true;
}
Ejemplo n.º 22
0
int main()
{
    gfxInitDefault();
    hidInit(NULL);

    void* device = gfxCreateDevice(240, 400);
    gfxMakeCurrent(device);

    glViewport(0, 0, 240, 400);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    float near = 0.1f;
    float far = 100.0f;
    float fov = 90.0f;
    float aspect = 240.0f / 400.0f;
    float t = tan(fov * 3.14159 / 360.0) * near;
    float b = -t;
    float l = aspect * b;
    float r = aspect * t;
    glFrustumf(l, r, b, t, near, far);
    //3DS' framebuffers are sideways
    glRotatef(-90.0f, 0.0f, 0.0f, 1.0f);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glEnable(GL_DEPTH_TEST);

    while (aptMainLoop())
    {
        hidScanInput();

        if (keysDown() & KEY_START)
            break;

        DrawGLScene();

        gfxFlush(gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL));
        gfxFlushBuffers();
        gfxSwapBuffersGpu();
        gspWaitForVBlank();
    }

    // Exit services
    gfxExit();
    hidExit();
    return 0;
}
static gboolean
executeCallback (gpointer data)
{
  GstSample *sample = (GstSample *) data;

  g_mutex_lock (&app_lock);

  DrawGLScene (sample);

  g_cond_signal (&app_cond);
  g_mutex_unlock (&app_lock);

  return FALSE;
}
Ejemplo n.º 24
0
LRESULT CALLBACK viewwndProc(HWND hwnd, UINT message,
    WPARAM wParam, LPARAM lParam)
{  
    switch (message)
    {
    case WM_CREATE: 
        break; 
    case WM_MOUSEMOVE:
        if (wParam & MK_LBUTTON)
        {
            int xPos = LOWORD(lParam);
            int yPos = HIWORD(lParam);
            objCamera.Mouse_Move(width, height);
            DrawGLScene();
        }
        break;

    case WM_LBUTTONDOWN: {
        ShowCursor(FALSE);
        POINT p;
        p.x = LOWORD(lParam);
        p.y = HIWORD(lParam);
        ClientToScreen(hwnd, &p);
        objCamera.centerX = p.x;
        objCamera.centerY = p.y;
        break;
    } 
    case WM_LBUTTONUP:
    case WM_KILLFOCUS:
        ShowCursor(TRUE);
    case WM_ACTIVATE:                              // Watch For Window Activate Message 
    case WM_NCLBUTTONDOWN:
        SetFocus(mainWindow); 
        break;

    case WM_SYSCOMMAND:                            // Intercept System Commands
        {
            switch (wParam)                        // Check System Calls
            {
            case SC_SCREENSAVE:                    // Screensaver Trying To Start?
            case SC_MONITORPOWER:                  //  Monitor Trying To Enter Powersave?
                return 0;                          // Prevent From Happening
            }
            break;                                 // Exit
        } 
    }
    return DefMDIChildProc(hwnd, message, wParam, lParam);
}
Ejemplo n.º 25
0
void Idle(){

  bool trigger = 1;
  
  
  if(acquire_countdown <= 0){
    trigger = pollGPIO();
  }
  
  if(!trigger){ // gpio is a pull-up so look for 0
    acquireFrame();
  }
  
  fflush(stdout);
  DrawGLScene();
}
Ejemplo n.º 26
0
bool OMG_Impl::System_Start()
	{
	System_Log("Trying to start!");

	//timer
	timer->Start();
	t_last = timer->Get();
	t_new = timer->Get();

	//main loop
	for(;;)
		{
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
			{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
			}
		if(active)
			{
			if (done)
				break;
			t_new = timer->Get();
			if(t_new - t_last > t_step)
				{
				if (!DrawGLScene())
					done = TRUE;

				if(procFrameFunc)
					if (procFrameFunc())
						break;

				_Input_Update();

				SwapBuffers(hDC);
				t_last = t_new;
				}

			else
				Sleep(0);
			}
			else
				Sleep(1);
	}
	KillGLWindow();
	return true;
	}
Ejemplo n.º 27
0
gboolean update_gl_scene (void *fk)
{
  GstElement *fakesink = (GstElement *) fk;
  GAsyncQueue *queue_input_buf =
      (GAsyncQueue *) g_object_get_data (G_OBJECT (fakesink),
      "queue_input_buf");
  GAsyncQueue *queue_output_buf =
      (GAsyncQueue *) g_object_get_data (G_OBJECT (fakesink),
      "queue_output_buf");
  GstGLBuffer *gst_gl_buf = (GstGLBuffer *) g_async_queue_pop (queue_input_buf);

  DrawGLScene (gst_gl_buf);

  /* push buffer so it can be unref later */
  g_async_queue_push (queue_output_buf, gst_gl_buf);

  return FALSE;
}
Ejemplo n.º 28
0
//
// Run_Anim
// - combine animation and draw scene
void Run_Anim(void)
{

    if (ant_globals->paused == 0) {
        AnimateScene();

        // play music
        //Play_Music();

    } // end of the fi

    DrawGLScene();		// render to window


    // Swap buffers
    glXSwapBuffers(GLWin.dpy, GLWin.win);

} // end of the function
Ejemplo n.º 29
0
void specialKeyPressed(int key, int x, int y) 
{
  switch(key) {
    case GLUT_KEY_LEFT: 
      cameraRotationSpeed += 0.001;
      break;
    case GLUT_KEY_RIGHT: 
      cameraRotationSpeed -= 0.001;
      break;
    case GLUT_KEY_UP: 
      cameraHeightTarget += 1;
      break;
    case GLUT_KEY_DOWN: 
      cameraHeightTarget -= 1;
      break;
  }
  DrawGLScene();
}
Ejemplo n.º 30
0
int main(int argc, char **argv) 
{  
  int done;

  /* Initialize SDL for video output */
  if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
    fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
    exit(1);
  }

  /* Create a 640x480 OpenGL screen */
  if ( SDL_SetVideoMode(640, 480, 0, SDL_OPENGL) == NULL ) {
    fprintf(stderr, "Unable to create OpenGL screen: %s\n", SDL_GetError());
    SDL_Quit();
    exit(2);
  }

  /* Set the title bar in environments that support it */
  SDL_WM_SetCaption("Jeff Molofee's GL Code Tutorial ... NeHe '99", NULL);

  /* Loop, drawing and checking events */
  InitGL(640, 480);
  done = 0;
  while ( ! done ) {
    DrawGLScene();

    /* This could go in a separate function */
    { SDL_Event event;
      while ( SDL_PollEvent(&event) ) {
        if ( event.type == SDL_QUIT ) {
          done = 1;
        }
        if ( event.type == SDL_KEYDOWN ) {
          if ( event.key.keysym.sym == SDLK_ESCAPE ) {
            done = 1;
          }
        }
      }
    }
  }
  SDL_Quit();
  return 1;
}