/** * Zeichnet die Textur. * * @author FloSoft */ void glArchivItem_Bitmap::Draw(short dst_x, short dst_y, short dst_w, short dst_h, short src_x, short src_y, short src_w, short src_h, const unsigned int color, const unsigned int unused) { if(texture == 0) GenerateTexture(); if(texture == 0) return; if(src_w == 0) src_w = width_; if(src_h == 0) src_h = height_; if(dst_w == 0) dst_w = src_w; if(dst_h == 0) dst_h = src_h; VIDEODRIVER.BindTexture(texture); assert(getBobType() != libsiedler2::BOBTYPE_BITMAP_PLAYER); struct GL_T2F_C4UB_V3F_Struct { GLfloat tx, ty; GLubyte r, g, b, a; GLfloat x, y, z; }; GL_T2F_C4UB_V3F_Struct tmp[4]; int x = -nx_ + dst_x; int y = -ny_ + dst_y; tmp[0].x = tmp[1].x = GLfloat(x); tmp[2].x = tmp[3].x = GLfloat(x + dst_w); tmp[0].y = tmp[3].y = GLfloat(y); tmp[1].y = tmp[2].y = GLfloat(y + dst_h); tmp[0].z = tmp[1].z = tmp[2].z = tmp[3].z = 0.0f; tmp[0].tx = tmp[1].tx = (GLfloat)src_x / tex_width_; tmp[2].tx = tmp[3].tx = (GLfloat)(src_x + src_w) / tex_width_; tmp[0].ty = tmp[3].ty = (GLfloat)src_y / tex_height_; tmp[1].ty = tmp[2].ty = (GLfloat)(src_y + src_h) / tex_height_; tmp[0].r = tmp[1].r = tmp[2].r = tmp[3].r = GetRed(color); tmp[0].g = tmp[1].g = tmp[2].g = tmp[3].g = GetGreen(color); tmp[0].b = tmp[1].b = tmp[2].b = tmp[3].b = GetBlue(color); tmp[0].a = tmp[1].a = tmp[2].a = tmp[3].a = GetAlpha(color); glInterleavedArrays(GL_T2F_C4UB_V3F, 0, tmp); glDrawArrays(GL_QUADS, 0, 4); return; }
/** * Zeichnet die Textur. */ void glArchivItem_Bitmap::Draw(Rect dstArea, Rect srcArea, unsigned color /*= COLOR_WHITE*/) { if(GetTexture() == 0) return; RTTR_Assert(dstArea.getSize().x > 0 && dstArea.getSize().y > 0); RTTR_Assert(srcArea.getSize().x > 0 && srcArea.getSize().y > 0); // Compatibility only! Extent srcSize = srcArea.getSize(); if(srcSize.x == 0) srcSize.x = getWidth(); if(srcSize.y == 0) srcSize.y = getHeight(); srcArea.setSize(srcSize); Extent dstSize = dstArea.getSize(); if(dstSize.x == 0) dstSize.x = srcSize.x; if(dstSize.y == 0) dstSize.y = srcSize.y; dstArea.setSize(dstSize); RTTR_Assert(getBobType() != libsiedler2::BOBTYPE_BITMAP_PLAYER); std::array<Point<GLfloat>, 4> texCoords, vertices; dstArea.move(-GetOrigin()); vertices[0].x = vertices[1].x = GLfloat(dstArea.left); vertices[2].x = vertices[3].x = GLfloat(dstArea.right); vertices[0].y = vertices[3].y = GLfloat(dstArea.top); vertices[1].y = vertices[2].y = GLfloat(dstArea.bottom); Point<GLfloat> srcOrig = Point<GLfloat>(srcArea.getOrigin()) / GetTexSize(); Point<GLfloat> srcEndPt = Point<GLfloat>(srcArea.getEndPt()) / GetTexSize(); texCoords[0].x = texCoords[1].x = srcOrig.x; texCoords[2].x = texCoords[3].x = srcEndPt.x; texCoords[0].y = texCoords[3].y = srcOrig.y; texCoords[1].y = texCoords[2].y = srcEndPt.y; glVertexPointer(2, GL_FLOAT, 0, vertices.data()); glTexCoordPointer(2, GL_FLOAT, 0, texCoords.data()); VIDEODRIVER.BindTexture(GetTexture()); glColor4ub(GetRed(color), GetGreen(color), GetBlue(color), GetAlpha(color)); glDrawArrays(GL_QUADS, 0, 4); }