Remove support for non power of two textures.

This commit is contained in:
UnknownShadow200 2015-05-23 06:16:17 +10:00
parent f2563ffde5
commit c2b6ee83b1
5 changed files with 4 additions and 35 deletions

View file

@ -120,23 +120,9 @@ namespace ClassicalSharp {
public static Texture Make2DTexture( IGraphicsApi graphics, Bitmap bmp, Size used, int x1, int y1 ) {
int textureID = graphics.LoadTexture( bmp );
if( !Utils.IsPowerOf2( bmp.Width ) || !Utils.IsPowerOf2( bmp.Height ) )
Utils.LogWarning( "Creating a non power of two texture." );
return new Texture( textureID, x1, y1, used.Width, used.Height,
(float)used.Width / bmp.Width, (float)used.Height / bmp.Height );
}
public static Bitmap ResizeToPower2( Bitmap bmp ) {
int adjWidth = Utils.NextPowerOf2( bmp.Width );
int adjHeight = Utils.NextPowerOf2( bmp.Height );
Bitmap adjBmp = new Bitmap( adjWidth, adjHeight );
using( Graphics g = Graphics.FromImage( adjBmp ) ) {
g.DrawImage( bmp, 0, 0 );
}
return adjBmp;
}
}
public static void Dispose() {
measuringBmp.Dispose();

View file

@ -125,7 +125,6 @@ namespace ClassicalSharp {
Console.ForegroundColor = ConsoleColor.Green;
Graphics.PrintApiSpecificInfo();
Console.WriteLine( "Max 2D texture dimensions: " + Graphics.MaxTextureDimensions );
Console.WriteLine( "Supports non power of 2 textures: " + Graphics.SupportsNonPowerOf2Textures );
Console.WriteLine( "== End of graphics info ==" );
Console.ResetColor();
}

View file

@ -99,14 +99,6 @@ namespace ClassicalSharp.GraphicsAPI {
device.RenderState.FogStart = value;
}
public override bool SupportsNonPowerOf2Textures {
get {
return !caps.TextureCaps.SupportsPower2 &&
!caps.TextureCaps.SupportsNonPower2Conditional;
}
}
public override int MaxTextureDimensions {
get {
return Math.Min( caps.MaxTextureHeight, caps.MaxTextureWidth );

View file

@ -9,10 +9,6 @@ namespace ClassicalSharp.GraphicsAPI {
public abstract class IGraphicsApi {
/// <summary> Whether the underlying graphics API (and card) fully
/// supports using non power of two textures. </summary>
public abstract bool SupportsNonPowerOf2Textures { get; }
/// <summary> Maximum supported length of a dimension
/// (i.e. max width and max height) in a 2D texture. </summary>
public abstract int MaxTextureDimensions { get; }

View file

@ -15,8 +15,6 @@ namespace ClassicalSharp.GraphicsAPI {
public class OpenGLApi : IGraphicsApi {
int textureDimensions;
bool nonPow2;
const string nonPow2Ext = "GL_ARB_texture_non_power_of_two";
const string vboExt = "GL_ARB_vertex_buffer_object";
bool useVbos = true;
BeginMode[] modeMappings = new BeginMode[] {
@ -27,7 +25,6 @@ namespace ClassicalSharp.GraphicsAPI {
public OpenGLApi() {
GL.GetInteger( GetPName.MaxTextureSize, out textureDimensions );
string extensions = GL.GetString( StringName.Extensions );
nonPow2 = extensions.Contains( nonPow2Ext );
useVbos = extensions.Contains( vboExt );
if( !useVbos ) {
Utils.LogWarning( "Unable to use OpenGL VBOs, you may experience reduced performance." );
@ -42,10 +39,6 @@ namespace ClassicalSharp.GraphicsAPI {
get { return textureDimensions; }
}
public override bool SupportsNonPowerOf2Textures {
get { return nonPow2; }
}
public override bool AlphaTest {
set { ToggleCap( EnableCap.AlphaTest, value ); }
}
@ -137,6 +130,9 @@ namespace ClassicalSharp.GraphicsAPI {
}
static int LoadTexture( int width, int height, IntPtr scan0 ) {
if( !Utils.IsPowerOf2( width ) || !Utils.IsPowerOf2( height ) )
Utils.LogWarning( "Creating a non power of two texture." );
int texId = GL.GenTexture();
GL.Enable( EnableCap.Texture2D );
GL.BindTexture( TextureTarget.Texture2D, texId );