gl context works
This commit is contained in:
@@ -1,22 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OpenRa.Gl
|
||||
using Tao.OpenGl;
|
||||
using Tao.Cg;
|
||||
using Tao.Platform.Windows;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenRa.GlRenderer
|
||||
{
|
||||
public class GraphicsDevice
|
||||
{
|
||||
public GraphicsDevice(Control host, int width, int height, bool fullscreen, bool vsync) { }
|
||||
public void EnableScissor(int left, int top, int width, int height) { }
|
||||
public void DisableScissor() { }
|
||||
Graphics g;
|
||||
IntPtr dc;
|
||||
IntPtr rc;
|
||||
|
||||
public GraphicsDevice(Control control, int width, int height, bool fullscreen, bool vsync)
|
||||
{
|
||||
g = control.CreateGraphics();
|
||||
dc = g.GetHdc();
|
||||
|
||||
var pfd = new Gdi.PIXELFORMATDESCRIPTOR
|
||||
{
|
||||
nSize = (short)Marshal.SizeOf(typeof(Gdi.PIXELFORMATDESCRIPTOR)),
|
||||
nVersion = 1,
|
||||
dwFlags = Gdi.PFD_SUPPORT_OPENGL | Gdi.PFD_DRAW_TO_BITMAP | Gdi.PFD_DOUBLEBUFFER,
|
||||
iPixelType = Gdi.PFD_TYPE_RGBA,
|
||||
cColorBits = 24,
|
||||
iLayerType = Gdi.PFD_MAIN_PLANE
|
||||
};
|
||||
|
||||
var iFormat = Gdi.ChoosePixelFormat(dc, ref pfd);
|
||||
Gdi.SetPixelFormat(dc, iFormat, ref pfd);
|
||||
|
||||
rc = Wgl.wglCreateContext(dc);
|
||||
if (rc == IntPtr.Zero)
|
||||
throw new InvalidOperationException("can't create wglcontext");
|
||||
Wgl.wglMakeCurrent(dc, rc);
|
||||
}
|
||||
|
||||
public void EnableScissor(int left, int top, int width, int height)
|
||||
{
|
||||
Gl.glScissor(left, top, width, height);
|
||||
Gl.glEnable(Gl.GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
public void DisableScissor()
|
||||
{
|
||||
Gl.glDisable(Gl.GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
public void Begin() { }
|
||||
public void End() { }
|
||||
public void Clear(Color c) { }
|
||||
public void Present() { }
|
||||
|
||||
public void Clear(Color c)
|
||||
{
|
||||
Gl.glClearColor(1, 1, 1, 1);
|
||||
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
public void Present()
|
||||
{
|
||||
Wgl.wglSwapBuffers(dc);
|
||||
}
|
||||
|
||||
public void DrawIndexedPrimitives(PrimitiveType pt, Range<int> vertices, Range<int> indices) { }
|
||||
public void DrawIndexedPrimitives(PrimitiveType pt, int numVerts, int numPrimitives) { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user