hack around crash in glfw with events before we're done with setup

This commit is contained in:
Chris Forbes
2010-02-17 23:56:08 +13:00
parent 5637b0dc43
commit 998572a589
2 changed files with 13 additions and 9 deletions

View File

@@ -166,7 +166,6 @@
<Compile Include="Graphics\SheetBuilder.cs" /> <Compile Include="Graphics\SheetBuilder.cs" />
<Compile Include="Graphics\HardwarePalette.cs" /> <Compile Include="Graphics\HardwarePalette.cs" />
<Compile Include="MainWindow.cs"> <Compile Include="MainWindow.cs">
<SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Support\Program.cs" /> <Compile Include="Support\Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />

View File

@@ -55,7 +55,9 @@ namespace OpenRa.GlRenderer
public GraphicsDevice( int width, int height, bool fullscreen, bool vsync ) public GraphicsDevice( int width, int height, bool fullscreen, bool vsync )
{ {
Glfw.glfwInit(); Glfw.glfwInit();
Glfw.glfwOpenWindow( width, height, 0, 0, 0, 0, 0, 0, /*fullscreen ? Glfw.GLFW_FULLSCREEN :*/ Glfw.GLFW_WINDOW ); Glfw.glfwOpenWindow(width, height, 0, 0, 0, 0, 0, 0, /*fullscreen ? Glfw.GLFW_FULLSCREEN :*/ Glfw.GLFW_WINDOW);
Glfw.glfwSetWindowTitle("OpenRA (OpenGL version)");
bool initDone = false;
Glfw.glfwSetMouseButtonCallback( mouseButtonCallback = ( button, action ) => Glfw.glfwSetMouseButtonCallback( mouseButtonCallback = ( button, action ) =>
{ {
var b = button == Glfw.GLFW_MOUSE_BUTTON_1 ? MouseButtons.Left var b = button == Glfw.GLFW_MOUSE_BUTTON_1 ? MouseButtons.Left
@@ -65,17 +67,18 @@ namespace OpenRa.GlRenderer
Game.DispatchMouseInput( action == Glfw.GLFW_PRESS ? MouseInputEvent.Down : MouseInputEvent.Up, Game.DispatchMouseInput( action == Glfw.GLFW_PRESS ? MouseInputEvent.Down : MouseInputEvent.Up,
new MouseEventArgs( b, action == Glfw.GLFW_PRESS ? 1 : 0, mouseX, mouseY, 0 ), 0 ); new MouseEventArgs( b, action == Glfw.GLFW_PRESS ? 1 : 0, mouseX, mouseY, 0 ), 0 );
} ); } );
//Glfw.glfwSetMousePosCallback( mousePositionCallback = ( x, y ) => Glfw.glfwSetMousePosCallback(mousePositionCallback = (x, y) =>
// { {
// mouseX = x; mouseX = x;
// mouseY = y; mouseY = y;
// Game.DispatchMouseInput( MouseInputEvent.Move, new MouseEventArgs( 0, 0, x, y, 0 ), 0 ); if (initDone)
// } ); Game.DispatchMouseInput(MouseInputEvent.Move, new MouseEventArgs(0, 0, x, y, 0), 0);
});
Glfw.glfwSetWindowCloseCallback( windowCloseCallback = () => Glfw.glfwSetWindowCloseCallback( windowCloseCallback = () =>
{ {
Game.Exit(); Game.Exit();
Glfw.glfwIconifyWindow(); Glfw.glfwIconifyWindow();
return Gl.GL_FALSE; return Gl.GL_TRUE;
} ); } );
CheckGlError(); CheckGlError();
@@ -93,6 +96,8 @@ namespace OpenRa.GlRenderer
CheckGlError(); CheckGlError();
Gl.glEnableClientState( Gl.GL_TEXTURE_COORD_ARRAY ); Gl.glEnableClientState( Gl.GL_TEXTURE_COORD_ARRAY );
CheckGlError(); CheckGlError();
initDone = true;
} }
static Cg.CGerrorCallbackFuncDelegate CgErrorCallback = () => static Cg.CGerrorCallbackFuncDelegate CgErrorCallback = () =>