//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)); } }
/* Function to render the menus line in the bottom of the window param: the renderer to handle all the rendering in the window param: font for the names of each option */ void RenderMenu(SDL_Renderer *renderer, TTF_Font *Queen) { SDL_Color white = {255, 255, 255}; RenderImage(renderer, "Home.bmp", XHOME, YHOME); RenderImage(renderer, "New_Game.bmp", XNEWGAME, YNEWGAME); RenderImage(renderer, "Statistics.bmp", XSTATISTICS, YSTATISTICS); RenderText(XHOMETXT, YHOMETXT, "Home", Queen, &white, renderer); RenderText(XNGTXT, YNGTXT, "New Game", Queen, &white, renderer); RenderText(XSTATS, YSTATS, "Statistics", Queen, &white, renderer); }
emImage emGifFileModel::RenderAll() const { emImage image, undoImage; Render * r; int i; image.Setup(Width,Height,ChannelCount); if (RenderCount<=0) { image.Fill(BGColor); return image; } r=RenderArray[0]; if (r->Transparent>=0 || r->X!=0 || r->Y!=0 || r->Width!=Width || r->Height!=Height) { image.Fill(0,0,Width,Height,BGColor); } RenderImage(0,&image); for (i=1; i<RenderCount; i++) { if (r->Disposal==2) { image.Fill( r->X, r->Y, r->Width, r->Height, BGColor ); } else if (r->Disposal==3) { if (!undoImage.IsEmpty()) { image.Copy(r->X,r->Y,undoImage); } else { image.Fill( r->X, r->Y, r->Width, r->Height, BGColor ); } } r=RenderArray[i]; if (r->Disposal==3) { undoImage.Setup(r->Width,r->Height,image.GetChannelCount()); undoImage.Copy(-r->X,-r->X,image); } else { undoImage.Empty(); } RenderImage(i,&image); } return image; }
/* Function to render the avaluation for the 5 board param: the renderer to handle all the renderering in the window param: size of the board, number of pieces per play param: Array with the number of correct pieces in the right places per play param: Array with the number of correct pieces in the wrong places per play param: variable indicating how many plays have already been made */ void RenderAvalFive(SDL_Renderer *renderer, int boardsize, int blacks[], int whites[], int nplays) { int i = 0; int j = 0; int x = (MAXBOARD-boardsize)*BOARDCORR + FIRSTPIECEX + boardsize*PIECESIZE + EXTRAPOS + AVALCORRX; int y = FIRSTPIECEY + (MAXNPLAYS - i)*YPERPLAY + YPIECECORR; int bl = 0; int wh = 0; for(j=0; j <= nplays; j++) { bl = blacks[j]; i=0; x = (MAXBOARD-boardsize)*BOARDCORR + FIRSTPIECEX + boardsize*PIECESIZE + EXTRAPOS + AVALCORRX; y = FIRSTPIECEY + (MAXNPLAYS - j)*YPERPLAY + YPIECECORR + AVALCORRY; while(bl != 0) { bl --; RenderImage(renderer, "Black.bmp", x, y); y += AVALPOS; i++; if(i == 2) { x += 2*AVALPOS; y = FIRSTPIECEY + (MAXNPLAYS - j)*YPERPLAY + YPIECECORR + AVALCORRY; } else if( i == 4) { x = (MAXBOARD-boardsize)*BOARDCORR + FIRSTPIECEX + boardsize*PIECESIZE + EXTRAPOS + AVALCORRX + AVALPOS; y = FIRSTPIECEY + (MAXNPLAYS - j)*YPERPLAY + YPIECECORR + AVALCORRY + AVALCORRYF; } } wh = whites[j]; while(wh != 0) { wh --; RenderImage(renderer, "White.bmp", x, y); y += AVALPOS; i++; if(i == 2) { x += 2*AVALPOS; y = FIRSTPIECEY + (MAXNPLAYS - j)*YPERPLAY + YPIECECORR + AVALCORRY; } else if( i == 4) { x = (MAXBOARD-boardsize)*BOARDCORR + FIRSTPIECEX + boardsize*PIECESIZE + EXTRAPOS + AVALCORRX + AVALPOS; y = FIRSTPIECEY + (MAXNPLAYS - j)*YPERPLAY + YPIECECORR + AVALCORRY + AVALCORRYF; } } } }
//void PlotBlock(TetrisGame* game,int x,int y,int blockCol) //used by render board and render block to draw a single block of various //color types void PlotBlock(TetrisGame* game,int x,int y,int blockCol) { RECT srcRect = {0,0,BLOCK_SIZE,BLOCK_SIZE}; D3DXCOLOR color; //set the d3d color to the appropriate type switch(blockCol) { case INVISIBLE: color = D3DXCOLOR(1.0f,1.0f,1.0f,1.0f); break; case L_BLOCK: color = D3DXCOLOR(1.0f,1.0f,game->colorOffset,1.0f); break; case R_BLOCK: color = D3DXCOLOR(1.0f,game->colorOffset,game->colorOffset,1.0f); break; case T_BLOCK: color = D3DXCOLOR(game->colorOffset,1.0f,game->colorOffset,1.0f); break; case S_BLOCK: color = D3DXCOLOR(game->colorOffset,game->colorOffset,1.0f,1.0f); break; case SQ_BLOCK: color = D3DXCOLOR(1.0f,game->colorOffset,1.0f,1.0f); break; case Z_BLOCK: color = D3DXCOLOR(game->colorOffset,1.0f,1.0f,1.0f); break; case LONG_BLOCK: color = D3DXCOLOR(1.0f,1.0f,game->colorOffset,1.0f); break; case EMPTY: color = D3DXCOLOR(0.0f,0.0f,0.0f,1.0f); break; } //if the block isn't invisible render the blocktexture, //otherwise don't! if(blockCol != INVISIBLE) { if(blockCol != EMPTY) RenderImage(game,x,y,color,&(game->blockImg)); else RenderImage(game,x,y,color,&(game->blockImg2)); } else { RenderImage(game,x,y,color,&(game->wallImg)); } }
/* Function to render the home menu param: the renderer to handle all the rendering in the window param: font for the names of each option param: font for the game name in the top */ void RenderHome(SDL_Renderer *renderer, TTF_Font *Queen, TTF_Font *QueenBig) { SDL_Color white = {255, 255, 255}; RenderImage(renderer, "Fundo.bmp", BACKGROUNDX, BACKGROUNDY); RenderImage(renderer, "TextBox.bmp", XTEXTBOX, YTEXTBOX); RenderImage(renderer, "TextBox.bmp", XTEXTBOX, YTEXTBOX + BOXHEIGHT); RenderImage(renderer, "TextBox.bmp", XTEXTBOX, YTEXTBOX + 2*BOXHEIGHT); RenderText(XCGAME, YOPTION, "Current Game", Queen, &white, renderer); RenderText(XNGAME, YOPTION + BOXHEIGHT, "New Game", Queen, &white, renderer); RenderText(XHOMESTATS, YOPTION + 2*BOXHEIGHT, "Statistics", Queen, &white, renderer); RenderImage(renderer, "ScreenshotJogo.bmp", XSCREENSHOT, YSCREENSHOT); RenderText(XTITLE, YTITLE, "Mastermind", QueenBig, &white, renderer); }
// 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); } } }
void Render(double time) { const Vec3f light_position(16.0, 10.0, 9.0); const Vec3f torus_center(0.0, 1.5, 0.0); const Mat4f torus_matrix = ModelMatrixf::Translation(torus_center) * ModelMatrixf::RotationZ(FullCircles(time / 16.0)); const Mat4f light_proj_matrix = CamMatrixf::PerspectiveX(Degrees(10), 1.0, 1, 80) * CamMatrixf::LookingAt(light_position, torus_center); transf_prog.light_position.Set(light_position); RenderFrameShadowMap( light_position, torus_matrix, light_proj_matrix ); RenderGlassShadowMap( light_position, torus_center, torus_matrix, light_proj_matrix ); RenderImage( time, torus_center, torus_matrix, light_proj_matrix ); }
/* Function renders the board for the game param: the renderer to handle all rendering in the window param: size of the board, number of pieces per play param: Array of the avaluation images */ void RenderBoard(SDL_Renderer *renderer, int boardsize, SDL_Surface **Avaluations) { int i = 0; int j = 0; int holex = FIRSTPIECEX; int holey = FIRSTPIECEY; int xcorrect = (MAXBOARD-boardsize)*BOARDCORR + FIRSTPIECEX; SDL_Rect BoardPos; SDL_Texture *AvalTexture; // Rendering the background image RenderImage(renderer, "Fundo.bmp", BACKGROUNDX, BACKGROUNDY); // Rendering the number of each play RenderImage(renderer, "Numeros_Jogada.bmp", xcorrect + NUMBERX, NUMBERSY); // Rendering the pieces for each play for(i=0; i < MAXPLAYS; i++) { holex = xcorrect; for(j=0; j < boardsize; j++) { RenderImage(renderer, "Hole.bmp", holex, holey); holex += PIECESIZE; } holey += PIECESIZE; } xcorrect += boardsize*PIECESIZE + EXTRAPOS/2; AvalTexture = SDL_CreateTextureFromSurface(renderer, Avaluations[boardsize-MINLEVEL]); BoardPos.x = xcorrect; BoardPos.y = AVALY; BoardPos.w = (Avaluations[boardsize-MINLEVEL])->w + EXTRAPOS; BoardPos.h = (Avaluations[boardsize-MINLEVEL])->h + EXTRAPOS; for(i=0; i < MAXPLAYS; i++) { SDL_RenderCopy(renderer, AvalTexture, NULL, &BoardPos); BoardPos.y += PIECESIZE; } SDL_DestroyTexture(AvalTexture); xcorrect += (BoardPos.w + EXTRAPOS); // Rendering the block of colors RenderImage(renderer, "Cores.bmp", xcorrect, COLORSY); RenderImage(renderer, "Nome.bmp", XNOME, YNOME); }
void RenderDataUI::Render() { if (_pCanvasRenderData->_renderType == eCanvasRender::IMAGE) { RenderImage((ImageRender*)(_pCanvasRenderData->_pCanvasRender)); } else if (_pCanvasRenderData->_renderType == eCanvasRender::TEXT) { TextRender* pTextRender = (TextRender*)(_pCanvasRenderData->_pCanvasRender); RenderText(pTextRender); } }
/* Function to render the new game menu param: the renderer to handle all the rendering in the window param: font for text of the namee param: font for the game name in the top */ void RenderNewGame(SDL_Renderer *renderer, TTF_Font *Queen, TTF_Font *QueenBig, char *playername, int boardsize, int nameread) { SDL_Color white = {255, 255, 255}; RenderImage(renderer, "Fundo.bmp", BACKGROUNDX, BACKGROUNDY); RenderImage(renderer, "Numeros.bmp", XNUMEROS, YNUMEROS); RenderText(XTITLE, YTITLE, "Mastermind", QueenBig, &white, renderer); RenderImage(renderer, "NameBox.bmp", XNAME, YNAME); RenderText(XINFNAME, YINFNAME, "Introduza um nome de jogador!", Queen, &white, renderer); if(boardsize != 0) { RenderImage(renderer, "Bordo.bmp", XNUMEROS, YNUMEROS + (boardsize-MINLEVEL)*NUMBERSIZE); } if(playername[0] == 0 && nameread == 0) { RenderText(XNAMEBOX + CORRXNAME, YNAMEBOX + CORRYNAME, "Username", Queen, &white, renderer); } else if(playername[0] != 0) { RenderText(XNAMEBOX + CORRXNAME, YNAMEBOX + CORRYNAME, playername, Queen, &white, renderer); } }
/* Function that renders an arrow indicating the current Play param: the renderer to handle all the rendering in the window param: variable indicating how many plays have already been made param: size of the board, number of pieces per play */ void RenderPlay(SDL_Renderer *renderer, int nplays, int boardsize) { int x = (MAXBOARD-boardsize)*BOARDCORR + FIRSTPIECEX + PLAYX; int y = FIRSTPIECEY + (MAXNPLAYS - nplays)*YPERPLAY; if(nplays < 10) { y = FIRSTPIECEY + (MAXNPLAYS - nplays)*YPERPLAY; } else { y = FIRSTPIECEY; } RenderImage(renderer, "Play.bmp", x, y); }
void RenderHUDComponent(TetrisGame* game,char* text,const int* position,int value) { game->os.str(""); game->os << text; if(value != -1) { game->os << value; } RenderImage(game,position[0] - 10, position[1] - 10,D3DXCOLOR(1.0f,1.0f,1.0f,1.0f),&(game->textBg)); game->text.Print(position[0],position[1],game->os.str(),0xFFFFFFFF); }
//Render animation on surface bool CTableCellAnimationBase::Render(SDL_Surface* pSurface) { //Verify completion on pedin animations CleanPendingAnimations(); if(!ContinueRendering()) return false; //Update any related information on animation UpdateForAnimation(); SDL_Surface* pImage = CGemsResources::GetInstance().ResourceFor(m_resource); if(!pImage) return true; //Draw the animation RenderImage(pImage, pSurface); return true; }
int main(int argc, char **argv) { // Parse program arguments if (!ParseArgs(argc, argv)) exit(-1); // Read scene scene = ReadScene(input_scene_name); if (!scene) exit(-1); // Check output image file if (output_image_name) { // Set scene viewport scene->SetViewport(R2Viewport(0, 0, render_image_width, render_image_height)); // Render image R2Image *image = RenderImage(scene, render_image_width, render_image_height, print_verbose); if (!image) exit(-1); // Write image if (!WriteImage(image, output_image_name)) exit(-1); // Delete image delete image; } else { // Initialize GLUT GLUTInit(&argc, argv); // Create viewer viewer = new R3Viewer(scene->Viewer()); if (!viewer) exit(-1); // Run GLUT interface GLUTMainLoop(); // Delete viewer (doesn't ever get here) delete viewer; } // Return success return 0; }
// Update toolbar cache BOOL GetToolBarCache(ToolBarInfo *toolbar,BOOL real) { short depth,width,height,num,x,y; short last_width=0,last_height=0; Cfg_Button *button; struct TagItem tags[4]; struct Rectangle rect; // Invalid toolbar? if (!toolbar) return 0; // Free existing cache FreeToolBarCache(toolbar); // Remap toolbar if this is for real if (real && !toolbar->done_remap) { // Do remap RemapToolBar(toolbar); toolbar->done_remap=1; } // Initialise tags tags[0].ti_Tag=IM_Depth; tags[0].ti_Data=1; tags[1].ti_Tag=IM_Width; tags[1].ti_Data=0; tags[2].ti_Tag=IM_Height; tags[2].ti_Data=0; tags[3].ti_Tag=TAG_DONE; // Minimum depth depth=1; // Count items in toolbar for (button=(Cfg_Button *)toolbar->buttons->buttons.lh_Head,toolbar->count=0; button->node.ln_Succ; button=(Cfg_Button *)button->node.ln_Succ,toolbar->count++); // Allocate position array if (!(toolbar->button_array=AllocVec(sizeof(struct Rectangle)*(toolbar->count+2),MEMF_CLEAR))) { FreeToolBarCache(toolbar); return 0; } // Go through buttons again for (button=(Cfg_Button *)toolbar->buttons->buttons.lh_Head,num=0,toolbar->max_width=0; button->node.ln_Succ; button=(Cfg_Button *)button->node.ln_Succ,num++) { Cfg_ButtonFunction *func; short width,height,x; // Get left button image if ((func=(Cfg_ButtonFunction *) FindFunctionType((struct List *)&button->function_list,FTYPE_LEFT_BUTTON)) && func->image) { // Get depth and other info GetImageAttrs(func->image,tags); // Biggest depth so far? if (tags[0].ti_Data>depth) depth=tags[0].ti_Data; // Get size width=tags[1].ti_Data; height=tags[2].ti_Data; } // Or textual button? else if (!(button->button.flags&BUTNF_GRAPHIC) && func) { struct TextExtent extent; // Get length of label TextExtent(&GUI->screen_pointer->RastPort,func->label,strlen(func->label),&extent); // Get size width=extent.te_Width; height=extent.te_Height; } // Use last size else { width=last_width; height=last_height; } // Minimum size if (width<2) width=8; if (height<2) height=8; // Save size last_width=width; last_height=height; // Increase size for border if (!(toolbar->buttons->window.flags&BTNWF_BORDERLESS)) { width+=2; height+=2; } // Biggest width so far? if (width>toolbar->max_width) toolbar->max_width=width; // Get last position x=(num>0)?toolbar->button_array[num-1].MaxX+1:0; // Store position in array toolbar->button_array[num].MinX=x; toolbar->button_array[num].MinY=0; toolbar->button_array[num].MaxX=x+width-1; toolbar->button_array[num].MaxY=height-1; } // No actual buttons? if (toolbar->count<1 || depth<1) { FreeToolBarCache(toolbar); return 0; } // Store rows/cols toolbar->cols=toolbar->count; toolbar->rows=1; // Valid toolbar arrow? if (GUI->toolbar_arrow_image) { short width,height; // Get size of the arrow button GetImageAttrs(GUI->toolbar_arrow_image,tags); // Biggest depth so far? if (tags[0].ti_Data>depth) depth=tags[0].ti_Data; // Get size width=tags[1].ti_Data; height=tags[2].ti_Data; // Increase size for border if (!(toolbar->buttons->window.flags&BTNWF_BORDERLESS)) { width+=2; height+=2; } // Store size in array toolbar->button_array[toolbar->count].MaxX=width-1; toolbar->button_array[toolbar->count].MaxY=height-1; // Add to maximum width toolbar->max_width+=width; } // Get height of toolbar for (num=0,height=0;num<=toolbar->count;num++) { if ((width=RECTHEIGHT(&toolbar->button_array[num]))>height) height=width; } // Store toolbar height toolbar->button_height=height; // Get cache size toolbar->width=toolbar->button_array[toolbar->count-1].MaxX+1; toolbar->height=toolbar->button_height; // Don't want cache? if (!real) return 1; // Allocate cache bitmap if (!(toolbar->bitmap= NewBitMap( toolbar->width, toolbar->height, depth, BMF_CLEAR, GUI->screen_pointer->RastPort.BitMap))) // 0))) { // Failed FreeToolBarCache(toolbar); return 0; } // Initialise RastPort InitRastPort(&toolbar->rp); toolbar->rp.BitMap=toolbar->bitmap; // Got cache successfully toolbar->cache=1; // Set pens and font SetAPen(&toolbar->rp,1); SetBPen(&toolbar->rp,0); SetFont(&toolbar->rp,GUI->screen_pointer->RastPort.Font); // Initialise draw tags tags[0].ti_Tag=IM_Rectangle; tags[0].ti_Data=(ULONG)▭ tags[1].ti_Tag=IM_ClipBoundary; tags[1].ti_Data=(toolbar->buttons->window.flags&BTNWF_BORDERLESS)?0:2; tags[2].ti_Tag=IM_NoIconRemap; tags[2].ti_Data=(environment->env->desktop_flags&DESKTOPF_NO_REMAP)?TRUE:FALSE; tags[3].ti_Tag=TAG_DONE; // Go through buttons for (button=(Cfg_Button *)toolbar->buttons->buttons.lh_Head,x=0,y=0,num=0; button->node.ln_Succ; button=(Cfg_Button *)button->node.ln_Succ,num++) { Cfg_ButtonFunction *func; BOOL ok=0; // Get button rectangle rect=toolbar->button_array[num]; // Get left button image if ((func=(Cfg_ButtonFunction *)FindFunctionType((struct List *)&button->function_list,FTYPE_LEFT_BUTTON)) && func->image) { // Draw button image RenderImage(&toolbar->rp,func->image,0,0,tags); ok=1; } // Or textual button? else if (!(button->button.flags&BUTNF_GRAPHIC) && func && func->label && *func->label) { // Draw label Move(&toolbar->rp,x,y+toolbar->rp.TxBaseline); Text(&toolbar->rp,func->label,strlen(func->label)); ok=1; } // Draw button border if (!ok || !(toolbar->buttons->window.flags&BTNWF_BORDERLESS)) DrawBox(&toolbar->rp,&rect,GUI->draw_info,0); } return 1; }
void Accel_ImagePanel::Update(wxPaintEvent& event) { if(ImagePanel) { int rend_width, rend_height; //Update scroll width if(img_width < parent_->GetSize().GetWidth() - scroll_size) { rend_width = img_width; hscroll_->Enable(false); x_off = 0; } else { rend_width = parent_->GetSize().GetWidth() - scroll_size; if(!hscroll_->IsEnabled()) { hscroll_->SetThumbPosition(0); hscroll_->Enable(true); } if(hscroll_->GetRange() != img_width - rend_width) hscroll_->SetScrollbar(hscroll_->GetThumbPosition(), hscroll_->GetThumbSize(), (img_width - rend_width), 10); x_off = hscroll_->GetThumbPosition(); } //Update scroll height if(img_height < parent_->GetSize().GetHeight() - scroll_size) { rend_height = img_height; vscroll_->Enable(false); y_off = 0; } else { rend_height = parent_->GetSize().GetHeight() - scroll_size; if(!vscroll_->IsEnabled()) { vscroll_->SetThumbPosition(0); vscroll_->Enable(true); } if(vscroll_->GetRange() != img_height - rend_height) vscroll_->SetScrollbar(vscroll_->GetThumbPosition(), vscroll_->GetThumbSize(), img_height - rend_height, 10); y_off = vscroll_->GetThumbPosition(); } //Make the image the right size and position ImagePanel->SetSize(rend_width, rend_height); ImagePanel->SetPosition(wxPoint((parent_->GetSize().GetWidth() - rend_width - scroll_size) / 2, (parent_->GetSize().GetHeight() - rend_height - scroll_size) / 2)); //Render the image wxBufferedPaintDC dc(ImagePanel); for(int y = 0; y < ImagePanel->GetSize().GetHeight(); y += 128) for(int x = 0; x < ImagePanel->GetSize().GetWidth(); x += 128) dc.DrawBitmap(Background,x,y, true); //for(unsigned layer = 0; layer < Layers.size(); layer++) // if(Layers[layer].Enabled) // dc.DrawBitmap(*Layers[layer].Image, -x_off, -y_off, true); if(need_paint == FULL_REPAINT) { need_paint = NO_REPAINT; RenderImage(); } dc.DrawBitmap(Render, -x_off, -y_off, true); } }
/* Function that renders all stats for the played games param: the renderer to handle all the rendering in the window param: the font for the game name param: the font for the titles param: the font for the info param: name of the player of the game with best number of plays param: number of plays for the game with best number of plays param: time for the game with best number of plays param: size of the board for the game with best number of plays param: name of the player of the game with best time param: number of plays for the game with best time param: time for the game with best time param: size of the board for the game with best time param: total number of games param: total of the time of all games param: total of plays for all games param: total of the sum of the boardsize of all games */ void RenderStats(SDL_Renderer *renderer, TTF_Font *GameFont, TTF_Font *Titlesfont, TTF_Font *font, char *bpplayername, int bpplays, int bptime, int bpsize, char *btplayername, int btplays, int bttime, int btsize, int ngames, int totaltime, int totalplays, int totalboard) { SDL_Color white = {255, 255, 255}; SDL_Color black = {0, 0, 0}; char str[STRMAX] = {0}; float avtime = totaltime/ngames; float avplays = totalplays/ngames; float avsize = totalboard/ngames; RenderImage(renderer, "Fundo.bmp", BACKGROUNDX, BACKGROUNDY); RenderText(XTITLE, YTITLE, "Mastermind", GameFont, &white, renderer); RenderText(XBESTPLAYS, YBESTPLAYS, "Won game in record plays", Titlesfont, &white, renderer); RenderText(XBESTTIME, YBESTTIME, "Won game in record time", Titlesfont, &white, renderer); RenderText(XAVARAGES, YAVARAGES, "Statistics for all games played", Titlesfont, &white, renderer); RenderText(XBPPLAYER, YBPPLAYER, "Player name :", Titlesfont, &black, renderer); RenderText(XBPPLAYS, YBPPLAYS, "Number of plays :", Titlesfont, &black, renderer); RenderText(XBPTIME, YBPTIME, "Time of the game :", Titlesfont, &black, renderer); RenderText(XBPSIZE, YBPSIZE, "Size of the board :", Titlesfont, &black, renderer); RenderText(XBTPLAYER, YBTPLAYER, "Player name :", Titlesfont, &black, renderer); RenderText(XBTPLAYS, YBTPLAYS, "Number of plays :", Titlesfont, &black, renderer); RenderText(XBTTIME, YBTTIME, "Time of the game :", Titlesfont, &black, renderer); RenderText(XBTSIZE, YBTSIZE, "Size of the board :", Titlesfont, &black, renderer); RenderText(XNGAMES, YNGAMES, "Number of games played :", Titlesfont, &black, renderer); RenderText(XAVTIME, YAVTIME, "Time per game :", Titlesfont, &black, renderer); RenderText(XAVPLAYS, YAVPLAYS, "Plays per game :", Titlesfont, &black, renderer); RenderText(XAVSIZE, YAVSIZE, "Av. size of the board :", Titlesfont, &black, renderer); if(bpplayername[0] != 0) { RenderText(XBPPLAYERD, YBPPLAYER + STATSCORR, bpplayername, font, &white, renderer); sprintf(str, "%d", bpplays); RenderText(XBPPLAYSD, YBPPLAYS + STATSCORR, str, font, &white, renderer); sprintf(str, "%d", bptime); RenderText(XBPTIMED, YBPTIME + STATSCORR, str, font, &white, renderer); sprintf(str, "%d", bpsize); RenderText(XBPSIZED, YBPSIZE + STATSCORR, str, font, &white, renderer); } if(btplayername[0] != 0) { RenderText(XBTPLAYERD, YBTPLAYER + STATSCORR, btplayername, font, &white, renderer); sprintf(str, "%d", btplays); RenderText(XBTPLAYSD, YBTPLAYS + STATSCORR, str, font, &white, renderer); sprintf(str, "%d", bttime); RenderText(XBTTIMED, YBTTIME + STATSCORR, str, font, &white, renderer); sprintf(str, "%d", btsize); RenderText(XBTSIZED, YBTSIZE + STATSCORR, str, font, &white, renderer); } if(ngames != 0) { sprintf(str, "%d", ngames); RenderText(XNGAMESD, YNGAMES + STATSCORR, str, font, &white, renderer); sprintf(str, "%0.2f", avtime); RenderText(XAVTIMED, YAVTIME + STATSCORR, str, font, &white, renderer); sprintf(str, "%0.2f", avplays); RenderText(XAVPLAYSD, YAVPLAYS + STATSCORR, str, font, &white, renderer); sprintf(str, "%0.2f", avsize); RenderText(XAVSIZED, YAVSIZE + STATSCORR, str, font, &white, renderer); } }
//RenderBackground(TetrisGame* game) - render the space image void RenderBackground(TetrisGame* game) { RenderImage(game,0,0,D3DXCOLOR(1.0f,1.0f,1.0f,1.0f),&(game->background)); }
// ---------------------------------------------------------------------------- // Name : Render() // Desc : // ---------------------------------------------------------------------------- void CUIHelp::Render() { CDrawPort* pDrawPort = CUIManager::getSingleton()->GetDrawPort(); m_bVisible = TRUE; // Set web board texture pDrawPort->InitTextureData( m_ptdBaseTexture ); // Add render regions int nX, nY, nX2, nY2; // Background // Upper left nX = m_nPosX; nY = m_nPosY; nX2 = m_nPosX + m_nWidth; nY2 = m_nPosY + 28; pDrawPort->AddTexture( nX, nY, nX + 49, nY2, m_rtTitleUL.U0, m_rtTitleUL.V0, m_rtTitleUL.U1, m_rtTitleUL.V1, 0xFFFFFFFF ); // Upper middle pDrawPort->AddTexture( nX + 49, nY, nX2 - 32, nY2, m_rtTitleUM.U0, m_rtTitleUM.V0, m_rtTitleUM.U1, m_rtTitleUM.V1, 0xFFFFFFFF ); // Upper right pDrawPort->AddTexture( nX2 - 32, nY, nX2, nY2, m_rtTitleUR.U0, m_rtTitleUR.V0, m_rtTitleUR.U1, m_rtTitleUR.V1, 0xFFFFFFFF ); nY = nY2; nY2 = nY2 + 10; pDrawPort->AddTexture( nX, nY, nX + 49, nY2, m_rtBackUL.U0, m_rtBackUL.V0, m_rtBackUL.U1, m_rtBackUL.V1, 0xFFFFFFFF ); // Upper middle pDrawPort->AddTexture( nX + 49, nY, nX2 - 32, nY2, m_rtBackUM.U0, m_rtBackUM.V0, m_rtBackUM.U1, m_rtBackUM.V1, 0xFFFFFFFF ); // Upper right pDrawPort->AddTexture( nX2 - 32, nY, nX2, nY2, m_rtBackUR.U0, m_rtBackUR.V0, m_rtBackUR.U1, m_rtBackUR.V1, 0xFFFFFFFF ); // Middle left nY = m_nPosY + m_nHeight - 15; pDrawPort->AddTexture( nX, nY2, nX + 49, nY, m_rtBackML.U0, m_rtBackML.V0, m_rtBackML.U1, m_rtBackML.V1, 0xFFFFFFFF ); // Middle middle pDrawPort->AddTexture( nX + 49, nY2, nX2 - 32, nY, m_rtBackMM.U0, m_rtBackMM.V0, m_rtBackMM.U1, m_rtBackMM.V1, 0xFFFFFFFF ); // Middle right pDrawPort->AddTexture( nX2 - 32, nY2, nX2, nY, m_rtBackMR.U0, m_rtBackMR.V0, m_rtBackMR.U1, m_rtBackMR.V1, 0xFFFFFFFF ); // Lower left nY2 = m_nPosY + m_nHeight; pDrawPort->AddTexture( nX, nY, nX + 49, nY2, m_rtBackLL.U0, m_rtBackLL.V0, m_rtBackLL.U1, m_rtBackLL.V1, 0xFFFFFFFF ); // Lower middle pDrawPort->AddTexture( nX + 49, nY, nX2 - 32, nY2, m_rtBackLM.U0, m_rtBackLM.V0, m_rtBackLM.U1, m_rtBackLM.V1, 0xFFFFFFFF ); // Lower right pDrawPort->AddTexture( nX2 - 32, nY, nX2, nY2, m_rtBackLR.U0, m_rtBackLR.V0, m_rtBackLR.U1, m_rtBackLR.V1, 0xFFFFFFFF ); // Close button m_btnClose.Render(); // Text in web board // Title pDrawPort->PutTextEx( _S( 1610, "도움말" ), m_nPosX + HELP_TITLE_OFFSETX, m_nPosY + HELP_TITLE_OFFSETY, 0xFFFFFFFF ); // Render subject List RenderList(); RenderContent(); // Flush all render queue pDrawPort->FlushRenderingQueue(); pDrawPort->EndTextEx(); // Render Help Image if( m_iImageIdx>=0 ) RenderImage( m_iImageIdx ); }
void Render(double time) { UpdateMetaballs(time); RenderImage(time); }
void RenderCursor(int image_id,float sizeX,float sizeY,float hotSpotX,float hotSpotY) { RenderImage(image_id,win_cursorX-hotSpotX,win_cursorY-hotSpotY,sizeX, sizeY); }
int main(int argc, char **argv) { // Look for help for (int i = 0; i < argc; i++) { if (!strcmp(argv[i], "-help")) { ShowUsage(); } } // Read input and output filenames if (argc < 3) ShowUsage(); argv++, argc--; // First argument is program name char *input_scene_name = *argv; argv++, argc--; char *output_image_name = *argv; argv++, argc--; // Initialize arguments to default values int width = 256; int height = 256; int max_depth = 0; int num_distributed_rays_per_intersection = 0; int num_primary_rays_per_pixel = 1; bool hard_shadow = false; // Parse arguments while (argc > 0) { if (!strcmp(*argv, "-width")) { CheckOption(*argv, argc, 2); width = atoi(argv[1]); argv += 2, argc -= 2; } else if (!strcmp(*argv, "-height")) { CheckOption(*argv, argc, 2); height = atoi(argv[1]); argv += 2, argc -= 2; } else if (!strcmp(*argv, "-max_depth")) { CheckOption(*argv, argc, 2); max_depth = atoi(argv[1]); argv += 2, argc -= 2; } else if (!strcmp(*argv, "-antialias")) { CheckOption(*argv, argc, 2); num_primary_rays_per_pixel = atoi(argv[1]); argv += 2, argc -= 2; } else if (!strcmp(*argv, "-distribute")) { CheckOption(*argv, argc, 2); num_distributed_rays_per_intersection = atoi(argv[1]); argv += 2, argc -= 2; } else if (!strcmp(*argv, "-hard_shadow")) { hard_shadow = true; argv += 1, argc -= 1; } else { // Unrecognized program argument fprintf(stderr, "meshpro: invalid option: %s\n", *argv); ShowUsage(); } } // Read scene R3Scene *scene = ReadScene(input_scene_name, width, height); if (!scene) { fprintf(stderr, "Unable to read scene from %s\n", input_scene_name); exit(-1); } // Render image R2Image *image = RenderImage(scene, width, height, max_depth, num_primary_rays_per_pixel, num_distributed_rays_per_intersection, hard_shadow); if (!image) { fprintf(stderr, "Did not render image from scene\n"); exit(-1); } // Transfer the image to sRGB color space: for Windows + Linux and Mac OS X // 10.6+ (for earlier MAC OS X it will look slightly too bright, but not as // much as it would be too dark otherwise. This function also clamps the // image values; however, it does not scale the brightness and also does not // perform any more complicated tone mapping image->TosRGB(); // Write output image if (!image->Write(output_image_name)) { fprintf(stderr, "Did not write image to %s\n", output_image_name); exit(-1); } // Delete everything delete scene; delete image; // Return success return EXIT_SUCCESS; }
int main( int argc, char *argv[] ) { void *buffer; int i; char *filename = NULL; /* Create an RGBA-mode context */ #if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305 /* specify Z, stencil, accum sizes */ OSMesaContext ctx = OSMesaCreateContextExt( OSMESA_RGBA, 16, 0, 0, NULL ); #else OSMesaContext ctx = OSMesaCreateContext( OSMESA_RGBA, NULL ); #endif if (!ctx) { printf("OSMesaCreateContext failed!\n"); return 0; } for ( i=1; i<argc; i++ ) { if (argv[i][0] != '-') filename = argv[i]; } /* Allocate the image buffer */ buffer = malloc( WIDTH * HEIGHT * 4 * sizeof(GLubyte) ); if (!buffer) { printf("Alloc image buffer failed!\n"); return 0; } /* Bind the buffer to the context and make it current */ if (!OSMesaMakeCurrent( ctx, buffer, GL_UNSIGNED_BYTE, WIDTH, HEIGHT )) { printf("OSMesaMakeCurrent failed!\n"); return 0; } { int z, s, a; glGetIntegerv(GL_DEPTH_BITS, &z); glGetIntegerv(GL_STENCIL_BITS, &s); glGetIntegerv(GL_ACCUM_RED_BITS, &a); printf("Depth=%d Stencil=%d Accum=%d\n", z, s, a); } InitGL(); RenderImage(); if (filename != NULL) { write_ppm(filename, (GLubyte*)buffer, WIDTH, HEIGHT); } else { printf("Specify a filename (with ppm extension) if you want to make an image file\n"); } printf("all done\n"); /* free the image buffer */ free( buffer ); /* destroy the context */ OSMesaDestroyContext( ctx ); return 0; }