int main() { //init vertex Vector3f v1 = Vector3f(0.3, 0.3, 0.3); Vector3f v2 = Vector3f(0.3, 0.3, 0.6); //print Vertex puts("Init Vertex"); PrintVertex(v1); PrintVertex(v2); //set Camera myLookAt(Vector3f(0.0, 0.0, 2.0), Vector3f(0.0, 0.0, 0.0), Vector3f(0.0, 1.0, 0.0)); //set Ortho myOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); //print Vertex puts("Ortho"); PrintVertex(DrawVertex(v1)); PrintVertex(DrawVertex(v2)); //set Frustum myFrustum(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); //print Vertex puts("Frustum"); PrintVertex(DrawVertex(v1)); PrintVertex(DrawVertex(v2)); getchar(); return 0; }
void CScroll::Draw() { Math::Point pos, dim, ppos, ddim; float hButton; int icon, n, i; hButton = m_buttonUp?m_dim.x/0.75f:0.0f; // Draws the bottom. pos.x = m_pos.x; pos.y = m_pos.y+hButton; dim.x = m_dim.x; dim.y = m_dim.y-hButton*2.0f; if ( m_state & STATE_ENABLE ) icon = 0; else icon = 1; DrawVertex(pos, dim, icon); // Draws the cabin. if ( m_visibleRatio < 1.0f && (m_state & STATE_ENABLE) ) { pos.x += 0.003f; // ch'tite(?) margin pos.y += 0.003f; dim.x -= 0.006f; dim.y -= 0.006f; pos.y += dim.y*(1.0f-m_visibleRatio)*(1.0f-m_visibleValue); dim.y *= m_visibleRatio; DrawVertex(pos, dim, 2); n = static_cast<int>(dim.y*0.8f/0.012f); if ( n < 1 ) n = 1; if ( n > 5 ) n = 5; ppos.x = pos.x+0.003f; ppos.y = pos.y+(dim.y-(n-1)*0.012f-0.008f)/2.0f; ddim.x = dim.x-0.006f; ddim.y = 0.008f; for ( i=0 ; i<n ; i++ ) { DrawVertex(ppos, ddim, 3); // horizontal bar ppos.y += 0.012f; } } if (m_buttonUp != nullptr) { m_buttonUp->Draw(); } if (m_buttonDown != nullptr) { m_buttonDown->Draw(); } }
void C4FoWDrawWireframeStrategy::DrawDarkVertex(float x, float y) { vertices.emplace_back(); Vertex& vtx = vertices.back(); vtx.x = x; vtx.y = y; switch(phase) { case P_None: return; case P_Fade: vtx.r = 0.0f; vtx.g = 0.5f; vtx.b = 0.0f; vtx.a = 1.0f; break; case P_Intermediate: vtx.r = 0.0f; vtx.g = 0.0f; vtx.b = 0.5f; vtx.a = 1.0f; break; default: assert(false); // only fade has dark vertices } DrawVertex(vtx); C4FoWDrawStrategy::DrawDarkVertex(x, y); }
/** * Zeichnet den Vektor. * Zeichnet einen Strahl von den angegeben Koordinaten zum Vektor. * Dabei geht die Farbe des Strahls von weiß in die des Vektors über. * @param from der Ursprung des Strahls */ void SGLVektor::DrawVektor(SGLVektor from) { // bool Texture2D=glIsEnabled(GL_TEXTURE_2D); // bool Light=glIsEnabled(GL_LIGHTING); /* Bringt nur was, wenn diese Flags IN der GL-Maschine gesetzt sind ein glEnable weiter ober in dieser oder einer anderen Liste steht zwar dort, aber es kann nicht garantiert werden, da�es schon "wirkt". Man sollte deshalb in der aufrufenden Funktion selbst, mit unbedingten glEnable/glDisable vorbeugen. Und denkt daran, nvidia optimiert "obselote" Flag-Setzungen weg => Reihenfolge beibehalten if(Texture2D)glDisable(GL_TEXTURE_2D); if(Light)glDisable(GL_LIGHTING); */ glBegin(GL_LINES); DrawVertex(); glColor3f(1,1,1); from.DrawVertex(); glEnd(); /* if(Texture2D)glEnable(GL_TEXTURE_2D); if(Light)glEnable(GL_LIGHTING); s.O. richtet mehr schaden an, als es bringt ("reaktiviert" xyz obwohl xyz gar nicht an war) */ }
void CShortcut::Draw() { float zoom; int icon, mode; icon = 0; zoom = 0.8f; mode = Gfx::ENG_RSTATE_TTEXTURE_WHITE; if ( m_state & STATE_HILIGHT ) { icon = 4; zoom = 0.9f; mode = Gfx::ENG_RSTATE_NORMAL; } if ( m_state & STATE_CHECK ) { icon = 1; zoom = 0.8f; mode = Gfx::ENG_RSTATE_NORMAL; } if ( m_state & STATE_PRESS ) { icon = 1; zoom = 1.0f; mode = Gfx::ENG_RSTATE_NORMAL; } if ( m_icon == 128+6 || m_icon == 128+7 || m_icon == 58 ) // pause or film? { icon = -1; // no bottom zoom = 1.0f; } m_engine->SetTexture("textures/interface/button3.png"); if ( icon != -1 ) { m_engine->SetState(mode); DrawVertex(icon, 0.95f); } icon = m_icon; if ( icon >= 128 ) { icon -= 128; m_engine->SetTexture("textures/interface/button3.png"); } else if ( icon >= 64 ) { icon -= 64; m_engine->SetTexture("textures/interface/button2.png"); } else { m_engine->SetTexture("textures/interface/button1.png"); } if (m_icon == 58) { m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); } else { m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK); } DrawVertex(icon, zoom); if ( m_state & STATE_FRAME ) { Math::Point p1, p2, c, uv1, uv2; float dp; m_engine->SetTexture("textures/interface/button2.png"); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); zoom = 0.9f+sinf(m_time*8.0f)*0.1f; p1.x = m_pos.x; p1.y = m_pos.y; p2.x = m_pos.x + m_dim.x; p2.y = m_pos.y + m_dim.y; c.x = (p1.x+p2.x)/2.0f; c.y = (p1.y+p2.y)/2.0f; // center p1.x = (p1.x-c.x)*zoom + c.x; p1.y = (p1.y-c.y)*zoom + c.y; p2.x = (p2.x-c.x)*zoom + c.x; p2.y = (p2.y-c.y)*zoom + c.y; p2.x -= p1.x; p2.y -= p1.y; uv1.x = 176.0f/256.0f; uv1.y = 224.0f/256.0f; uv2.x = 192.0f/256.0f; uv2.y = 240.0f/256.0f; dp = 0.5f/256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; uv2.y -= dp; DrawIcon(p1, p2, uv1, uv2); } if ( (m_state & STATE_RUN) && Math::Mod(m_time, 0.7f) >= 0.3f ) { Math::Point uv1, uv2; float dp; m_engine->SetTexture("textures/interface/button3.png"); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); uv1.x = 160.0f/256.0f; uv1.y = 0.0f/256.0f; uv2.x = 192.0f/256.0f; uv2.y = 32.0f/256.0f; dp = 0.5f/256.0f; uv1.x += dp; uv1.y += dp; uv2.x -= dp; uv2.y -= dp; DrawIcon(m_pos, m_dim, uv1, uv2); } }
void CSlider::Draw() { Math::Point pos, dim, ppos, ddim, spos; int icon; float h; if ( (m_state & STATE_VISIBLE) == 0 ) return; if (m_buttonLeft != nullptr) { m_buttonLeft->Draw(); } if ( m_bHoriz ) { pos.x = m_pos.x+m_marginButton; pos.y = m_pos.y; dim.x = m_dim.x-m_marginButton*2.0f; dim.y = m_dim.y; } else { pos.x = m_pos.x; pos.y = m_pos.y+m_marginButton; dim.x = m_dim.x; dim.y = m_dim.y-m_marginButton*2.0f; } // Draws the bottom. if ( m_bHoriz ) { ppos.x = pos.x + CURSOR_WIDTH/2.0f; ppos.y = pos.y + (dim.y-HOLE_WIDTH)/2.0f; ddim.x = dim.x - CURSOR_WIDTH; ddim.y = HOLE_WIDTH; } else { ppos.x = pos.x + (dim.x-HOLE_WIDTH*0.75f)/2.0f; ppos.y = pos.y + CURSOR_WIDTH/2.0f; ddim.x = HOLE_WIDTH*0.75f; ddim.y = dim.y - CURSOR_WIDTH; } if ( m_state & STATE_SHADOW ) { spos = ppos; spos.x -= 0.005f*0.75f; spos.y += 0.005f; DrawShadow(spos, ddim); } if ( m_state & STATE_ENABLE ) icon = 0; else icon = 1; DrawVertex(ppos, ddim, icon); // Draws the cabin. if ( m_state & STATE_ENABLE ) { if ( m_bHoriz ) { ppos.x = pos.x + (dim.x-CURSOR_WIDTH)*m_visibleValue; ppos.y = pos.y; ddim.x = CURSOR_WIDTH; ddim.y = dim.y; } else { ppos.x = pos.x; ppos.y = pos.y + (dim.y-CURSOR_WIDTH)*m_visibleValue; ddim.x = dim.x; ddim.y = CURSOR_WIDTH; } DrawShadow(ppos, ddim, 0.7f); DrawVertex(ppos, ddim, 2); } if (m_buttonRight != nullptr) { m_buttonRight->Draw(); } if ( m_bHoriz ) { if ( m_state & STATE_ENABLE ) { std::string text = GetLabel(); h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize); pos.x = m_pos.x+m_dim.x+(10.0f/640.0f); pos.y = m_pos.y+(m_dim.y-h)/2.0f; m_engine->GetText()->DrawText(text, m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_LEFT, 0); } } else { if ( m_state & STATE_VALUE && m_state & STATE_ENABLE ) { pos.x = m_pos.x+m_dim.x+4.0f/640.0f; h = m_dim.y-m_marginButton*2.0f; pos.y = m_pos.y+m_marginButton-4.0f/480.0f; pos.y += (h-CURSOR_WIDTH)*m_visibleValue; dim.x = 50.0f/640.0f; dim.y = 16.0f/480.0f; std::string text = GetLabel(); m_engine->GetText()->DrawText(text, m_fontType, m_fontSize, pos, dim.x, Gfx::TEXT_ALIGN_RIGHT, 0); } } }
/** * Ruft glVertex mit den Eigenschaften dieses Vektors auf. * Wenn Normale definiert ist, wird sie gesetzt. * Danach DrawVertex() aufgerufen. * @param Normale die Normale die für diesen Vektor angenommen werden soll. */ void SGLVektor::DrawVertex(SGLVektor* Normale) { if(Normale)Normale->SetNormale(); else{SGLprintWarning("Zeichne Vertex ohne Normale");} DrawVertex(); }
void C4FoWDrawLightTextureStrategy::DrawLightVertex(float x, float y) { DrawVertex(x,y, true); C4FoWDrawStrategy::DrawLightVertex(x, y); }
void C4FoWDrawLightTextureStrategy::DrawDarkVertex(float x, float y) { DrawVertex(x,y, false); C4FoWDrawStrategy::DrawDarkVertex(x, y); }
void World::DrawBox(Box& box) { Vector3 vertices[8]; box.ComputeVertices(vertices); glBegin(GL_LINE_LOOP); DrawVertex(vertices[0]); DrawVertex(vertices[1]); DrawVertex(vertices[2]); DrawVertex(vertices[3]); glEnd(); glBegin(GL_LINE_LOOP); DrawVertex(vertices[0]); DrawVertex(vertices[4]); DrawVertex(vertices[5]); DrawVertex(vertices[1]); glEnd(); glBegin(GL_LINE_LOOP); DrawVertex(vertices[7]); DrawVertex(vertices[6]); DrawVertex(vertices[5]); DrawVertex(vertices[4]); glEnd(); glBegin(GL_LINE_LOOP); DrawVertex(vertices[3]); DrawVertex(vertices[2]); DrawVertex(vertices[6]); DrawVertex(vertices[7]); glEnd(); glBegin(GL_LINE_LOOP); DrawVertex(vertices[1]); DrawVertex(vertices[5]); DrawVertex(vertices[6]); DrawVertex(vertices[2]); glEnd(); glBegin(GL_LINE_LOOP); DrawVertex(vertices[0]); DrawVertex(vertices[3]); DrawVertex(vertices[7]); DrawVertex(vertices[4]); glEnd(); }