void iV_DrawImage2(const QString &filename, float x, float y, float width, float height) { ImageDef *image = iV_GetImage(filename, x, y); const GLfloat invTextureSize = image->invTextureSize; const int tu = image->Tu; const int tv = image->Tv; const int w = width > 0 ? width : image->Width; const int h = height > 0 ? height : image->Height; x += image->XOffset; y += image->YOffset; pie_SetTexturePage(image->textureId); glColor4ubv(WZCOL_WHITE.vector); pie_SetRendMode(REND_ALPHA); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(tu * image->invTextureSize, tv * invTextureSize); glVertex2f(x, y); glTexCoord2f((tu + image->Width) * invTextureSize, tv * invTextureSize); glVertex2f(x + w, y); glTexCoord2f(tu * invTextureSize, (tv + image->Height) * invTextureSize); glVertex2f(x, y + h); glTexCoord2f((tu + image->Width) * invTextureSize, (tv + image->Height) * invTextureSize); glVertex2f(x + w, y + h); glEnd(); }
void pie_DrawSkybox(float scale) { GL_DEBUG("Drawing skybox"); glPushAttrib(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT | GL_FOG_BIT); // no use in updating the depth buffer glDepthMask(GL_FALSE); // fog should not affect the sky glDisable(GL_FOG); // So we have realistic colors glColor4ub(0xFF,0xFF,0xFF,0xFF); // enable alpha pie_SetRendMode(REND_ALPHA); // for the nice blend of the sky with the fog glDisable(GL_ALPHA_TEST); // Apply scale matrix glScalef(scale, scale/2.0f, scale); skyboxGfx->draw(); glPopAttrib(); }
static void pie_Draw3DButton(iIMDShape *shape) { const PIELIGHT colour = WZCOL_WHITE; const PIELIGHT teamcolour = pal_GetTeamColour(NetPlay.players[selectedPlayer].colour); pie_SetFogStatus(false); pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON); pie_ActivateShader(SHADER_BUTTON, shape, teamcolour, colour); pie_SetRendMode(REND_OPAQUE); glColor4ubv(colour.vector); // Only need to set once for entire model pie_SetTexturePage(shape->texpage); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glBindBuffer(GL_ARRAY_BUFFER, shape->buffers[VBO_VERTEX]); glVertexPointer(3, GL_FLOAT, 0, NULL); glBindBuffer(GL_ARRAY_BUFFER, shape->buffers[VBO_NORMAL]); glNormalPointer(GL_FLOAT, 0, NULL); glBindBuffer(GL_ARRAY_BUFFER, shape->buffers[VBO_TEXCOORD]); glTexCoordPointer(2, GL_FLOAT, 0, NULL); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, shape->buffers[VBO_INDEX]); glDrawElements(GL_TRIANGLES, shape->npolys * 3, GL_UNSIGNED_SHORT, NULL); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); polyCount += shape->npolys; pie_DeactivateShader(); pie_SetDepthBufferStatus(DEPTH_CMP_ALWAYS_WRT_ON); }
static void pie_DrawShadows(void) { const float width = pie_GetVideoBufferWidth(); const float height = pie_GetVideoBufferHeight(); pie_SetTexturePage(TEXPAGE_NONE); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glDepthFunc(GL_LESS); glDepthMask(GL_FALSE); glEnable(GL_STENCIL_TEST); ShadowStencilFunc(); glEnable(GL_CULL_FACE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilMask(~0); glStencilFunc(GL_LESS, 0, ~0); glDisable(GL_DEPTH_TEST); PIELIGHT grey; grey.byte = { 0, 0, 0, 128 }; pie_BoxFill(0, 0, width, height, grey, REND_ALPHA); pie_SetRendMode(REND_OPAQUE); glDisable(GL_STENCIL_TEST); glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); scshapes.resize(0); }
void pie_RenderRadarRotated(IMAGEDEF *Image,iBitmap *Bmp,UDWORD Modulus,int x,int y,int angle) { PIEIMAGE pieImage; PIERECT dest; //special case of pie_ImageDef switch (pie_GetRenderEngine()) { case ENGINE_4101: case ENGINE_SR: pie_ImageDef(Image,Bmp,Modulus,x,y,FALSE); break; case ENGINE_GLIDE: pie_ImageDef(Image,Bmp,Modulus,x,y,TRUE); break; case ENGINE_D3D: pie_SetBilinear(TRUE); pie_SetRendMode(REND_GOURAUD_TEX); pie_SetColour(COLOURINTENSITY); pie_SetColourKeyedBlack(TRUE); //special case function because texture is held outside of texture list pieImage.texPage = RADAR_TEXPAGE_D3D; pieImage.tu = 0; pieImage.tv = 0; pieImage.tw = dtm_GetRadarTexImageSize(); pieImage.th = dtm_GetRadarTexImageSize(); dest.x = x; dest.y = y; dest.w = 128; dest.h = 128; pie_DrawImage(&pieImage, &dest, &rendStyle); default: break; } }
// Repeat a texture void iV_DrawImageRepeatX(IMAGEFILE *ImageFile, UWORD ID, int x, int y, int Width) { int hRep, hRemainder; assertValidImage(ImageFile, ID); const ImageDef *Image = &ImageFile->imageDefs[ID]; pie_SetRendMode(REND_OPAQUE); pie_SetAlphaTest(true); PIERECT dest; Vector2i pieImage = makePieImage(ImageFile, ID, &dest, x, y); hRemainder = Width % Image->Width; for (hRep = 0; hRep < Width / Image->Width; hRep++) { pie_DrawImage(ImageFile, ID, pieImage, &dest); dest.x += Image->Width; } // draw remainder if (hRemainder > 0) { pieImage.x = hRemainder; dest.w = hRemainder; pie_DrawImage(ImageFile, ID, pieImage, &dest); } }
void pie_Line(int x0, int y0, int x1, int y1, uint32 colour) { PIELIGHT light; iColour* psPalette; pie_SetRendMode(REND_FLAT); pie_SetColour(colour); pie_SetTexturePage(-1); switch (pie_GetRenderEngine()) { case ENGINE_4101: case ENGINE_SR: line(x0, y0, x1, y1, colour); break; case ENGINE_GLIDE: gl_Line(x0, y0, x1, y1, colour); break; case ENGINE_D3D: /* Get our colour values from the ivis palette */ psPalette = pie_GetGamePal(); light.byte.r = psPalette[colour].r; light.byte.g = psPalette[colour].g; light.byte.b = psPalette[colour].b; light.byte.a = MAX_UB_LIGHT; pie_DrawLine(x0, y0, x1, y1, light.argb, TRUE); default: break; } }
/// Draws a fog colored box which is wider at the top void pie_DrawFogBox(float left, float right, float front, float back, float height, float wider) { PIELIGHT fog_colour = pie_GetFogColour(); pie_SetTexturePage(TEXPAGE_NONE); glColor4ub(fog_colour.byte.r,fog_colour.byte.g,fog_colour.byte.b,0xFF); pie_SetRendMode(REND_OPAQUE); glPushAttrib(GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_FOG_BIT); // no use in updating the depth buffer glDepthMask(GL_FALSE); glDisable(GL_FOG); glBegin(GL_QUAD_STRIP); // Front glVertex3f(-left, 0, front); // bottom left glVertex3f(-left-wider, height, front+wider); // top left glVertex3f( right, 0, front); // bottom right glVertex3f( right+wider, height, front+wider); // top right // Right glVertex3f( right, 0,-back); // bottom r glVertex3f( right+wider, height,-back-wider); // top r // Back glVertex3f(-left, 0, -back); // bottom right glVertex3f(-left-wider, height, -back-wider); // top right // Left glVertex3f(-left, 0, front); // bottom r glVertex3f(-left-wider, height, front+wider); // top r glEnd(); glPopAttrib(); }
void pie_DrawViewingWindow() { SDWORD i; PIELIGHT colour = pieColour; pie_SetTexturePage(TEXPAGE_NONE); pie_SetRendMode(REND_ALPHA); glColor4ub(colour.byte.r, colour.byte.g, colour.byte.b, colour.byte.a >> 1); glBegin(GL_TRIANGLE_FAN); for (i = 0; i < VW_VERTICES; i++) { glVertex2f(pieVrts[i].x, pieVrts[i].y); } glEnd(); glColor4ub(colour.byte.r, colour.byte.g, colour.byte.b, colour.byte.a); glBegin(GL_LINE_STRIP); for (i = 0; i < VW_VERTICES; i++) { glVertex2f(pieVrts[i].x, pieVrts[i].y); } glVertex2f(pieVrts[0].x, pieVrts[0].y); glEnd(); }
void iV_DrawImageRepeatY(IMAGEFILE *ImageFile, UWORD ID, int x, int y, int Height) { int vRep, vRemainder; assertValidImage(ImageFile, ID); const ImageDef *Image = &ImageFile->imageDefs[ID]; pie_SetRendMode(REND_OPAQUE); pie_SetAlphaTest(true); PIERECT dest; Vector2i pieImage = makePieImage(ImageFile, ID, &dest, x, y); vRemainder = Height % Image->Height; for (vRep = 0; vRep < Height / Image->Height; vRep++) { pie_DrawImage(ImageFile, ID, pieImage, &dest); dest.y += Image->Height; } // draw remainder if (vRemainder > 0) { pieImage.y = vRemainder; dest.h = vRemainder; pie_DrawImage(ImageFile, ID, pieImage, &dest); } }
void iV_ShadowBox(int x0, int y0, int x1, int y1, int pad, PIELIGHT first, PIELIGHT second, PIELIGHT fill) { pie_SetRendMode(REND_OPAQUE); pie_SetTexturePage(TEXPAGE_NONE); pie_DrawRect(x0 + pad, y0 + pad, x1 - pad, y1 - pad, fill); iV_Box2(x0, y0, x1, y1, first, second); }
static void pie_DrawShadows(void) { const float width = pie_GetVideoBufferWidth(); const float height = pie_GetVideoBufferHeight(); pie_SetTexturePage(TEXPAGE_NONE); glPushMatrix(); pie_SetAlphaTest(false); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glDepthFunc(GL_LESS); glDepthMask(GL_FALSE); glEnable(GL_STENCIL_TEST); ShadowStencilFunc(); pie_SetRendMode(REND_ALPHA); glEnable(GL_CULL_FACE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilMask(~0); glStencilFunc(GL_LESS, 0, ~0); glColor4f(0, 0, 0, 0.5); pie_PerspectiveEnd(); glLoadIdentity(); glDisable(GL_DEPTH_TEST); glBegin(GL_TRIANGLE_STRIP); glVertex2f(0, 0); glVertex2f(width, 0); glVertex2f(0, height); glVertex2f(width, height); glEnd(); pie_PerspectiveBegin(); pie_SetRendMode(REND_OPAQUE); glDisable(GL_STENCIL_TEST); glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); glPopMatrix(); scshapes.clear(); }
static void drawDecals(const glm::mat4 &ModelViewProjection, const glm::vec4 ¶msXLight, const glm::vec4 ¶msYLight, const glm::mat4 &textureMatrix) { const auto &renderState = getCurrentRenderState(); const glm::vec4 fogColor( renderState.fogColour.vector[0] / 255.f, renderState.fogColour.vector[1] / 255.f, renderState.fogColour.vector[2] / 255.f, renderState.fogColour.vector[3] / 255.f ); const auto &program = pie_ActivateShader(SHADER_DECALS, ModelViewProjection, paramsXLight, paramsYLight, 0, 1, textureMatrix, renderState.fogEnabled, renderState.fogBegin, renderState.fogEnd, fogColor); // select the terrain texture page pie_SetTexturePage(terrainPage); // use the alpha to blend pie_SetRendMode(REND_ALPHA); // and the texture coordinates buffer decalVBO->bind(); glVertexAttribPointer(program.locVertex, 3, GL_FLOAT, GL_FALSE, sizeof(DecalVertex), BUFFER_OFFSET(0)); glEnableVertexAttribArray(program.locVertex); glVertexAttribPointer(program.locTexCoord, 2, GL_FLOAT, GL_FALSE, sizeof(DecalVertex), BUFFER_OFFSET(12)); glEnableVertexAttribArray(program.locTexCoord); glBindBuffer(GL_ARRAY_BUFFER, 0); int size = 0; int offset = 0; for (int x = 0; x < xSectors; x++) { for (int y = 0; y < ySectors + 1; y++) { if (y < ySectors && offset + size == sectors[x * ySectors + y].decalOffset && sectors[x * ySectors + y].draw) { // append size += sectors[x * ySectors + y].decalSize; continue; } // can't append, so draw what we have and start anew if (size > 0) { glDrawArrays(GL_TRIANGLES, offset, size); } size = 0; if (y < ySectors && sectors[x * ySectors + y].draw) { offset = sectors[x * ySectors + y].decalOffset; size = sectors[x * ySectors + y].decalSize; } } } glDepthMask(GL_TRUE); glDisableVertexAttribArray(program.locTexCoord); glDisableVertexAttribArray(program.locVertex); pie_DeactivateShader(); }
// Re-enable when Qt's font rendering is improved. void WzMainWindow::drawPixmap(int XPos, int YPos, QPixmap *pix) { QPainter painter(context()->device()); painter.drawPixmap(XPos, YPos, *pix); painter.end(); glEnable(GL_CULL_FACE); rendStatesRendModeHack(); // rendStates.rendMode = REND_ALPHA; pie_SetRendMode(REND_OPAQUE); // beat state machinery into submission }
void pie_DrawSkybox(float scale, const glm::mat4 &viewMatrix) { // no use in updating the depth buffer glDepthMask(GL_FALSE); // enable alpha pie_SetRendMode(REND_ALPHA); // Apply scale matrix skyboxGfx->draw(pie_PerspectiveGet() * viewMatrix * glm::scale(scale, scale / 2.f, scale)); }
static void drawDepthOnly(const glm::mat4 &ModelViewProjection, const glm::vec4 ¶msXLight, const glm::vec4 ¶msYLight) { const auto &program = pie_ActivateShader(SHADER_TERRAIN_DEPTH, ModelViewProjection, paramsXLight, paramsYLight, 1, glm::mat4(1.f), glm::mat4(1.f)); pie_SetTexturePage(TEXPAGE_NONE); pie_SetRendMode(REND_OPAQUE); // we only draw in the depth buffer of using fog of war, as the clear color is black then if (!pie_GetFogStatus()) { glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); } // draw slightly higher distance than it actually is so it will not // by accident obscure the actual terrain glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0.1f, 1.0f); // bind the vertex buffer geometryIndexVBO->bind(); geometryVBO->bind(); glVertexAttribPointer(program.locVertex, 3, GL_FLOAT, GL_FALSE, sizeof(RenderVertex), BUFFER_OFFSET(0)); glEnableVertexAttribArray(program.locVertex); for (int x = 0; x < xSectors; x++) { for (int y = 0; y < ySectors; y++) { if (sectors[x * ySectors + y].draw) { addDrawRangeElements(GL_TRIANGLES, sectors[x * ySectors + y].geometryOffset, sectors[x * ySectors + y].geometryOffset + sectors[x * ySectors + y].geometrySize, sectors[x * ySectors + y].geometryIndexSize, GL_UNSIGNED_INT, sectors[x * ySectors + y].geometryIndexOffset); } } } finishDrawRangeElements(); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); if (!pie_GetFogStatus()) { glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); } // disable the depth offset glDisable(GL_POLYGON_OFFSET_FILL); glDisableVertexAttribArray(program.locVertex); pie_DeactivateShader(); }
/** Display radar texture using the given height and width, depending on zoom level. */ void pie_RenderRadar(int x, int y, int width, int height) { pie_SetTexturePage(radarTexture); pie_SetRendMode(REND_ALPHA); glColor4ubv(WZCOL_WHITE.vector); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, 0); glVertex2f(x, y); glTexCoord2f(radarTexX, 0); glVertex2f(x + width, y); glTexCoord2f(0, radarTexY); glVertex2f(x, y + height); glTexCoord2f(radarTexX, radarTexY); glVertex2f(x + width, y + height); glEnd(); }
void pie_Box(int x0,int y0, int x1, int y1, uint32 colour) { PIELIGHT light; iColour* psPalette; pie_SetRendMode(REND_FLAT); pie_SetColour(colour); pie_SetTexturePage(-1); if (x0>psRendSurface->clip.right || x1<psRendSurface->clip.left || y0>psRendSurface->clip.bottom || y1<psRendSurface->clip.top) return; if (x0<psRendSurface->clip.left) x0 = psRendSurface->clip.left; if (x1>psRendSurface->clip.right) x1 = psRendSurface->clip.right; if (y0<psRendSurface->clip.top) y0 = psRendSurface->clip.top; if (y1>psRendSurface->clip.bottom) y1 = psRendSurface->clip.bottom; switch (pie_GetRenderEngine()) { case ENGINE_4101: case ENGINE_SR: box(x0,y0,x1,y1,colour); break; case ENGINE_GLIDE: gl_Line(x0, y0, x1, y0, colour); gl_Line(x1, y0, x1, y1, colour); gl_Line(x1, y1, x0, y1, colour); gl_Line(x0, y1, x0, y0, colour); break; case ENGINE_D3D: psPalette = pie_GetGamePal(); /* Get our colour values from the ivis palette */ light.byte.r = psPalette[colour].r; light.byte.g = psPalette[colour].g; light.byte.b = psPalette[colour].b; light.byte.a = MAX_UB_LIGHT; pie_DrawLine(x0, y0, x1, y0, light.argb, FALSE); pie_DrawLine(x1, y0, x1, y1, light.argb, FALSE); pie_DrawLine(x1, y1, x0, y1, light.argb, FALSE); pie_DrawLine(x0, y1, x0, y0, light.argb, FALSE); default: break; } }
void drawRadar(void) { float pixSizeH, pixSizeV; ASSERT(radarBuffer, "No radar buffer allocated"); if (!radarBuffer) { return; } CalcRadarPixelSize(&pixSizeH, &pixSizeV); if (frameSkip <= 0) { bool filter = true; if (!rotateRadar) { filter = RadarZoom % 16 != 0; } DrawRadarTiles(); DrawRadarObjects(); pie_DownLoadRadar(radarBuffer, radarTexWidth, radarTexHeight, filter); frameSkip = RADAR_FRAME_SKIP; } frameSkip--; pie_SetRendMode(REND_ALPHA); pie_MatBegin(); pie_TRANSLATE(radarCenterX, radarCenterY, 0); if (rotateRadar) { // rotate the map pie_MatRotZ(player.r.y); DrawNorth(); } // draw the box at the dimensions of the map iV_TransBoxFill(-radarWidth/2.0 - 1, -radarHeight/2.0 - 1, radarWidth/2.0, radarHeight/2.0); pie_RenderRadar(-radarWidth/2.0 - 1, -radarHeight/2.0 - 1, radarWidth, radarHeight); pie_MatBegin(); pie_TRANSLATE(-radarWidth/2 - 1, -radarHeight/2 - 1, 0); DrawRadarExtras(0, 0, pixSizeH, pixSizeV); pie_MatEnd(); drawRadarBlips(-radarWidth/2.0 - 1, -radarHeight/2.0 - 1, pixSizeH, pixSizeV); pie_MatEnd(); }
void iV_DrawImage(IMAGEFILE *ImageFile, UWORD ID, int x, int y) { if (!assertValidImage(ImageFile, ID)) { return; } PIERECT dest; Vector2i pieImage = makePieImage(ImageFile, ID, &dest, x, y); pie_SetRendMode(REND_ALPHA); pie_DrawImage(ImageFile, ID, pieImage, &dest); }
void pie_TransColouredTriangle(const std::array<Vector3f, 3> &vrt, PIELIGHT c, const glm::mat4 &modelViewMatrix) { pie_SetTexturePage(TEXPAGE_NONE); pie_SetRendMode(REND_ADDITIVE); glm::vec4 color(c.byte.r / 255.f, c.byte.g / 255.f, c.byte.b / 255.f, 128.f / 255.f); const auto &program = pie_ActivateShader(SHADER_GENERIC_COLOR, pie_PerspectiveGet() * modelViewMatrix, color); static glBufferWrapper buffer; glBindBuffer(GL_ARRAY_BUFFER, buffer.id); glBufferData(GL_ARRAY_BUFFER, 3 * sizeof(Vector3f), vrt.data(), GL_STREAM_DRAW); glVertexAttribPointer(program.locVertex, 3, GL_FLOAT, GL_FALSE, 0, nullptr); glEnableVertexAttribArray(program.locVertex); glDrawArrays(GL_TRIANGLE_FAN, 0, 3); glDisableVertexAttribArray(program.locVertex); }
void pie_DrawViewingWindow(Vector3i *v, UDWORD x1, UDWORD y1, UDWORD x2, UDWORD y2, PIELIGHT colour) { CLIP_VERTEX pieVrts[pie_MAX_VERTICES_PER_POLYGON]; SDWORD i; pie_SetTexturePage(TEXPAGE_NONE); pie_SetRendMode(REND_ALPHA); pieVrts[0].pos.x = v[1].x; pieVrts[0].pos.y = v[1].y; //cull triangles with off screen points pieVrts[0].pos.z = INTERFACE_DEPTH; pieVrts[0].u = 0; pieVrts[0].v = 0; pieVrts[0].light = colour; pieVrts[1] = pieVrts[0]; pieVrts[2] = pieVrts[0]; pieVrts[3] = pieVrts[0]; pieVrts[4] = pieVrts[0]; pieVrts[1].pos.x = v[0].x; pieVrts[1].pos.y = v[0].y; pieVrts[2].pos.x = v[2].x; pieVrts[2].pos.y = v[2].y; pieVrts[3].pos.x = v[3].x; pieVrts[3].pos.y = v[3].y; glColor4ub(colour.byte.r, colour.byte.g, colour.byte.b, colour.byte.a >> 1); glBegin(GL_TRIANGLE_FAN); for (i = 0; i < 5; i++) { glVertex2f(pieVrts[i].pos.x, pieVrts[i].pos.y); } glEnd(); glColor4ub(colour.byte.r, colour.byte.g, colour.byte.b, colour.byte.a); glBegin(GL_LINE_STRIP); for (i = 0; i < 5; i++) { glVertex2f(pieVrts[i].pos.x, pieVrts[i].pos.y); } glVertex2f(pieVrts[0].pos.x, pieVrts[0].pos.y); glEnd(); }
void pie_UniTransBoxFill(SDWORD x0,SDWORD y0, SDWORD x1, SDWORD y1, UDWORD rgb, UDWORD transparency) { UDWORD light; // pie_doWeirdBoxFX(x0,y0,x1,y1); // return; if (x0>psRendSurface->clip.right || x1<psRendSurface->clip.left || y0>psRendSurface->clip.bottom || y1<psRendSurface->clip.top) return; if (x0<psRendSurface->clip.left) x0 = psRendSurface->clip.left; if (x1>psRendSurface->clip.right) x1 = psRendSurface->clip.right; if (y0<psRendSurface->clip.top) y0 = psRendSurface->clip.top; if (y1>psRendSurface->clip.bottom) y1 = psRendSurface->clip.bottom; switch (pie_GetRenderEngine()) { case ENGINE_4101: case ENGINE_SR: TransBoxFill(x0,y0,x1,y1); break; case ENGINE_GLIDE: if(pie_SwirlyBoxes()) { pie_doWeirdBoxFX(x0,y0,x1,y1,rgb); } else { gl_IntelTransBoxFill(x0, y0, x1, y1, rgb, transparency); } break; case ENGINE_D3D: if (transparency == 0 ) { transparency = 127; } pie_SetTexturePage(-1); pie_SetRendMode(REND_ALPHA_FLAT); light = (rgb & 0x00ffffff) + (transparency << 24); pie_DrawRect(x0, y0, x1, y1, light, FALSE); default: break; } }
void iV_DrawImageTc(Image image, Image imageTc, int x, int y, PIELIGHT colour) { if (!assertValidImage(image.images, image.id) || !assertValidImage(imageTc.images, imageTc.id)) { return; } PIERECT dest; Vector2i pieImage = makePieImage(image.images, image.id, &dest, x, y); Vector2i pieImageTc = makePieImage(imageTc.images, imageTc.id); pie_SetRendMode(REND_ALPHA); pie_DrawImage(image.images, image.id, pieImage, &dest); pie_DrawImage(imageTc.images, imageTc.id, pieImageTc, &dest, colour); }
void pie_TransColouredTriangle(Vector3f *vrt, PIELIGHT c) { UDWORD i; pie_SetTexturePage(TEXPAGE_NONE); pie_SetRendMode(REND_ADDITIVE); glColor4ub(c.byte.r, c.byte.g, c.byte.b, 128); glBegin(GL_TRIANGLE_FAN); for (i = 0; i < 3; ++i) { glVertex3f(vrt[i].x, vrt[i].y, vrt[i].z); } glEnd(); }
void iV_DrawImageTc(IMAGEFILE *imageFile, unsigned id, unsigned idTc, int x, int y, PIELIGHT colour) { if (!assertValidImage(imageFile, id) || !assertValidImage(imageFile, idTc)) { return; } PIERECT dest; PIEIMAGE pieImage = makePieImage(imageFile, id, &dest, x, y); PIEIMAGE pieImageTc = makePieImage(imageFile, idTc); pie_SetRendMode(REND_ALPHA); pie_SetAlphaTest(true); pie_DrawImage(&pieImage, &dest); pie_DrawImage(&pieImageTc, &dest, colour); }
void iV_DrawImageScaled(IMAGEFILE *ImageFile, UWORD ID, int x, int y, int w, int h) { if (!assertValidImage(ImageFile, ID)) { return; } PIERECT dest; Vector2i pieImage = makePieImage(ImageFile, ID, &dest, x, y); dest.w = w; dest.h = h; pie_SetRendMode(REND_ALPHA); pie_SetAlphaTest(true); pie_DrawImage(ImageFile, ID, pieImage, &dest); }
void pie_DrawSkybox(float scale, int u, int v, int w, int h) { const float r = 1.0f; // just because it is shorter than 1.0f glPushAttrib(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT | GL_FOG_BIT); // no use in updating the depth buffer glDepthMask(GL_FALSE); // fog should not affect the sky glDisable(GL_FOG); // So we have realistic colors glColor4ub(0xFF,0xFF,0xFF,0xFF); // enable alpha pie_SetRendMode(REND_ALPHA); // for the nice blend of the sky with the fog glDisable(GL_ALPHA_TEST); // Apply scale matrix glScalef(scale, scale/2.0f, scale); glBegin(GL_QUAD_STRIP); // Front glTexCoord2f(u + w * 0, v + h); glVertex3f(-r, 0, r); // bottom left glTexCoord2f(u + w * 0, v); glVertex3f(-r, r, r); // top left glTexCoord2f(u + w * 2, v + h); glVertex3f( r, 0, r); // bottom right glTexCoord2f(u + w * 2, v); glVertex3f( r, r, r); // top right // Right glTexCoord2f(u + w * 4, v + h); glVertex3f( r, 0,-r); // bottom r glTexCoord2f(u + w * 4, v); glVertex3f( r, r,-r); // top r // Back glTexCoord2f(u + w * 6, v + h); glVertex3f(-r, 0, -r); // bottom right glTexCoord2f(u + w * 6, v); glVertex3f(-r, r, -r); // top right // Left glTexCoord2f(u + w * 8, v + h); glVertex3f(-r, 0, r); // bottom r glTexCoord2f(u + w * 8, v); glVertex3f(-r, r, r); // top r glEnd(); glPopAttrib(); }
static void pie_Draw3DButton(iIMDShape *shape, PIELIGHT teamcolour) { const PIELIGHT colour = WZCOL_WHITE; pie_SetFogStatus(false); pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON); SHADER_PROGRAM &program = pie_ActivateShader(SHADER_BUTTON, shape, teamcolour, colour); pie_SetRendMode(REND_OPAQUE); pie_SetTexturePage(shape->texpage); enableArray(shape->buffers[VBO_VERTEX], program.locVertex, 3, GL_FLOAT, false, 0, 0); enableArray(shape->buffers[VBO_NORMAL], program.locNormal, 3, GL_FLOAT, false, 0, 0); enableArray(shape->buffers[VBO_TEXCOORD], program.locTexCoord, 2, GL_FLOAT, false, 0, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, shape->buffers[VBO_INDEX]); glDrawElements(GL_TRIANGLES, shape->npolys * 3, GL_UNSIGNED_SHORT, NULL); disableArrays(); polyCount += shape->npolys; pie_DeactivateShader(); pie_SetDepthBufferStatus(DEPTH_CMP_ALWAYS_WRT_ON); }
void pie_SetDefaultStates()//Sets all states { PIELIGHT black; //fog off rendStates.fogEnabled = false;// enable fog before renderer rendStates.fog = false;//to force reset to false pie_SetFogStatus(false); black.rgba = 0; black.byte.a = 255; pie_SetFogColour(black); //depth Buffer on pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON); rendStates.rendMode = REND_ALPHA; // to force reset to REND_OPAQUE pie_SetRendMode(REND_OPAQUE); }