void TestScreen::Draw() { glColor4f(1.f,1.f,1.f,1.f); glPushMatrix(); glTranslatef(10.f,(float)GameDisplay::Height() - 10.f,0.f); font->Render(testData.c_str()); glTranslatef(0.f,-15.f,0.f); font->Render(testInfo.c_str()); glBindTexture(GL_TEXTURE_2D, 0); glPopMatrix(); glBegin(GL_LINES); glVertex2f(line1Start.X(),line1Start.Y()); glVertex2f(line1End.X(), line1End.Y()); glVertex2f(line2Start.X(),line2Start.Y()); glVertex2f(line2End.X(), line2End.Y()); glEnd(); glPushMatrix(); glTranslatef(circleCenter.X() + sin(circleMod) * 100.f, circleCenter.Y() + cos(circleMod) * 100.f, 0.f); glBegin(GL_LINES); glVertex2f(-5.f, 0.f); glVertex2f(+5.f, 0.f); glEnd(); glPopMatrix(); glPushMatrix(); glTranslatef(320.f,40.f,0.f); particleEmitter->Draw(); glPopMatrix(); glPushMatrix(); glBegin(GL_TRIANGLES); glColor4f(1.f,1.f,1.f,1.f); glVertex2f(0.f,100.f); glColor4f(0.f,0.f,0.f,1.f); glVertex2f(0.f,0.f); glColor4f(0.f,0.f,1.f,1.f); glVertex2f(100.f,50.f); Colour test = Colour(.7f, 1.f, .7f, 1.f); glColor4fv(test.RGBA()); glVertex2f(0.f,100.f); glColor4fv(ColourUtils::Invert(test).RGBA()); glVertex2f(100.f,100.f); glColor4fv(ColourUtils::Negative(test).RGBA()); glVertex2f(50.f,150.f); glEnd(); glPopMatrix(); GameComponent* gameComponent = gameObject->GetComponent(GCIdType("VisualComponent")); VisualComponent* visualComponent = static_cast<VisualComponent*>(gameComponent); if (visualComponent) { visualComponent->Draw(); } }
void BrowserControl::handleXEvent(const XEvent& event) { VisualComponent *component = 0; XFindContext(event.xany.display, event.xany.window, m_context, (XPointer*)&component); // Send event to the appropriate component that will be handle if (component) component->handleEvent(event); }
void HumanView::drawActor(Actor *a) { try { PhysicalComponent *phys = (PhysicalComponent*)a->getComponent(PHYSICAL); VisualComponent *vis = (VisualComponent*)a->getComponent(VISUAL); vector< Vec2D<double> > vertices; bm::Color col = vis->colorData; // if the actor is invisible, don't render it if (!vis->isVisible()) return; // Apply position offset to each vertex for (auto i = vis->vertexData.begin(); i != vis->vertexData.end(); i++) { vertices.push_back((*i) + phys->getPos()); } // if there is a texture to render, set it up if (vis->texture != nullptr) { glBindTexture(GL_TEXTURE_2D, vis->texture->id); glEnable(GL_TEXTURE_2D); } // Draw the actor glBegin(GL_TRIANGLE_STRIP); for (int i = 0; i < vertices.size(); i++) { glTexCoord2d(vis->textureData[i].x, vis->textureData[i].y); glColor4ub(col.r, col.g, col.b, col.a); // unsigned-byte (0-255) glVertex2d(vertices[i].x, vertices[i].y); } // Cleanup glEnd(); glDisable(GL_TEXTURE_2D); vertices.clear(); } catch (Status s) { if (s != NO_SUCH_COMPONENT_ERR) throw s; } }
void Decorator::Resize () { _component->Resize(); }
void Decorator::Draw () { _component->Draw(); }