Style fixes for Renderer.SdlCommon.

This commit is contained in:
Paul Chote
2013-07-18 18:13:16 +12:00
parent 1b4e387ecc
commit 7853c2127e
7 changed files with 127 additions and 122 deletions

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Renderer.SdlCommon
public static void CheckGlError() public static void CheckGlError()
{ {
var n = Gl.glGetError(); var n = Gl.glGetError();
if( n != Gl.GL_NO_ERROR ) if (n != Gl.GL_NO_ERROR)
{ {
var error = "GL Error: {0}\n{1}".F((GlError)n, new StackTrace()); var error = "GL Error: {0}\n{1}".F((GlError)n, new StackTrace());
WriteGraphicsLog(error); WriteGraphicsLog(error);
@@ -53,5 +53,4 @@ namespace OpenRA.Renderer.SdlCommon
Log.Write("graphics", Gl.glGetString(Gl.GL_EXTENSIONS)); Log.Write("graphics", Gl.glGetString(Gl.GL_EXTENSIONS));
} }
} }
} }

View File

@@ -64,6 +64,22 @@ namespace OpenRA.Renderer.SdlCommon
ErrorHandler.CheckGlError(); ErrorHandler.CheckGlError();
} }
static int[] ViewportRectangle()
{
var v = new int[4];
unsafe
{
fixed (int* ptr = &v[0])
{
IntPtr intPtr = new IntPtr((void*)ptr);
Gl.glGetIntegerv(Gl.GL_VIEWPORT, intPtr);
}
}
ErrorHandler.CheckGlError();
return v;
}
void FinalizeInner() void FinalizeInner()
{ {
Gl.glDeleteFramebuffersEXT(1, ref framebuffer); Gl.glDeleteFramebuffersEXT(1, ref framebuffer);
@@ -74,22 +90,6 @@ namespace OpenRA.Renderer.SdlCommon
~FrameBuffer() { Game.RunAfterTick(FinalizeInner); } ~FrameBuffer() { Game.RunAfterTick(FinalizeInner); }
static int[] ViewportRectangle()
{
int[] v = new int[4];
unsafe
{
fixed (int *ptr = &v[0])
{
IntPtr intPtr = new IntPtr((void*)ptr);
Gl.glGetIntegerv(Gl.GL_VIEWPORT, intPtr);
}
}
ErrorHandler.CheckGlError();
return v;
}
int[] cv = new int[4]; int[] cv = new int[4];
public void Bind() public void Bind()
{ {

View File

@@ -14,33 +14,29 @@ using OpenRA.FileFormats;
public static class MultiTapDetection public static class MultiTapDetection
{ {
static Cache<string, TapHistory> KeyHistoryCache = static Cache<string, TapHistory> keyHistoryCache =
new Cache<string, TapHistory>(_ => new TapHistory(DateTime.Now - TimeSpan.FromSeconds(1))); new Cache<string, TapHistory>(_ => new TapHistory(DateTime.Now - TimeSpan.FromSeconds(1)));
static Cache<byte, TapHistory> ClickHistoryCache = static Cache<byte, TapHistory> clickHistoryCache =
new Cache<byte, TapHistory>(_ => new TapHistory(DateTime.Now - TimeSpan.FromSeconds(1))); new Cache<byte, TapHistory>(_ => new TapHistory(DateTime.Now - TimeSpan.FromSeconds(1)));
public static int DetectFromMouse(byte MBName, int2 xy) public static int DetectFromMouse(byte button, int2 xy)
{ {
var clickHistory = ClickHistoryCache[MBName]; return clickHistoryCache[button].GetTapCount(xy);
return clickHistory.GetTapCount(xy);
} }
public static int InfoFromMouse(byte MBName) public static int InfoFromMouse(byte button)
{ {
var clickHistory = ClickHistoryCache[MBName]; return clickHistoryCache[button].LastTapCount();
return clickHistory.LastTapCount();
} }
public static int DetectFromKeyboard(string KeyName) public static int DetectFromKeyboard(string key)
{ {
var keyHistory = KeyHistoryCache[KeyName]; return keyHistoryCache[key].GetTapCount(int2.Zero);
return keyHistory.GetTapCount(int2.Zero);
} }
public static int InfoFromKeyboard(string KeyName) public static int InfoFromKeyboard(string key)
{ {
var keyHistory = KeyHistoryCache[KeyName]; return keyHistoryCache[key].LastTapCount();
return keyHistory.LastTapCount();
} }
} }
@@ -50,12 +46,12 @@ class TapHistory
public TapHistory(DateTime now) public TapHistory(DateTime now)
{ {
FirstRelease = SecondRelease = ThirdRelease = Pair.New( now, int2.Zero ); FirstRelease = SecondRelease = ThirdRelease = Pair.New(now, int2.Zero);
} }
static bool CloseEnough(Pair<DateTime, int2> a, Pair<DateTime, int2> b) static bool CloseEnough(Pair<DateTime, int2> a, Pair<DateTime, int2> b)
{ {
return a.First - b.First < TimeSpan.FromMilliseconds( 250 ) return a.First - b.First < TimeSpan.FromMilliseconds(250)
&& (a.Second - b.Second).Length < 4; && (a.Second - b.Second).Length < 4;
} }
@@ -65,15 +61,21 @@ class TapHistory
SecondRelease = ThirdRelease; SecondRelease = ThirdRelease;
ThirdRelease = Pair.New(DateTime.Now, xy); ThirdRelease = Pair.New(DateTime.Now, xy);
if (!CloseEnough(ThirdRelease, SecondRelease)) return 1; if (!CloseEnough(ThirdRelease, SecondRelease))
if (!CloseEnough(SecondRelease, FirstRelease)) return 2; return 1;
if (!CloseEnough(SecondRelease, FirstRelease))
return 2;
return 3; return 3;
} }
public int LastTapCount() public int LastTapCount()
{ {
if (!CloseEnough(ThirdRelease, SecondRelease)) return 1; if (!CloseEnough(ThirdRelease, SecondRelease))
if (!CloseEnough(SecondRelease, FirstRelease)) return 2; return 1;
if (!CloseEnough(SecondRelease, FirstRelease))
return 2;
return 3; return 3;
} }
} }

View File

@@ -43,13 +43,13 @@ namespace OpenRA.Renderer.SdlCommon
IntPtr InitializeSdlGl(ref Size size, WindowMode window, string[] requiredExtensions) IntPtr InitializeSdlGl(ref Size size, WindowMode window, string[] requiredExtensions)
{ {
Sdl.SDL_Init( Sdl.SDL_INIT_NOPARACHUTE | Sdl.SDL_INIT_VIDEO ); Sdl.SDL_Init(Sdl.SDL_INIT_NOPARACHUTE | Sdl.SDL_INIT_VIDEO);
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_DOUBLEBUFFER, 1 ); Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_DOUBLEBUFFER, 1);
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_RED_SIZE, 8 ); Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_RED_SIZE, 8);
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_GREEN_SIZE, 8 ); Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_GREEN_SIZE, 8);
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_BLUE_SIZE, 8 ); Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_BLUE_SIZE, 8);
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_ALPHA_SIZE, 0 ); Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_ALPHA_SIZE, 0);
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_STENCIL_SIZE, 1 ); Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_STENCIL_SIZE, 1);
int windowFlags = 0; int windowFlags = 0;
switch (window) switch (window)
@@ -59,16 +59,16 @@ namespace OpenRA.Renderer.SdlCommon
break; break;
case WindowMode.PseudoFullscreen: case WindowMode.PseudoFullscreen:
windowFlags |= Sdl.SDL_NOFRAME; windowFlags |= Sdl.SDL_NOFRAME;
Environment.SetEnvironmentVariable( "SDL_VIDEO_WINDOW_POS", "0,0" ); Environment.SetEnvironmentVariable("SDL_VIDEO_WINDOW_POS", "0,0");
break; break;
case WindowMode.Windowed: case WindowMode.Windowed:
Environment.SetEnvironmentVariable( "SDL_VIDEO_CENTERED", "1" ); Environment.SetEnvironmentVariable("SDL_VIDEO_CENTERED", "1");
break; break;
default: default:
break; break;
} }
var info = (Sdl.SDL_VideoInfo) Marshal.PtrToStructure( var info = (Sdl.SDL_VideoInfo)Marshal.PtrToStructure(
Sdl.SDL_GetVideoInfo(), typeof(Sdl.SDL_VideoInfo)); Sdl.SDL_GetVideoInfo(), typeof(Sdl.SDL_VideoInfo));
Console.WriteLine("Desktop resolution: {0}x{1}", Console.WriteLine("Desktop resolution: {0}x{1}",
info.current_w, info.current_h); info.current_w, info.current_h);
@@ -76,7 +76,7 @@ namespace OpenRA.Renderer.SdlCommon
if (size.Width == 0 && size.Height == 0) if (size.Width == 0 && size.Height == 0)
{ {
Console.WriteLine("No custom resolution provided, using desktop resolution"); Console.WriteLine("No custom resolution provided, using desktop resolution");
size = new Size( info.current_w, info.current_h ); size = new Size(info.current_w, info.current_h);
} }
Console.WriteLine("Using resolution: {0}x{1}", size.Width, size.Height); Console.WriteLine("Using resolution: {0}x{1}", size.Width, size.Height);
@@ -110,13 +110,14 @@ namespace OpenRA.Renderer.SdlCommon
int ModeFromPrimitiveType(PrimitiveType pt) int ModeFromPrimitiveType(PrimitiveType pt)
{ {
switch(pt) switch (pt)
{ {
case PrimitiveType.PointList: return Gl.GL_POINTS; case PrimitiveType.PointList: return Gl.GL_POINTS;
case PrimitiveType.LineList: return Gl.GL_LINES; case PrimitiveType.LineList: return Gl.GL_LINES;
case PrimitiveType.TriangleList: return Gl.GL_TRIANGLES; case PrimitiveType.TriangleList: return Gl.GL_TRIANGLES;
case PrimitiveType.QuadList: return Gl.GL_QUADS; case PrimitiveType.QuadList: return Gl.GL_QUADS;
} }
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -193,5 +194,4 @@ namespace OpenRA.Renderer.SdlCommon
public IFrameBuffer CreateFrameBuffer(Size s) { return new FrameBuffer(s); } public IFrameBuffer CreateFrameBuffer(Size s) { return new FrameBuffer(s); }
public abstract IShader CreateShader(string name); public abstract IShader CreateShader(string name);
} }
} }

View File

@@ -19,9 +19,9 @@ namespace OpenRA.Renderer.SdlCommon
MouseButton lastButtonBits = (MouseButton)0; MouseButton lastButtonBits = (MouseButton)0;
IntPtr surface; IntPtr surface;
public SdlInput( IntPtr surface ) { this.surface = surface; } public SdlInput(IntPtr surface) { this.surface = surface; }
MouseButton MakeButton( byte b ) MouseButton MakeButton(byte b)
{ {
return b == Sdl.SDL_BUTTON_LEFT ? MouseButton.Left return b == Sdl.SDL_BUTTON_LEFT ? MouseButton.Left
: b == Sdl.SDL_BUTTON_RIGHT ? MouseButton.Right : b == Sdl.SDL_BUTTON_RIGHT ? MouseButton.Right
@@ -31,26 +31,26 @@ namespace OpenRA.Renderer.SdlCommon
: 0; : 0;
} }
Modifiers MakeModifiers( int raw ) Modifiers MakeModifiers(int raw)
{ {
return ( ( raw & Sdl.KMOD_ALT ) != 0 ? Modifiers.Alt : 0 ) return ((raw & Sdl.KMOD_ALT) != 0 ? Modifiers.Alt : 0)
| ( ( raw & Sdl.KMOD_CTRL ) != 0 ? Modifiers.Ctrl : 0 ) | ((raw & Sdl.KMOD_CTRL) != 0 ? Modifiers.Ctrl : 0)
| ( ( raw & Sdl.KMOD_META ) != 0 ? Modifiers.Meta : 0 ) | ((raw & Sdl.KMOD_META) != 0 ? Modifiers.Meta : 0)
| ( ( raw & Sdl.KMOD_SHIFT ) != 0 ? Modifiers.Shift : 0 ); | ((raw & Sdl.KMOD_SHIFT) != 0 ? Modifiers.Shift : 0);
} }
public void PumpInput( IInputHandler inputHandler ) public void PumpInput(IInputHandler inputHandler)
{ {
Game.HasInputFocus = 0 != ( Sdl.SDL_GetAppState() & Sdl.SDL_APPINPUTFOCUS ); Game.HasInputFocus = 0 != (Sdl.SDL_GetAppState() & Sdl.SDL_APPINPUTFOCUS);
var mods = MakeModifiers( Sdl.SDL_GetModState() ); var mods = MakeModifiers(Sdl.SDL_GetModState());
inputHandler.ModifierKeys( mods ); inputHandler.ModifierKeys(mods);
MouseInput? pendingMotion = null; MouseInput? pendingMotion = null;
Sdl.SDL_Event e; Sdl.SDL_Event e;
while( Sdl.SDL_PollEvent( out e ) != 0 ) while (Sdl.SDL_PollEvent(out e) != 0)
{ {
switch( e.type ) switch (e.type)
{ {
case Sdl.SDL_QUIT: case Sdl.SDL_QUIT:
OpenRA.Game.Exit(); OpenRA.Game.Exit();
@@ -58,118 +58,121 @@ namespace OpenRA.Renderer.SdlCommon
case Sdl.SDL_MOUSEBUTTONDOWN: case Sdl.SDL_MOUSEBUTTONDOWN:
{ {
if( pendingMotion != null ) if (pendingMotion != null)
{ {
inputHandler.OnMouseInput( pendingMotion.Value ); inputHandler.OnMouseInput(pendingMotion.Value);
pendingMotion = null; pendingMotion = null;
} }
var button = MakeButton( e.button.button ); var button = MakeButton(e.button.button);
lastButtonBits |= button; lastButtonBits |= button;
var pos = new int2( e.button.x, e.button.y ); var pos = new int2(e.button.x, e.button.y);
inputHandler.OnMouseInput(new MouseInput( inputHandler.OnMouseInput(new MouseInput(
MouseInputEvent.Down, button, pos, mods, MouseInputEvent.Down, button, pos, mods,
MultiTapDetection.DetectFromMouse(e.button.button, pos) MultiTapDetection.DetectFromMouse(e.button.button, pos)));
));
} break; break;
}
case Sdl.SDL_MOUSEBUTTONUP: case Sdl.SDL_MOUSEBUTTONUP:
{ {
if( pendingMotion != null ) if (pendingMotion != null)
{ {
inputHandler.OnMouseInput( pendingMotion.Value ); inputHandler.OnMouseInput(pendingMotion.Value);
pendingMotion = null; pendingMotion = null;
} }
var button = MakeButton( e.button.button ); var button = MakeButton(e.button.button);
lastButtonBits &= ~button; lastButtonBits &= ~button;
var pos = new int2( e.button.x, e.button.y ); var pos = new int2(e.button.x, e.button.y);
inputHandler.OnMouseInput(new MouseInput( inputHandler.OnMouseInput(new MouseInput(
MouseInputEvent.Up, button, pos, mods, MouseInputEvent.Up, button, pos, mods,
MultiTapDetection.InfoFromMouse(e.button.button) MultiTapDetection.InfoFromMouse(e.button.button)));
));
} break; break;
}
case Sdl.SDL_MOUSEMOTION: case Sdl.SDL_MOUSEMOTION:
{ {
pendingMotion = new MouseInput( pendingMotion = new MouseInput(
MouseInputEvent.Move, MouseInputEvent.Move, lastButtonBits,
lastButtonBits, new int2(e.motion.x, e.motion.y), mods, 0);
new int2( e.motion.x, e.motion.y ),
mods, 0 ); break;
} break; }
case Sdl.SDL_KEYDOWN: case Sdl.SDL_KEYDOWN:
{ {
var keyName = Sdl.SDL_GetKeyName( e.key.keysym.sym ); var keyName = Sdl.SDL_GetKeyName(e.key.keysym.sym);
var keyEvent = new KeyInput var keyEvent = new KeyInput
{ {
Event = KeyInputEvent.Down, Event = KeyInputEvent.Down,
Modifiers = mods, Modifiers = mods,
UnicodeChar = (char)e.key.keysym.unicode, UnicodeChar = (char)e.key.keysym.unicode,
KeyName = Sdl.SDL_GetKeyName( e.key.keysym.sym ), KeyName = Sdl.SDL_GetKeyName(e.key.keysym.sym),
VirtKey = e.key.keysym.sym, VirtKey = e.key.keysym.sym,
MultiTapCount = MultiTapDetection.DetectFromKeyboard(keyName) MultiTapCount = MultiTapDetection.DetectFromKeyboard(keyName)
}; };
if( !HandleSpecialKey( keyEvent ) ) if (!HandleSpecialKey(keyEvent))
inputHandler.OnKeyInput( keyEvent ); inputHandler.OnKeyInput(keyEvent);
} break;
break;
}
case Sdl.SDL_KEYUP: case Sdl.SDL_KEYUP:
{ {
var keyName = Sdl.SDL_GetKeyName( e.key.keysym.sym ); var keyName = Sdl.SDL_GetKeyName(e.key.keysym.sym);
var keyEvent = new KeyInput var keyEvent = new KeyInput
{ {
Event = KeyInputEvent.Up, Event = KeyInputEvent.Up,
Modifiers = mods, Modifiers = mods,
UnicodeChar = (char)e.key.keysym.unicode, UnicodeChar = (char)e.key.keysym.unicode,
KeyName = Sdl.SDL_GetKeyName( e.key.keysym.sym ), KeyName = Sdl.SDL_GetKeyName(e.key.keysym.sym),
VirtKey = e.key.keysym.sym, VirtKey = e.key.keysym.sym,
MultiTapCount = MultiTapDetection.InfoFromKeyboard(keyName) MultiTapCount = MultiTapDetection.InfoFromKeyboard(keyName)
}; };
inputHandler.OnKeyInput( keyEvent ); inputHandler.OnKeyInput(keyEvent);
} break; break;
}
} }
} }
if( pendingMotion != null ) if (pendingMotion != null)
{ {
inputHandler.OnMouseInput( pendingMotion.Value ); inputHandler.OnMouseInput(pendingMotion.Value);
pendingMotion = null; pendingMotion = null;
} }
ErrorHandler.CheckGlError(); ErrorHandler.CheckGlError();
} }
bool HandleSpecialKey( KeyInput k ) bool HandleSpecialKey(KeyInput k)
{ {
switch( k.VirtKey ) switch (k.VirtKey)
{ {
case Sdl.SDLK_F13: case Sdl.SDLK_F13:
var path = Environment.GetFolderPath( Environment.SpecialFolder.Personal ) var path = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
+ Path.DirectorySeparatorChar + DateTime.UtcNow.ToString( "OpenRA-yyyy-MM-ddThhmmssZ" ) + ".bmp"; + Path.DirectorySeparatorChar + DateTime.UtcNow.ToString("OpenRA-yyyy-MM-ddThhmmssZ") + ".bmp";
Sdl.SDL_SaveBMP( surface, path ); Sdl.SDL_SaveBMP(surface, path);
return true; return true;
case Sdl.SDLK_F4: case Sdl.SDLK_F4:
if( k.Modifiers.HasModifier( Modifiers.Alt ) ) if (k.Modifiers.HasModifier(Modifiers.Alt))
{ {
OpenRA.Game.Exit(); OpenRA.Game.Exit();
return true; return true;
} }
return false;
return false;
default: default:
return false; return false;
} }
} }
} }
} }

View File

@@ -84,14 +84,14 @@ namespace OpenRA.Renderer.SdlCommon
int height = colors.GetUpperBound(0) + 1; int height = colors.GetUpperBound(0) + 1;
if (!Exts.IsPowerOf2(width) || !Exts.IsPowerOf2(height)) if (!Exts.IsPowerOf2(width) || !Exts.IsPowerOf2(height))
throw new InvalidDataException("Non-power-of-two array {0}x{1}".F(width,height)); throw new InvalidDataException("Non-power-of-two array {0}x{1}".F(width, height));
size = new Size(width, height); size = new Size(width, height);
unsafe unsafe
{ {
fixed (uint* ptr = &colors[0,0]) fixed (uint* ptr = &colors[0, 0])
{ {
IntPtr intPtr = new IntPtr((void *) ptr); IntPtr intPtr = new IntPtr((void*)ptr);
PrepareTexture(); PrepareTexture();
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA8, width, height, Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA8, width, height,
0, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, intPtr); 0, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, intPtr);
@@ -107,8 +107,7 @@ namespace OpenRA.Renderer.SdlCommon
size = new Size(bitmap.Width, bitmap.Height); size = new Size(bitmap.Width, bitmap.Height);
var bits = bitmap.LockBits(bitmap.Bounds(), var bits = bitmap.LockBits(bitmap.Bounds(),
ImageLockMode.ReadOnly, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
PixelFormat.Format32bppArgb);
PrepareTexture(); PrepareTexture();
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA8, bits.Width, bits.Height, Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA8, bits.Width, bits.Height,
@@ -119,18 +118,20 @@ namespace OpenRA.Renderer.SdlCommon
public byte[] GetData() public byte[] GetData()
{ {
var data = new byte[4*size.Width * size.Height]; var data = new byte[4 * size.Width * size.Height];
ErrorHandler.CheckGlError(); ErrorHandler.CheckGlError();
Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture); Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture);
unsafe unsafe
{ {
fixed (byte *ptr = &data[0]) fixed (byte* ptr = &data[0])
{ {
IntPtr intPtr = new IntPtr((void*)ptr); IntPtr intPtr = new IntPtr((void*)ptr);
Gl.glGetTexImage(Gl.GL_TEXTURE_2D, 0, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, intPtr); Gl.glGetTexImage(Gl.GL_TEXTURE_2D, 0, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, intPtr);
} }
} }
ErrorHandler.CheckGlError();
return data; return data;
} }

View File

@@ -18,8 +18,8 @@ namespace OpenRA.Renderer.SdlCommon
public class VertexBuffer<T> : IVertexBuffer<T> public class VertexBuffer<T> : IVertexBuffer<T>
where T : struct where T : struct
{ {
static readonly int VertexSize = Marshal.SizeOf(typeof(T));
int buffer; int buffer;
static readonly int vertexSize = Marshal.SizeOf(typeof(T));
public VertexBuffer(int size) public VertexBuffer(int size)
{ {
@@ -27,8 +27,8 @@ namespace OpenRA.Renderer.SdlCommon
ErrorHandler.CheckGlError(); ErrorHandler.CheckGlError();
Bind(); Bind();
Gl.glBufferDataARB(Gl.GL_ARRAY_BUFFER_ARB, Gl.glBufferDataARB(Gl.GL_ARRAY_BUFFER_ARB,
new IntPtr(vertexSize * size), new IntPtr(VertexSize * size),
new T[ size ], new T[size],
Gl.GL_DYNAMIC_DRAW_ARB); Gl.GL_DYNAMIC_DRAW_ARB);
ErrorHandler.CheckGlError(); ErrorHandler.CheckGlError();
} }
@@ -38,7 +38,7 @@ namespace OpenRA.Renderer.SdlCommon
Bind(); Bind();
Gl.glBufferSubDataARB(Gl.GL_ARRAY_BUFFER_ARB, Gl.glBufferSubDataARB(Gl.GL_ARRAY_BUFFER_ARB,
IntPtr.Zero, IntPtr.Zero,
new IntPtr(vertexSize * length), new IntPtr(VertexSize * length),
data); data);
ErrorHandler.CheckGlError(); ErrorHandler.CheckGlError();
} }
@@ -47,13 +47,13 @@ namespace OpenRA.Renderer.SdlCommon
{ {
Gl.glBindBufferARB(Gl.GL_ARRAY_BUFFER_ARB, buffer); Gl.glBindBufferARB(Gl.GL_ARRAY_BUFFER_ARB, buffer);
ErrorHandler.CheckGlError(); ErrorHandler.CheckGlError();
Gl.glVertexPointer(3, Gl.GL_FLOAT, vertexSize, IntPtr.Zero); Gl.glVertexPointer(3, Gl.GL_FLOAT, VertexSize, IntPtr.Zero);
ErrorHandler.CheckGlError(); ErrorHandler.CheckGlError();
Gl.glTexCoordPointer(4, Gl.GL_FLOAT, vertexSize, new IntPtr(12)); Gl.glTexCoordPointer(4, Gl.GL_FLOAT, VertexSize, new IntPtr(12));
ErrorHandler.CheckGlError(); ErrorHandler.CheckGlError();
} }
void FinalizeInner() { Gl.glDeleteBuffersARB( 1, ref buffer ); } void FinalizeInner() { Gl.glDeleteBuffersARB(1, ref buffer); }
~VertexBuffer() { Game.RunAfterTick( FinalizeInner ); } ~VertexBuffer() { Game.RunAfterTick(FinalizeInner); }
} }
} }