- simplify texture binding

This commit is contained in:
Magnus Norddahl 2019-08-17 03:21:11 +02:00
parent c88b94e1c9
commit c914aadcaa
7 changed files with 89 additions and 97 deletions

View file

@ -3454,7 +3454,7 @@ namespace CodeImp.DoomBuilder.Data
// Set render settings...
General.Map.Graphics.SetZEnable(false);
General.Map.Graphics.SetCullMode(Cull.None);
General.Map.Graphics.SetSamplerState(0, TextureAddress.Clamp);
General.Map.Graphics.SetSamplerState(TextureAddress.Clamp);
// Setup matrices
Vector3 offset = new Vector3(0f, 0f, -1.8f); // Sphere size is 10 mu
@ -3479,9 +3479,9 @@ namespace CodeImp.DoomBuilder.Data
// Set appropriate texture
switch(meshes.Skins[j])
{
case "top.png": General.Map.Graphics.SetTexture(0, textop); break;
case "bottom.png": General.Map.Graphics.SetTexture(0, texbottom); break;
case "side.png": General.Map.Graphics.SetTexture(0, texside); break;
case "top.png": General.Map.Graphics.SetTexture(textop); break;
case "bottom.png": General.Map.Graphics.SetTexture(texbottom); break;
case "side.png": General.Map.Graphics.SetTexture(texside); break;
default: throw new Exception("Unexpected skin!");
}

View file

@ -182,29 +182,29 @@ namespace CodeImp.DoomBuilder.Rendering
RenderDevice_SetZWriteEnable(Handle, value);
}
public void SetTexture(int unit, BaseTexture value)
public void SetTexture(BaseTexture value)
{
RenderDevice_SetTexture(Handle, unit, value != null ? value.Handle : IntPtr.Zero);
RenderDevice_SetTexture(Handle, value != null ? value.Handle : IntPtr.Zero);
}
public void SetSamplerFilter(int unit, TextureFilter filter)
public void SetSamplerFilter(TextureFilter filter)
{
SetSamplerFilter(unit, filter, filter, TextureFilter.None, 0.0f);
SetSamplerFilter(filter, filter, TextureFilter.None, 0.0f);
}
public void SetSamplerFilter(int unit, TextureFilter minfilter, TextureFilter magfilter, TextureFilter mipfilter, float maxanisotropy)
public void SetSamplerFilter(TextureFilter minfilter, TextureFilter magfilter, TextureFilter mipfilter, float maxanisotropy)
{
RenderDevice_SetSamplerFilter(Handle, unit, minfilter, magfilter, mipfilter, maxanisotropy);
RenderDevice_SetSamplerFilter(Handle, minfilter, magfilter, mipfilter, maxanisotropy);
}
public void SetSamplerState(int unit, TextureAddress address)
public void SetSamplerState(TextureAddress address)
{
SetSamplerState(unit, address, address, address);
SetSamplerState(address, address, address);
}
public void SetSamplerState(int unit, TextureAddress addressU, TextureAddress addressV, TextureAddress addressW)
public void SetSamplerState(TextureAddress addressU, TextureAddress addressV, TextureAddress addressW)
{
RenderDevice_SetSamplerState(Handle, unit, addressU, addressV, addressW);
RenderDevice_SetSamplerState(Handle, addressU, addressV, addressW);
}
public void DrawIndexed(PrimitiveType type, int startIndex, int primitiveCount)
@ -351,11 +351,11 @@ namespace CodeImp.DoomBuilder.Rendering
SetZWriteEnable(false);
// Texture addressing
SetSamplerState(0, TextureAddress.Wrap);
SetSamplerState(TextureAddress.Wrap);
//mxd. It's still nice to have anisotropic filtering when texture filtering is disabled
TextureFilter magminfilter = (General.Settings.VisualBilinear ? TextureFilter.Linear : TextureFilter.Point);
SetSamplerFilter(0,
SetSamplerFilter(
General.Settings.FilterAnisotropy > 1.0f ? TextureFilter.Anisotropic : magminfilter,
magminfilter,
General.Settings.VisualBilinear ? TextureFilter.Linear : TextureFilter.None, // [SB] use None, otherwise textures are still filtered
@ -416,13 +416,13 @@ namespace CodeImp.DoomBuilder.Rendering
static extern void RenderDevice_SetZWriteEnable(IntPtr handle, bool value);
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void RenderDevice_SetTexture(IntPtr handle, int unit, IntPtr texture);
static extern void RenderDevice_SetTexture(IntPtr handle, IntPtr texture);
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void RenderDevice_SetSamplerFilter(IntPtr handle, int unit, TextureFilter minfilter, TextureFilter magfilter, TextureFilter mipfilter, float maxanisotropy);
static extern void RenderDevice_SetSamplerFilter(IntPtr handle, TextureFilter minfilter, TextureFilter magfilter, TextureFilter mipfilter, float maxanisotropy);
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void RenderDevice_SetSamplerState(IntPtr handle, int unit, TextureAddress addressU, TextureAddress addressV, TextureAddress addressW);
static extern void RenderDevice_SetSamplerState(IntPtr handle, TextureAddress addressU, TextureAddress addressV, TextureAddress addressW);
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void RenderDevice_Draw(IntPtr handle, PrimitiveType type, int startIndex, int primitiveCount);

View file

@ -238,7 +238,7 @@ namespace CodeImp.DoomBuilder.Rendering
case RendererLayer.Background:
if((backimageverts == null) || (General.Map.Grid.Background.Texture == null)) break;
graphics.SetShader(aapass);
graphics.SetTexture(0, General.Map.Grid.Background.Texture);
graphics.SetTexture(General.Map.Grid.Background.Texture);
SetDisplay2DSettings(1f / windowsize.Width, 1f / windowsize.Height, FSAA_FACTOR, layer.alpha, false, true);
graphics.Draw(PrimitiveType.TriangleStrip, 0, 2, backimageverts);
graphics.SetVertexBuffer(screenverts);
@ -247,7 +247,7 @@ namespace CodeImp.DoomBuilder.Rendering
// GRID
case RendererLayer.Grid:
graphics.SetShader(aapass);
graphics.SetTexture(0, backtex);
graphics.SetTexture(backtex);
SetDisplay2DSettings(1f / backsize.Width, 1f / backsize.Height, FSAA_FACTOR, layer.alpha, false, true);
graphics.Draw(PrimitiveType.TriangleStrip, 0, 2);
break;
@ -255,7 +255,7 @@ namespace CodeImp.DoomBuilder.Rendering
// GEOMETRY
case RendererLayer.Geometry:
graphics.SetShader(aapass);
graphics.SetTexture(0, plottertex);
graphics.SetTexture(plottertex);
SetDisplay2DSettings(1f / structsize.Width, 1f / structsize.Height, FSAA_FACTOR, layer.alpha, false, false);
graphics.Draw(PrimitiveType.TriangleStrip, 0, 2);
break;
@ -263,7 +263,7 @@ namespace CodeImp.DoomBuilder.Rendering
// THINGS
case RendererLayer.Things:
graphics.SetShader(aapass);
graphics.SetTexture(0, thingstex);
graphics.SetTexture(thingstex);
SetDisplay2DSettings(1f / thingssize.Width, 1f / thingssize.Height, FSAA_FACTOR, layer.alpha, false, true);
graphics.Draw(PrimitiveType.TriangleStrip, 0, 2);
break;
@ -271,7 +271,7 @@ namespace CodeImp.DoomBuilder.Rendering
// OVERLAY
case RendererLayer.Overlay:
graphics.SetShader(aapass);
graphics.SetTexture(0, overlaytex);
graphics.SetTexture(overlaytex);
SetDisplay2DSettings(1f / overlaysize.Width, 1f / overlaysize.Height, FSAA_FACTOR, layer.alpha, false, true);
graphics.Draw(PrimitiveType.TriangleStrip, 0, 2);
break;
@ -279,7 +279,7 @@ namespace CodeImp.DoomBuilder.Rendering
// SURFACE
case RendererLayer.Surface:
graphics.SetShader(aapass);
graphics.SetTexture(0, surfacetex);
graphics.SetTexture(surfacetex);
SetDisplay2DSettings(1f / overlaysize.Width, 1f / overlaysize.Height, FSAA_FACTOR, layer.alpha, false, true);
graphics.Draw(PrimitiveType.TriangleStrip, 0, 2);
break;
@ -291,7 +291,7 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.Present();
// Release binds
graphics.SetTexture(0, null);
graphics.SetTexture(null);
graphics.SetVertexBuffer(null);
}
@ -502,7 +502,7 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetUniform(UniformName.transformsettings, worldmatrix * viewmatrix * Matrix.Scaling(1f, -1f, 1f));
else
graphics.SetUniform(UniformName.transformsettings, worldmatrix * viewmatrix);
graphics.SetSamplerFilter(0, bilinear ? TextureFilter.Linear : TextureFilter.Point);
graphics.SetSamplerFilter(bilinear ? TextureFilter.Linear : TextureFilter.Point);
}
private void SetThings2DSettings(float alpha)
@ -1236,7 +1236,7 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetVertexBuffer(thingsvertices);
// Set things texture
graphics.SetTexture(0, General.Map.Data.ThingTexture.Texture); //mxd
graphics.SetTexture(General.Map.Data.ThingTexture.Texture); //mxd
SetWorldTransformation(false);
graphics.SetShader(ShaderName.things2d_thing);
SetThings2DSettings(alpha);
@ -1349,7 +1349,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
if(sprite.Texture == null) sprite.CreateTexture();
graphics.SetTexture(0, sprite.Texture);
graphics.SetTexture(sprite.Texture);
// Determine next lock size
locksize = (framegroup.Value.Count > THING_BUFFER_SIZE) ? THING_BUFFER_SIZE : framegroup.Value.Count;
@ -1444,7 +1444,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
//mxd. Render thing arrows
graphics.SetTexture(0, General.Map.Data.ThingTexture.Texture);
graphics.SetTexture(General.Map.Data.ThingTexture.Texture);
graphics.SetShader(ShaderName.things2d_thing);
// Determine next lock size
@ -1647,7 +1647,7 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
graphics.SetFogEnable(false);
graphics.SetShader(ShaderName.display2d_normal);
graphics.SetTexture(0, t);
graphics.SetTexture(t);
SetWorldTransformation(transformcoords);
SetDisplay2DSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
@ -1697,7 +1697,7 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
graphics.SetFogEnable(false);
graphics.SetShader(ShaderName.display2d_normal);
graphics.SetTexture(0, label.Texture);
graphics.SetTexture(label.Texture);
SetWorldTransformation(false);
SetDisplay2DSettings(1f, 1f, 0f, 1f, false);
graphics.SetVertexBuffer(label.VertexBuffer);
@ -1736,7 +1736,7 @@ namespace CodeImp.DoomBuilder.Rendering
// Text is created?
if(!label.SkipRendering)
{
graphics.SetTexture(0, label.Texture);
graphics.SetTexture(label.Texture);
graphics.SetVertexBuffer(label.VertexBuffer);
// Draw
@ -1796,7 +1796,7 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetFogEnable(false);
SetWorldTransformation(false);
graphics.SetShader(ShaderName.display2d_normal);
graphics.SetTexture(0, General.Map.Data.WhiteTexture.Texture);
graphics.SetTexture(General.Map.Data.WhiteTexture.Texture);
SetDisplay2DSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
// Draw
@ -1831,7 +1831,7 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetFogEnable(false);
SetWorldTransformation(false);
graphics.SetShader(ShaderName.display2d_normal);
graphics.SetTexture(0, General.Map.Data.WhiteTexture.Texture);
graphics.SetTexture(General.Map.Data.WhiteTexture.Texture);
SetDisplay2DSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
// Draw
@ -1863,7 +1863,7 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetFogEnable(false);
SetWorldTransformation(false);
graphics.SetShader(ShaderName.display2d_normal);
graphics.SetTexture(0, texture.Texture);
graphics.SetTexture(texture.Texture);
SetDisplay2DSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
// Draw
@ -1962,7 +1962,7 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetFogEnable(false);
SetWorldTransformation(false);
graphics.SetShader(ShaderName.display2d_normal);
graphics.SetTexture(0, General.Map.Data.WhiteTexture.Texture);
graphics.SetTexture(General.Map.Data.WhiteTexture.Texture);
SetDisplay2DSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
// Draw
@ -2014,7 +2014,7 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetFogEnable(false);
SetWorldTransformation(false);
graphics.SetShader(ShaderName.display2d_normal);
graphics.SetTexture(0, General.Map.Data.WhiteTexture.Texture);
graphics.SetTexture(General.Map.Data.WhiteTexture.Texture);
SetDisplay2DSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
// Draw

View file

@ -320,7 +320,7 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetUniform(UniformName.highlightcolor, new Color4()); //mxd
// Texture addressing
graphics.SetSamplerState(0, TextureAddress.Wrap);
graphics.SetSamplerState(TextureAddress.Wrap);
// Matrices
world = Matrix.Identity;
@ -499,7 +499,7 @@ namespace CodeImp.DoomBuilder.Rendering
if(General.Settings.GZShowEventLines) RenderArrows(eventlines);
// Remove references
graphics.SetTexture(0, null);
graphics.SetTexture(null);
//mxd. Trash collections
solidgeo = null;
@ -759,7 +759,7 @@ namespace CodeImp.DoomBuilder.Rendering
curtexture.CreateTexture();
// Apply texture
graphics.SetTexture(0, curtexture.Texture);
graphics.SetTexture(curtexture.Texture);
//mxd. Sort geometry by sector index
group.Value.Sort((g1, g2) => g1.Sector.Sector.FixedIndex - g2.Sector.Sector.FixedIndex);
@ -838,7 +838,7 @@ namespace CodeImp.DoomBuilder.Rendering
if(thingspass.Count > 0)
{
// Texture addressing
graphics.SetSamplerState(0, TextureAddress.Clamp);
graphics.SetSamplerState(TextureAddress.Clamp);
graphics.SetCullMode(Cull.None); //mxd. Disable backside culling, because otherwise sprites with positive ScaleY and negative ScaleX will be facing away from the camera...
Color4 vertexcolor = new Color4(); //mxd
@ -859,7 +859,7 @@ namespace CodeImp.DoomBuilder.Rendering
curtexture.CreateTexture();
// Apply texture
graphics.SetTexture(0, curtexture.Texture);
graphics.SetTexture(curtexture.Texture);
// Render all things with this texture
foreach(VisualThing t in group.Value)
@ -949,7 +949,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
// Texture addressing
graphics.SetSamplerState(0, TextureAddress.Wrap);
graphics.SetSamplerState(TextureAddress.Wrap);
graphics.SetCullMode(Cull.Clockwise); //mxd
}
}
@ -1039,7 +1039,7 @@ namespace CodeImp.DoomBuilder.Rendering
curtexture.CreateTexture();
// Apply texture
graphics.SetTexture(0, curtexture.Texture);
graphics.SetTexture(curtexture.Texture);
curtexturename = g.Texture.LongName;
}
@ -1112,7 +1112,7 @@ namespace CodeImp.DoomBuilder.Rendering
if(thingspass.Count > 0)
{
// Texture addressing
graphics.SetSamplerState(0, TextureAddress.Clamp);
graphics.SetSamplerState(TextureAddress.Clamp);
graphics.SetCullMode(Cull.None); //mxd. Disable backside culling, because otherwise sprites with positive ScaleY and negative ScaleX will be facing away from the camera...
// Sort geometry by camera distance. First vertex of the BoundingBox is it's center
@ -1173,7 +1173,7 @@ namespace CodeImp.DoomBuilder.Rendering
curtexture.CreateTexture();
// Apply texture
graphics.SetTexture(0, curtexture.Texture);
graphics.SetTexture(curtexture.Texture);
curtexturename = t.Texture.LongName;
}
@ -1256,7 +1256,7 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetUniform(UniformName.stencilColor, new Color4(1f, 1f, 1f, 0f));
// Texture addressing
graphics.SetSamplerState(0, TextureAddress.Wrap);
graphics.SetSamplerState(TextureAddress.Wrap);
graphics.SetCullMode(Cull.Clockwise); //mxd
}
}
@ -1335,7 +1335,7 @@ namespace CodeImp.DoomBuilder.Rendering
continue;
if (settexture)
graphics.SetTexture(0, g.Texture.Texture);
graphics.SetTexture(g.Texture.Texture);
//normal lights
int count = lightOffsets[0];
@ -1493,7 +1493,7 @@ namespace CodeImp.DoomBuilder.Rendering
foreach (KeyValuePair<ImageData, List<VisualGeometry>> group in geometrytolit)
{
if (group.Key.Texture == null) continue;
graphics.SetTexture(0, group.Key.Texture);
graphics.SetTexture(group.Key.Texture);
sector = RenderLightsFromGeometryList(group.Value, lights, sector, false);
}
@ -1616,7 +1616,7 @@ namespace CodeImp.DoomBuilder.Rendering
GZModel model = General.Map.Data.ModeldefEntries[t.Thing.Type].Model;
for (int j = 0; j < model.Meshes.Count; j++)
{
graphics.SetTexture(0, model.Textures[j]);
graphics.SetTexture(model.Textures[j]);
if (!lightpass)
{
@ -1755,7 +1755,7 @@ namespace CodeImp.DoomBuilder.Rendering
// Set render settings
graphics.SetShader(ShaderName.world3d_skybox);
graphics.SetTexture(0, General.Map.Data.SkyBox);
graphics.SetTexture(General.Map.Data.SkyBox);
graphics.SetUniform(UniformName.world, world);
graphics.SetUniform(UniformName.campos, new Vector4(cameraposition.x, cameraposition.y, cameraposition.z, 0f));
@ -2023,12 +2023,12 @@ namespace CodeImp.DoomBuilder.Rendering
if(crosshairbusy)
{
if(General.Map.Data.CrosshairBusy3D.Texture == null) General.Map.Data.CrosshairBusy3D.CreateTexture();
graphics.SetTexture(0, General.Map.Data.CrosshairBusy3D.Texture);
graphics.SetTexture(General.Map.Data.CrosshairBusy3D.Texture);
}
else
{
if(General.Map.Data.Crosshair3D.Texture == null) General.Map.Data.Crosshair3D.CreateTexture();
graphics.SetTexture(0, General.Map.Data.Crosshair3D.Texture);
graphics.SetTexture(General.Map.Data.Crosshair3D.Texture);
}
// Draw
@ -2041,7 +2041,7 @@ namespace CodeImp.DoomBuilder.Rendering
Vector4 values = new Vector4(texelx, texely, fsaafactor, alpha);
graphics.SetUniform(UniformName.rendersettings, values);
graphics.SetUniform(UniformName.transformsettings, worldmatrix * viewmatrix);
graphics.SetSamplerFilter(0, bilinear ? TextureFilter.Linear : TextureFilter.Point);
graphics.SetSamplerFilter(bilinear ? TextureFilter.Linear : TextureFilter.Point);
}
// This switches fog on and off

View file

@ -614,7 +614,7 @@ namespace CodeImp.DoomBuilder.Rendering
foreach(KeyValuePair<ImageData, List<SurfaceEntry>> imgsurfaces in surfaces)
{
graphics.SetShader(pass);
graphics.SetTexture(0, imgsurfaces.Key.Texture);
graphics.SetTexture(imgsurfaces.Key.Texture);
// Go for all surfaces
VertexBuffer lastbuffer = null;

View file

@ -111,17 +111,17 @@ void RenderDevice::SetZWriteEnable(bool value)
mNeedApply = true;
}
void RenderDevice::SetTexture(int index, Texture* texture)
void RenderDevice::SetTexture(Texture* texture)
{
mTextureUnits[index].Tex = texture;
mTextureUnit.Tex = texture;
mNeedApply = true;
}
void RenderDevice::SetSamplerFilter(int index, TextureFilter minfilter, TextureFilter magfilter, TextureFilter mipfilter, float maxanisotropy)
void RenderDevice::SetSamplerFilter(TextureFilter minfilter, TextureFilter magfilter, TextureFilter mipfilter, float maxanisotropy)
{
mTextureUnits[index].MinFilter = GetGLMinFilter(minfilter, mipfilter);
mTextureUnits[index].MagFilter = (magfilter == TextureFilter::Point || magfilter == TextureFilter::None) ? GL_NEAREST : GL_LINEAR;
mTextureUnits[index].MaxAnisotropy = maxanisotropy;
mTextureUnit.MinFilter = GetGLMinFilter(minfilter, mipfilter);
mTextureUnit.MagFilter = (magfilter == TextureFilter::Point || magfilter == TextureFilter::None) ? GL_NEAREST : GL_LINEAR;
mTextureUnit.MaxAnisotropy = maxanisotropy;
mNeedApply = true;
}
@ -150,11 +150,11 @@ GLint RenderDevice::GetGLMinFilter(TextureFilter filter, TextureFilter mipfilter
}
}
void RenderDevice::SetSamplerState(int index, TextureAddress addressU, TextureAddress addressV, TextureAddress addressW)
void RenderDevice::SetSamplerState(TextureAddress addressU, TextureAddress addressV, TextureAddress addressW)
{
mTextureUnits[index].AddressU = addressU;
mTextureUnits[index].AddressV = addressV;
mTextureUnits[index].AddressW = addressW;
mTextureUnit.AddressU = addressU;
mTextureUnit.AddressV = addressV;
mTextureUnit.AddressW = addressW;
mNeedApply = true;
}
@ -529,25 +529,21 @@ void RenderDevice::ApplyTextures()
{
static const int wrapMode[] = { GL_REPEAT, GL_CLAMP_TO_EDGE };
for (size_t i = 0; i < NumSlots; i++)
glActiveTexture(GL_TEXTURE0);
if (mTextureUnit.Tex)
{
auto& binding = mTextureUnits[i];
glActiveTexture(GL_TEXTURE0 + (GLenum)i);
if (binding.Tex)
{
GLenum target = binding.Tex->IsCubeTexture() ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D;
GLenum target = mTextureUnit.Tex->IsCubeTexture() ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D;
glBindTexture(target, binding.Tex->GetTexture());
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, binding.MinFilter);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, binding.MagFilter);
glTexParameteri(target, GL_TEXTURE_WRAP_S, wrapMode[(int)binding.AddressU]);
glTexParameteri(target, GL_TEXTURE_WRAP_T, wrapMode[(int)binding.AddressV]);
glTexParameteri(target, GL_TEXTURE_WRAP_R, wrapMode[(int)binding.AddressW]);
}
else
{
glBindTexture(GL_TEXTURE_2D, 0);
}
glBindTexture(target, mTextureUnit.Tex->GetTexture());
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, mTextureUnit.MinFilter);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, mTextureUnit.MagFilter);
glTexParameteri(target, GL_TEXTURE_WRAP_S, wrapMode[(int)mTextureUnit.AddressU]);
glTexParameteri(target, GL_TEXTURE_WRAP_T, wrapMode[(int)mTextureUnit.AddressV]);
glTexParameteri(target, GL_TEXTURE_WRAP_R, wrapMode[(int)mTextureUnit.AddressW]);
}
else
{
glBindTexture(GL_TEXTURE_2D, 0);
}
}
@ -642,19 +638,19 @@ void RenderDevice_SetZWriteEnable(RenderDevice* device, bool value)
device->SetZWriteEnable(value);
}
void RenderDevice_SetTexture(RenderDevice* device, int unit, Texture* texture)
void RenderDevice_SetTexture(RenderDevice* device, Texture* texture)
{
device->SetTexture(unit, texture);
device->SetTexture(texture);
}
void RenderDevice_SetSamplerFilter(RenderDevice* device, int unit, TextureFilter minfilter, TextureFilter magfilter, TextureFilter mipfilter, float maxanisotropy)
void RenderDevice_SetSamplerFilter(RenderDevice* device, TextureFilter minfilter, TextureFilter magfilter, TextureFilter mipfilter, float maxanisotropy)
{
device->SetSamplerFilter(unit, minfilter, magfilter, mipfilter, maxanisotropy);
device->SetSamplerFilter(minfilter, magfilter, mipfilter, maxanisotropy);
}
void RenderDevice_SetSamplerState(RenderDevice* device, int unit, TextureAddress addressU, TextureAddress addressV, TextureAddress addressW)
void RenderDevice_SetSamplerState(RenderDevice* device, TextureAddress addressU, TextureAddress addressV, TextureAddress addressW)
{
device->SetSamplerState(unit, addressU, addressV, addressW);
device->SetSamplerState(addressU, addressV, addressW);
}
void RenderDevice_Draw(RenderDevice* device, PrimitiveType type, int startIndex, int primitiveCount)

View file

@ -91,9 +91,9 @@ public:
void SetMultisampleAntialias(bool value);
void SetZEnable(bool value);
void SetZWriteEnable(bool value);
void SetTexture(int unit, Texture* texture);
void SetSamplerFilter(int unit, TextureFilter minfilter, TextureFilter magfilter, TextureFilter mipfilter, float maxanisotropy);
void SetSamplerState(int unit, TextureAddress addressU, TextureAddress addressV, TextureAddress addressW);
void SetTexture(Texture* texture);
void SetSamplerFilter(TextureFilter minfilter, TextureFilter magfilter, TextureFilter mipfilter, float maxanisotropy);
void SetSamplerState(TextureAddress addressU, TextureAddress addressV, TextureAddress addressW);
void Draw(PrimitiveType type, int startIndex, int primitiveCount);
void DrawIndexed(PrimitiveType type, int startIndex, int primitiveCount);
void DrawData(PrimitiveType type, int startIndex, int primitiveCount, const void* data);
@ -141,11 +141,7 @@ public:
TextureAddress AddressU = TextureAddress::Wrap;
TextureAddress AddressV = TextureAddress::Wrap;
TextureAddress AddressW = TextureAddress::Wrap;
};
enum { NumSlots = 16 };
TextureUnit mTextureUnits[NumSlots];
} mTextureUnit;
VertexBuffer* mVertexBuffer = nullptr;
IndexBuffer* mIndexBuffer = nullptr;