void GraphicsManager::renderScene() { Common::enforceMainThread(); cleanupAbandoned(); if (_frameLock.load(boost::memory_order_acquire) > 0) { _frameEndSignal.store(true, boost::memory_order_release); return; } beginScene(); if (playVideo()) { endScene(); return; } renderGUIBack(); renderWorld(); renderGUIFront(); renderCursor(); endScene(); _frameEndSignal.store(true, boost::memory_order_release); }
void keyReleaseEvent(int keyCode) { if(keyCode == MAK_CLEAR) { if(currentLength!=0)currentLength--; currentString[currentLength] = 0; int h = renderCurrent(); sprintf(buff, "%s", currentString); mExtent = maGetTextSize(buff); maDrawText(1,h,buff); h+=EXTENT_Y(mExtent); renderCursor(h, EXTENT_X(mExtent)); } if(keyCode == MAK_SOFTRIGHT) { const char* ms = matchString.c_str(); if(strcmp(ms, currentString) == 0) assert(name, true); else assert(name, false); MAUtil::Environment::getEnvironment().removeKeyListener(this); //printf("charInput test finished\n"); suite->runNextCase(); } }
/* * Start the aim screen. */ void initAim() { aimX = 0; aimY = 0; renderMap(&enemyMap); renderCursor(aimX, aimY); renderAimInfo(); }
void Viewer::onRender() { // clear the vertex and face counters m_vertexCount = 0; m_faceCount = 0; // clear all the buffers glClearColor(0.0f, 0.0f, 0.3f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // set the projection transformation glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f, (GLdouble)m_width / (GLdouble)m_height, m_scale * 50.0, m_scale * 1000.0); // set the model transformation glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // light attributes const GLfloat light_ambient[] = { 0.3f, 0.3f, 0.3f, 1.0f }; const GLfloat light_diffuse[] = { 0.52f, 0.5f, 0.5f, 1.0f }; const GLfloat light_specular[] = { 0.1f, 0.1f, 0.1f, 1.0f }; // setup the light attributes glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); // set the light position GLfloat lightPosition[] = { 0.0f, -1.0f, 1.0f, 1.0f }; glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); // set camera position glTranslatef(0.0f, 0.0f, -m_distance * m_scale); glRotatef(m_tiltAngle, 1.0f, 0.0f, 0.0f); glRotatef(m_twistAngle, 0.0f, 0.0f, 1.0f); glTranslatef(0.0f, 0.0f, -90.0f * m_scale); glTranslatef(0.0f, 0.0f, m_camheight); // render the model renderModel(); // render the cursor renderCursor(); // swap the front- and back-buffer glutSwapBuffers(); // increase frame counter m_fpsFrames++; //printf("%d\n",m_fps); }
void characterChanged(char c) { int h = renderCurrent(); currentString[currentLength] = c; currentString[currentLength+1] = 0; sprintf(buff, "%s", currentString); mExtent = maGetTextSize(buff); maDrawText(1,h,buff); h+=EXTENT_Y(mExtent); renderCursor(h, EXTENT_X(mExtent)-8); }
void GraphicsManager::renderScene() { Common::enforceMainThread(); cleanupAbandoned(); if (_frameLock > 0) return; beginScene(); if (playVideo()) { endScene(); return; } renderWorld(); renderGUIFront(); renderCursor(); endScene(); }
void Viewer::onRender() { static char s[20]; // clear the vertex and face counters m_vertexCount = 0; m_faceCount = 0; // clear all the buffers g_pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,77), 1.0f, 0 ); // Setup Prespective matrix g_pD3DDevice->BeginScene(); D3DXMATRIX matProj; D3DXMatrixPerspectiveFovRH( &matProj, D3DX_PI/4, (float) m_width / (float) m_height, m_scale * 50.0f, m_scale * 1000.0f ); g_pD3DDevice->SetTransform( D3DTS_PROJECTION, &matProj ); // setup the light attributes D3DLIGHT9 light; ZeroMemory( &light, sizeof(D3DLIGHT9) ); light.Type = D3DLIGHT_DIRECTIONAL; light.Ambient.r=0.3f;light.Ambient.g=0.3f;light.Ambient.b=0.3f;light.Ambient.a=1.0f; light.Diffuse.r=0.9f;light.Diffuse.g=0.9f;light.Diffuse.b=0.9f;light.Diffuse.a=1.0f; light.Specular.r=0.1f;light.Specular.g=0.1f;light.Specular.b=0.1f;light.Specular.a=1.0f; light.Direction= D3DXVECTOR3(0.0f,0.70f,0.70f); g_pD3DDevice->SetLight( 0, &light ); g_pD3DDevice->LightEnable( 0, TRUE ); g_pD3DDevice->SetRenderState( D3DRS_LIGHTING, TRUE ); D3DXMATRIX Mat1,Mat2; D3DXMatrixIdentity(&Mat1); D3DXMatrixTranslation(&Mat2,0.0f,0.0f,-m_distance * m_scale); D3DXMatrixMultiply(&Mat1,&Mat2,&Mat1); D3DXMatrixRotationX(&Mat2, m_tiltAngle/180.0f*3.14159f); D3DXMatrixMultiply(&Mat1,&Mat2,&Mat1); D3DXMatrixRotationZ(&Mat2, m_twistAngle/180.0f*3.14159f); D3DXMatrixMultiply(&Mat1,&Mat2,&Mat1); D3DXMatrixTranslation(&Mat2,0.0f,0.0f,-90.0f * m_scale); //I have done à 1/1 translation D3DXMatrixMultiply(&Mat1,&Mat2,&Mat1); //of the OpenGL version g_pD3DDevice->SetTransform( D3DTS_VIEW, &Mat1 ); D3DXMatrixIdentity( &Mat1 ); g_pD3DDevice->SetTransform( D3DTS_WORLD, &Mat1 ); // render the model renderModel(); g_pD3DDevice->SetRenderState( D3DRS_LIGHTING, FALSE ); // render the cursor renderCursor(); RECT FontPosition; FontPosition.top = 0; FontPosition.left = 0; FontPosition.right = 100; FontPosition.bottom = 100; sprintf(s,"%d",m_fps); // // There are changes here between Direct3D SDK 9 and Direct3D SDK 9 summer 2003 update // /* Original SDK m_pFont->Begin(); m_pFont->DrawText(s,-1,&FontPosition,DT_CENTER,0xffffffff); m_pFont->End(); */ ///* Update m_pFont->DrawText(NULL,s,-1,&FontPosition,DT_CENTER,0xffffffff); //*/ g_pD3DDevice->EndScene(); // swap the front- and back-buffer g_pD3DDevice->Present( NULL, NULL, NULL, NULL ); // increase frame counter m_fpsFrames++; }
void Viewer::onRender() { static char s[40]; // clear the vertex and face counters m_vertexCount = 0; m_faceCount = 0; // clear all the buffers g_pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,77), 1.0f, 0 ); // Setup Prespective matrix g_pD3DDevice->BeginScene(); D3DXMATRIX matProj,matWorld,matView, matViewInv; D3DXMatrixPerspectiveFovRH( &matProj, D3DX_PI/4, (float)m_width / (float)m_height, m_scale * 50.0f, m_scale * 1000.0f ); g_pD3DDevice->SetTransform( D3DTS_PROJECTION, &matProj ); D3DXMATRIX Mat1,Mat2; // tmp matrix D3DXMatrixIdentity(&Mat1); D3DXMatrixTranslation(&Mat2,0.0f,0.0f,-m_distance * m_scale); D3DXMatrixMultiply(&Mat1,&Mat2,&Mat1); D3DXMatrixRotationX(&Mat2, m_tiltAngle/180.0f*3.14159f); D3DXMatrixMultiply(&Mat1,&Mat2,&Mat1); D3DXMatrixRotationZ(&Mat2, m_twistAngle/180.0f*3.14159f); D3DXMatrixMultiply(&Mat1,&Mat2,&Mat1); D3DXMatrixTranslation(&Mat2,0.0f,0.0f,-90.0f * m_scale); //I have done à 1/1 translation D3DXMatrixMultiply(&matView,&Mat2,&Mat1); //of the OpenGL version g_pD3DDevice->SetTransform( D3DTS_VIEW, &matView ); D3DXMatrixIdentity(&matWorld); g_pD3DDevice->SetTransform( D3DTS_WORLD, &matWorld ); // setup the light attributes D3DLIGHT9 light; ZeroMemory( &light, sizeof(D3DLIGHT9) ); light.Type = D3DLIGHT_DIRECTIONAL; light.Ambient.r=0.2f;light.Ambient.g=0.2f;light.Ambient.b=0.2f;light.Ambient.a=1.0f; light.Diffuse.r=1.0f;light.Diffuse.g=1.0f;light.Diffuse.b=1.0f;light.Diffuse.a=1.0f; light.Specular.r=0.1f;light.Specular.g=0.1f;light.Specular.b=0.1f;light.Specular.a=1.0f; //light.Direction= D3DXVECTOR3(0.0f,0.70f,0.70f); light.Direction= D3DXVECTOR3(sinf(Tick::getTick()/1000.0f),cosf(Tick::getTick()/1000.0f),-0.5f); float r=light.Direction.x*light.Direction.x +light.Direction.y*light.Direction.y +light.Direction.z*light.Direction.z; light.Direction.x/=r; light.Direction.y/=r; light.Direction.z/=r; g_pD3DDevice->SetLight( 0, &light ); g_pD3DDevice->LightEnable( 0, TRUE ); g_pD3DDevice->SetRenderState( D3DRS_LIGHTING, TRUE ); if(m_bBump) { g_pD3DDevice->SetVertexShaderConstantF(13, (float*)&light.Diffuse, 1 ); g_pD3DDevice->SetVertexShaderConstantF(14, (float*)&light.Specular, 1 ); g_pD3DDevice->SetVertexShaderConstantF(15, (float*)&light.Ambient, 1 ); g_pD3DDevice->SetVertexShaderConstantF(16, (float*)&(-((D3DXVECTOR3)light.Direction)), 1 ); D3DXMatrixTranspose( &Mat1, &matWorld ); g_pD3DDevice->SetVertexShaderConstantF( 0, (float*)&Mat1, 4 ); D3DXMatrixMultiply( &Mat1, &matView, &matProj ); D3DXMatrixMultiply( &Mat1, &matWorld, &Mat1 ); D3DXMatrixTranspose( &Mat1, &Mat1 ); g_pD3DDevice->SetVertexShaderConstantF( 4, (float*)&Mat1, 4 ); float Const[4] = {0.5f,0.5f,0.5f,0.5f}; g_pD3DDevice->SetVertexShaderConstantF( 20,Const, 1 ); } // render the model renderModel(); g_pD3DDevice->SetRenderState( D3DRS_LIGHTING, FALSE ); // render the cursor renderCursor(); RECT FontPosition; FontPosition.top = 0; FontPosition.left = 0; FontPosition.right = m_width; FontPosition.bottom = 100; sprintf(s,"%d fps, press 'b' to toggle bump mapping",m_fps); // // There are changes here between Direct3D SDK 9 and Direct3D SDK 9 summer 2003 update // /* Original SDK m_pFont->Begin(); m_pFont->DrawText(s,-1,&FontPosition,DT_CENTER,0xffffffff); m_pFont->End(); */ ///* Update m_pFont->DrawText(NULL,s,-1,&FontPosition,DT_CENTER,0xffffffff); //*/ g_pD3DDevice->EndScene(); // swap the front- and back-buffer g_pD3DDevice->Present( NULL, NULL, NULL, NULL ); // increase frame counter m_fpsFrames++; }
/** * Update the aim screen. * @returns bool true if the player has fired, false otherwise */ bool updateAim() { float vert = joyReadF(true), horiz = joyReadF(false); bool updated = false; if(vert < -joyThreshold && aimY > 0) { aimY--; updated = true; } else if(vert > joyThreshold && aimY < MAP_SIZE - 1) { aimY++; updated = true; } if(horiz < -joyThreshold && aimX > 0) { aimX--; updated = true; } else if(horiz > joyThreshold && aimX < MAP_SIZE - 1) { aimX++; updated = true; } if (updated) { renderMap(&enemyMap); renderCursor(aimX, aimY); } if(buttonAPressed() && getState(enemyMap.squares[indexFromPos(aimX, aimY)]) == Map::UNKNOWN) { // Fire the shot! listenUntil(ENQ); sendPosition(aimX, aimY); // Get back a response bool hit = false; Ship::TYPES type = Ship::NONE; getResponse(&hit, &type); Serial.print("Hit: ");//DEBUG Serial.println(hit);//DEBUG Serial.print("Type: ");//DEBUG Serial.println(getTypeName(type));//DEBUG if (hit) { if (type != Ship::NONE) { String name = getTypeName(type); enemyMap.ships[getShipIndex(type)].health = 0; String message[] = {"You sunk the enemy's", name + "!"}; renderMessage(message, 2); } else { String message[] = {"You hit!"}; renderMessage(message, 1); } } else { String message[] = {"You missed!"}; renderMessage(message, 1); } setState(&enemyMap.squares[indexFromPos(aimX, aimY)], hit ? Map::HIT : Map::MISS); renderMap(&enemyMap); renderCursor(aimX, aimY); while (!buttonAPressed()) {} return true; } return false; }
/* The main drawing function. */ void DrawGLScene(void) { glMatrixMode(GL_MODELVIEW); // clear all the buffers - gives OpenGL full control // OpenSG doesn't clear the background because of the PassiveBackground object glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // set the model transformation glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // set camera position from mouse movement glTranslatef(0.0f, 0.0f, -m_distance); glRotatef(m_tiltAngle, 1.0f, 0.0f, 0.0f); glRotatef(m_twistAngle, 0.0f, 0.0f, 1.0f); //glTranslatef(0.0f, 0.0f, -90.0f); glPushMatrix(); // OpenSG will overwrite OSG::Real32 proj_matrix[16], model_matrix[16]; glGetFloatv(GL_PROJECTION_MATRIX, proj_matrix); glGetFloatv(GL_MODELVIEW_MATRIX, model_matrix); // retrieve OpenGL's matrices OSG::Matrix proj, model; proj.setValue(proj_matrix); model.setValue(model_matrix); newcam->setProjectionMatrix(proj); // transform the world just like the OpenGL content // necessary since OpenSG's modelview transforms start from the unity matrix. newcam->setModelviewMatrix(model); // setup an initial transformation OSG::Matrix m1; OSG::Quaternion q1; // mind that the VRML base coordinate system has different meanings for X, Y, Z, hence the rotation for 90 degrees. // this, together with the MatrixCamera code above hooks OpenSG to OpenGL ! m1.setIdentity(); q1.setValueAsAxisDeg(1, 0, 0., 90); // rotation m1.setRotate(q1); trans->setMatrix(m1); OSG::commitChanges(); // redraw the OpenSG window content - the calls are a bit after one's own taste pwin->render(mgr->getRenderAction()); //pwin->frameInit(); //pwin->frameExit(); //mgr->redraw(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); //################ START FOR OPENGL STUFF // light attributes const GLfloat light_ambient[] = { 0.3f, 0.3f, 0.3f, 1.0f }; const GLfloat light_diffuse[] = { 0.52f, 0.5f, 0.5f, 1.0f }; const GLfloat light_specular[] = { 0.1f, 0.1f, 0.1f, 1.0f }; // setup the light attributes glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); // set the light position GLfloat lightPosition[] = { 0.0f, -10.0f, 10.0f, 0.0f }; glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); glEnable(GL_NORMALIZE); glDisable(GL_NORMALIZE); //glDisable(GL_BLEND); glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture[0]); // choose the texture to use. GLfloat TableDiffuse[] = { 0.3f, 0.0f, 1.0f, 0.5f }; GLfloat TableSpecular[] = { 0.6f, 0.0f, 0.8f, 0.5f }; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, TableDiffuse); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, TableSpecular); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.4f); glEnable(GL_BLEND); gluPartialDisk(quadric,0,12.0f,32,16, 0, 360); // A Disk Like The One Before #if 1 glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); // X axis on table glColor3f(1,0,0); glBegin(GL_LINES); glVertex3f(0,0,0.1f); glVertex3f(120,0,0.1f); glEnd(); // Y axis on table glColor3f(0,1,0); glBegin(GL_LINES); glVertex3f(0,0,0.1f); glVertex3f(0,120,0.1f); glEnd(); glEnable(GL_LIGHTING); #endif glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); glDisable(GL_LIGHTING); // render the cursor renderCursor(); // swap the front- and back-buffer glutSwapBuffers(); }
void GridMapFrame::render() { glShadeModel(GL_FLAT); renderActivationPattern(); renderCursor(); }