// RenderPreviews(TetrisGame* game) - render the next four blocks as a preview void RenderPreviews(TetrisGame* game) { int index = game->currentIndex; int blockNum; for(int y = 0; y < 2; y++) { for(int x = 0; x < 2; x++) { if(index >= 7) { index = 0; blockNum = game->nextSet[index++]; } else { blockNum = game->inUseSet[index++]; } RenderImage(game,NEXT_BLOCK_POS[0] + x * 110 - 10,NEXT_BLOCK_POS[1] + 50 + y * 100,D3DXCOLOR(1.0f,1.0f,1.0f,1.0f),&(game->blockBg)); RenderBlock(game,NEXT_BLOCK_POS[0] + x * 110,NEXT_BLOCK_POS[1] + 70 + y * 100,&BLOCK_DATA[blockNum][0][0][0],false); } } }
//RenderGame(TetrisGame* game) - depending on the game state, render the game void RenderGame(TetrisGame* game) { if(game->state != TITLE_SCREEN) { //we are in main game mode, or a version of it - render from back to front RenderBackground(game); RenderBoard(game); //if the block is falling render it if(game->state == BLOCK_FALLING) { RenderBlock(game,game->currentBlockPos[0] * BLOCK_SIZE + GAME_BOARD_TOP_LEFT_X, game->currentBlockPos[1] * BLOCK_SIZE + GAME_BOARD_TOP_LEFT_Y,game->currentBlock,true); } //render the score and level display etc RenderHUD(game); //if game over, render the game over sign if(game->state == GAME_OVER && game->GameOverImageBool) { RenderImage(game,200,200,D3DXCOLOR(1.0f,1.0f,1.0f,1.0f),&(game->gameOverImage)); } } else { //otherwise, we are in title screen mode, so render the main title, //the levels to choose from and the transparent cursor int xOffset = 230 + (game->Level + 4) % 5 * 35; int yOffset = 310 + (game->Level / 6) * 35; RenderImage(game,0,0,D3DXCOLOR(1.0f,1.0f,1.0f,1.0f),&(game->titleScreen)); RenderImage(game,xOffset,yOffset,D3DXCOLOR(1.0f,1.0f,1.0f,game->transparency),&(game->cursorImg)); } }
/////////////////////////////////////////////////////////////////////////////// // Called to draw scene void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); // Reflection step... draw cube upside down, the floor // blended on top of it if(nStep == 5) { glDisable(GL_CULL_FACE); modelViewMatrix.PushMatrix(); modelViewMatrix.Scale(1.0f, -1.0f, 1.0f); modelViewMatrix.Translate(0.0f, 2.0f, 0.0f); modelViewMatrix.Rotate(35.0f, 0.0f, 1.0f, 0.0f); RenderBlock(); modelViewMatrix.PopMatrix(); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); RenderFloor(); glDisable(GL_BLEND); } modelViewMatrix.PushMatrix(); // Draw normally modelViewMatrix.Rotate(35.0f, 0.0f, 1.0f, 0.0f); RenderBlock(); modelViewMatrix.PopMatrix(); // If not the reflection pass, draw floor last if(nStep != 5) RenderFloor(); modelViewMatrix.PopMatrix(); // Flush drawing commands glutSwapBuffers(); }
bool BlockControl::DrawBlock(SDL_Renderer *ren, std::vector<Square> board_squares, float frame_time) { if (UpdatePosition(board_squares, frame_time)) { return true; } RenderBlock(ren); return false; }
void SCRenderer::RenderWorldSolid(RSArea* area, int LOD, int verticesPerBlock){ glMatrixMode(GL_PROJECTION); Matrix* projectionMatrix = camera.GetProjectionMatrix(); glLoadMatrixf(projectionMatrix->ToGL()); running = true; glDisable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); Point3D newPosition; newPosition.x= 4100;//lookAt[0] + 5256*cos(counter/2); newPosition.y= 100; newPosition.z= 3000;//lookAt[2];// + 5256*sin(counter/2); camera.SetPosition(&newPosition); Point3D lookAt = {3856,0,2856}; camera.LookAt(&lookAt); GLuint fogMode[]= { GL_EXP, GL_EXP2, GL_LINEAR }; // Storage For Three Types Of Fog GLuint fogfilter= 0; // Which Fog To Use GLfloat fogColor[4]= {1.0f, 1.0f, 1.0f, 1.0f}; glFogi(GL_FOG_MODE, fogMode[fogfilter]); // Fog Mode glFogfv(GL_FOG_COLOR, fogColor); // Set Fog Color glFogf(GL_FOG_DENSITY, 0.0002f); // How Dense Will The Fog Be glHint(GL_FOG_HINT, GL_DONT_CARE); // Fog Hint Value glFogf(GL_FOG_START, 600.0f); // Fog Start Depth glFogf(GL_FOG_END, 8000.0f); // Fog End Depth glEnable(GL_FOG); glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); Matrix* modelViewMatrix = camera.GetViewMatrix(); glLoadMatrixf(modelViewMatrix->ToGL()); //Island /* newPosition[0]= 2500;//lookAt[0] + 5256*cos(counter/2); newPosition[1]= 350; newPosition[2]= 600;//lookAt[2];// + 5256*sin(counter/2); vec3_t lookAt = {2456,0,256}; */ //City Top //City view on mountains /* counter = 23; vec3_t lookAt = {3856,30,2856}; newPosition[0]= lookAt[0] + 256*cos(counter/2); newPosition[1]= 60; newPosition[2]= lookAt[2] + 256*sin(counter/2); */ //Canyon ///* //*/ //counter += 0.02; glDepthFunc(GL_LESS); glBegin(GL_TRIANGLES); //for(int i=97 ; i < 98 ; i++) for(int i=0 ; i < BLOCKS_PER_MAP ; i++) RenderBlock(area, LOD, i,false); glEnd(); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glDepthFunc(GL_EQUAL); //for(int i=97 ; i < 98 ; i++) for(int i=0 ; i < BLOCKS_PER_MAP ; i++) RenderBlock(area, LOD, i,true); glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); //Render objects on the map //for(int i=97 ; i < 98 ; i++) //for(int i=0 ; i < BLOCKS_PER_MAP ; i++) // RenderObjects(area,i); RenderJets(area); }