void RenderTargetTestScreen::Update(float32 timeElapsed) { ftime += timeElapsed; if (ftime > 5.0f) { UIHoleTransition *ft = new UIHoleTransition(); Polygon2 testPoly; testPoly.AddPoint(Vector2(50, 85)); testPoly.AddPoint(Vector2(size.x - 50, 50)); testPoly.AddPoint(Vector2(size.x - 25, size.y - 85)); testPoly.AddPoint(Vector2(80, size.y - 50)); Matrix3 t, invT, r; t.BuildTranslation(size/-2); invT.BuildTranslation(size/2); r.BuildRotation(DegToRad(10)); Matrix3 res = t * r * invT; testPoly.Transform(res); testPoly.Scale(size/2, 2.0f); ft->SetDuration(10.f); ft->SetPolygon(testPoly); UIScreenManager::Instance()->SetScreen(SCREEN_STATIC_TEXT, ft); SafeRelease(ft); ftime = 0; } }
void Box2DDebugDraw::DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) { RenderManager::Instance()->SetColor(color.r, color.g, color.b, 1.0f); Polygon2 polygon; for (int32 i = 0; i < vertexCount; ++i) { polygon.AddPoint(Vector2(vertices[i].x * ptdRatio + cameraPos.x, -vertices[i].y * ptdRatio + cameraPos.y)); } RenderHelper::Instance()->DrawPolygon(polygon, true); RenderManager::Instance()->ResetColor(); /*glEnable(GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(0.5f * color.r, 0.5f * color.g, 0.5f * color.b, 0.5f); glBegin(GL_TRIANGLE_FAN); for (int32 i = 0; i < vertexCount; ++i) { glVertex2f(vertices[i].x, vertices[i].y); } glEnd(); glDisable(GL_BLEND); glColor4f(color.r, color.g, color.b, 1.0f); glBegin(GL_LINE_LOOP); for (int32 i = 0; i < vertexCount; ++i) { glVertex2f(vertices[i].x, vertices[i].y); } glEnd();*/ }
void Box2DDebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color) { RenderManager::Instance()->SetColor(color.r, color.g, color.b, 1.0f); Polygon2 polygon; const float32 k_segments = 16.0f; const float32 k_increment = 2.0f * b2_pi / k_segments; float32 theta = 0.0f; for (int32 i = 0; i < k_segments; ++i) { b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); //glVertex2f(v.x, v.y); polygon.AddPoint(Vector2(v.x * ptdRatio + cameraPos.x, -v.y * ptdRatio + cameraPos.y)); theta += k_increment; } RenderHelper::Instance()->DrawPolygon(polygon, true); RenderManager::Instance()->ResetColor(); /*const float32 k_segments = 16.0f; const float32 k_increment = 2.0f * b2_pi / k_segments; float32 theta = 0.0f; glEnable(GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(0.5f * color.r, 0.5f * color.g, 0.5f * color.b, 0.5f); glBegin(GL_TRIANGLE_FAN); for (int32 i = 0; i < k_segments; ++i) { b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); glVertex2f(v.x, v.y); theta += k_increment; } glEnd(); glDisable(GL_BLEND); theta = 0.0f; glColor4f(color.r, color.g, color.b, 1.0f); glBegin(GL_LINE_LOOP); for (int32 i = 0; i < k_segments; ++i) { b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); glVertex2f(v.x, v.y); theta += k_increment; } glEnd(); b2Vec2 p = center + radius * axis; glBegin(GL_LINES); glVertex2f(center.x, center.y); glVertex2f(p.x, p.y); glEnd();*/ }
void ResultScreen::DrawStatImage(Rect rect) { RenderHelper *helper = RenderHelper::Instance(); RenderManager *manager = RenderManager::Instance(); for(uint32 i = 0; i < testData.GetItemCount(); ++i) { FpsStatItem item = testData.GetItem(i); Rect curRect = testData.TranslateRect(item.rect, rect); for(uint32 j = 0; j < SECTORS_COUNT; j++) { manager->SetColor(SettingsManager::Instance()->GetColorByFps(item.avFps[j])); Polygon2 curSector; curSector.AddPoint(curRect.GetCenter()); curSector.AddPoint(GetVecInRect(curRect, DegToRad((SECTORS_COUNT - j) * 45.f - 22.5f))); curSector.AddPoint(GetVecInRect(curRect, DegToRad((SECTORS_COUNT - j) * 45.f))); curSector.AddPoint(GetVecInRect(curRect, DegToRad((SECTORS_COUNT - j) * 45.f + 22.5f))); helper->FillPolygon(curSector); manager->SetColor(Color::Black()); helper->DrawPolygon(curSector, true); } } }
void Box2DDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color) { RenderManager::Instance()->SetColor(color.r, color.g, color.b, 1.0f); Polygon2 polygon; const float32 k_segments = 16.0f; const float32 k_increment = 2.0f * b2_pi / k_segments; float32 theta = 0.0f; for (int32 i = 0; i < k_segments; ++i) { b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); //glVertex2f(v.x, v.y); polygon.AddPoint(Vector2(v.x * ptdRatio + cameraPos.x, -v.y * ptdRatio + cameraPos.y)); theta += k_increment; } RenderHelper::Instance()->DrawPolygon(polygon, true); RenderManager::Instance()->ResetColor(); }
void RenderHelper::DrawCircle(const Vector2 & center, float32 radius) { Polygon2 pts; float32 angle = SEGMENT_LENGTH / radius; int ptsCount = (int)(2 * PI / angle) + 1; for (int k = 0; k < ptsCount; ++k) { float32 angle = ((float)k / (ptsCount - 1)) * 2 * PI; float32 sinA = sinf(angle); float32 cosA = cosf(angle); Vector2 pos = center - Vector2(sinA * radius, cosA * radius); pts.AddPoint(pos); } DrawPolygon(pts, false); }
void Box2DDebugDraw::DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) { /*glColor3f(color.r, color.g, color.b); glBegin(GL_LINE_LOOP); for (int32 i = 0; i < vertexCount; ++i) { glVertex2f(vertices[i].x, vertices[i].y); } glEnd();*/ RenderManager::Instance()->SetColor(color.r, color.g, color.b, 1.0f); Polygon2 polygon; for (int32 i = 0; i < vertexCount; ++i) { polygon.AddPoint(Vector2(vertices[i].x * ptdRatio + cameraPos.x, -vertices[i].y * ptdRatio + cameraPos.y)); } RenderHelper::Instance()->DrawPolygon(polygon, true); RenderManager::Instance()->ResetColor(); }