some of a glfw window
This commit is contained in:
@@ -30,6 +30,8 @@ using OpenRa.Network;
|
|||||||
using OpenRa.Support;
|
using OpenRa.Support;
|
||||||
using OpenRa.Traits;
|
using OpenRa.Traits;
|
||||||
using Timer = OpenRa.Support.Timer;
|
using Timer = OpenRa.Support.Timer;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace OpenRa
|
namespace OpenRa
|
||||||
{
|
{
|
||||||
@@ -285,7 +287,7 @@ namespace OpenRa
|
|||||||
return sp;
|
return sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void DispatchMouseInput(MouseInputEvent ev, MouseEventArgs e, Keys ModifierKeys)
|
public static void DispatchMouseInput(MouseInputEvent ev, MouseEventArgs e, Keys ModifierKeys)
|
||||||
{
|
{
|
||||||
int sync = Game.world.SyncHash();
|
int sync = Game.world.SyncHash();
|
||||||
|
|
||||||
@@ -302,7 +304,7 @@ namespace OpenRa
|
|||||||
throw new InvalidOperationException( "Desync in DispatchMouseInput" );
|
throw new InvalidOperationException( "Desync in DispatchMouseInput" );
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void HandleKeyDown( KeyEventArgs e )
|
public static void HandleKeyDown( KeyEventArgs e )
|
||||||
{
|
{
|
||||||
int sync = Game.world.SyncHash();
|
int sync = Game.world.SyncHash();
|
||||||
|
|
||||||
@@ -315,7 +317,7 @@ namespace OpenRa
|
|||||||
throw new InvalidOperationException( "Desync in OnKeyDown" );
|
throw new InvalidOperationException( "Desync in OnKeyDown" );
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void HandleKeyPress( KeyPressEventArgs e )
|
public static void HandleKeyPress( KeyPressEventArgs e )
|
||||||
{
|
{
|
||||||
int sync = Game.world.SyncHash();
|
int sync = Game.world.SyncHash();
|
||||||
|
|
||||||
@@ -327,5 +329,80 @@ namespace OpenRa
|
|||||||
if( sync != Game.world.SyncHash() )
|
if( sync != Game.world.SyncHash() )
|
||||||
throw new InvalidOperationException( "Desync in OnKeyPress" );
|
throw new InvalidOperationException( "Desync in OnKeyPress" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Size GetResolution(Settings settings)
|
||||||
|
{
|
||||||
|
var desktopResolution = Screen.PrimaryScreen.Bounds.Size;
|
||||||
|
if (Game.Settings.Width > 0 && Game.Settings.Height > 0)
|
||||||
|
{
|
||||||
|
desktopResolution.Width = Game.Settings.Width;
|
||||||
|
desktopResolution.Height = Game.Settings.Height;
|
||||||
|
}
|
||||||
|
return new Size(
|
||||||
|
desktopResolution.Width,
|
||||||
|
desktopResolution.Height);
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("user32")]
|
||||||
|
static extern int ShowCursor([MarshalAs(UnmanagedType.Bool)] bool visible);
|
||||||
|
|
||||||
|
public static void PreInit(Settings settings)
|
||||||
|
{
|
||||||
|
while (!File.Exists("redalert.mix"))
|
||||||
|
{
|
||||||
|
var current = Directory.GetCurrentDirectory();
|
||||||
|
if (Directory.GetDirectoryRoot(current) == current)
|
||||||
|
throw new InvalidOperationException("Unable to load MIX files.");
|
||||||
|
Directory.SetCurrentDirectory("..");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LoadUserSettings(settings);
|
||||||
|
Game.LobbyInfo.GlobalSettings.Mods = Game.Settings.InitialMods;
|
||||||
|
|
||||||
|
// Load the default mod to access required files
|
||||||
|
Game.LoadModPackages(new Manifest(Game.LobbyInfo.GlobalSettings.Mods));
|
||||||
|
|
||||||
|
UiOverlay.ShowUnitDebug = Game.Settings.UnitDebug;
|
||||||
|
WorldRenderer.ShowUnitPaths = Game.Settings.PathDebug;
|
||||||
|
Renderer.SheetSize = Game.Settings.SheetSize;
|
||||||
|
|
||||||
|
bool windowed = !Game.Settings.Fullscreen;
|
||||||
|
var resolution = GetResolution(settings);
|
||||||
|
renderer = new Renderer(resolution, windowed);
|
||||||
|
|
||||||
|
var controller = new Controller(() => (Modifiers)(int)0/*ModifierKeys*/); /* a bit of insane input routing */
|
||||||
|
|
||||||
|
Game.Initialize(Game.Settings.Map, renderer, new int2(resolution), Game.Settings.Player, controller);
|
||||||
|
|
||||||
|
ShowCursor(false);
|
||||||
|
Game.ResetTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void LoadUserSettings(Settings settings)
|
||||||
|
{
|
||||||
|
Game.Settings = new UserSettings();
|
||||||
|
var settingsFile = settings.GetValue("settings", "settings.ini");
|
||||||
|
FileSystem.Mount("./");
|
||||||
|
if (FileSystem.Exists(settingsFile))
|
||||||
|
FieldLoader.Load(Game.Settings,
|
||||||
|
new IniFile(FileSystem.Open(settingsFile)).GetSection("Settings"));
|
||||||
|
FileSystem.UnmountAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool quit;
|
||||||
|
internal static void Run()
|
||||||
|
{
|
||||||
|
while (!quit)
|
||||||
|
{
|
||||||
|
Game.Tick();
|
||||||
|
Application.DoEvents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Exit()
|
||||||
|
{
|
||||||
|
quit = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,10 +49,9 @@ namespace OpenRa.Graphics
|
|||||||
SpriteRenderer rgbaRenderer;
|
SpriteRenderer rgbaRenderer;
|
||||||
Sprite textSprite;
|
Sprite textSprite;
|
||||||
|
|
||||||
public Renderer(Control control, Size resolution, bool windowed)
|
public Renderer(Size resolution, bool windowed)
|
||||||
{
|
{
|
||||||
control.ClientSize = resolution;
|
device = CreateDevice( Assembly.LoadFile( Path.GetFullPath( "OpenRa.Gl.dll" ) ), resolution.Width, resolution.Height, windowed, false );
|
||||||
device = CreateDevice( Assembly.LoadFile( Path.GetFullPath( "OpenRa.Gl.dll" ) ), control, resolution.Width, resolution.Height, windowed, false );
|
|
||||||
|
|
||||||
SpriteShader = device.CreateShader(FileSystem.Open("world-shp.fx"));
|
SpriteShader = device.CreateShader(FileSystem.Open("world-shp.fx"));
|
||||||
LineShader = device.CreateShader(FileSystem.Open("line.fx"));
|
LineShader = device.CreateShader(FileSystem.Open("line.fx"));
|
||||||
@@ -66,12 +65,12 @@ namespace OpenRa.Graphics
|
|||||||
textSprite = new Sprite(textSheet, new Rectangle(0, 0, 256, 256), TextureChannel.Alpha);
|
textSprite = new Sprite(textSheet, new Rectangle(0, 0, 256, 256), TextureChannel.Alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
IGraphicsDevice CreateDevice( Assembly rendererDll, Control control, int width, int height, bool fullscreen, bool vsync )
|
IGraphicsDevice CreateDevice( Assembly rendererDll, int width, int height, bool fullscreen, bool vsync )
|
||||||
{
|
{
|
||||||
foreach( RendererAttribute r in rendererDll.GetCustomAttributes( typeof( RendererAttribute ), false ) )
|
foreach( RendererAttribute r in rendererDll.GetCustomAttributes( typeof( RendererAttribute ), false ) )
|
||||||
{
|
{
|
||||||
return (IGraphicsDevice)r.Type.GetConstructor( new Type[] { typeof( Control ), typeof( int ), typeof( int ), typeof( bool ), typeof( bool ) } )
|
return (IGraphicsDevice)r.Type.GetConstructor( new Type[] { typeof( int ), typeof( int ), typeof( bool ), typeof( bool ) } )
|
||||||
.Invoke( new object[] { control, width, height, fullscreen, vsync } );
|
.Invoke( new object[] { width, height, fullscreen, vsync } );
|
||||||
}
|
}
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,128 +29,128 @@ using OpenRa.Graphics;
|
|||||||
|
|
||||||
namespace OpenRa
|
namespace OpenRa
|
||||||
{
|
{
|
||||||
class MainWindow : Form
|
//class MainWindow : Form
|
||||||
{
|
//{
|
||||||
readonly Renderer renderer;
|
// readonly Renderer renderer;
|
||||||
|
|
||||||
static Size GetResolution(Settings settings)
|
// static Size GetResolution(Settings settings)
|
||||||
{
|
// {
|
||||||
var desktopResolution = Screen.PrimaryScreen.Bounds.Size;
|
// var desktopResolution = Screen.PrimaryScreen.Bounds.Size;
|
||||||
if (Game.Settings.Width > 0 && Game.Settings.Height > 0)
|
// if (Game.Settings.Width > 0 && Game.Settings.Height > 0)
|
||||||
{
|
// {
|
||||||
desktopResolution.Width = Game.Settings.Width;
|
// desktopResolution.Width = Game.Settings.Width;
|
||||||
desktopResolution.Height = Game.Settings.Height;
|
// desktopResolution.Height = Game.Settings.Height;
|
||||||
}
|
// }
|
||||||
return new Size(
|
// return new Size(
|
||||||
desktopResolution.Width,
|
// desktopResolution.Width,
|
||||||
desktopResolution.Height);
|
// desktopResolution.Height);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[DllImport("user32")]
|
// [DllImport("user32")]
|
||||||
static extern int ShowCursor([MarshalAs(UnmanagedType.Bool)] bool visible);
|
// static extern int ShowCursor([MarshalAs(UnmanagedType.Bool)] bool visible);
|
||||||
|
|
||||||
public MainWindow(Settings settings)
|
// public MainWindow(Settings settings)
|
||||||
{
|
// {
|
||||||
Icon = Resources1.OpenRA;
|
// Icon = Resources1.OpenRA;
|
||||||
FormBorderStyle = FormBorderStyle.None;
|
// FormBorderStyle = FormBorderStyle.None;
|
||||||
BackColor = Color.Black;
|
// BackColor = Color.Black;
|
||||||
StartPosition = FormStartPosition.Manual;
|
// StartPosition = FormStartPosition.Manual;
|
||||||
Location = Point.Empty;
|
// Location = Point.Empty;
|
||||||
Visible = true;
|
// Visible = true;
|
||||||
|
|
||||||
while (!File.Exists("redalert.mix"))
|
// while (!File.Exists("redalert.mix"))
|
||||||
{
|
// {
|
||||||
var current = Directory.GetCurrentDirectory();
|
// var current = Directory.GetCurrentDirectory();
|
||||||
if (Directory.GetDirectoryRoot(current) == current)
|
// if (Directory.GetDirectoryRoot(current) == current)
|
||||||
throw new InvalidOperationException("Unable to load MIX files.");
|
// throw new InvalidOperationException("Unable to load MIX files.");
|
||||||
Directory.SetCurrentDirectory("..");
|
// Directory.SetCurrentDirectory("..");
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
LoadUserSettings(settings);
|
// LoadUserSettings(settings);
|
||||||
Game.LobbyInfo.GlobalSettings.Mods = Game.Settings.InitialMods;
|
// Game.LobbyInfo.GlobalSettings.Mods = Game.Settings.InitialMods;
|
||||||
|
|
||||||
// Load the default mod to access required files
|
// // Load the default mod to access required files
|
||||||
Game.LoadModPackages(new Manifest(Game.LobbyInfo.GlobalSettings.Mods));
|
// Game.LoadModPackages(new Manifest(Game.LobbyInfo.GlobalSettings.Mods));
|
||||||
|
|
||||||
UiOverlay.ShowUnitDebug = Game.Settings.UnitDebug;
|
// UiOverlay.ShowUnitDebug = Game.Settings.UnitDebug;
|
||||||
WorldRenderer.ShowUnitPaths = Game.Settings.PathDebug;
|
// WorldRenderer.ShowUnitPaths = Game.Settings.PathDebug;
|
||||||
Renderer.SheetSize = Game.Settings.SheetSize;
|
// Renderer.SheetSize = Game.Settings.SheetSize;
|
||||||
|
|
||||||
bool windowed = !Game.Settings.Fullscreen;
|
// bool windowed = !Game.Settings.Fullscreen;
|
||||||
renderer = new Renderer(this, GetResolution(settings), windowed);
|
// renderer = new Renderer(this, GetResolution(settings), windowed);
|
||||||
|
|
||||||
var controller = new Controller(() => (Modifiers)(int)ModifierKeys); /* a bit of insane input routing */
|
// var controller = new Controller(() => (Modifiers)(int)ModifierKeys); /* a bit of insane input routing */
|
||||||
|
|
||||||
Game.Initialize(Game.Settings.Map, renderer, new int2(ClientSize), Game.Settings.Player, controller);
|
// Game.Initialize(Game.Settings.Map, renderer, new int2(ClientSize), Game.Settings.Player, controller);
|
||||||
|
|
||||||
ShowCursor(false);
|
// ShowCursor(false);
|
||||||
Game.ResetTimer();
|
// Game.ResetTimer();
|
||||||
}
|
// }
|
||||||
|
|
||||||
static void LoadUserSettings(Settings settings)
|
// static void LoadUserSettings(Settings settings)
|
||||||
{
|
// {
|
||||||
Game.Settings = new UserSettings();
|
// Game.Settings = new UserSettings();
|
||||||
var settingsFile = settings.GetValue("settings", "settings.ini");
|
// var settingsFile = settings.GetValue("settings", "settings.ini");
|
||||||
FileSystem.Mount("./");
|
// FileSystem.Mount("./");
|
||||||
if (FileSystem.Exists(settingsFile))
|
// if (FileSystem.Exists(settingsFile))
|
||||||
FieldLoader.Load(Game.Settings,
|
// FieldLoader.Load(Game.Settings,
|
||||||
new IniFile(FileSystem.Open(settingsFile)).GetSection("Settings"));
|
// new IniFile(FileSystem.Open(settingsFile)).GetSection("Settings"));
|
||||||
FileSystem.UnmountAll();
|
// FileSystem.UnmountAll();
|
||||||
}
|
// }
|
||||||
|
|
||||||
internal void Run()
|
// internal void Run()
|
||||||
{
|
// {
|
||||||
while (Created && Visible)
|
// while (Created && Visible)
|
||||||
{
|
// {
|
||||||
Game.Tick();
|
// Game.Tick();
|
||||||
Application.DoEvents();
|
// Application.DoEvents();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
int2 lastPos;
|
// int2 lastPos;
|
||||||
|
|
||||||
protected override void OnMouseDown(MouseEventArgs e)
|
// protected override void OnMouseDown(MouseEventArgs e)
|
||||||
{
|
// {
|
||||||
base.OnMouseDown(e);
|
// base.OnMouseDown(e);
|
||||||
lastPos = new int2(e.Location);
|
// lastPos = new int2(e.Location);
|
||||||
Game.DispatchMouseInput(MouseInputEvent.Down, e, ModifierKeys);
|
// Game.DispatchMouseInput(MouseInputEvent.Down, e, ModifierKeys);
|
||||||
}
|
// }
|
||||||
|
|
||||||
protected override void OnMouseMove(MouseEventArgs e)
|
// protected override void OnMouseMove(MouseEventArgs e)
|
||||||
{
|
// {
|
||||||
base.OnMouseMove(e);
|
// base.OnMouseMove(e);
|
||||||
|
|
||||||
if (e.Button == MouseButtons.Middle || e.Button == (MouseButtons.Left | MouseButtons.Right))
|
// if (e.Button == MouseButtons.Middle || e.Button == (MouseButtons.Left | MouseButtons.Right))
|
||||||
{
|
// {
|
||||||
int2 p = new int2(e.Location);
|
// int2 p = new int2(e.Location);
|
||||||
Game.viewport.Scroll(lastPos - p);
|
// Game.viewport.Scroll(lastPos - p);
|
||||||
lastPos = p;
|
// lastPos = p;
|
||||||
}
|
// }
|
||||||
|
|
||||||
Game.DispatchMouseInput(MouseInputEvent.Move, e, ModifierKeys);
|
// Game.DispatchMouseInput(MouseInputEvent.Move, e, ModifierKeys);
|
||||||
}
|
// }
|
||||||
|
|
||||||
protected override void OnMouseUp(MouseEventArgs e)
|
// protected override void OnMouseUp(MouseEventArgs e)
|
||||||
{
|
// {
|
||||||
base.OnMouseUp(e);
|
// base.OnMouseUp(e);
|
||||||
Game.DispatchMouseInput(MouseInputEvent.Up, e, ModifierKeys);
|
// Game.DispatchMouseInput(MouseInputEvent.Up, e, ModifierKeys);
|
||||||
}
|
// }
|
||||||
|
|
||||||
protected override void OnKeyDown(KeyEventArgs e)
|
// protected override void OnKeyDown(KeyEventArgs e)
|
||||||
{
|
// {
|
||||||
base.OnKeyDown(e);
|
// base.OnKeyDown(e);
|
||||||
|
|
||||||
Game.HandleKeyDown( e );
|
// Game.HandleKeyDown( e );
|
||||||
}
|
// }
|
||||||
|
|
||||||
protected override void OnKeyPress(KeyPressEventArgs e)
|
// protected override void OnKeyPress(KeyPressEventArgs e)
|
||||||
{
|
// {
|
||||||
base.OnKeyPress(e);
|
// base.OnKeyPress(e);
|
||||||
|
|
||||||
Game.HandleKeyPress( e );
|
// Game.HandleKeyPress( e );
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum MouseButton
|
public enum MouseButton
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ namespace OpenRa
|
|||||||
|
|
||||||
static void Run( string[] args )
|
static void Run( string[] args )
|
||||||
{
|
{
|
||||||
new MainWindow( new Settings( args ) ).Run();
|
Game.PreInit( new Settings( args ) );
|
||||||
|
Game.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@ using System.Text.RegularExpressions;
|
|||||||
|
|
||||||
namespace OpenRa
|
namespace OpenRa
|
||||||
{
|
{
|
||||||
class Settings
|
public class Settings
|
||||||
{
|
{
|
||||||
Dictionary<string, string> settings = new Dictionary<string, string>();
|
Dictionary<string, string> settings = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ using Tao.Cg;
|
|||||||
using Tao.OpenGl;
|
using Tao.OpenGl;
|
||||||
using Tao.Platform.Windows;
|
using Tao.Platform.Windows;
|
||||||
using OpenRa.FileFormats.Graphics;
|
using OpenRa.FileFormats.Graphics;
|
||||||
|
using Tao.Glfw;
|
||||||
|
|
||||||
[assembly: Renderer( typeof( OpenRa.GlRenderer.GraphicsDevice ))]
|
[assembly: Renderer( typeof( OpenRa.GlRenderer.GraphicsDevice ))]
|
||||||
|
|
||||||
@@ -36,56 +37,63 @@ namespace OpenRa.GlRenderer
|
|||||||
public class GraphicsDevice : IGraphicsDevice
|
public class GraphicsDevice : IGraphicsDevice
|
||||||
{
|
{
|
||||||
Size windowSize;
|
Size windowSize;
|
||||||
Graphics g;
|
|
||||||
internal IntPtr dc;
|
|
||||||
internal IntPtr rc;
|
|
||||||
internal IntPtr cgContext;
|
internal IntPtr cgContext;
|
||||||
internal int vertexProfile, fragmentProfile;
|
internal int vertexProfile, fragmentProfile;
|
||||||
|
|
||||||
|
readonly Glfw.GLFWmousebuttonfun mouseButtonCallback;
|
||||||
|
readonly Glfw.GLFWmouseposfun mousePositionCallback;
|
||||||
|
readonly Glfw.GLFWwindowclosefun windowCloseCallback;
|
||||||
|
int mouseX, mouseY;
|
||||||
|
|
||||||
internal static void CheckGlError()
|
internal static void CheckGlError()
|
||||||
{
|
{
|
||||||
var n = Gl.glGetError();
|
var n = Gl.glGetError();
|
||||||
if (n != Gl.GL_NO_ERROR)
|
if (n != Gl.GL_NO_ERROR)
|
||||||
throw new InvalidOperationException("GL Error");
|
throw new InvalidOperationException("GL Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
public GraphicsDevice(Control control, int width, int height, bool fullscreen, bool vsync)
|
public GraphicsDevice( int width, int height, bool fullscreen, bool vsync )
|
||||||
{
|
{
|
||||||
|
Glfw.glfwInit();
|
||||||
|
Glfw.glfwOpenWindow( width, height, 0, 0, 0, 0, 0, 0, /*fullscreen ? Glfw.GLFW_FULLSCREEN :*/ Glfw.GLFW_WINDOW );
|
||||||
|
Glfw.glfwSetMouseButtonCallback( mouseButtonCallback = ( button, action ) =>
|
||||||
|
{
|
||||||
|
var b = button == Glfw.GLFW_MOUSE_BUTTON_1 ? MouseButtons.Left
|
||||||
|
: button == Glfw.GLFW_MOUSE_BUTTON_2 ? MouseButtons.Right
|
||||||
|
: button == Glfw.GLFW_MOUSE_BUTTON_3 ? MouseButtons.Middle
|
||||||
|
: 0;
|
||||||
|
Game.DispatchMouseInput( action == Glfw.GLFW_PRESS ? MouseInputEvent.Down : MouseInputEvent.Up,
|
||||||
|
new MouseEventArgs( b, action == Glfw.GLFW_PRESS ? 1 : 0, mouseX, mouseY, 0 ), 0 );
|
||||||
|
} );
|
||||||
|
//Glfw.glfwSetMousePosCallback( mousePositionCallback = ( x, y ) =>
|
||||||
|
// {
|
||||||
|
// mouseX = x;
|
||||||
|
// mouseY = y;
|
||||||
|
// Game.DispatchMouseInput( MouseInputEvent.Move, new MouseEventArgs( 0, 0, x, y, 0 ), 0 );
|
||||||
|
// } );
|
||||||
|
Glfw.glfwSetWindowCloseCallback( windowCloseCallback = () =>
|
||||||
|
{
|
||||||
|
Game.Exit();
|
||||||
|
Glfw.glfwIconifyWindow();
|
||||||
|
return Gl.GL_FALSE;
|
||||||
|
} );
|
||||||
|
CheckGlError();
|
||||||
|
|
||||||
windowSize = new Size( width, height );
|
windowSize = new Size( width, height );
|
||||||
g = control.CreateGraphics();
|
|
||||||
dc = g.GetHdc();
|
|
||||||
|
|
||||||
var pfd = new Gdi.PIXELFORMATDESCRIPTOR
|
cgContext = Cg.cgCreateContext();
|
||||||
{
|
Cg.cgSetErrorCallback( CgErrorCallback );
|
||||||
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);
|
CgGl.cgGLRegisterStates( cgContext );
|
||||||
Gdi.SetPixelFormat(dc, iFormat, ref pfd);
|
CgGl.cgGLSetManageTextureParameters( cgContext, true );
|
||||||
|
vertexProfile = CgGl.cgGLGetLatestProfile( CgGl.CG_GL_VERTEX );
|
||||||
|
fragmentProfile = CgGl.cgGLGetLatestProfile( CgGl.CG_GL_FRAGMENT );
|
||||||
|
|
||||||
rc = Wgl.wglCreateContext(dc);
|
Gl.glEnableClientState( Gl.GL_VERTEX_ARRAY );
|
||||||
if (rc == IntPtr.Zero)
|
CheckGlError();
|
||||||
throw new InvalidOperationException("can't create wglcontext");
|
Gl.glEnableClientState( Gl.GL_TEXTURE_COORD_ARRAY );
|
||||||
Wgl.wglMakeCurrent(dc, rc);
|
CheckGlError();
|
||||||
|
}
|
||||||
cgContext = Cg.cgCreateContext();
|
|
||||||
Cg.cgSetErrorCallback(CgErrorCallback);
|
|
||||||
|
|
||||||
CgGl.cgGLRegisterStates(cgContext);
|
|
||||||
CgGl.cgGLSetManageTextureParameters(cgContext, true);
|
|
||||||
vertexProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_VERTEX);
|
|
||||||
fragmentProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_FRAGMENT);
|
|
||||||
|
|
||||||
Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
|
|
||||||
CheckGlError();
|
|
||||||
Gl.glEnableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
|
|
||||||
CheckGlError();
|
|
||||||
}
|
|
||||||
|
|
||||||
static Cg.CGerrorCallbackFuncDelegate CgErrorCallback = () =>
|
static Cg.CGerrorCallbackFuncDelegate CgErrorCallback = () =>
|
||||||
{
|
{
|
||||||
@@ -124,7 +132,7 @@ namespace OpenRa.GlRenderer
|
|||||||
|
|
||||||
public void Present()
|
public void Present()
|
||||||
{
|
{
|
||||||
Wgl.wglSwapBuffers(dc);
|
Glfw.glfwSwapBuffers();
|
||||||
CheckGlError();
|
CheckGlError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
<Reference Include="Tao.Cg, Version=2.0.0.0, Culture=neutral, PublicKeyToken=52fa5aba625fe731, processorArchitecture=MSIL">
|
<Reference Include="Tao.Cg, Version=2.0.0.0, Culture=neutral, PublicKeyToken=52fa5aba625fe731, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<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.OpenGl, Version=2.1.0.12, Culture=neutral, PublicKeyToken=1ca010269a4501ef, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
</Reference>
|
</Reference>
|
||||||
@@ -64,6 +65,10 @@
|
|||||||
<Project>{BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}</Project>
|
<Project>{BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}</Project>
|
||||||
<Name>OpenRa.FileFormats</Name>
|
<Name>OpenRa.FileFormats</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\OpenRa.Game\OpenRa.Game.csproj">
|
||||||
|
<Project>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</Project>
|
||||||
|
<Name>OpenRa.Game</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
|||||||
Reference in New Issue
Block a user