gl context works
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -18,3 +18,8 @@ sheet-*.png
|
||||
log.txt
|
||||
|
||||
/replay.rep
|
||||
|
||||
# dependency DLLs (different for every platform!)
|
||||
cg.dll
|
||||
cgGL.dll
|
||||
glfw.dll
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.Drawing;
|
||||
using OpenRa.Gl;
|
||||
using OpenRa.GlRenderer;
|
||||
|
||||
namespace OpenRa.Graphics
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Xml;
|
||||
using System.Drawing;
|
||||
using OpenRa.Gl;
|
||||
using OpenRa.GlRenderer;
|
||||
using System.IO;
|
||||
namespace OpenRa.Graphics
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using OpenRa.Gl;
|
||||
using OpenRa.GlRenderer;
|
||||
using OpenRa.FileFormats;
|
||||
using OpenRa.Support;
|
||||
|
||||
@@ -22,10 +22,10 @@ namespace OpenRa.Graphics
|
||||
//readonly SpriteHelper sh;
|
||||
//readonly FontHelper fhDebug, fhTitle;
|
||||
|
||||
public Renderer(Control host, Size resolution, bool windowed)
|
||||
public Renderer(Control control, Size resolution, bool windowed)
|
||||
{
|
||||
host.ClientSize = resolution;
|
||||
device = new GraphicsDevice(host, resolution.Width, resolution.Height, windowed, false);
|
||||
control.ClientSize = resolution;
|
||||
device = new GraphicsDevice(control, resolution.Width, resolution.Height, windowed, false);
|
||||
|
||||
SpriteShader = new Shader(device, FileSystem.Open("world-shp.fx"));
|
||||
SpriteShader.Quality = ShaderQuality.Low;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.Drawing;
|
||||
using OpenRa.Gl;
|
||||
using OpenRa.GlRenderer;
|
||||
using OpenRa.FileFormats;
|
||||
|
||||
namespace OpenRa.Graphics
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using OpenRa.Gl;
|
||||
using OpenRa.GlRenderer;
|
||||
|
||||
namespace OpenRa.Graphics
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.Drawing;
|
||||
using OpenRa.Gl;
|
||||
using OpenRa.GlRenderer;
|
||||
using IjwFramework.Collections;
|
||||
using OpenRa.FileFormats;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using OpenRa.Gl;
|
||||
using OpenRa.GlRenderer;
|
||||
|
||||
namespace OpenRa.Graphics
|
||||
{
|
||||
|
||||
@@ -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) { }
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<ProjectGuid>{67CF1A10-C5F6-48FA-B1A7-FE83BE4CE2CC}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>OpenRa.Gl</RootNamespace>
|
||||
<RootNamespace>OpenRa.GlRenderer</RootNamespace>
|
||||
<AssemblyName>OpenRa.Gl</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
@@ -48,6 +48,7 @@
|
||||
<Reference Include="Tao.Cg, Version=2.0.0.0, Culture=neutral, PublicKeyToken=52fa5aba625fe731, processorArchitecture=MSIL" />
|
||||
<Reference Include="Tao.Glfw, Version=2.6.0.0, Culture=neutral, PublicKeyToken=2bb092b6587e4402, processorArchitecture=MSIL" />
|
||||
<Reference Include="Tao.OpenGl, Version=2.1.0.12, Culture=neutral, PublicKeyToken=1ca010269a4501ef, processorArchitecture=MSIL" />
|
||||
<Reference Include="Tao.Platform.Windows, Version=1.0.0.5, Culture=neutral, PublicKeyToken=701104b2da67a104, processorArchitecture=MSIL" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="GraphicsDevice.cs" />
|
||||
|
||||
Reference in New Issue
Block a user