mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-09 12:55:26 +00:00
Updated documentation on the *GLNative classes. X11/X11GLNative.cs now doesn't create a render window during the constructor call, but rather when CreateWindow is called explicitly.
This commit is contained in:
parent
8e440de4ac
commit
519b432cd7
|
@ -33,7 +33,8 @@ namespace OpenTK.Platform.Windows
|
||||||
#region --- Contructors ---
|
#region --- Contructors ---
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs a new WinGLNative window, using safe defaults for the DisplayMode.
|
/// Constructs a new WinGLNative class. Call CreateWindow to create the
|
||||||
|
/// actual render window.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public WinGLNative()
|
public WinGLNative()
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,12 +37,12 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
#region --- Public Constructor ---
|
#region --- Public Constructor ---
|
||||||
|
|
||||||
private X11GLContext()
|
internal X11GLContext()
|
||||||
{
|
{
|
||||||
this.mode = new DisplayMode();
|
this.mode = new DisplayMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public X11GLContext(IWindowInfo info, DisplayMode mode)
|
internal X11GLContext(IWindowInfo info, DisplayMode mode)
|
||||||
{
|
{
|
||||||
X11WindowInfo xInfo = info as X11WindowInfo;
|
X11WindowInfo xInfo = info as X11WindowInfo;
|
||||||
this.windowInfo.Window = xInfo.Window;
|
this.windowInfo.Window = xInfo.Window;
|
||||||
|
@ -54,32 +54,6 @@ namespace OpenTK.Platform.X11
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public X11GLContext(
|
|
||||||
IntPtr handle,
|
|
||||||
IntPtr display,
|
|
||||||
IntPtr rootWindow,
|
|
||||||
int screenNo,
|
|
||||||
IntPtr handleToTopLevelControl,
|
|
||||||
ColorDepth color,
|
|
||||||
ColorDepth accum,
|
|
||||||
int depthBits,
|
|
||||||
int stencilBits,
|
|
||||||
int auxBits,
|
|
||||||
bool stereo,
|
|
||||||
bool doublebuffer
|
|
||||||
)
|
|
||||||
{
|
|
||||||
Trace.WriteLine("Creating opengl context (X11GLContext driver)");
|
|
||||||
Trace.Indent();
|
|
||||||
|
|
||||||
this.display = display;
|
|
||||||
this.screenNo = screenNo;
|
|
||||||
//this.depthBits = depthBits;
|
|
||||||
//this.stencilBits = stencilBits;
|
|
||||||
|
|
||||||
this.CreateVisual();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- IGLContext Members ---
|
#region --- IGLContext Members ---
|
||||||
|
@ -210,8 +184,8 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
public void CreateVisual()
|
public void CreateVisual()
|
||||||
{
|
{
|
||||||
Trace.WriteLine("Creating visual.");
|
Debug.WriteLine("Creating visual.");
|
||||||
Trace.Indent();
|
Debug.Indent();
|
||||||
|
|
||||||
ColorDepth color = new ColorDepth(24);
|
ColorDepth color = new ColorDepth(24);
|
||||||
int depthBits = 16;
|
int depthBits = 16;
|
||||||
|
@ -248,7 +222,7 @@ namespace OpenTK.Platform.X11
|
||||||
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DOUBLEBUFFER);
|
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DOUBLEBUFFER);
|
||||||
visualAttributes.Add((int)Glx.Enums.GLXAttribute.NONE);
|
visualAttributes.Add((int)Glx.Enums.GLXAttribute.NONE);
|
||||||
*/
|
*/
|
||||||
Trace.Write(
|
Debug.Write(
|
||||||
String.Format(
|
String.Format(
|
||||||
"Requesting visual: {0} ({1}{2}{3}{4})... ",
|
"Requesting visual: {0} ({1}{2}{3}{4})... ",
|
||||||
mode.ToString(),
|
mode.ToString(),
|
||||||
|
@ -266,8 +240,8 @@ namespace OpenTK.Platform.X11
|
||||||
}
|
}
|
||||||
visualInfo = (VisualInfo)Marshal.PtrToStructure(visual, typeof(VisualInfo));
|
visualInfo = (VisualInfo)Marshal.PtrToStructure(visual, typeof(VisualInfo));
|
||||||
|
|
||||||
Trace.WriteLine(String.Format("done! (id: {0})", x11context));
|
Debug.Print("done! (id: {0})", x11context);
|
||||||
Trace.Unindent();
|
Debug.Unindent();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -26,57 +26,39 @@ namespace OpenTK.Platform.X11
|
||||||
private IntPtr window;
|
private IntPtr window;
|
||||||
|
|
||||||
private DisplayMode mode = new DisplayMode();
|
private DisplayMode mode = new DisplayMode();
|
||||||
|
|
||||||
private bool created;
|
|
||||||
|
|
||||||
//private X11Keyboard key;
|
|
||||||
|
|
||||||
// Number of pending events.
|
// Number of pending events.
|
||||||
private int pending = 0;
|
private int pending = 0;
|
||||||
|
|
||||||
// C# ResizeEventArgs
|
// C# ResizeEventArgs
|
||||||
private ResizeEventArgs resizeEventArgs = new ResizeEventArgs();
|
private ResizeEventArgs resizeEventArgs = new ResizeEventArgs();
|
||||||
|
|
||||||
// Low level X11 resize request
|
// Low level X11 resize request
|
||||||
private X11.Event xresize = new Event();
|
private X11.Event xresize = new Event();
|
||||||
// This is never written in the code. If at some point it gets != 0,
|
|
||||||
// then memory corruption is taking place from the xresize struct.
|
|
||||||
// Event used for event loop.
|
// Event used for event loop.
|
||||||
private Event e = new Event();
|
private Event e = new Event();
|
||||||
|
// This is never written in the code. If at some point it gets != 0,
|
||||||
|
// then memory corruption is taking place from the xresize struct.
|
||||||
|
int memGuard = 0;
|
||||||
private ConfigureNotifyEvent configure = new ConfigureNotifyEvent();
|
private ConfigureNotifyEvent configure = new ConfigureNotifyEvent();
|
||||||
private ReparentNotifyEvent reparent = new ReparentNotifyEvent();
|
private ReparentNotifyEvent reparent = new ReparentNotifyEvent();
|
||||||
private ExposeEvent expose = new ExposeEvent();
|
private ExposeEvent expose = new ExposeEvent();
|
||||||
private CreateWindowEvent createWindow = new CreateWindowEvent();
|
private CreateWindowEvent createWindow = new CreateWindowEvent();
|
||||||
private DestroyWindowEvent destroyWindow = new DestroyWindowEvent();
|
private DestroyWindowEvent destroyWindow = new DestroyWindowEvent();
|
||||||
// This is never written in the code. If at some point it gets != 0,
|
|
||||||
// then memory corruption is taking place from the xresize struct.
|
|
||||||
int memGuard = 0;
|
|
||||||
|
|
||||||
//private int width, height;
|
|
||||||
|
|
||||||
private bool disposed;
|
private bool disposed;
|
||||||
|
private bool created;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- Public Constructors ---
|
#region --- Public Constructors ---
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs a new X11GLNative window, with its associated context.
|
/// Constructs and initializes a new X11GLNative window.
|
||||||
/// Safe defaults for visual, colormap, etc.
|
/// Call CreateWindow to create the actual render window.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public X11GLNative()
|
public X11GLNative()
|
||||||
{
|
{
|
||||||
Trace.WriteLine("Creating GameWindow (X11GLNative driver)");
|
|
||||||
Trace.Indent();
|
|
||||||
|
|
||||||
// Set default (safe) DisplayMode.
|
|
||||||
mode.Width = 640;
|
|
||||||
mode.Height = 480;
|
|
||||||
mode.Color = new ColorDepth(24);
|
|
||||||
mode.DepthBits = 16;
|
|
||||||
mode.Buffers = 2;
|
|
||||||
|
|
||||||
Trace.WriteLine(String.Format("Display mode: {0}", mode));
|
|
||||||
|
|
||||||
this.CreateWindow(mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -85,8 +67,24 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
#region public void CreateWindow(DisplayMode mode)
|
#region public void CreateWindow(DisplayMode mode)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Opens a new render window with the given DisplayMode.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mode">The DisplayMode of the render window.</param>
|
||||||
|
/// <remarks>
|
||||||
|
/// Creates the window visual and colormap. Associates the colormap/visual
|
||||||
|
/// with the window and raises the window on top of the window stack.
|
||||||
|
/// <para>
|
||||||
|
/// Colormap creation is currently disabled.
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
public void CreateWindow(DisplayMode mode)
|
public void CreateWindow(DisplayMode mode)
|
||||||
{
|
{
|
||||||
|
Debug.WriteLine("Creating GameWindow (X11GLNative driver)");
|
||||||
|
Debug.Indent();
|
||||||
|
|
||||||
|
Debug.WriteLine(String.Format("Display mode: {0}", mode));
|
||||||
|
|
||||||
windowInfo.Display = display = API.OpenDisplay(null); // null == default display
|
windowInfo.Display = display = API.OpenDisplay(null); // null == default display
|
||||||
if (display == IntPtr.Zero)
|
if (display == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
|
@ -95,20 +93,18 @@ namespace OpenTK.Platform.X11
|
||||||
windowInfo.Screen = screen = API.DefaultScreen(display);
|
windowInfo.Screen = screen = API.DefaultScreen(display);
|
||||||
windowInfo.RootWindow = rootWindow = API.RootWindow(display, screen);
|
windowInfo.RootWindow = rootWindow = API.RootWindow(display, screen);
|
||||||
|
|
||||||
Trace.WriteLine(
|
Debug.Print(
|
||||||
String.Format(
|
"Display: {0}, Screen {1}, Root window: {2}",
|
||||||
"Display: {0}, Screen {1}, Root window: {2}",
|
windowInfo.Display,
|
||||||
windowInfo.Display,
|
windowInfo.Screen,
|
||||||
windowInfo.Screen,
|
windowInfo.RootWindow
|
||||||
windowInfo.RootWindow
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
glContext = new X11GLContext(windowInfo, mode);
|
glContext = new X11GLContext(windowInfo, mode);
|
||||||
glContext.CreateVisual();
|
glContext.CreateVisual();
|
||||||
|
|
||||||
// Create a window on this display using the visual above
|
// Create a window on this display using the visual above
|
||||||
Trace.Write("Creating output window... ");
|
Debug.Write("Creating output window... ");
|
||||||
|
|
||||||
SetWindowAttributes wnd_attributes = new SetWindowAttributes();
|
SetWindowAttributes wnd_attributes = new SetWindowAttributes();
|
||||||
wnd_attributes.background_pixel = 0;
|
wnd_attributes.background_pixel = 0;
|
||||||
|
@ -146,7 +142,7 @@ namespace OpenTK.Platform.X11
|
||||||
throw new Exception("Could not create window.");
|
throw new Exception("Could not create window.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Trace.WriteLine("done! (id: " + window + ")");
|
Debug.WriteLine("done! (id: " + window + ")");
|
||||||
|
|
||||||
// Set the window hints
|
// Set the window hints
|
||||||
/*
|
/*
|
||||||
|
@ -177,12 +173,12 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
API.MapRaised(display, window);
|
API.MapRaised(display, window);
|
||||||
|
|
||||||
Trace.WriteLine("Mapped window.");
|
Debug.WriteLine("Mapped window.");
|
||||||
|
|
||||||
//glContext.MakeCurrent();
|
//glContext.MakeCurrent();
|
||||||
|
|
||||||
Trace.WriteLine("Our shiny new context is now current - ready to rock 'n' roll!");
|
Debug.WriteLine("Our shiny new context is now current - ready to rock 'n' roll!");
|
||||||
Trace.Unindent();
|
Debug.Unindent();
|
||||||
created = true;
|
created = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue