本文整理汇总了C++中FMaterial::GetVT方法的典型用法代码示例。如果您正苦于以下问题:C++ FMaterial::GetVT方法的具体用法?C++ FMaterial::GetVT怎么用?C++ FMaterial::GetVT使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FMaterial
的用法示例。
在下文中一共展示了FMaterial::GetVT方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawTexture
void FGLRenderer::DrawTexture(FTexture *img, DrawParms &parms)
{
double xscale = parms.destwidth / parms.texwidth;
double yscale = parms.destheight / parms.texheight;
double x = parms.x - parms.left * xscale;
double y = parms.y - parms.top * yscale;
double w = parms.destwidth;
double h = parms.destheight;
float u1, v1, u2, v2;
int light = 255;
FMaterial * gltex = FMaterial::ValidateTexture(img, false);
if (parms.colorOverlay && (parms.colorOverlay & 0xffffff) == 0)
{
// Right now there's only black. Should be implemented properly later
light = 255 - APART(parms.colorOverlay);
parms.colorOverlay = 0;
}
gl_SetRenderStyle(parms.style, !parms.masked, false);
if (!img->bHasCanvas)
{
int translation = 0;
if (!parms.alphaChannel)
{
if (parms.remap != NULL && !parms.remap->Inactive)
{
GLTranslationPalette * pal = static_cast<GLTranslationPalette*>(parms.remap->GetNative());
if (pal) translation = -pal->GetIndex();
}
}
gl_RenderState.SetMaterial(gltex, CLAMP_XY_NOMIP, translation, -1, !!(parms.style.Flags & STYLEF_RedIsAlpha));
u1 = gltex->GetUL();
v1 = gltex->GetVT();
u2 = gltex->GetUR();
v2 = gltex->GetVB();
}
else
{
gl_RenderState.SetMaterial(gltex, CLAMP_XY_NOMIP, 0, -1, false);
u1 = 0.f;
v1 = 1.f;
u2 = 1.f;
v2 = 0.f;
gl_RenderState.SetTextureMode(TM_OPAQUE);
}
if (parms.flipX)
{
float temp = u1;
u1 = u2;
u2 = temp;
}
if (parms.windowleft > 0 || parms.windowright < parms.texwidth)
{
double wi = MIN(parms.windowright, parms.texwidth);
x += parms.windowleft * xscale;
w -= (parms.texwidth - wi + parms.windowleft) * xscale;
u1 = float(u1 + parms.windowleft / parms.texwidth);
u2 = float(u2 - (parms.texwidth - wi) / parms.texwidth);
}
PalEntry color;
if (parms.style.Flags & STYLEF_ColorIsFixed)
{
color = parms.fillcolor;
}
else
{
color = PalEntry(light, light, light);
}
color.a = (BYTE)(parms.Alpha * 255);
// scissor test doesn't use the current viewport for the coordinates, so use real screen coordinates
int btm = (SCREENHEIGHT - screen->GetHeight()) / 2;
btm = SCREENHEIGHT - btm;
glEnable(GL_SCISSOR_TEST);
int space = (static_cast<OpenGLFrameBuffer*>(screen)->GetTrueHeight()-screen->GetHeight())/2;
glScissor(parms.lclip, btm - parms.dclip + space, parms.rclip - parms.lclip, parms.dclip - parms.uclip);
gl_RenderState.SetColor(color);
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
gl_RenderState.Apply();
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
ptr->Set(x, y, 0, u1, v1); ptr++;
ptr->Set(x, y + h, 0, u1, v2); ptr++;
ptr->Set(x + w, y, 0, u2, v1); ptr++;
ptr->Set(x + w, y + h, 0, u2, v2); ptr++;
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP);
if (parms.colorOverlay)
{
//.........这里部分代码省略.........
示例2: DrawTexture
void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms)
{
double xscale = parms.destwidth / parms.texwidth;
double yscale = parms.destheight / parms.texheight;
double x = parms.x - parms.left * xscale;
double y = parms.y - parms.top * yscale;
double w = parms.destwidth;
double h = parms.destheight;
float u1, v1, u2, v2, r, g, b;
float light = 1.f;
FMaterial * gltex = FMaterial::ValidateTexture(img);
if (parms.colorOverlay && (parms.colorOverlay & 0xffffff) == 0)
{
// Right now there's only black. Should be implemented properly later
light = 1.f - APART(parms.colorOverlay)/255.f;
parms.colorOverlay = 0;
}
if (!img->bHasCanvas)
{
if (!parms.alphaChannel)
{
int translation = 0;
if (parms.remap != NULL && !parms.remap->Inactive)
{
GLTranslationPalette * pal = static_cast<GLTranslationPalette*>(parms.remap->GetNative());
if (pal) translation = -pal->GetIndex();
}
gltex->BindPatch(CM_DEFAULT, translation);
}
else
{
// This is an alpha texture
gltex->BindPatch(CM_SHADE, 0);
}
u1 = gltex->GetUL();
v1 = gltex->GetVT();
u2 = gltex->GetUR();
v2 = gltex->GetVB();
}
else
{
gltex->Bind(CM_DEFAULT, 0, 0);
u2=1.f;
v2=-1.f;
u1 = v1 = 0.f;
gl_RenderState.SetTextureMode(TM_OPAQUE);
}
if (parms.flipX)
{
float temp = u1;
u1 = u2;
u2 = temp;
}
if (parms.windowleft > 0 || parms.windowright < parms.texwidth)
{
x += parms.windowleft * xscale;
w -= (parms.texwidth - parms.windowright + parms.windowleft) * xscale;
u1 = float(u1 + parms.windowleft / parms.texwidth);
u2 = float(u2 - (parms.texwidth - parms.windowright) / parms.texwidth);
}
if (parms.style.Flags & STYLEF_ColorIsFixed)
{
r = RPART(parms.fillcolor)/255.0f;
g = GPART(parms.fillcolor)/255.0f;
b = BPART(parms.fillcolor)/255.0f;
}
else
{
r = g = b = light;
}
// scissor test doesn't use the current viewport for the coordinates, so use real screen coordinates
int btm = (SCREENHEIGHT - screen->GetHeight()) / 2;
btm = SCREENHEIGHT - btm;
glEnable(GL_SCISSOR_TEST);
int space = (static_cast<OpenGLFrameBuffer*>(screen)->GetTrueHeight()-screen->GetHeight())/2;
glScissor(parms.lclip, btm - parms.dclip + space, parms.rclip - parms.lclip, parms.dclip - parms.uclip);
gl_SetRenderStyle(parms.style, !parms.masked, false);
if (img->bHasCanvas)
{
gl_RenderState.SetTextureMode(TM_OPAQUE);
}
glColor4f(r, g, b, FIXED2FLOAT(parms.alpha));
gl_RenderState.EnableAlphaTest(false);
gl_RenderState.Apply();
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(u1, v1);
//.........这里部分代码省略.........
示例3: DrawDecal
//.........这里部分代码省略.........
left = decalpixpos;
lefttex = 0;
}
// decal is off the right edge
if (decalpixpos + decalwidth > linelength)
{
right = linelength;
righttex = right - decalpixpos;
}
else
{
right = decalpixpos + decalwidth;
righttex = decalwidth;
}
if (right<=left) return; // nothing to draw
// one texture unit on the wall as vector
float vx=(glseg.x2-glseg.x1)/linelength;
float vy=(glseg.y2-glseg.y1)/linelength;
dv[1].x=dv[0].x=glseg.x1+vx*left;
dv[1].y=dv[0].y=glseg.y1+vy*left;
dv[3].x=dv[2].x=glseg.x1+vx*right;
dv[3].y=dv[2].y=glseg.y1+vy*right;
zpos+= FRACUNIT*(flipy? decalheight-decaltopo : decaltopo);
tex->BindPatch(p.colormap, decal->Translation);
dv[1].z=dv[2].z = FIXED2FLOAT(zpos);
dv[0].z=dv[3].z = dv[1].z - decalheight;
dv[1].v=dv[2].v = tex->GetVT();
dv[1].u=dv[0].u = tex->GetU(lefttex / FIXED2FLOAT(decal->ScaleX));
dv[3].u=dv[2].u = tex->GetU(righttex / FIXED2FLOAT(decal->ScaleX));
dv[0].v=dv[3].v = tex->GetVB();
// now clip to the top plane
float vzt=(ztop[1]-ztop[0])/linelength;
float topleft=this->ztop[0]+vzt*left;
float topright=this->ztop[0]+vzt*right;
// completely below the wall
if (topleft<dv[0].z && topright<dv[3].z)
return;
if (topleft<dv[1].z || topright<dv[2].z)
{
// decal has to be clipped at the top
// let texture clamping handle all extreme cases
dv[1].v=(dv[1].z-topleft)/(dv[1].z-dv[0].z)*dv[0].v;
dv[2].v=(dv[2].z-topright)/(dv[2].z-dv[3].z)*dv[3].v;
dv[1].z=topleft;
dv[2].z=topright;
}
// now clip to the bottom plane
float vzb=(zbottom[1]-zbottom[0])/linelength;
float bottomleft=this->zbottom[0]+vzb*left;
float bottomright=this->zbottom[0]+vzb*right;
// completely above the wall
if (bottomleft>dv[1].z && bottomright>dv[2].z)
示例4: DrawDecal
//.........这里部分代码省略.........
else
{
left = decalpixpos;
lefttex = 0;
}
// decal is off the right edge
if (decalpixpos + decalwidth > linelength)
{
right = linelength;
righttex = right - decalpixpos;
}
else
{
right = decalpixpos + decalwidth;
righttex = decalwidth;
}
if (right<=left) return; // nothing to draw
// one texture unit on the wall as vector
float vx=(glseg.x2-glseg.x1)/linelength;
float vy=(glseg.y2-glseg.y1)/linelength;
dv[1].x=dv[0].x=glseg.x1+vx*left;
dv[1].y=dv[0].y=glseg.y1+vy*left;
dv[3].x=dv[2].x=glseg.x1+vx*right;
dv[3].y=dv[2].y=glseg.y1+vy*right;
zpos+= (flipy? decalheight-decaltopo : decaltopo);
dv[1].z=dv[2].z = zpos;
dv[0].z=dv[3].z = dv[1].z - decalheight;
dv[1].v=dv[2].v = tex->GetVT();
dv[1].u=dv[0].u = tex->GetU(lefttex / decal->ScaleX);
dv[3].u=dv[2].u = tex->GetU(righttex / decal->ScaleX);
dv[0].v=dv[3].v = tex->GetVB();
// now clip to the top plane
float vzt=(ztop[1]-ztop[0])/linelength;
float topleft=this->ztop[0]+vzt*left;
float topright=this->ztop[0]+vzt*right;
// completely below the wall
if (topleft<dv[0].z && topright<dv[3].z)
return;
if (topleft<dv[1].z || topright<dv[2].z)
{
// decal has to be clipped at the top
// let texture clamping handle all extreme cases
dv[1].v=(dv[1].z-topleft)/(dv[1].z-dv[0].z)*dv[0].v;
dv[2].v=(dv[2].z-topright)/(dv[2].z-dv[3].z)*dv[3].v;
dv[1].z=topleft;
dv[2].z=topright;
}
// now clip to the bottom plane
float vzb=(zbottom[1]-zbottom[0])/linelength;
float bottomleft=this->zbottom[0]+vzb*left;
float bottomright=this->zbottom[0]+vzb*right;
// completely above the wall
if (bottomleft>dv[1].z && bottomright>dv[2].z)