IDirect3DVertexBuffer9* BufferFactory::coloredCubeBuffer() { //=================================================================== // Colored Cube vertex buffer // Obtain a pointer to a new vertex buffer. HR(gd3dDevice->CreateVertexBuffer(8 * sizeof(VertexCol), D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED, &mColoredCubeVB, 0)); // Now lock it to obtain a pointer to its internal data, and write the // cube's vertex data. VertexCol* v = 0; HR(mColoredCubeVB->Lock(0, 0, (void**)&v, 0)); v[0] = VertexCol(-1.0f, -1.0f, -1.0f); v[1] = VertexCol(-1.0f, 1.0f, -1.0f); v[2] = VertexCol( 1.0f, 1.0f, -1.0f); v[3] = VertexCol( 1.0f, -1.0f, -1.0f); v[4] = VertexCol(-1.0f, -1.0f, 1.0f); v[5] = VertexCol(-1.0f, 1.0f, 1.0f); v[6] = VertexCol( 1.0f, 1.0f, 1.0f); v[7] = VertexCol( 1.0f, -1.0f, 1.0f); HR(mColoredCubeVB->Unlock()); return mColoredCubeVB; }
void CText::DrawHighlight(FontHighlight hl, Math::Point pos, Math::Point size) { // Gradient colors Color grad[4]; // TODO: switch to alpha factors switch (hl) { case FONT_HIGHLIGHT_LINK: grad[0] = grad[1] = grad[2] = grad[3] = Color(0.0f, 0.0f, 1.0f, 0.5f); break; case FONT_HIGHLIGHT_TOKEN: grad[0] = grad[1] = Color(248.0f / 256.0f, 248.0f / 256.0f, 248.0f / 256.0f, 0.5f); grad[2] = grad[3] = Color(248.0f / 256.0f, 220.0f / 256.0f, 188.0f / 256.0f, 0.5f); break; case FONT_HIGHLIGHT_TYPE: grad[0] = grad[1] = Color(248.0f / 256.0f, 248.0f / 256.0f, 248.0f / 256.0f, 0.5f); grad[2] = grad[3] = Color(169.0f / 256.0f, 234.0f / 256.0f, 169.0f / 256.0f, 0.5f); break; case FONT_HIGHLIGHT_CONST: grad[0] = grad[1] = Color(248.0f / 256.0f, 248.0f / 256.0f, 248.0f / 256.0f, 0.5f); grad[2] = grad[3] = Color(248.0f / 256.0f, 176.0f / 256.0f, 169.0f / 256.0f, 0.5f); break; case FONT_HIGHLIGHT_REM: grad[0] = grad[1] = Color(248.0f / 256.0f, 248.0f / 256.0f, 248.0f / 256.0f, 0.5f); grad[2] = grad[3] = Color(248.0f / 256.0f, 169.0f / 256.0f, 248.0f / 256.0f, 0.5f); break; case FONT_HIGHLIGHT_KEY: grad[0] = grad[1] = grad[2] = grad[3] = Color(192.0f / 256.0f, 192.0f / 256.0f, 192.0f / 256.0f, 0.5f); break; default: return; } Math::IntPoint vsize = m_engine->GetWindowSize(); float h = 0.0f; if (vsize.y <= 768.0f) // 1024x768 or less? h = 1.01f / vsize.y; // 1 pixel else // more than 1024x768? h = 2.0f / vsize.y; // 2 pixels Math::Point p1, p2; p1.x = pos.x; p2.x = pos.x + size.x; if (hl == FONT_HIGHLIGHT_LINK) { p1.y = pos.y; p2.y = pos.y + h; // just emphasized } else { p1.y = pos.y; p2.y = pos.y + size.y; } m_device->SetTextureEnabled(0, false); VertexCol quad[] = { VertexCol(Math::Vector(p1.x, p1.y, 0.0f), grad[3]), VertexCol(Math::Vector(p1.x, p2.y, 0.0f), grad[0]), VertexCol(Math::Vector(p2.x, p1.y, 0.0f), grad[2]), VertexCol(Math::Vector(p2.x, p2.y, 0.0f), grad[1]) }; m_device->DrawPrimitive(PRIMITIVE_TRIANGLE_STRIP, quad, 4); m_engine->AddStatisticTriangle(2); m_device->SetTextureEnabled(0, true); }