void drawDemo(int renderToTexture) { if (!G_Help) { if (!renderToTexture) { switch(G_ShowTexture) { case 0: drawColoredQuad(G_ShaderColor, 0, 0, 1); break; case 1: drawPosColoredQuad(G_ShaderPosColor); break; case 2: drawTexturedQuad(G_ShaderTexture, G_TexImageRocks); break; case 3: drawTexturedQuad(G_ShaderTexture, G_TexCamera); break; case 4: drawTexturedQuad(G_ShaderDepthTexture, G_TexCameraDepth); break; } } else { drawTexturedQuad(G_ShaderTexture, G_TexImageRocks); } tellThemKidsWhatsGoingOn(); } else { printHelp(); } }
void ContentLayerChromium::draw() { if (m_skipsDraw) return; ASSERT(layerRenderer()); const ContentLayerChromium::SharedValues* sv = layerRenderer()->contentLayerSharedValues(); ASSERT(sv && sv->initialized()); GraphicsContext3D* context = layerRendererContext(); GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0)); GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_contentsTexture)); layerRenderer()->useShader(sv->contentShaderProgram()); GLC(context, context->uniform1i(sv->shaderSamplerLocation(), 0)); if (requiresClippedUpdateRect()) { float m43 = drawTransform().m43(); TransformationMatrix transform; transform.translate3d(m_largeLayerDrawRect.center().x(), m_largeLayerDrawRect.center().y(), m43); drawTexturedQuad(context, layerRenderer()->projectionMatrix(), transform, m_largeLayerDrawRect.width(), m_largeLayerDrawRect.height(), drawOpacity(), sv->shaderMatrixLocation(), sv->shaderAlphaLocation()); } else { drawTexturedQuad(context, layerRenderer()->projectionMatrix(), drawTransform(), m_bounds.width(), m_bounds.height(), drawOpacity(), sv->shaderMatrixLocation(), sv->shaderAlphaLocation()); } }
void drawMapMenu (){ /* _________________ Dessin du sous-menu pour choisir la carte_______________*/ /* dessin du fond*/ glPushMatrix(); glLoadIdentity(); glColor3ub(255,255,255); glBegin(GL_LINE_LOOP); glVertex2f(-300., 200.); glVertex2f(300., 200.); glVertex2f(300., -225.); glVertex2f(-300., -225.); glEnd(); glTranslatef(0., -30., 0.); glScalef(590., 383., 1.); glColor3ub(0,0,0); drawQuad(); glPopMatrix(); /* dessin de la légende */ glPushMatrix(); glColor3ub(0,204,204); glScalef(300,60,1); glTranslatef(0.,-4.3,0); drawTexturedQuad(MENU_TEXTURES_ID.PUSH_ENTER); glPopMatrix(); /*dessin des flèches */ glPushMatrix(); glColor3ub(0,204,204); glScalef(100,300,1); glTranslatef(3.5,0,0); drawTexturedQuad(MENU_TEXTURES_ID.FLECHES); glPopMatrix(); Button* curButton = NULL; goToHeadList(BUTTON_OF_MENU.lstMapButton); while( (curButton = (Button*) nextData(BUTTON_OF_MENU.lstMapButton)) != NULL){ if( BUTTON_OF_MENU.lstMapButton->position == BUTTON_OF_MENU.indexButtonClicked) glColor3ub(0,204,204); else glColor3ub(255,255,255); drawButton(curButton); } }
void drawVideo(int x,int y,unsigned int tex_id,TheoraVideoClip* clip) { //glLoadIdentity(); //glTranslatef(x,y,0); glBindTexture(GL_TEXTURE_2D,tex_id); TheoraVideoFrame* f=clip->getNextFrame(); if (f) { glTexSubImage2D(GL_TEXTURE_2D,0,0,0,clip->getWidth(),f->getHeight(),uploadFormat,GL_UNSIGNED_BYTE,f->getBuffer()); clip->popFrame(); } float w=clip->getWidth(),h=clip->getHeight(); float tw=nextPow2(w),th=nextPow2(h); glEnable(GL_TEXTURE_2D); if (shader_on) enable_shader(); drawTexturedQuad(tex_id, x,y,395,285,w/tw,h/th); if (shader_on) disable_shader(); glDisable(GL_TEXTURE_2D); drawColoredQuad(x,y+285,395,15,0,0,0,1); drawWiredQuad(x,y+285,395,14,1,1,1,1); float p=clip->getTimePosition()/clip->getDuration(); drawColoredQuad(x+1.5f,y+574/2,784*p/2,11,1,1,1,1); }
void draw() { glBindTexture(GL_TEXTURE_2D,tex_id); TheoraVideoFrame* f=clip->getNextFrame(); if (f) { glTexSubImage2D(GL_TEXTURE_2D,0,0,0,clip->getWidth(),f->getHeight(),GL_RGB,GL_UNSIGNED_BYTE,f->getBuffer()); clip->popFrame(); } float w=clip->getWidth(),h=clip->getHeight(); float tw=nextPow2(w),th=nextPow2(h); glEnable(GL_TEXTURE_2D); if (shader_on) enable_shader(); drawTexturedQuad(0,0,800,600,w/tw,h/th); if (shader_on) disable_shader(); glDisable(GL_TEXTURE_2D); drawColoredQuad(0,570,800,30,0,0,0,1); drawWiredQuad(0,570,800,30,1,1,1,1); float x=clip->getTimePosition()/clip->getDuration(); drawColoredQuad(3,573,794*x,24,1,1,1,1); }
void draw() { glBindTexture(GL_TEXTURE_2D,tex_id); TheoraVideoFrame* f=clips[cClip]->getNextFrame(); if (f) { unsigned char* src=f->getBuffer(); int i,j,k,x,y,w=f->getWidth(); for (y=0;y<300;y++) { for (x=0;x<203;x++) { i=(y*203+x)*4; j=((y+2)*w+x+4)*3; k=((y+2)*w+x+205+4)*3; buffer[i ]=src[j]; buffer[i+1]=src[j+1]; buffer[i+2]=src[j+2]; buffer[i+3]=src[k]; } } glTexSubImage2D(GL_TEXTURE_2D,0,0,0,203,300,GL_RGBA,GL_UNSIGNED_BYTE,buffer); clips[cClip]->popFrame(); } glEnable(GL_TEXTURE_2D); drawTexturedQuad(tex_id,298,150,203,300,203.0f/256.0f,300.0f/512.0f); }
void VideoLayerChromium::drawYUV(const SharedValues* sv) { GraphicsContext3D* context = layerRendererContext(); GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE1)); GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textures[VideoFrameChromium::yPlane])); GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE2)); GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textures[VideoFrameChromium::uPlane])); GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE3)); GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textures[VideoFrameChromium::vPlane])); layerRenderer()->useShader(sv->yuvShaderProgram()); unsigned frameWidth = m_frameSizes[VideoFrameChromium::yPlane].width(); unsigned textureWidth = m_textureSizes[VideoFrameChromium::yPlane].width(); float widthScaleFactor = static_cast<float>(frameWidth) / textureWidth; GLC(context, context->uniform1f(sv->yuvWidthScaleFactorLocation(), widthScaleFactor)); GLC(context, context->uniform1i(sv->yTextureLocation(), 1)); GLC(context, context->uniform1i(sv->uTextureLocation(), 2)); GLC(context, context->uniform1i(sv->vTextureLocation(), 3)); GLC(context, context->uniformMatrix3fv(sv->ccMatrixLocation(), 0, const_cast<float*>(yuv2RGB), 1)); drawTexturedQuad(context, layerRenderer()->projectionMatrix(), drawTransform(), bounds().width(), bounds().height(), drawOpacity(), sv->yuvShaderMatrixLocation(), sv->yuvAlphaLocation()); // Reset active texture back to texture 0. GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0)); }
void _drawVideo(int x, int y, unsigned int textureId, theoraplayer::VideoClip* clip) { glBindTexture(GL_TEXTURE_2D, textureId); theoraplayer::VideoFrame* frame = clip->fetchNextFrame(); if (frame != NULL) { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, clip->getWidth(), frame->getHeight(), uploadFormat, GL_UNSIGNED_BYTE, frame->getBuffer()); clip->popFrame(); } float w = clip->getSubFrameWidth(); float h = clip->getSubFrameHeight(); float sx = clip->getSubFrameX(); float sy = clip->getSubFrameY(); float tw = potCeil(w); float th = potCeil(h); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, textureId); if (shaderActive) { enableShader(); } drawTexturedQuad(textureId, x, y, 395.0f, 285.0f, w / tw, h / th, sx / tw, sy / th); if (shaderActive) { disableShader(); } glDisable(GL_TEXTURE_2D); drawColoredQuad(x, y + 285.0f, 395.0f, 15.0f, 0.0f, 0.0f, 0.0f, 1.0f); drawWiredQuad(x, y + 285.0f, 395.0f, 14.0f, 1.0f, 1.0f, 1.0f, 1.0f); float p = clip->getTimePosition() / clip->getDuration(); drawColoredQuad(x + 1.5f, y + 286.0f, 784.0f * p * 0.5f, 11.0f, 1.0f, 1.0f, 1.0f, 1.0f); }
// -------------------------------------------------------- void TouchWidgetRenderer::drawPrecisionHandle( GLResourceContainer * container, const QPointF & grip, const QPointF & tip, float aspect_ratio, float alpha ) const { // compute difference QLineF diff(grip, tip); float length = diff.length(); // compute affine transformation QPointF pos = (grip+tip)/2; QSizeF handle_size(length, length * aspect_ratio); QSizeF grip_size(length * aspect_ratio * 1.125f, length * aspect_ratio * 1.125f); float rotation = atan2f(-diff.dy(),-diff.dx()) / 3.1415f * 180; // draw drawTexturedQuad(container->texture("precision_handle"), pos, handle_size, rotation, alpha); drawTexturedQuad(container->texture("precision_handle_grip"), grip, grip_size, rotation, 1.0f); }
void CanvasLayerChromium::draw() { ASSERT(layerRenderer()); const CanvasLayerChromium::SharedValues* sv = layerRenderer()->canvasLayerSharedValues(); ASSERT(sv && sv->initialized()); GLC(glActiveTexture(GL_TEXTURE0)); GLC(glBindTexture(GL_TEXTURE_2D, m_textureId)); layerRenderer()->useShader(sv->canvasShaderProgram()); GLC(glUniform1i(sv->shaderSamplerLocation(), 0)); drawTexturedQuad(layerRenderer()->projectionMatrix(), drawTransform(), bounds().width(), bounds().height(), drawOpacity(), sv->shaderMatrixLocation(), sv->shaderAlphaLocation()); }
void ContentLayerChromium::draw() { if (m_skipsDraw) return; ASSERT(layerRenderer()); const ContentLayerChromium::SharedValues* sv = layerRenderer()->contentLayerSharedValues(); ASSERT(sv && sv->initialized()); GraphicsContext3D* context = layerRendererContext(); GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0)); GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_contentsTexture)); layerRenderer()->useShader(sv->contentShaderProgram()); GLC(context, context->uniform1i(sv->shaderSamplerLocation(), 0)); drawTexturedQuad(context, layerRenderer()->projectionMatrix(), drawTransform(), bounds().width(), bounds().height(), drawOpacity(), sv->shaderMatrixLocation(), sv->shaderAlphaLocation()); }
void VideoLayerChromium::drawRGBA(const SharedValues* sv) { GraphicsContext3D* context = layerRendererContext(); GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0)); GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textures[VideoFrameChromium::rgbPlane])); layerRenderer()->useShader(sv->rgbaShaderProgram()); unsigned frameWidth = m_frameSizes[VideoFrameChromium::rgbPlane].width(); unsigned textureWidth = m_textureSizes[VideoFrameChromium::rgbPlane].width(); float widthScaleFactor = static_cast<float>(frameWidth) / textureWidth; GLC(context, context->uniform1f(sv->rgbaWidthScaleFactorLocation(), widthScaleFactor)); GLC(context, context->uniform1i(sv->rgbaTextureLocation(), 0)); drawTexturedQuad(context, layerRenderer()->projectionMatrix(), drawTransform(), bounds().width(), bounds().height(), drawOpacity(), sv->rgbaShaderMatrixLocation(), sv->rgbaAlphaLocation()); }
void MGuiImage::draw(void) { MRenderingContext * render = MGui::getInstance()->getRenderingContext(); if(! isVisible()) return; if(hasNormalTexture()) { render->setColor4(getNormalColor()); render->enableTexture(); drawTexturedQuad(getNormalTexture()); return; } render->setColor4(getNormalColor()); render->disableTexture(); drawQuad(); }
void drawButton(const Button* button){ if(button == NULL) return; GLuint textureId = 0; switch(button->action){ case PUT_GUN : textureId = GAME_TEXTURES_ID.GUN_BUTTON_ID; break; case PUT_HYBRID : textureId = GAME_TEXTURES_ID.HYBRID_BUTTON_ID; break; case PUT_LASER : textureId = GAME_TEXTURES_ID.LASER_BUTTON_ID; break; case PUT_ROCKET : textureId = GAME_TEXTURES_ID.ROCKET_BUTTON_ID; break; case QUIT_GAME : textureId = GAME_TEXTURES_ID.QUIT_GAME_ID; break; case AIDE_MENU : textureId = MENU_TEXTURES_ID.AIDE_BUTTON; break; case CHOIX_MENU : textureId = MENU_TEXTURES_ID.MAP_CHOICE_BUTTON; break; case PLAY_MENU : textureId = MENU_TEXTURES_ID.PLAY_BUTTON; break; case MAP_MENU : goToPosition(BUTTON_OF_MENU.lstMapTextureIndex, BUTTON_OF_MENU.lstMapButton->position); textureId = *((GLuint*)currentData(BUTTON_OF_MENU.lstMapTextureIndex)); break; case CLOSE_RULES_MENU : textureId = MENU_TEXTURES_ID.RULES_CLOSE; break; default : return; break; } glPushMatrix(); glTranslatef(button->position.x , button->position.y , button->position.z); glScalef(button->width, button->height,1.); drawTexturedQuad(textureId); glPopMatrix(); }
void draw() { glBindTexture(GL_TEXTURE_2D,tex_id); if (!needsSeek) { TheoraVideoFrame* f=clip->getNextFrame(); if (f) { glTexSubImage2D(GL_TEXTURE_2D,0,0,0,clip->getWidth(),f->getHeight(),GL_RGB,GL_UNSIGNED_BYTE,f->getBuffer()); needsSeek = 1; if (f->getFrameNumber() != cFrame) nWrongSeeks++; cFrame++; if (cFrame >= clip->getNumFrames()) cFrame = 0; printf("Displayed frame %d\n", f->getFrameNumber()); clip->popFrame(); } } float w=clip->getWidth(),h=clip->getHeight(); float tw=nextPow2(w),th=nextPow2(h); glEnable(GL_TEXTURE_2D); if (shader_on) enable_shader(); drawTexturedQuad(tex_id,0,0,800,600,w/tw,h/th); if (shader_on) disable_shader(); glDisable(GL_TEXTURE_2D); drawColoredQuad(0,570,800,30,0,0,0,1); drawWiredQuad(0,570,800,30,1,1,1,1); float x=clip->getTimePosition()/clip->getDuration(); drawColoredQuad(3,573,794*x,24,1,1,1,1); }
// -------------------------------------------------------- void TouchDisplayWidgetRenderer::paint( GLResourceContainer * container, int pass, TouchWidgetRenderer * to_texture_renderer ) const { Q_UNUSED(to_texture_renderer); if(pass==0) { // draw line if(_twm->currentBallTarget() != NULL) { const RigidWidgetController * ball = _twm->currentBallTarget()->first; const RigidWidgetController * target = _twm->currentBallTarget()->second; glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); glLineWidth(2); //glColor4f(240.0/255,198.0/255,0,1); glColor4f(1,1,1,1); glBegin(GL_LINE_STRIP); glVertex2f(ball->pos().x(), ball->pos().y()); glVertex2f(target->pos().x(), target->pos().y()); glEnd(); } foreach(const SceneTouchPoint * stp, _tpm->touches()) { // draw bubble //const QList<RigidWidgetController *> & closest_widgets = stp->closestRigidWidgets(); //if(closest_widgets.size()>=2) //{ // // labeled as in the bubble cursor 2005 paper // //float con_d_i = QLineF(closest_widgets[0]->pos(), stp->transformedPoint()->pos()).length() + closest_widgets[0]->radius(); // //float int_d_j = QLineF(closest_widgets[1]->pos(), stp->transformedPoint()->pos()).length() - closest_widgets[1]->radius(); // float con_d_i = closest_widgets[0]->containmentDistance(stp->transformedPoint()->pos()); // float int_d_j = closest_widgets[1]->intersectingDistance(stp->transformedPoint()->pos()); // float radius = qMin(con_d_i, int_d_j); // drawTexturedQuad(container->texture("halo"), stp->transformedPoint()->pos(), QSizeF(radius, radius)*2, 0, 0.5f); //} QRectF bubble_rect = stp->bubbleRect(); if(!bubble_rect.isEmpty()) { Q_ASSERT(QLineF(stp->pos(), bubble_rect.center()).length() < 0.001f); drawTexturedQuad(container->texture("halo"), stp->pos(), bubble_rect.size(), 0, 0.3f); } // we don't want to show all the gory details in magnifying glasses if(to_texture_renderer!=NULL) { //qDebug() << stp->visibilityInMagnification(); if(stp->visibilityInMagnification() == SceneTouchPoint::NeverVisible) continue; if(stp->visibilityInMagnification() == SceneTouchPoint::VisibleOnlyWithAreaCursor) { if(!stp->isFree() || _twm->selectionMode()!=DirectAreaSelection) //if(_twm->selectionMode()!=DirectAreaSelection) continue; } } else { if(!stp->visibleInScene()) continue; } if(_tool_setting_container.boolProperty("simplified_mg") && to_texture_renderer!=NULL) continue; // determine texture name QString texture_name("touch_bright/touch"); if(stp->state() == Qt::TouchPointPressed) { texture_name += "_new"; } else { texture_name += (stp->numPressedWidgets() == 0) ? "_free" : "_bound"; // TODO: SETTING "SHOW YOUNG CURSORS" //if(stp->isYoung()) //{ // texture_name += "_young"; //} } // geometry const QRectF & rect = stp->rect(); if(_tool_setting_container.boolProperty("pointy_cursor")) { drawTexturedQuad(container->texture(texture_name), rect.center(), rect.size(), 0, 0.25f); drawHollowCircle(container, rect.center(), rect.size().width()/2*1.2f, 0.5f, Qt::white, 0.0004f, 300); drawCross(container, rect.center(), rect.size()*1.2f); } else { drawTexturedQuad(container->texture(texture_name), rect.center(), rect.size(), 0, 0.25f); drawHollowCircle(container, rect.center(), rect.size().width()/2*1.2f, 1.0f, Qt::white, 0.0005f, 300); } } } }
//TODO void drawInterface(Interface* interface, World* world){ if(interface == NULL) return; glLoadIdentity(); //Dessin du fond de l'interface glColor3ub(0,0,0); glLineWidth(1.0); glPushMatrix(); glTranslatef(interface->position.x, interface->position.y, interface->position.z); glScalef(interface->width, interface->height, 1.0); drawQuad(); glPopMatrix(); //Dessin du texte argent if(interface->lastMoney != world->money){ updateMoneyTexture(interface, world->money); interface->lastMoney = world->money; } glPushMatrix(); glLoadIdentity(); glColor3ub(255,255,255); glTranslatef(interface->moneyPosition.x, interface->moneyPosition.y, 0.); glScalef(interface->moneyWidth,interface->moneyHeight,1.); drawTexturedQuad(GAME_TEXTURES_ID.MONEY_ID); glPopMatrix(); //Dessin des boutons glColor3ub(255,255,255); goToHeadList(interface->lstButtons); Button* cur = NULL; while( (cur = (Button*)nextData(interface->lstButtons) ) != NULL){ int towerCost; switch(cur->action){ case PUT_GUN : towerCost = world->map.towerdatas->costM; break; case PUT_HYBRID : towerCost = world->map.towerdatas->costH; break; case PUT_LASER : towerCost = world->map.towerdatas->costL; break; case PUT_ROCKET : towerCost = world->map.towerdatas->costR; break; default : towerCost = 0; } if(world->money < towerCost) glColor3ub(255,0,0); else glColor3ub(255,255,255); drawButton(cur); } //Dessin des infos sur une tour cliquée (si une tour a été cliquée) glPushMatrix(); glLoadIdentity(); glColor3ub(255,255,255); glTranslatef(interface->infoPosition.x, interface->infoPosition.y, 0.); glScalef(interface->infoWidth,interface->infoHeight,1.); drawTexturedQuad(GAME_TEXTURES_ID.INFO_PANEL_ID); glPopMatrix(); //Dessin d'une tour sur la souris si l'action courante est de poser une tour GLuint textureId = 0; bool drawUnderMouse = true; //TODO switch(interface->currentAction){ case PUT_GUN : textureId = GAME_TEXTURES_ID.GUN_TOWER_ID; break; case PUT_HYBRID : textureId = GAME_TEXTURES_ID.HYBRID_TOWER_ID; break; case PUT_LASER : textureId = GAME_TEXTURES_ID.LASER_TOWER_ID; break; case PUT_ROCKET: textureId = GAME_TEXTURES_ID.ROCKET_TOWER_ID; break; case NO_ACTION : drawUnderMouse = false; break; case QUIT_GAME : drawUnderMouse = false; break; default : drawUnderMouse = false; } //Si le jeu est mis en pause if(interface->currentAction == PAUSE_GAME){ glPushMatrix(); glLoadIdentity(); glColor3ub(255,255,255); glScalef(WINDOW_WIDTH / 5.0,WINDOW_HEIGHT / 10.0,1.); drawTexturedQuad(GAME_TEXTURES_ID.PAUSE_MESSAGE_ID); glPopMatrix(); } if(drawUnderMouse){ int mouseX, mouseY; SDL_GetMouseState(&mouseX, &mouseY); Point3D oglMouse = sdlToOpenGL(PointXYZ(mouseX,mouseY, 0.0)); //Besoin des coordonnées réelles pour le test de tour Point3D oglRealMouse = oglMouse; oglRealMouse.x -= world->cameraPosition.x; oglRealMouse.y -= world->cameraPosition.y; glPushMatrix(); glLoadIdentity(); glTranslatef(oglMouse.x, oglMouse.y, oglMouse.z); glScalef(TOWER_WIDTH_PX,TOWER_HEIGHT_PX, 1.0); if(!canIPutATowerHere(world, oglRealMouse, openGLToItd(world->map.width, world->map.height, oglRealMouse))){ glColor3ub(255, 0,0); } else glColor3ub(0,255,0); drawTexturedQuad(textureId); glPopMatrix(); } glColor3ub(255,255,255); //Affichage du message "Wave X" if(world->isBetweenWaves){ if(interface->messageDisplayTime == 0){ glDeleteTextures(1, &(GAME_TEXTURES_ID.WAVE_MESSAGE_ID)); GAME_TEXTURES_ID.WAVE_MESSAGE_ID = createWaveMessage(world->currentMonstersWave + 1); interface->messageDisplayTime = SDL_GetTicks(); } Uint32 elapsedTime = SDL_GetTicks() - interface->messageDisplayTime; if(elapsedTime <= MESSAGE_DISPLAY_DURATION){ glPushMatrix(); glLoadIdentity(); glColor3ub(255,255,255); glScalef(WINDOW_WIDTH / 2.5, WINDOW_HEIGHT / 15.0, 1.0); drawTexturedQuad(GAME_TEXTURES_ID.WAVE_MESSAGE_ID); glPopMatrix(); } }else{ interface->messageDisplayTime = 0; } //Si on a gagné/perdu affichage du message if(world->gameWinned){ glPushMatrix(); glLoadIdentity(); glScalef(WINDOW_WIDTH / 2.5, WINDOW_HEIGHT / 2.0, 1.); drawTexturedQuad(GAME_TEXTURES_ID.WIN_MESSAGE_ID); glPopMatrix(); } else if(world->gameLoosed){ glPushMatrix(); glLoadIdentity(); glScalef(WINDOW_WIDTH / 2.5, WINDOW_HEIGHT / 2.0, 1.); drawTexturedQuad(GAME_TEXTURES_ID.LOOSE_MESSAGE_ID); glPopMatrix(); } }
// -------------------------------------------------------- void TouchWidgetRenderer::drawResizers( GLResourceContainer * container, const SceneTouchPoint * resizing_point, const QPointF & circle_center, float circle_radius, const QPointF & base_target, QList<float> resizer_angles ) const { static Warping<qreal> resizer_activeness(0.0f, 0.2f); static bool resizer_active = false; static QPointF last_resizer_pos; static float touch_angle_target = 0; QPointF base_pos = QLineF(circle_center, base_target).unitVector().pointAt(circle_radius); float base_angle = QLineF(base_target, circle_center).angleTo(QLineF(0,0,1,0)); // trigger the warp towards 1 or 0 if the status just changed and evaluate it if((resizing_point != NULL) != resizer_active) { resizer_active = (resizing_point != NULL); resizer_activeness.setTarget(resizer_active ? 1.0f : 0.0f); } float activeness = resizer_activeness.value(); // update resizer position and angle based on current touch if(resizer_active) { last_resizer_pos = resizing_point->pos(); touch_angle_target = QLineF(last_resizer_pos, circle_center).angleTo(QLineF(0,0,1,0));; touch_angle_target += 60; while(touch_angle_target>120) touch_angle_target-=120; while(touch_angle_target<-120) touch_angle_target+=120; touch_angle_target -= 60; } // compute resizer size const float resizer_diameter = 0.3f * circle_radius * (activeness*0.5+1); QSizeF resizer_size(resizer_diameter, resizer_diameter); // draw individual angles foreach(float resizer_angle, resizer_angles) { // compute desired angle float blended_angle = (touch_angle_target+resizer_angle)*activeness + resizer_angle*(1-activeness); // compute resizer handle location QTransform transform; transform.translate(circle_center.x(), circle_center.y()); transform.rotate(blended_angle); transform.translate(-circle_center.x(), -circle_center.y()); QPointF resizer_pos = transform.map(base_pos); // draw resizer handle if(activeness < 1) { drawTexturedQuad(container->texture("mglass_resizer"), resizer_pos, resizer_size, blended_angle+base_angle+180); } if(activeness > 0) { drawTexturedQuad(container->texture("mglass_resizer_active"), resizer_pos, resizer_size, blended_angle+base_angle+180, activeness); } }
// -------------------------------------------------------- void TouchWidgetRenderer::drawCross( GLResourceContainer * container, const QPointF & pos, const QSizeF size ) const { //static const ; drawTexturedQuad(container->texture("precision_cross"), pos, size); }
void MGuiWindow::draw(void) { MRenderingContext * render = MGui::getInstance()->getRenderingContext(); if(! isVisible()) return; MWindow * window = MWindow::getInstance(); rescaleScrollingBar(); render->enableScissorTest(); render->setScissor((int)getPosition().x, window->getHeight() - (int)getPosition().y - (unsigned int)getScale().y, (unsigned int)getScale().x, (unsigned int)getScale().y); // normal clear if((getNormalColor().w >= 1.0f) && (! hasNormalTexture())) { render->setClearColor(getNormalColor()); render->clear(M_BUFFER_COLOR); MGuiEvent guiEvent; guiEvent.type = MGUI_EVENT_DRAW; if(m_pointerEvent) m_pointerEvent(this, &guiEvent); // 2d mode set2dMode(render); render->disableDepthTest(); render->disableCullFace(); render->disableLighting(); render->enableBlending(); render->setBlendingMode(M_BLENDING_ALPHA); render->enableTexture(); } else { // background set2dMode(render); render->disableDepthTest(); render->disableCullFace(); render->disableLighting(); render->enableBlending(); render->setBlendingMode(M_BLENDING_ALPHA); if(hasNormalTexture()) // texture clear { render->enableTexture(); render->setColor4(getNormalColor()); drawTexturedQuad(getNormalTexture()); } else if(getNormalColor().w < 1.0f) { render->disableTexture(); render->setColor4(getNormalColor()); drawQuad(); } if(m_pointerEvent) { MGuiEvent guiEvent; guiEvent.type = MGUI_EVENT_DRAW; m_pointerEvent(this, &guiEvent); // 2d mode set2dMode(render); render->disableDepthTest(); render->disableCullFace(); render->disableLighting(); render->enableBlending(); render->setBlendingMode(M_BLENDING_ALPHA); render->enableTexture(); } } // gui render->pushMatrix(); render->translate(MVector3(getPosition().x, getPosition().y, 0)); render->pushMatrix(); render->translate(MVector3(getScroll().x, getScroll().y, 0)); // drawing unsigned int i; unsigned int oSize = m_objects.size(); for(i=0; i<oSize; i++) m_objects[i]->draw(); render->popMatrix(); // draw shadows if(hasShadow()) { render->disableScissorTest(); drawShadow(); render->enableScissorTest(); } // scolling slides if(isHorizontalScroll()) m_hScrollSlide.draw(); if(isVerticalScroll()) m_vScrollSlide.draw(); render->popMatrix(); }
void drawMenu( int* menuOpen,int* aideOpen,int* playIsPush, char* mapName){ glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); /*______________Bienvenue____________________________________*/ glPushMatrix(); glColor3ub(0,204,204); glScalef(400,70,1); glTranslatef(0,3.5,0); drawTexturedQuad(MENU_TEXTURES_ID.BIENVENUE); glPopMatrix(); /*______________Choix____________________________________*/ glPushMatrix(); glColor3ub(0,204,204); glScalef(150,40,1); glTranslatef(0.9,0,0); drawTexturedQuad(MENU_TEXTURES_ID.MAP_CHOICE_LEGEND); glPopMatrix(); /*______________PLay !____________________________________*/ glPushMatrix(); glColor3ub(0,204,204); glScalef(140,40,1); glTranslatef(0,-5,0); drawTexturedQuad(MENU_TEXTURES_ID.PLAY_LEGEND); glPopMatrix(); /*______________Règles____________________________________*/ glPushMatrix(); glColor3ub(0,204,204); glScalef(150,40,1); glTranslatef(-1,0.2,0); drawTexturedQuad(MENU_TEXTURES_ID.AIDE_LEGEND); glPopMatrix(); /* _________________ Dessin du bouton d'aide_______________*/ glColor3ub(255,255,255); drawButton(BUTTON_OF_MENU.regles); /* _________________ Dessin du bouton pour choisir la carte_______________*/ glColor3ub(255,255,255); drawButton(BUTTON_OF_MENU.choix_carte); /* _________________ Dessin du bouton play_______________*/ glColor3ub(255,255,255); drawButton(BUTTON_OF_MENU.jouer); if (*menuOpen == 1){ drawMapMenu(mapName); } if (*aideOpen == 1){ /*______________Règles____________________________________*/ glPushMatrix(); glColor3ub(255,255,255); glScalef(500,500,1); glTranslatef(0,0,0); drawTexturedQuad(MENU_TEXTURES_ID.RULES); glPopMatrix(); glColor3ub(255,255,255); drawButton(BUTTON_OF_MENU.close_rules); } if (*menuOpen == 1){ drawMapMenu(); } if (*playIsPush == 1){ if (mapName == NULL){ /*dessin de la bulle */ glPushMatrix(); glColor3ub(255,255,255); glScalef(250,250,1); glTranslatef(0.7,-0.5,0); drawTexturedQuad(MENU_TEXTURES_ID.BULLE); glPopMatrix(); } else{ *playIsPush =2; } } }
void MGui2d::draw(void) { MRenderingContext * render = MGui::getInstance()->getRenderingContext(); if(! isVisible()) return; if(isPressed()) // pressed { render->setColor4(getPressedColor()); if(hasPressedTexture()) { render->enableTexture(); drawTexturedQuad(getPressedTexture()); } else { render->disableTexture(); drawQuad(); } } else if(isHighLight()) // highLight { render->setColor4(getHighLightColor()); if(hasHighLightTexture()){ render->enableTexture(); drawTexturedQuad(getHighLightTexture()); } else { render->disableTexture(); drawQuad(); } } else // normal { render->setColor4(getNormalColor()); if(hasNormalTexture()) { render->enableTexture(); drawTexturedQuad(getNormalTexture()); } else { render->disableTexture(); drawQuad(); } } if(isDrawingText() && (getText() != NULL)) { render->enableTexture(); render->setColor4(getTextColor()); getFont()->draw(getText(), getPosition(), getTextSize()); } // draw shadows if(hasShadow()) { render->pushMatrix(); render->translate(MVector3(getPosition().x, getPosition().y, 0)); drawShadow(); render->popMatrix(); } }
void swcRectangle::draw() { if (!visible) return; const uint32_t outer_border_vertices[] = { //top radius_top_left.x, -border_size_top, width - radius_top_right.x, -border_size_top, width - radius_top_right.x, 0, radius_top_left.x, 0, //right width, radius_top_right.y, width + border_size_right, radius_top_right.y, width + border_size_right, height - radius_bottom_right.y, width, height - radius_bottom_right.y, //bottom radius_bottom_left.x, height, width - radius_bottom_right.x, height, width - radius_bottom_right.x, height + border_size_bottom, radius_bottom_left.x, height + border_size_bottom, //left -border_size_left, radius_top_left.y, 0, radius_top_left.y, 0, height - radius_bottom_left.y, -border_size_left, height - radius_bottom_left.y, }; const uint32_t inner_vertices[] = { radius_top_left.x, 0, width - radius_top_right.x, 0, width, radius_top_right.y, width, height - radius_bottom_right.y, width - radius_bottom_right.x, height, radius_bottom_left.x, height, 0, radius_top_left.y, 0, height - radius_bottom_left.y, radius_top_left.x, radius_top_left.y, width - radius_top_right.x, radius_top_right.y, width - radius_bottom_right.x, height - radius_bottom_right.y, radius_bottom_left.x, height - radius_bottom_left.y, }; //paint behind impPrePaint(); glPushMatrix(); glTranslatef(getX(), getY(), getZ()); // glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA); // glBlendFunc(GL_ONE, GL_ZERO); if (needReOrder()) { //setup stencils glClearStencil(0x0); glClear(GL_STENCIL_BUFFER_BIT); glEnable(GL_STENCIL_TEST); glStencilFunc(GL_ALWAYS, 0x0, 0x0); glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); //draw inner curved corners drawInnerCornerCurves(BOOL_EN_MSAA); //draw inner rectangle (cover) drawElements(GL_QUADS, sizeof(indices) / sizeof(indices[0]), GL_INT, &inner_vertices[0], &colors[0], &indices[0]); //draw a texturized quad if (hasTexture()) { // glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ZERO); glBlendFunc(GL_ONE, GL_ZERO); drawTexturedQuad(getByRef()); } glStencilFunc(GL_EQUAL, 0x0, 0xff); //draw outer curved/solid corners drawOuterCornerX(BOOL_EN_MSAA); //draw outer side borders drawElements(GL_QUADS, sizeof(outer_border_indices) / sizeof(outer_border_indices[0]), GL_INT, &outer_border_vertices[0], &border_colors[0], &outer_border_indices[0]); glDisable(GL_STENCIL_TEST); } else { //draw outer side borders drawElements(GL_QUADS, sizeof(outer_border_indices) / sizeof(outer_border_indices[0]), GL_INT, &outer_border_vertices[0], &border_colors[0], &outer_border_indices[0]); //draw outer curved/solid corners drawOuterCornerX(BOOL_EN_MSAA); //draw inner curved corners drawInnerCornerCurves(BOOL_EN_MSAA); //draw inner rectangle (cover) drawElements(GL_QUADS, sizeof(indices) / sizeof(indices[0]), GL_INT, &inner_vertices[0], &colors[0], &indices[0]); //draw a texturized quad if (hasTexture()) { glBlendFunc(GL_ONE, GL_ZERO); drawTexturedQuad(getByRef()); } } glPopMatrix(); //paint above the rectangle impPostPaint(); //paint the components impShowComponents(); //paint above all the others impSpecialPaint(); }