bool Graphics::resizeScreen(const int width, const int height) { #ifdef USE_SDL2 endDraw(); mRect.w = static_cast<int32_t>(width / mScale); mRect.h = static_cast<int32_t>(height / mScale); mWidth = width / mScale; mHeight = height / mScale; mActualWidth = width; mActualHeight = height; #ifdef USE_OPENGL // +++ probably this way will not work in windows/mac // Setup OpenGL glViewport(0, 0, mActualWidth, mActualHeight); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); #else // +++ need impliment resize in soft mode #endif // USE_OPENGL screenResized(); beginDraw(); return true; #else const int prevWidth = mWidth; const int prevHeight = mHeight; endDraw(); const bool success = setVideoMode(width, height, mScale, mBpp, mFullscreen, mHWAccel, mEnableResize, mNoFrame); // If it didn't work, try to restore the previous size. If that didn't // work either, bail out (but then we're in deep trouble). if (!success) { if (!setVideoMode(prevWidth, prevHeight, mScale, mBpp, mFullscreen, mHWAccel, mEnableResize, mNoFrame)) { return false; } } screenResized(); beginDraw(); return success; #endif // USE_SDL2 }
void Interface::drawScore() { beginDraw(); for(int i = 0; i < score.size(); i++) { if (i > 0) glLoadIdentity(); if (score[i].side == LEFT) { glColor3f(0.5, 1.0, 0.5); glTranslatef(2.0, 0, 0); } else { glColor3f(1.0, 0.5, 0.5); glTranslatef(400.0 - textWidth(score[i].name)*2.0 - 2.0, 0, 0); } glTranslatef(0, 300.0 - 62.0*(score[i].index) - 2.0, 0); glScalef(2.0, 2.0, 2.0); drawText(score[i].name); glLoadIdentity(); if (score[i].side == LEFT) { glTranslatef(2.0, 0, 0); } else { glTranslatef(400.0 - textWidth(score[i].points)*5.0 - 2.0, 0, 0); } glTranslatef(0, 300.0 - 62.0*(score[i].index) - 20.0, 0); glScalef(5.0, 5.0, 5.0); drawText(score[i].points); } endDraw(); }
void Cube::draw(){ beginDraw(); drawBox(size, GL_QUADS); endDraw(); }
//------------------------------------------------------------------------------------------------------------- void Mesh::Draw(){ beginDraw(); //setMaterial(); glDrawElements(GL_TRIANGLES, NumFaces * 3, GL_UNSIGNED_INT, reinterpret_cast<const GLvoid *>(0)); endDraw(); }
void kpTool::beginDrawInternal () { if (!m_beganDraw) { beginDraw (); m_beganDraw = true; emit beganDraw (m_currentPoint); } }
void Canvas::fillBackground(COLORREF bkColor) { HDC hDC = beginDraw(); RECT rAll = { 0, 0, m_nWidth, m_nHeight }; SetBkColor(hDC, bkColor); ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &rAll, NULL, 0, NULL); endDraw(); }
void Bee::draw(){ beginDraw(); glTranslatef(O[0],O[1],O[2]); glRotatef(-rot * 36/2*M_PI,0,1,0); glTranslatef(r,h,0); bee(size); glTranslatef(-r,-h,0); glRotatef(rot * 36/2*M_PI,0,1,0); glTranslatef(-O[0],-O[1],-O[2]); endDraw(); }
void Interface::drawRound() { beginDraw(); glColor3f(1.0, 1.0, 1.0); glTranslatef(200.0 - textWidth(roundnum)/2.0 * 2.0, 300.0 - 2.0, 0); glScalef(2.0, 2.0, 2.0); drawText(roundnum); endDraw(); }
void Renderer::beginRenderFBO() { glViewport(0, 0, WIDTH*msaa, HEIGHT*msaa); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f, (float)(WIDTH)/(HEIGHT), 0.01f, 999999.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo); beginDraw(); }
void Game2::render() { beginDraw(); ///////Game Window////////// //Draw background and faces window->draw(background); window->draw(body); window->draw(face); //Draw text option indicators window->draw(happyLogo); window->draw(sadLogo); window->draw(angryLogo); window->draw(excitedLogo); window->draw(rewardLogo); window->draw(punishLogo); //Draw text boxes window->draw(AITextBox); window->draw(optionButton1); window->draw(optionButton2); window->draw(optionButton3); window->draw(optionButton4); window->draw(happyNum); window->draw(sadNum); window->draw(angryNum); window->draw(excitedNum); window->draw(rewardButton); window->draw(punishButton); window->draw(rewardLet); window->draw(punishLet); //Draw text window->draw(AIText); window->draw(textOption1); window->draw(textOption2); window->draw(textOption3); window->draw(textOption4); window->draw(AIMoodText1); window->draw(AIMoodText2); window->draw(AIRewardValText1); window->draw(AIRewardValText2); window->draw(rewardText); window->draw(punishText); window->draw(instructText1); window->draw(instructText2); endDraw(); }
// resize to a bigger dimension if able void Painting::resize(tk::WDims dims) { auto prevDims = imgCanvas->dims(); if( dims.width < prevDims.width ) dims.width = prevDims.width; if( dims.height < prevDims.height ) dims.height = prevDims.height; if( prevDims == dims ) return; auto newImg = tk::image::create(tk::image::Params().dimensions(dims)); // copy contents of previous image auto & canvas = newImg->beginDraw(); imgCanvas->drawInto(canvas,tk::Point(0,0)); newImg->endDraw(); // replace the image with the resized one imgCanvas = newImg; }
void Interface::drawFPS() { beginDraw(); glEnable(GL_BLEND); glBlendFunc(GL_SRC_COLOR, GL_ONE); glColor4f(0.5, 1.0, 1.0, 0.75f); // the font has a height of 8 glTranslatef(2.0, 10.0, 0); glScalef(1.0, 1.0, 1.0); drawText(fps); glDisable(GL_BLEND); endDraw(); }
void Dot::draw(cairo_t *cr) const { beginDraw(cr, x, y, rad(0)); applyLineColor(cr); cairo_move_to(cr, size/fabs(zoom), 0); cairo_arc(cr, 0, 0, size/fabs(zoom), 0, rad(360)); cairo_stroke_preserve(cr); applyFillColor(cr); cairo_fill(cr); cairo_move_to(cr, 0, 0); putLabel(cr); cairo_stroke(cr); endDraw(cr); }
void Interface::drawScore() { const std::vector<Player*>& player = framework->getPlayers(); beginDraw(); for(int i = 0; i < 2; i++) { if (i == 0) { glColor3f(0.5, 1.0, 0.5); } else { glColor3f(1.0, 0.5, 0.5); } int namecount = 0; for (int j = 0; j < player.size(); ++j) { if (player[j]->getSide() == (i == 0 ? FRONT : BACK)) { const char* name = player[j]->getName().c_str(); glLoadIdentity(); if (i == 0) { glTranslatef(2.0, 0, 0); } else { glTranslatef(400.0 - textWidth(name)*2.0 - 2.0, 0, 0); } glTranslatef(0, 300.0 - 2.0 - 18.0 * namecount, 0); glScalef(2.0, 2.0, 2.0); drawText(name); namecount++; } } glLoadIdentity(); if (i == 0) { glTranslatef(2.0, 0, 0); } else { glTranslatef(400.0 - textWidth(score[i])*5.0 - 2.0, 0, 0); } glTranslatef(0, 300.0 - 2.0 - 18.0 * namecount, 0); glScalef(5.0, 5.0, 5.0); drawText(score[i]); } endDraw(); }
void Interface::drawBackground(bool cruel) { beginDraw(); // this is dirty, but it looks cruel :) if (cruel) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_COLOR, GL_ONE); } glBindTexture(GL_TEXTURE_2D, backTexture); glColor3f(1.0, 1.0, 1.0); glBegin(GL_QUADS); glTexCoord2f(0.0f, 1.0f); glVertex3f(0.0,0.0,0.0); glTexCoord2f(1.0f, 1.0f); glVertex3f(400.0,0.0,0.0); glTexCoord2f(1.0f, 0.0f); glVertex3f(400.0,300.0,0.0); glTexCoord2f(0.0f, 0.0f); glVertex3f(0.0,300.0,0.0); glEnd(); endDraw(); }
void Interface::drawMessages() { beginDraw(); for (std::list<Message>::iterator it = message.begin(); it != message.end(); it++) { switch (*it) { case YOU_SERVE: glEnable(GL_BLEND); glBlendFunc(GL_SRC_COLOR, GL_ONE); glColor4f(0.5, 0.5, 1.0, 0.65); glTranslatef(200.0 - textWidth("<You serve>")/2.0 * 6.0, 150.0 + 4.0 * 6.0, 0); glScalef(6.0, 6.0, 6.0); drawText("<You serve>"); glLoadIdentity(); glColor4f(1.0, 1.0, 1.0, 0.5); glTranslatef(200.0 - textWidth("Press the left mouse button to serve the ball.")/2.0 * 0.8, 10.0, 0); glScalef(0.8, 0.8, 0.8); drawText("Press the left mouse button to serve the ball."); glDisable(GL_BLEND); break; case CONNECTING: glEnable(GL_BLEND); glBlendFunc(GL_SRC_COLOR, GL_ONE); glColor4f(0.5, 0.5, 1.0, 0.65); glTranslatef(200.0 - textWidth("<Connecting>")/2.0 * 6.0, 150.0 + 4.0 * 6.0, 0); glScalef(6.0, 6.0, 6.0); drawText("<Connecting>"); glLoadIdentity(); glColor4f(1.0, 1.0, 1.0, 0.5); glTranslatef(200.0 - textWidth("Please make sure a server is running.")/2.0 * 0.8, 10.0, 0); glScalef(0.8, 0.8, 0.8); drawText("Please make sure a server is running."); glDisable(GL_BLEND); break; case WAITING_FOR_OPPONENT: glEnable(GL_BLEND); glBlendFunc(GL_SRC_COLOR, GL_ONE); glColor4f(0.5, 0.5, 1.0, 0.5); glTranslatef(200.0 - textWidth("<Waiting for opponent>")/2.0 * 2.0, 250.0 + 4.0 * 2.0, 0); glScalef(2.0, 2.0, 2.0); drawText("<Waiting for opponent>"); glDisable(GL_BLEND); break; case FLASH_GAME_STARTED: glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(1.0, 1.0, 0.5, flashalpha); glTranslatef(200.0 - textWidth("<Game started>")/2.0 * 4.0, 200.0 + 4.0 * 4.0, 0); glScalef(4.0, 4.0, 4.0); drawText("<Game started>"); glDisable(GL_BLEND); break; case FLASH_YOU_LOST: glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(1.0, 0.5, 0.0, flashalpha); glTranslatef(200.0 - textWidth("): YOU LOST :(")/2.0 * 4.0, 200.0 + 4.0 * 4.0, 0); glScalef(4.0, 4.0, 4.0); drawText("): YOU LOST :("); glDisable(GL_BLEND); break; case FLASH_YOU_WIN: glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(0.5, 1.0, 0.0, flashalpha); glTranslatef(200.0 - textWidth("(: YOU WIN :)")/2.0 * 4.0, 200.0 + 4.0 * 4.0, 0); glScalef(4.0, 4.0, 4.0); drawText("(: YOU WIN :)"); glDisable(GL_BLEND); break; } glLoadIdentity(); } if (paused) { glColor4f(1.0, 1.0, 1.0, 1.0); glTranslatef(200.0 - textWidth("* PAUSED *")/2.0 * 8.0, 150.0 + 4.0 * 8.0, 0); glScalef(8.0, 8.0, 8.0); drawText("* PAUSED *"); } endDraw(); }
void SegRing::draw() { beginDraw(); drawImmidiate(); endDraw(); }