void OGL14RendererDevice::BackbufferFill(PIXEL color) { glPushAttrib(GL_TEXTURE_BIT | GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT); const GLfloat vertices[] = { 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, }; glVertexPointer(2, GL_FLOAT, 0, vertices); glEnableClientState(GL_VERTEX_ARRAY); glDisable(GL_TEXTURE_2D); glEnable(GL_BLEND); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4ub(PIXEL_GET_R(color), PIXEL_GET_G(color), PIXEL_GET_B(color), PIXEL_GET_A(color)); glPushMatrix(); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glPopMatrix(); //glEnable(GL_TEXTURE_2D); glPopAttrib(); }
INLINE void OGL14RendererDevice::DrawRect(f32 x, f32 y, f32 w, f32 h, PIXEL color, BOOL fill) const { GLfloat vertices[8]; f32 ratio = ((f32)pScreen->GetHeight() / (f32)pScreen->GetWidth()); f32 fAspectHalfWidth = w / 2.0f; f32 fAspectHalfHeight = (h * ratio) / 2.0f; // A vertices[0] = - fAspectHalfWidth; vertices[1] = - fAspectHalfHeight; // B vertices[2] = + fAspectHalfWidth; vertices[3] = - fAspectHalfHeight; if (!fill) { // C vertices[4] = + fAspectHalfWidth; vertices[5] = + fAspectHalfHeight; // D vertices[6] = - fAspectHalfWidth; vertices[7] = + fAspectHalfHeight; } else { // C vertices[4] = - fAspectHalfWidth; vertices[5] = + fAspectHalfHeight; // D vertices[6] = + fAspectHalfWidth; vertices[7] = + fAspectHalfHeight; } glColor4ub(PIXEL_GET_R(color), PIXEL_GET_G(color), PIXEL_GET_B(color), PIXEL_GET_A(color)); glVertexPointer(2, GL_FLOAT, 0, vertices); glEnableClientState(GL_VERTEX_ARRAY); f32 nx = fAspectHalfWidth + x; f32 ny = fAspectHalfHeight + y * ratio; glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); glPushMatrix(); glLoadIdentity(); glTranslatef(nx, ny, 0.0f); if (fill) glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); else glDrawArrays(GL_LINE_LOOP, 0, 4); glPopMatrix(); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); }
INLINE void Texture::PutPixel(u32 x, u32 y, PIXEL px) { u8 mR = PIXEL_GET_R(px); u8 mG = PIXEL_GET_G(px); u8 mB = PIXEL_GET_B(px); u8 mA = PIXEL_GET_A(px); image.setPixel(x, y, qRgba(mR, mG, mB, mA)); }
void OGLES1RendererDevice::BackbufferFill(PIXEL color) { const GLfloat vertices[] = { 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, }; glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4ub(PIXEL_GET_R(color), PIXEL_GET_G(color), PIXEL_GET_B(color), PIXEL_GET_A(color)); glVertexPointer(2, GL_FLOAT, 0, vertices); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_COLOR_ARRAY); }
INLINE void OGL14RendererDevice::SetBlendingOperation(eBlendMode mode, PIXEL color) const { switch (mode) { /* REPLACE */ default: case BlendNone: { // http://home.comcast.net/~tom_forsyth/blog.wiki.html#[[Premultiplied%20alpha]] glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } break; /* BLEND */ case BlendDefault: { glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); } break; case BlendMerge: { glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA); } break; case BlendScreen: { glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); } break; /* DECAL */ case BlendDecalOverlay: { glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); glBlendFunc(GL_DST_COLOR, GL_ONE); u8 mR = PIXEL_GET_R(color); u8 mG = PIXEL_GET_G(color); u8 mB = PIXEL_GET_B(color); u8 mA = PIXEL_GET_A(color); glColor4ub(mR, mG, mB, mA); } break; /* MODULATE */ case BlendAdditive: { glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBlendFunc(GL_SRC_ALPHA, GL_ONE); u8 mR = PIXEL_GET_R(color); u8 mG = PIXEL_GET_G(color); u8 mB = PIXEL_GET_B(color); u8 mA = PIXEL_GET_A(color); glColor4ub(mR, mG, mB, mA); } break; case BlendOverlay: { glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBlendFunc(GL_DST_COLOR, GL_ONE); u8 mR = PIXEL_GET_R(color); u8 mG = PIXEL_GET_G(color); u8 mB = PIXEL_GET_B(color); u8 mA = PIXEL_GET_A(color); glColor4ub(mR, mG, mB, mA); } break; case BlendLighten: { glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); u8 mR = PIXEL_GET_R(color); u8 mG = PIXEL_GET_G(color); u8 mB = PIXEL_GET_B(color); u8 mA = PIXEL_GET_A(color); glColor4ub(mR, mG, mB, mA); } break; case BlendColorDodge: { glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBlendFunc(GL_ONE, GL_ONE); u8 mR = PIXEL_GET_R(color); u8 mG = PIXEL_GET_G(color); u8 mB = PIXEL_GET_B(color); u8 mA = PIXEL_GET_A(color); glColor4ub(mR, mG, mB, mA); } break; case BlendModulateAlpha: { glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); u8 mA = PIXEL_GET_A(color); glColor4ub(255, 255, 255, mA); } break; case BlendModulate: { glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); u8 mR = PIXEL_GET_R(color); u8 mG = PIXEL_GET_G(color); u8 mB = PIXEL_GET_B(color); u8 mA = PIXEL_GET_A(color); glColor4ub(mR, mG, mB, mA); } break; } }