本文整理汇总了C++中FMaterial类的典型用法代码示例。如果您正苦于以下问题:C++ FMaterial类的具体用法?C++ FMaterial怎么用?C++ FMaterial使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FMaterial类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void FMD3Model::RenderFrame(FTexture * skin, int frameno, int cm, int translation)
{
if (frameno>=numFrames) return;
MD3Frame * frame = &frames[frameno];
// I can't confirm correctness of this because no model I have tested uses this information
// glMatrixMode(GL_MODELVIEW);
// glTranslatef(frame->origin[0], frame->origin[1], frame->origin[2]);
for(int i=0;i<numSurfaces;i++)
{
MD3Surface * surf = &surfaces[i];
// [BB] In case no skin is specified via MODELDEF, check if the MD3 has a skin for the current surface.
// Note: Each surface may have a different skin.
FTexture *surfaceSkin = skin;
if (!surfaceSkin)
{
if (surf->numSkins==0) return;
surfaceSkin = surf->skins[0];
if (!surfaceSkin) return;
}
FMaterial * tex = FMaterial::ValidateTexture(surfaceSkin);
tex->Bind(cm, 0, translation);
RenderTriangles(surf, surf->vertices + frameno * surf->numVertices);
}
}
示例2:
void FMD3Model::RenderFrame(FTexture * skin, int frameno, int cm, Matrix3x4 *modeltoworld, int translation)
{
if (frameno>=numFrames) return;
MD3Frame * frame = &frames[frameno];
// I can't confirm correctness of this because no model I have tested uses this information
// gl.MatrixMode(GL_MODELVIEW);
// gl.Translatef(frame->origin[0], frame->origin[1], frame->origin[2]);
for(int i=0;i<numSurfaces;i++)
{
MD3Surface * surf = &surfaces[i];
if (!skin)
{
if (surf->numSkins==0) return;
skin = surf->skins[0];
if (!skin) return;
}
FMaterial * tex = FMaterial::ValidateTexture(skin);
tex->Bind(cm, 0, translation);
RenderTriangles(surf, surf->vertices + frameno * surf->numVertices, modeltoworld);
}
}
示例3: FMeshDrawingPolicy
FVelocityDrawingPolicy::FVelocityDrawingPolicy(
const FVertexFactory* InVertexFactory,
const FMaterialRenderProxy* InMaterialRenderProxy,
const FMaterial& InMaterialResource,
ERHIFeatureLevel::Type InFeatureLevel
)
: FMeshDrawingPolicy(InVertexFactory,InMaterialRenderProxy,InMaterialResource)
{
const FMaterialShaderMap* MaterialShaderIndex = InMaterialResource.GetRenderingThreadShaderMap();
const FMeshMaterialShaderMap* MeshShaderIndex = MaterialShaderIndex->GetMeshShaderMap(InVertexFactory->GetType());
HullShader = NULL;
DomainShader = NULL;
const EMaterialTessellationMode MaterialTessellationMode = InMaterialResource.GetTessellationMode();
if (RHISupportsTessellation(GShaderPlatformForFeatureLevel[InFeatureLevel])
&& InVertexFactory->GetType()->SupportsTessellationShaders()
&& MaterialTessellationMode != MTM_NoTessellation)
{
bool HasHullShader = MeshShaderIndex->HasShader(&FVelocityHS::StaticType);
bool HasDomainShader = MeshShaderIndex->HasShader(&FVelocityDS::StaticType);
HullShader = HasHullShader ? MeshShaderIndex->GetShader<FVelocityHS>() : NULL;
DomainShader = HasDomainShader ? MeshShaderIndex->GetShader<FVelocityDS>() : NULL;
}
bool HasVertexShader = MeshShaderIndex->HasShader(&FVelocityVS::StaticType);
VertexShader = HasVertexShader ? MeshShaderIndex->GetShader<FVelocityVS>() : NULL;
bool HasPixelShader = MeshShaderIndex->HasShader(&FVelocityPS::StaticType);
PixelShader = HasPixelShader ? MeshShaderIndex->GetShader<FVelocityPS>() : NULL;
}
示例4: FillSimplePoly
void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints,
double originx, double originy, double scalex, double scaley,
angle_t rotation, FDynamicColormap *colormap, int lightlevel)
{
if (npoints < 3)
{ // This is no polygon.
return;
}
FMaterial *gltexture = FMaterial::ValidateTexture(texture);
if (gltexture == NULL)
{
return;
}
FColormap cm;
cm = colormap;
lightlevel = gl_CalcLightLevel(lightlevel, 0, true);
PalEntry pe = gl_CalcLightColor(lightlevel, cm.LightColor, cm.blendfactor, true);
glColor3ub(pe.r, pe.g, pe.b);
gltexture->Bind(cm.colormap);
int i;
float rot = float(rotation * M_PI / float(1u << 31));
bool dorotate = rot != 0;
float cosrot = cos(rot);
float sinrot = sin(rot);
//float yoffs = GatheringWipeScreen ? 0 : LBOffset;
float uscale = float(1.f / (texture->GetScaledWidth() * scalex));
float vscale = float(1.f / (texture->GetScaledHeight() * scaley));
if (gltexture->tex->bHasCanvas)
{
vscale = 0 - vscale;
}
float ox = float(originx);
float oy = float(originy);
gl_RenderState.Apply();
glBegin(GL_TRIANGLE_FAN);
for (i = 0; i < npoints; ++i)
{
float u = points[i].X - 0.5f - ox;
float v = points[i].Y - 0.5f - oy;
if (dorotate)
{
float t = u;
u = t * cosrot - v * sinrot;
v = v * cosrot + t * sinrot;
}
glTexCoord2f(u * uscale, v * vscale);
glVertex3f(points[i].X, points[i].Y /* + yoffs */, 0);
}
glEnd();
}
示例5: PrecacheTexture
void FGLInterface::PrecacheTexture(FTexture *tex, int cache)
{
if (cache & (FTextureManager::HIT_Wall | FTextureManager::HIT_Flat | FTextureManager::HIT_Sky))
{
FMaterial * gltex = FMaterial::ValidateTexture(tex, false);
if (gltex) gltex->Precache();
}
}
示例6:
unsigned char *FGLRenderer::GetTextureBuffer(FTexture *tex, int &w, int &h)
{
FMaterial * gltex = FMaterial::ValidateTexture(tex);
if (gltex)
{
return gltex->CreateTexBuffer(CM_DEFAULT, 0, w, h);
}
return NULL;
}
示例7: FMesh
class FMesh* FPrimitiveBuilder::CreateMesh(class FTexture* Texture, const glm::vec4& Colour, bool bUseIndexBuffer)
{
FMesh* Mesh = new FMesh(bUseIndexBuffer);
FMaterial* Material = new FMaterial(Texture);
Material->SetDiffuse(Colour);
// TODO: Might need to fix this or add more stuff. check it later
ProceduralModel->Meshes.push_back(Mesh);
ProceduralModel->Materials.push_back(Material);
Mesh->SetMaterial(Material);
return Mesh;
}
示例8: if
VulkanDescriptorSet *VkHardwareTexture::GetDescriptorSet(const FMaterialState &state)
{
FMaterial *mat = state.mMaterial;
FTexture *tex = state.mMaterial->tex;
int clampmode = state.mClampMode;
int translation = state.mTranslation;
if (tex->UseType == ETextureType::SWCanvas) clampmode = CLAMP_NOFILTER;
if (tex->isHardwareCanvas()) clampmode = CLAMP_CAMTEX;
else if ((tex->isWarped() || tex->shaderindex >= FIRST_USER_SHADER) && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE;
// Textures that are already scaled in the texture lump will not get replaced by hires textures.
int flags = state.mMaterial->isExpanded() ? CTF_Expand : (gl_texture_usehires && !tex->isScaled() && clampmode <= CLAMP_XY) ? CTF_CheckHires : 0;
if (tex->isHardwareCanvas()) static_cast<FCanvasTexture*>(tex)->NeedUpdate();
for (auto &set : mDescriptorSets)
{
if (set.descriptor && set.clampmode == clampmode && set.flags == flags) return set.descriptor.get();
}
int numLayers = mat->GetLayers();
auto fb = GetVulkanFrameBuffer();
auto descriptor = fb->GetRenderPassManager()->AllocateTextureDescriptorSet(numLayers);
descriptor->SetDebugName("VkHardwareTexture.mDescriptorSets");
VulkanSampler *sampler = fb->GetSamplerManager()->Get(clampmode);
WriteDescriptors update;
update.addCombinedImageSampler(descriptor.get(), 0, GetImage(tex, translation, flags)->View.get(), sampler, mImage.Layout);
for (int i = 1; i < numLayers; i++)
{
FTexture *layer;
auto systex = static_cast<VkHardwareTexture*>(mat->GetLayer(i, 0, &layer));
update.addCombinedImageSampler(descriptor.get(), i, systex->GetImage(layer, 0, mat->isExpanded() ? CTF_Expand : 0)->View.get(), sampler, systex->mImage.Layout);
}
update.updateSets(fb->device);
mDescriptorSets.emplace_back(clampmode, flags, std::move(descriptor));
return mDescriptorSets.back().descriptor.get();
}
示例9:
FDepthDrawingPolicy::FDepthDrawingPolicy(
const FVertexFactory* InVertexFactory,
const FMaterialRenderProxy* InMaterialRenderProxy,
const FMaterial& InMaterialResource,
bool bIsTwoSided,
ERHIFeatureLevel::Type InFeatureLevel
):
FMeshDrawingPolicy(InVertexFactory,InMaterialRenderProxy,InMaterialResource,false,/*bInTwoSidedOverride=*/ bIsTwoSided)
{
// The primitive needs to be rendered with the material's pixel and vertex shaders if it is masked
bNeedsPixelShader = false;
if (InMaterialResource.IsMasked())
{
bNeedsPixelShader = true;
PixelShader = InMaterialResource.GetShader<FDepthOnlyPS>(InVertexFactory->GetType());
}
else
{
PixelShader = NULL;
}
const EMaterialTessellationMode TessellationMode = InMaterialResource.GetTessellationMode();
VertexShader = NULL;
HullShader = NULL;
DomainShader = NULL;
if (RHISupportsTessellation(GShaderPlatformForFeatureLevel[InFeatureLevel])
&& InVertexFactory->GetType()->SupportsTessellationShaders()
&& TessellationMode != MTM_NoTessellation)
{
VertexShader = InMaterialResource.GetShader<TDepthOnlyVS<false> >(VertexFactory->GetType());
HullShader = InMaterialResource.GetShader<FDepthOnlyHS>(VertexFactory->GetType());
DomainShader = InMaterialResource.GetShader<FDepthOnlyDS>(VertexFactory->GetType());
}
else
{
VertexShader = InMaterialResource.GetShader<TDepthOnlyVS<false> >(InVertexFactory->GetType());
}
}
示例10: RenderTextureView
void FGLRenderer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV)
{
// This doesn't need to clear the fake flat cache. It can be shared between camera textures and the main view of a scene.
FMaterial * gltex = FMaterial::ValidateTexture(tex, false);
int width = gltex->TextureWidth();
int height = gltex->TextureHeight();
StartOffscreen();
BindToFrameBuffer(gltex);
IntRect bounds;
bounds.left = bounds.top = 0;
bounds.width = FHardwareTexture::GetTexDimension(gltex->GetWidth());
bounds.height = FHardwareTexture::GetTexDimension(gltex->GetHeight());
FRenderViewpoint texvp;
RenderViewpoint(texvp, Viewpoint, &bounds, FOV, (float)width / height, (float)width / height, false, false);
EndOffscreen();
tex->SetUpdated(true);
static_cast<OpenGLFrameBuffer*>(screen)->camtexcount++;
}
示例11: RenderTextureView
void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, int FOV)
{
FMaterial * gltex = FMaterial::ValidateTexture(tex, false);
int width = gltex->TextureWidth();
int height = gltex->TextureHeight();
gl_fixedcolormap=CM_DEFAULT;
gl_RenderState.SetFixedColormap(CM_DEFAULT);
if (gl.legacyMode)
{
// In legacy mode, fail if the requested texture is too large.
if (gltex->GetWidth() > screen->GetWidth() || gltex->GetHeight() > screen->GetHeight()) return;
glFlush();
}
else
{
GLRenderer->StartOffscreen();
gltex->BindToFrameBuffer();
}
GL_IRECT bounds;
bounds.left=bounds.top=0;
bounds.width=FHardwareTexture::GetTexDimension(gltex->GetWidth());
bounds.height=FHardwareTexture::GetTexDimension(gltex->GetHeight());
GLRenderer->RenderViewpoint(Viewpoint, &bounds, FOV, (float)width/height, (float)width/height, false, false);
if (gl.legacyMode)
{
glFlush();
gl_RenderState.SetMaterial(gltex, 0, 0, -1, false);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, bounds.width, bounds.height);
}
else
{
GLRenderer->EndOffscreen();
}
tex->SetUpdated();
camtexcount++;
}
示例12: DrawFloodedPlane
//==========================================================================
//
// Draw the plane segment into the gap
//
//==========================================================================
void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, bool ceiling)
{
GLSectorPlane plane;
int lightlevel;
FColormap Colormap;
FMaterial * gltexture;
plane.GetFromSector(sec, ceiling);
gltexture=FMaterial::ValidateTexture(plane.texture, true);
if (!gltexture) return;
if (gl_fixedcolormap)
{
Colormap.GetFixedColormap();
lightlevel=255;
}
else
{
Colormap=sec->ColorMap;
if (gltexture->tex->isFullbright())
{
Colormap.LightColor.r = Colormap.LightColor.g = Colormap.LightColor.b = 0xff;
lightlevel=255;
}
else lightlevel=abs(ceiling? sec->GetCeilingLight() : sec->GetFloorLight());
}
int rel = getExtraLight();
gl_SetColor(lightlevel, rel, &Colormap, 1.0f);
gl_SetFog(lightlevel, rel, &Colormap, false);
gltexture->Bind(Colormap.colormap);
float fviewx = FIXED2FLOAT(viewx);
float fviewy = FIXED2FLOAT(viewy);
float fviewz = FIXED2FLOAT(viewz);
gl_RenderState.Apply();
bool pushed = gl_SetPlaneTextureRotation(&plane, gltexture);
glBegin(GL_TRIANGLE_FAN);
float prj_fac1 = (planez-fviewz)/(ws->z1-fviewz);
float prj_fac2 = (planez-fviewz)/(ws->z2-fviewz);
float px1 = fviewx + prj_fac1 * (ws->x1-fviewx);
float py1 = fviewy + prj_fac1 * (ws->y1-fviewy);
float px2 = fviewx + prj_fac2 * (ws->x1-fviewx);
float py2 = fviewy + prj_fac2 * (ws->y1-fviewy);
float px3 = fviewx + prj_fac2 * (ws->x2-fviewx);
float py3 = fviewy + prj_fac2 * (ws->y2-fviewy);
float px4 = fviewx + prj_fac1 * (ws->x2-fviewx);
float py4 = fviewy + prj_fac1 * (ws->y2-fviewy);
glTexCoord2f(px1 / 64, -py1 / 64);
glVertex3f(px1, planez, py1);
glTexCoord2f(px2 / 64, -py2 / 64);
glVertex3f(px2, planez, py2);
glTexCoord2f(px3 / 64, -py3 / 64);
glVertex3f(px3, planez, py3);
glTexCoord2f(px4 / 64, -py4 / 64);
glVertex3f(px4, planez, py4);
glEnd();
if (pushed)
{
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
}
示例13: 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);
const PatchTextureInfo * pti;
if (parms.colorOverlay)
{
// Right now there's only black. Should be implemented properly later
light = 1.f - APART(parms.colorOverlay)/255.f;
}
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();
}
pti = gltex->BindPatch(CM_DEFAULT, translation);
}
else
{
// This is an alpha texture
pti = gltex->BindPatch(CM_SHADE, 0);
}
if (!pti) return;
u1 = pti->GetUL();
v1 = pti->GetVT();
u2 = pti->GetUR();
v2 = pti->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;
gl.Enable(GL_SCISSOR_TEST);
int space = (static_cast<OpenGLFrameBuffer*>(screen)->GetTrueHeight()-screen->GetHeight())/2;
gl.Scissor(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);
}
gl.Color4f(r, g, b, FIXED2FLOAT(parms.alpha));
gl_RenderState.EnableAlphaTest(false);
//.........这里部分代码省略.........
示例14: RenderBox
static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, int CM_Index, bool sky2)
{
FSkyBox * sb = static_cast<FSkyBox*>(gltex->tex);
int faces;
FMaterial * tex;
if (!sky2)
glRotatef(-180.0f+x_offset, glset.skyrotatevector.X, glset.skyrotatevector.Z, glset.skyrotatevector.Y);
else
glRotatef(-180.0f+x_offset, glset.skyrotatevector2.X, glset.skyrotatevector2.Z, glset.skyrotatevector2.Y);
glColor3f(R, G ,B);
if (sb->faces[5])
{
faces=4;
// north
tex = FMaterial::ValidateTexture(sb->faces[0]);
tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0);
gl_RenderState.Apply();
glBegin(GL_TRIANGLE_FAN);
glTexCoord2f(0, 0);
glVertex3f(128.f, 128.f, -128.f);
glTexCoord2f(1, 0);
glVertex3f(-128.f, 128.f, -128.f);
glTexCoord2f(1, 1);
glVertex3f(-128.f, -128.f, -128.f);
glTexCoord2f(0, 1);
glVertex3f(128.f, -128.f, -128.f);
glEnd();
// east
tex = FMaterial::ValidateTexture(sb->faces[1]);
tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0);
gl_RenderState.Apply();
glBegin(GL_TRIANGLE_FAN);
glTexCoord2f(0, 0);
glVertex3f(-128.f, 128.f, -128.f);
glTexCoord2f(1, 0);
glVertex3f(-128.f, 128.f, 128.f);
glTexCoord2f(1, 1);
glVertex3f(-128.f, -128.f, 128.f);
glTexCoord2f(0, 1);
glVertex3f(-128.f, -128.f, -128.f);
glEnd();
// south
tex = FMaterial::ValidateTexture(sb->faces[2]);
tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0);
gl_RenderState.Apply();
glBegin(GL_TRIANGLE_FAN);
glTexCoord2f(0, 0);
glVertex3f(-128.f, 128.f, 128.f);
glTexCoord2f(1, 0);
glVertex3f(128.f, 128.f, 128.f);
glTexCoord2f(1, 1);
glVertex3f(128.f, -128.f, 128.f);
glTexCoord2f(0, 1);
glVertex3f(-128.f, -128.f, 128.f);
glEnd();
// west
tex = FMaterial::ValidateTexture(sb->faces[3]);
tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0);
gl_RenderState.Apply();
glBegin(GL_TRIANGLE_FAN);
glTexCoord2f(0, 0);
glVertex3f(128.f, 128.f, 128.f);
glTexCoord2f(1, 0);
glVertex3f(128.f, 128.f, -128.f);
glTexCoord2f(1, 1);
glVertex3f(128.f, -128.f, -128.f);
glTexCoord2f(0, 1);
glVertex3f(128.f, -128.f, 128.f);
glEnd();
}
else
{
faces=1;
// all 4 sides
tex = FMaterial::ValidateTexture(sb->faces[0]);
tex->Bind(CM_Index, GLT_CLAMPX|GLT_CLAMPY, 0);
gl_RenderState.Apply();
glBegin(GL_TRIANGLE_FAN);
glTexCoord2f(0, 0);
glVertex3f(128.f, 128.f, -128.f);
glTexCoord2f(.25f, 0);
glVertex3f(-128.f, 128.f, -128.f);
glTexCoord2f(.25f, 1);
glVertex3f(-128.f, -128.f, -128.f);
glTexCoord2f(0, 1);
glVertex3f(128.f, -128.f, -128.f);
glEnd();
// east
glBegin(GL_TRIANGLE_FAN);
glTexCoord2f(.25f, 0);
glVertex3f(-128.f, 128.f, -128.f);
//.........这里部分代码省略.........
示例15: PrecacheSprite
void FGLInterface::PrecacheSprite(FTexture *tex, SpriteHits &hits)
{
FMaterial * gltex = FMaterial::ValidateTexture(tex, true);
if (gltex) gltex->PrecacheList(hits);
}