Permalink
Browse files

port GL GraphicsDevice to OpenTK

  • Loading branch information...
Mailaender committed Sep 12, 2012
1 parent a3a6f22 commit ce2f260a34487f62f72e93d7acb74d61a49f6013
Showing with 11 additions and 7 deletions.
  1. +11 −7 OpenRA.Renderer.Gl/GraphicsDevice.cs
@@ -14,7 +14,7 @@
using OpenRA.Renderer.SdlCommon;
using OpenTK;
using OpenTK.Compatibility;
-using Tao.OpenGl;
+using OpenTK.Graphics.OpenGL;
using Tao.Sdl;
[assembly: Renderer(typeof(OpenRA.Renderer.Glsl.DeviceFactory))]
@@ -50,10 +50,14 @@ public GraphicsDevice(Size size, WindowMode window)
};
surf = SdlGraphics.InitializeSdlGl(ref windowSize, window, extensions);
+ OpenTK.Graphics.GraphicsContext dummyContext = OpenTK.Graphics.GraphicsContext.CreateDummyContext(new OpenTK.ContextHandle(surf));
+ OpenTK.Platform.IWindowInfo windowInfo = OpenTK.Platform.Utilities.CreateDummyWindowInfo();
+ dummyContext.MakeCurrent(windowInfo);
+ OpenTK.Graphics.OpenGL.GL.LoadAll();
- Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
+ GL.EnableClientState(ArrayCap.VertexArray);
ErrorHandler.CheckGlError();
- Gl.glEnableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
+ GL.EnableClientState(ArrayCap.TextureCoordArray);
ErrorHandler.CheckGlError();
Sdl.SDL_SetModState(0);
@@ -66,15 +70,15 @@ public void EnableScissor(int left, int top, int width, int height)
if (width < 0) width = 0;
if (height < 0) height = 0;
- Gl.glScissor(left, windowSize.Height - ( top + height ), width, height);
+ GL.Scissor(left, windowSize.Height - ( top + height ), width, height);
ErrorHandler.CheckGlError();
- Gl.glEnable(Gl.GL_SCISSOR_TEST);
+ GL.Enable(EnableCap.ScissorTest);
ErrorHandler.CheckGlError();
}
public void DisableScissor()
{
- Gl.glDisable(Gl.GL_SCISSOR_TEST);
+ GL.Disable(EnableCap.ScissorTest);
ErrorHandler.CheckGlError();
}
@@ -89,7 +93,7 @@ public void DrawPrimitives(PrimitiveType pt, int firstVertex, int numVertices)
public void SetLineWidth( float width )
{
- Gl.glLineWidth(width);
+ GL.LineWidth(width);
ErrorHandler.CheckGlError();
}

0 comments on commit ce2f260

Please sign in to comment.