mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-09 21:45:32 +00:00
Preparatory work for linux support (added basic X and GLX bindings)
Major update to OpenTK.OpenGL.Bind. Updated OpenGL specs to 2.1 (were 2.0)
This commit is contained in:
parent
83da572596
commit
8cd76686d0
|
@ -49,6 +49,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "OpenGL", "OpenGL", "{2F3FEA
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.OpenGL", "Source\OpenGL\OpenGL\OpenTK.OpenGL.csproj", "{836876D1-0C8D-4240-BEE4-859D9D3D46CB}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.OpenGL", "Source\OpenGL\OpenGL\OpenTK.OpenGL.csproj", "{836876D1-0C8D-4240-BEE4-859D9D3D46CB}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{1EDDE592-3923-4898-9006-3D69579E1745} = {1EDDE592-3923-4898-9006-3D69579E1745}
|
||||||
{FDFA00B6-FA81-4658-86E1-F312EFB42E1C} = {FDFA00B6-FA81-4658-86E1-F312EFB42E1C}
|
{FDFA00B6-FA81-4658-86E1-F312EFB42E1C} = {FDFA00B6-FA81-4658-86E1-F312EFB42E1C}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
|
|
@ -10,7 +10,7 @@ using OpenTK.OpenGL;
|
||||||
|
|
||||||
namespace OpenTK.Examples.OpenGL.GLSL
|
namespace OpenTK.Examples.OpenGL.GLSL
|
||||||
{
|
{
|
||||||
public partial class Cube : GLForm
|
public partial class Cube : Framework
|
||||||
{
|
{
|
||||||
#region Shaders
|
#region Shaders
|
||||||
string[] vertex_shader_source =
|
string[] vertex_shader_source =
|
||||||
|
@ -125,7 +125,7 @@ namespace OpenTK.Examples.OpenGL.GLSL
|
||||||
DrawCube();
|
DrawCube();
|
||||||
|
|
||||||
Context.SwapBuffers();
|
Context.SwapBuffers();
|
||||||
this.Invalidate();
|
//this.Invalidate();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,10 @@ namespace OpenTK.OpenGL.Bind
|
||||||
long ticks = System.DateTime.Now.Ticks;
|
long ticks = System.DateTime.Now.Ticks;
|
||||||
|
|
||||||
// GL binding generation.
|
// GL binding generation.
|
||||||
|
|
||||||
|
Translation.GLTypes = SpecReader.ReadTypeMap("gl.tm");
|
||||||
|
Translation.CSTypes = SpecReader.ReadTypeMap("csharp.tm");
|
||||||
|
|
||||||
List<Function> wrappers;
|
List<Function> wrappers;
|
||||||
List<Function> functions = SpecReader.ReadFunctionSpecs("gl.spec");
|
List<Function> functions = SpecReader.ReadFunctionSpecs("gl.spec");
|
||||||
Hashtable enums = SpecReader.ReadEnumSpecs("enum.spec");
|
Hashtable enums = SpecReader.ReadEnumSpecs("enum.spec");
|
||||||
|
@ -87,9 +91,6 @@ namespace OpenTK.OpenGL.Bind
|
||||||
((Enum)enums[e.Name]).ConstantCollection.Add(c.Name, c);
|
((Enum)enums[e.Name]).ConstantCollection.Add(c.Name, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
Translation.GLTypes = SpecReader.ReadTypeMap("gl.tm");
|
|
||||||
Translation.CSTypes = SpecReader.ReadTypeMap("csharp.tm");
|
|
||||||
|
|
||||||
Translation.TranslateFunctions(functions, enums, out wrappers);
|
Translation.TranslateFunctions(functions, enums, out wrappers);
|
||||||
Translation.TranslateEnums(enums);
|
Translation.TranslateEnums(enums);
|
||||||
|
|
||||||
|
@ -102,7 +103,7 @@ namespace OpenTK.OpenGL.Bind
|
||||||
|
|
||||||
// GLX binding generation.
|
// GLX binding generation.
|
||||||
//Translation.GLXTypes = SpecReader.ReadTypeMap("glx.tm"); // Works semi-ok.
|
//Translation.GLXTypes = SpecReader.ReadTypeMap("glx.tm"); // Works semi-ok.
|
||||||
//functions = SpecReader.ReadFunctionSpecs("glx.spec"); // Works ok!
|
//List<Function> functions = SpecReader.ReadFunctionSpecs("glx.spec"); // Works ok!
|
||||||
//Hashtable enums = SpecReader.ReadEnumSpecs("glxenum.spec"); // Works ok!
|
//Hashtable enums = SpecReader.ReadEnumSpecs("glxenum.spec"); // Works ok!
|
||||||
//SpecWriter.WriteSpecs(Settings.OutputPath, "Glx", functions, null, enums); // Needs updating.
|
//SpecWriter.WriteSpecs(Settings.OutputPath, "Glx", functions, null, enums); // Needs updating.
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,8 @@ namespace OpenTK.OpenGL.Bind
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents an opengl constant in C# format. Both the constant name and value
|
/// Represents an opengl constant in C# format. Both the constant name and value
|
||||||
/// can be retrieved or set. All opengl constants are translated to 'const uint'.
|
/// can be retrieved or set. The value can be either a number, another constant
|
||||||
|
/// or an alias to a constant
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Constant
|
public class Constant
|
||||||
{
|
{
|
||||||
|
|
|
@ -104,6 +104,28 @@ namespace OpenTK.OpenGL.Bind
|
||||||
|
|
||||||
public static void TranslateEnums(System.Collections.Hashtable enums)
|
public static void TranslateEnums(System.Collections.Hashtable enums)
|
||||||
{
|
{
|
||||||
|
// Add missing enums.
|
||||||
|
{
|
||||||
|
Enum e = new Enum();
|
||||||
|
Constant c;
|
||||||
|
e.Name = "SGIX_icc_texture";
|
||||||
|
c = new Constant("RGB_ICC_SGIX", "0x8460"); e.ConstantCollection.Add(c.Name, c);
|
||||||
|
c = new Constant("RGBA_ICC_SGIX", "0x8461"); e.ConstantCollection.Add(c.Name, c);
|
||||||
|
c = new Constant("ALPHA_ICC_SGIX", "0x8462"); e.ConstantCollection.Add(c.Name, c);
|
||||||
|
c = new Constant("LUMINANCE_ICC_SGIX", "0x8463"); e.ConstantCollection.Add(c.Name, c);
|
||||||
|
c = new Constant("INTENSITY_ICC_SGIX", "0x8464"); e.ConstantCollection.Add(c.Name, c);
|
||||||
|
c = new Constant("LUMINANCE_ALPHA_ICC_SGIX", "0x8465"); e.ConstantCollection.Add(c.Name, c);
|
||||||
|
c = new Constant("R5_G6_B5_ICC_SGIX", "0x8466"); e.ConstantCollection.Add(c.Name, c);
|
||||||
|
c = new Constant("R5_G6_B5_A8_ICC_SGIX", "0x8467"); e.ConstantCollection.Add(c.Name, c);
|
||||||
|
c = new Constant("ALPHA16_ICC_SGIX", "0x8468"); e.ConstantCollection.Add(c.Name, c);
|
||||||
|
c = new Constant("LUMINANCE16_ICC_SGIX", "0x8469"); e.ConstantCollection.Add(c.Name, c);
|
||||||
|
c = new Constant("INTENSITY16_ICC_SGIX", "0x846A"); e.ConstantCollection.Add(c.Name, c);
|
||||||
|
c = new Constant("LUMINANCE16_ALPHA8_ICC_SGIX", "0x846B"); e.ConstantCollection.Add(c.Name, c);
|
||||||
|
|
||||||
|
enums.Add(e.Name, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Translate enums.
|
||||||
foreach (Enum e in enums.Values)
|
foreach (Enum e in enums.Values)
|
||||||
{
|
{
|
||||||
if (Char.IsDigit(e.Name[0]))
|
if (Char.IsDigit(e.Name[0]))
|
||||||
|
@ -114,13 +136,37 @@ namespace OpenTK.OpenGL.Bind
|
||||||
|
|
||||||
foreach (Constant c in e.ConstantCollection.Values)
|
foreach (Constant c in e.ConstantCollection.Values)
|
||||||
{
|
{
|
||||||
|
// Prepend an '_' if the first letter is a number (e.g. 4_BYTES -> _4_BYTES)
|
||||||
if (Char.IsDigit(c.Name[0]))
|
if (Char.IsDigit(c.Name[0]))
|
||||||
c.Name = c.Name.Insert(0, "_");
|
c.Name = c.Name.Insert(0, "_");
|
||||||
|
|
||||||
|
// Prepend an '_' to the aliased value, if it starts with a number (e.g. DataType.4_BYTES -> DataType._4_BYTES)
|
||||||
if (c.Value.Contains(".") && Char.IsDigit(c.Value[c.Value.IndexOf('.') + 1]))
|
if (c.Value.Contains(".") && Char.IsDigit(c.Value[c.Value.IndexOf('.') + 1]))
|
||||||
c.Value = c.Value.Insert(c.Value.IndexOf('.') + 1, "_");
|
c.Value = c.Value.Insert(c.Value.IndexOf('.') + 1, "_");
|
||||||
|
|
||||||
|
// There are cases when a value is not a number but an aliased constant, with no enum specified.
|
||||||
|
// In this case try searching all enums for the correct constant to alias (stupid opengl group).
|
||||||
|
if (!c.Value.Contains(".") && !c.Value.StartsWith("0x") && !Char.IsDigit(c.Value[0]))
|
||||||
|
{
|
||||||
|
if (c.Value.StartsWith("GL_"))
|
||||||
|
c.Value = c.Value.TrimStart('G', 'L', '_');
|
||||||
|
|
||||||
|
if (Char.IsDigit(c.Value[0]))
|
||||||
|
c.Value = c.Value.Insert(0, "_");
|
||||||
|
|
||||||
|
foreach (Enum search_enum in enums.Values)
|
||||||
|
foreach (Constant search_constant in search_enum.ConstantCollection.Values)
|
||||||
|
if (search_constant.Name == c.Value || search_constant.Name == c.Value.TrimStart('_'))
|
||||||
|
c.Value = c.Value.Insert(0, search_enum.Name + ".");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle enum.spec bugs:
|
||||||
|
if (c.Value.Contains("LightProperty"))
|
||||||
|
c.Value = c.Value.Replace("LightProperty", "LightParameter");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -67,6 +67,7 @@ namespace OpenTK.OpenGL.Bind
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Write types
|
#region Write types
|
||||||
|
|
||||||
private static void WriteTypes(StreamWriter sw)
|
private static void WriteTypes(StreamWriter sw)
|
||||||
{
|
{
|
||||||
sw.WriteLine(" #region Types");
|
sw.WriteLine(" #region Types");
|
||||||
|
@ -79,6 +80,7 @@ namespace OpenTK.OpenGL.Bind
|
||||||
sw.WriteLine(" #endregion");
|
sw.WriteLine(" #endregion");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Write enums
|
#region Write enums
|
||||||
|
@ -93,38 +95,6 @@ namespace OpenTK.OpenGL.Bind
|
||||||
sw.WriteLine(" #region Missing Constants");
|
sw.WriteLine(" #region Missing Constants");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
|
|
||||||
// Version 1.4 enum
|
|
||||||
sw.WriteLine(" const uint GL_FOG_COORDINATE_SOURCE = 0x8450;");
|
|
||||||
sw.WriteLine(" const uint GL_FOG_COORDINATE = 0x8451;");
|
|
||||||
sw.WriteLine(" const uint GL_CURRENT_FOG_COORDINATE = 0x8453;");
|
|
||||||
sw.WriteLine(" const uint GL_FOG_COORDINATE_ARRAY_TYPE = 0x8454;");
|
|
||||||
sw.WriteLine(" const uint GL_FOG_COORDINATE_ARRAY_STRIDE = 0x8455;");
|
|
||||||
sw.WriteLine(" const uint GL_FOG_COORDINATE_ARRAY_POINTER = 0x8456;");
|
|
||||||
sw.WriteLine(" const uint GL_FOG_COORDINATE_ARRAY = 0x8457;");
|
|
||||||
|
|
||||||
// Version 1.5 enum
|
|
||||||
sw.WriteLine(" const uint GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING = 0x889D;");
|
|
||||||
|
|
||||||
// Version 1.3 enum
|
|
||||||
sw.WriteLine(" const uint GL_SOURCE0_RGB = 0x8580;");
|
|
||||||
sw.WriteLine(" const uint GL_SOURCE1_RGB = 0x8581;");
|
|
||||||
sw.WriteLine(" const uint GL_SOURCE2_RGB = 0x8582;");
|
|
||||||
sw.WriteLine(" const uint GL_SOURCE0_ALPHA = 0x8588;");
|
|
||||||
sw.WriteLine(" const uint GL_SOURCE1_ALPHA = 0x8589;");
|
|
||||||
sw.WriteLine(" const uint GL_SOURCE2_ALPHA = 0x858A;");
|
|
||||||
|
|
||||||
// Version 2.0 enum
|
|
||||||
sw.WriteLine(" const uint GL_BLEND_EQUATION = 0x8009;");
|
|
||||||
|
|
||||||
sw.WriteLine(" const uint GL_MODELVIEW_MATRIX = 0x0BA6;");
|
|
||||||
sw.WriteLine(" const uint GL_MODELVIEW = 0x1700;");
|
|
||||||
sw.WriteLine(" const uint GL_MODELVIEW_STACK_DEPTH = 0x0BA3;");
|
|
||||||
|
|
||||||
// NV_texture_shader enum
|
|
||||||
sw.WriteLine(" const uint GL_OFFSET_TEXTURE_MATRIX_NV = 0x86E1;");
|
|
||||||
sw.WriteLine(" const uint GL_OFFSET_TEXTURE_SCALE_NV = 0x86E2;");
|
|
||||||
sw.WriteLine(" const uint GL_OFFSET_TEXTURE_BIAS_NV = 0x86E3;");
|
|
||||||
|
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
sw.WriteLine(" #endregion");
|
sw.WriteLine(" #endregion");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -591,6 +591,12 @@ namespace OpenTK.OpenGL
|
||||||
GL.VertexAttrib4uiv_ = (GL.Delegates.VertexAttrib4uiv_)GetAddress("glVertexAttrib4uiv", typeof(GL.Delegates.VertexAttrib4uiv_));
|
GL.VertexAttrib4uiv_ = (GL.Delegates.VertexAttrib4uiv_)GetAddress("glVertexAttrib4uiv", typeof(GL.Delegates.VertexAttrib4uiv_));
|
||||||
GL.VertexAttrib4usv_ = (GL.Delegates.VertexAttrib4usv_)GetAddress("glVertexAttrib4usv", typeof(GL.Delegates.VertexAttrib4usv_));
|
GL.VertexAttrib4usv_ = (GL.Delegates.VertexAttrib4usv_)GetAddress("glVertexAttrib4usv", typeof(GL.Delegates.VertexAttrib4usv_));
|
||||||
GL.VertexAttribPointer_ = (GL.Delegates.VertexAttribPointer_)GetAddress("glVertexAttribPointer", typeof(GL.Delegates.VertexAttribPointer_));
|
GL.VertexAttribPointer_ = (GL.Delegates.VertexAttribPointer_)GetAddress("glVertexAttribPointer", typeof(GL.Delegates.VertexAttribPointer_));
|
||||||
|
GL.UniformMatrix2x3fv_ = (GL.Delegates.UniformMatrix2x3fv_)GetAddress("glUniformMatrix2x3fv", typeof(GL.Delegates.UniformMatrix2x3fv_));
|
||||||
|
GL.UniformMatrix3x2fv_ = (GL.Delegates.UniformMatrix3x2fv_)GetAddress("glUniformMatrix3x2fv", typeof(GL.Delegates.UniformMatrix3x2fv_));
|
||||||
|
GL.UniformMatrix2x4fv_ = (GL.Delegates.UniformMatrix2x4fv_)GetAddress("glUniformMatrix2x4fv", typeof(GL.Delegates.UniformMatrix2x4fv_));
|
||||||
|
GL.UniformMatrix4x2fv_ = (GL.Delegates.UniformMatrix4x2fv_)GetAddress("glUniformMatrix4x2fv", typeof(GL.Delegates.UniformMatrix4x2fv_));
|
||||||
|
GL.UniformMatrix3x4fv_ = (GL.Delegates.UniformMatrix3x4fv_)GetAddress("glUniformMatrix3x4fv", typeof(GL.Delegates.UniformMatrix3x4fv_));
|
||||||
|
GL.UniformMatrix4x3fv_ = (GL.Delegates.UniformMatrix4x3fv_)GetAddress("glUniformMatrix4x3fv", typeof(GL.Delegates.UniformMatrix4x3fv_));
|
||||||
GL.ActiveTextureARB = (GL.Delegates.ActiveTextureARB)GetAddress("glActiveTextureARB", typeof(GL.Delegates.ActiveTextureARB));
|
GL.ActiveTextureARB = (GL.Delegates.ActiveTextureARB)GetAddress("glActiveTextureARB", typeof(GL.Delegates.ActiveTextureARB));
|
||||||
GL.ClientActiveTextureARB = (GL.Delegates.ClientActiveTextureARB)GetAddress("glClientActiveTextureARB", typeof(GL.Delegates.ClientActiveTextureARB));
|
GL.ClientActiveTextureARB = (GL.Delegates.ClientActiveTextureARB)GetAddress("glClientActiveTextureARB", typeof(GL.Delegates.ClientActiveTextureARB));
|
||||||
GL.MultiTexCoord1dARB = (GL.Delegates.MultiTexCoord1dARB)GetAddress("glMultiTexCoord1dARB", typeof(GL.Delegates.MultiTexCoord1dARB));
|
GL.MultiTexCoord1dARB = (GL.Delegates.MultiTexCoord1dARB)GetAddress("glMultiTexCoord1dARB", typeof(GL.Delegates.MultiTexCoord1dARB));
|
||||||
|
@ -1436,6 +1442,13 @@ namespace OpenTK.OpenGL
|
||||||
GL.GetFramebufferAttachmentParameterivEXT_ = (GL.Delegates.GetFramebufferAttachmentParameterivEXT_)GetAddress("glGetFramebufferAttachmentParameterivEXT", typeof(GL.Delegates.GetFramebufferAttachmentParameterivEXT_));
|
GL.GetFramebufferAttachmentParameterivEXT_ = (GL.Delegates.GetFramebufferAttachmentParameterivEXT_)GetAddress("glGetFramebufferAttachmentParameterivEXT", typeof(GL.Delegates.GetFramebufferAttachmentParameterivEXT_));
|
||||||
GL.GenerateMipmapEXT = (GL.Delegates.GenerateMipmapEXT)GetAddress("glGenerateMipmapEXT", typeof(GL.Delegates.GenerateMipmapEXT));
|
GL.GenerateMipmapEXT = (GL.Delegates.GenerateMipmapEXT)GetAddress("glGenerateMipmapEXT", typeof(GL.Delegates.GenerateMipmapEXT));
|
||||||
GL.StringMarkerGREMEDY_ = (GL.Delegates.StringMarkerGREMEDY_)GetAddress("glStringMarkerGREMEDY", typeof(GL.Delegates.StringMarkerGREMEDY_));
|
GL.StringMarkerGREMEDY_ = (GL.Delegates.StringMarkerGREMEDY_)GetAddress("glStringMarkerGREMEDY", typeof(GL.Delegates.StringMarkerGREMEDY_));
|
||||||
|
GL.StencilClearTagEXT = (GL.Delegates.StencilClearTagEXT)GetAddress("glStencilClearTagEXT", typeof(GL.Delegates.StencilClearTagEXT));
|
||||||
|
GL.BlitFramebufferEXT = (GL.Delegates.BlitFramebufferEXT)GetAddress("glBlitFramebufferEXT", typeof(GL.Delegates.BlitFramebufferEXT));
|
||||||
|
GL.RenderbufferStorageMultisampleEXT = (GL.Delegates.RenderbufferStorageMultisampleEXT)GetAddress("glRenderbufferStorageMultisampleEXT", typeof(GL.Delegates.RenderbufferStorageMultisampleEXT));
|
||||||
|
GL.GetQueryObjecti64vEXT_ = (GL.Delegates.GetQueryObjecti64vEXT_)GetAddress("glGetQueryObjecti64vEXT", typeof(GL.Delegates.GetQueryObjecti64vEXT_));
|
||||||
|
GL.GetQueryObjectui64vEXT_ = (GL.Delegates.GetQueryObjectui64vEXT_)GetAddress("glGetQueryObjectui64vEXT", typeof(GL.Delegates.GetQueryObjectui64vEXT_));
|
||||||
|
GL.ProgramEnvParameters4fvEXT_ = (GL.Delegates.ProgramEnvParameters4fvEXT_)GetAddress("glProgramEnvParameters4fvEXT", typeof(GL.Delegates.ProgramEnvParameters4fvEXT_));
|
||||||
|
GL.ProgramLocalParameters4fvEXT_ = (GL.Delegates.ProgramLocalParameters4fvEXT_)GetAddress("glProgramLocalParameters4fvEXT", typeof(GL.Delegates.ProgramLocalParameters4fvEXT_));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,19 +9,31 @@ using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using OpenTK.Platform.X;
|
||||||
|
|
||||||
namespace OpenTK.OpenGL.Platform
|
namespace OpenTK.OpenGL.Platform
|
||||||
{
|
{
|
||||||
public partial class X11Context : OpenTK.OpenGL.GLContext
|
public partial class X11Context : OpenTK.OpenGL.GLContext
|
||||||
{
|
{
|
||||||
int drawable, context;
|
int drawable;
|
||||||
|
IntPtr context;
|
||||||
|
IntPtr display;
|
||||||
const string _dll_name = "opengl.so";
|
const string _dll_name = "opengl.so";
|
||||||
|
|
||||||
public X11Context(Control c, int red, int green, int blue, int alpha, int depth, int stencil)
|
public X11Context(Control c, int red, int green, int blue, int alpha, int depth, int stencil)
|
||||||
{
|
{
|
||||||
|
//drawable = c.Handle.ToInt32();
|
||||||
|
display = Api.OpenDisplay("OpenTK X11 trial");
|
||||||
|
Api.VisualInfo visual = Glx.ChooseVisual(display, 0, new int[] { });
|
||||||
|
context = Glx.CreateContext(display, visual, IntPtr.Zero, true);
|
||||||
|
//Api.Free(new IntPtr(visual));
|
||||||
drawable = c.Handle.ToInt32();
|
drawable = c.Handle.ToInt32();
|
||||||
|
Glx.MakeCurrent(drawable, context);
|
||||||
|
|
||||||
throw new Exception("The method or operation is not implemented.");
|
//context = Glx.CreateContext(
|
||||||
|
//X11Context
|
||||||
|
|
||||||
|
//throw new Exception("The method or operation is not implemented.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SwapBuffers()
|
public override void SwapBuffers()
|
||||||
|
@ -45,7 +57,9 @@ namespace OpenTK.OpenGL.Platform
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
throw new Exception("The method or operation is not implemented.");
|
//throw new Exception("The method or operation is not implemented.");
|
||||||
|
Glx.DestroyContext(context);
|
||||||
|
Api.CloseDisplay(display);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,11 @@ using System.Drawing;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using OpenTK.Platform.Windows;
|
using OpenTK.Platform.Windows;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using OpenTK.OpenGL.Platform;
|
||||||
|
|
||||||
namespace OpenTK.OpenGL
|
namespace OpenTK.OpenGL
|
||||||
{
|
{
|
||||||
public class GLForm : Form, IDisposable
|
public class Framework : Form, IDisposable
|
||||||
{
|
{
|
||||||
#region Context
|
#region Context
|
||||||
private GLContext _context;
|
private GLContext _context;
|
||||||
|
@ -27,14 +28,51 @@ namespace OpenTK.OpenGL
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
delegate bool IsIdleDelegate();
|
||||||
|
IsIdleDelegate IsIdle;
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
public GLForm()
|
|
||||||
|
public Framework()
|
||||||
{
|
{
|
||||||
Open(null, 640, 480, 8, 8, 8, 8, 16, 0, false);
|
Open(null, 640, 480, 8, 8, 8, 8, 16, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Framework(string title, int width, int height, int red, int green, int blue, int alpha, int depth, int stencil, bool fullscreen)
|
||||||
|
{
|
||||||
|
Open(title, width, height, red, green, blue, alpha, depth, stencil, fullscreen);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public void Open(string title, int width, int height, int red, int green, int blue, int alpha, int depth, int stencil, bool fullscreen)
|
public void Open(string title, int width, int height, int red, int green, int blue, int alpha, int depth, int stencil, bool fullscreen)
|
||||||
|
{
|
||||||
|
Application.Idle += new EventHandler(OnIdle);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT ||
|
||||||
|
Environment.OSVersion.Platform == PlatformID.Win32Windows)
|
||||||
|
{
|
||||||
|
IsIdle = new IsIdleDelegate(WindowsIsIdle);
|
||||||
|
WindowsOpen(title, width, height, red, green, blue, alpha, depth, stencil, fullscreen);
|
||||||
|
}
|
||||||
|
else if (Environment.OSVersion.Platform == PlatformID.Unix)
|
||||||
|
{
|
||||||
|
IsIdle = new IsIdleDelegate(XIsIdle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new PlatformNotSupportedException("The platform on which you are trying to run this program is not currently supported. Sorry for the inconvenience.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
MessageBox.Show(e.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WindowsOpen(string title, int width, int height, int red, int green, int blue, int alpha, int depth, int stencil, bool fullscreen)
|
||||||
{
|
{
|
||||||
// Hack! Should add more constructors to the GLContext class.
|
// Hack! Should add more constructors to the GLContext class.
|
||||||
Context = GLContext.Create(this, 8, 8, 8, 8, 16, 0);
|
Context = GLContext.Create(this, 8, 8, 8, 8, 16, 0);
|
||||||
|
@ -81,74 +119,55 @@ namespace OpenTK.OpenGL
|
||||||
this.Size = new Size(width, height);
|
this.Size = new Size(width, height);
|
||||||
|
|
||||||
// Cross-platformness?
|
// Cross-platformness?
|
||||||
Application.Idle += new EventHandler(OnApplicationIdle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Application main loop
|
//override protected void WndProc(ref Message m)
|
||||||
|
//{
|
||||||
|
// base.WndProc(ref m);
|
||||||
|
// //OnPaint(null);
|
||||||
|
//}
|
||||||
|
|
||||||
|
#region IDisposable Members
|
||||||
|
|
||||||
|
void IDisposable.Dispose()
|
||||||
|
{
|
||||||
|
Application.Idle -= OnIdle;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Event Handlers
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when all pending messages have been processed, this is where the application 'Main Loop' resides.
|
/// Called when all pending messages have been processed, this is where the application 'Main Loop' resides.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender">Not used.</param>
|
/// <param name="sender">Not used.</param>
|
||||||
/// <param name="e">Not used.</param>
|
/// <param name="e">Not used.</param>
|
||||||
void OnApplicationIdle(object sender, EventArgs e)
|
private void OnIdle(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Check if any new messages have popped up. If not, then run the logic at full speed.
|
while (IsIdle())
|
||||||
//while (IsApplicationIdle())
|
{
|
||||||
////while (idle)
|
if (ActiveForm != this)
|
||||||
//{
|
Thread.Sleep(100);
|
||||||
// // We'd like to play nice with the scheduler. If the window is not in focus,
|
OnPaint(null);
|
||||||
// // we give back some thread-time to the OS, to allow other apps to function full-speed.
|
}
|
||||||
// // However, if the window _is_ in focus we grab all processor resources.
|
|
||||||
// // Hack! Should allow the user to set a sleep interval.
|
|
||||||
// if (ActiveForm != this)
|
|
||||||
// Thread.Sleep(100);
|
|
||||||
// OnPaint(null);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if there all pending messages have been processed.
|
/// Checks if there all pending messages have been processed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns true if there are no messages left, false otherwise.</returns>
|
/// <returns>Returns true if there are no messages left, false otherwise.</returns>
|
||||||
static public bool IsApplicationIdle()
|
private bool WindowsIsIdle()
|
||||||
{
|
{
|
||||||
//Message msg = Message.Create(this.Handle, A
|
|
||||||
|
|
||||||
//try
|
|
||||||
//{
|
|
||||||
//Message msg;
|
|
||||||
Api.Message msg;
|
Api.Message msg;
|
||||||
return !OpenTK.Platform.Windows.Api.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0);
|
return !OpenTK.Platform.Windows.Api.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0);
|
||||||
//}
|
|
||||||
//catch (Exception e)
|
|
||||||
//{
|
|
||||||
// //MessageBox.Show(e.ToString());
|
|
||||||
// return false;
|
|
||||||
//}
|
|
||||||
//WndProc(ref msg);
|
|
||||||
|
|
||||||
//if (msg.
|
|
||||||
//return false;
|
|
||||||
|
|
||||||
//Message msg = Message.Create(IntPtr.Zero, Api.Constants.WM_ENTERIDLE, IntPtr.Zero, IntPtr.Zero);
|
|
||||||
|
|
||||||
//return !Api.PeekMessage(ref msg, IntPtr.Zero, 0, 0, 0);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
bool idle;
|
|
||||||
|
|
||||||
protected override void WndProc(ref Message m)
|
|
||||||
{
|
|
||||||
base.WndProc(ref m);
|
|
||||||
//OnPaint(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IDisposable Members
|
private bool XIsIdle()
|
||||||
|
|
||||||
void IDisposable.Dispose()
|
|
||||||
{
|
{
|
||||||
Application.Idle -= OnApplicationIdle;
|
throw new NotImplementedException("IsIdle handler not implemented yet!");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -8,6 +8,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using OpenTK.Platform.X;
|
||||||
|
|
||||||
namespace OpenTK.OpenGL
|
namespace OpenTK.OpenGL
|
||||||
{
|
{
|
||||||
|
@ -43,7 +44,7 @@ namespace OpenTK.OpenGL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Glx
|
public class Glx
|
||||||
{
|
{
|
||||||
const string _dll_name = "glx.so";
|
const string _dll_name = "libgl";
|
||||||
|
|
||||||
#region Enums
|
#region Enums
|
||||||
|
|
||||||
|
@ -265,21 +266,28 @@ namespace OpenTK.OpenGL
|
||||||
|
|
||||||
#region GLX functions
|
#region GLX functions
|
||||||
|
|
||||||
[DllImport("_dll_name", EntryPoint = "glxCreateContext")]
|
[DllImport(_dll_name, EntryPoint = "glXCreateContext")]
|
||||||
public static extern void CreateContext(Int32 gc_id, Int32 screen, Int32 visual, Int32 share_list);
|
public static extern IntPtr CreateContext(IntPtr dpy, Api.VisualInfo vis, IntPtr shareList, bool direct);
|
||||||
|
//public static extern IntPtr CreateContext(IntPtr gc_id, Int32 screen, Int32 visual, IntPtr share_list);
|
||||||
|
|
||||||
[DllImport("_dll_name", EntryPoint = "glxDestroyContext")]
|
[DllImport(_dll_name, EntryPoint = "glXDestroyContext")]
|
||||||
public static extern void DestroyContext(Int32 context);
|
public static extern void DestroyContext(IntPtr context);
|
||||||
|
|
||||||
[DllImport("_dll_name", EntryPoint = "glxMakeCurrent")]
|
[DllImport(_dll_name, EntryPoint = "glXMakeCurrent")]
|
||||||
public static extern void MakeCurrent(Int32 drawable, Int32 context);
|
public static extern void MakeCurrent(Int32 drawable, IntPtr context);
|
||||||
|
|
||||||
[DllImport("_dll_name", EntryPoint = "glxSwapBuffers")]
|
[DllImport(_dll_name, EntryPoint = "glXSwapBuffers")]
|
||||||
public static extern void SwapBuffers(Int32 drawable);
|
public static extern void SwapBuffers(Int32 drawable);
|
||||||
|
|
||||||
[DllImport("_dll_name", EntryPoint = "glxGetProcAddress")]
|
[DllImport(_dll_name, EntryPoint = "glXGetProcAddress")]
|
||||||
public static extern IntPtr GetProcAddress([MarshalAs(UnmanagedType.LPTStr)] string procName);
|
public static extern IntPtr GetProcAddress([MarshalAs(UnmanagedType.LPTStr)] string procName);
|
||||||
|
|
||||||
|
[DllImport(_dll_name, EntryPoint = "glXChooseVisual")]
|
||||||
|
public static extern OpenTK.Platform.X.Api.VisualInfo ChooseVisual(IntPtr dpy, int screen, [MarshalAs(UnmanagedType.LPArray)]int[] attriblist);
|
||||||
|
|
||||||
|
//public static ChooseVisual()
|
||||||
|
|
||||||
|
|
||||||
//[DllImport("opengl32.dll", EntryPoint = "glCreateWindow")]
|
//[DllImport("opengl32.dll", EntryPoint = "glCreateWindow")]
|
||||||
//public static extern void CreateWindow(Int32 config, Int32 window, Int32 glxwindow);
|
//public static extern void CreateWindow(Int32 config, Int32 window, Int32 glxwindow);
|
||||||
//[DllImport("opengl32.dll", EntryPoint = "glDestroyWindow")]
|
//[DllImport("opengl32.dll", EntryPoint = "glDestroyWindow")]
|
||||||
|
|
|
@ -7,10 +7,46 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace OpenTK.Platform.X
|
namespace OpenTK.Platform.X
|
||||||
{
|
{
|
||||||
public class XApi
|
public static class Api
|
||||||
{
|
{
|
||||||
|
private const string _dll_name = "libX11";
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct VisualInfo
|
||||||
|
{
|
||||||
|
IntPtr visual;
|
||||||
|
int visualid;
|
||||||
|
int screen;
|
||||||
|
uint depth;
|
||||||
|
int @class;
|
||||||
|
ulong red_mask;
|
||||||
|
ulong green_mask;
|
||||||
|
ulong blue_mask;
|
||||||
|
int colormap_size;
|
||||||
|
int bits_per_rgb;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Functions
|
||||||
|
|
||||||
|
[DllImport(_dll_name, EntryPoint = "XOpenDisplay")]
|
||||||
|
public static extern IntPtr OpenDisplay([MarshalAs(UnmanagedType.LPTStr)] string display_name);
|
||||||
|
|
||||||
|
[DllImport(_dll_name, EntryPoint = "XCloseDisplay")]
|
||||||
|
public static extern void CloseDisplay(IntPtr display);
|
||||||
|
|
||||||
|
[DllImport(_dll_name, EntryPoint = "XDefaultScreen")]
|
||||||
|
public static extern int DefaultScreen(IntPtr display);
|
||||||
|
|
||||||
|
[DllImport(_dll_name, EntryPoint = "XDefaultVisual")]
|
||||||
|
public static extern IntPtr DefaultVisual(IntPtr display, int screen_number);
|
||||||
|
|
||||||
|
[DllImport(_dll_name, EntryPoint = "XFree")]
|
||||||
|
public static extern void Free(IntPtr data);
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
OpenTK 0.3.4 -> 0.3.5
|
OpenTK 0.3.4 -> 0.3.5
|
||||||
+ Major update to OpenTK.OpenGL.Bind (cleaner code, new functions, comments and many new wrappers).
|
+ Major update to OpenTK.OpenGL.Bind (cleaner code, new functions, comments and many new wrappers).
|
||||||
|
+ Updated the spec files for opengl 2.1.
|
||||||
|
+ Added the new 64 bit types to the typemaps (gl.tm and csharp.tm)
|
||||||
|
+ The bugs in the specs are still there:
|
||||||
|
+ SGIX_icc_texture is still commented out, while enums use it.
|
||||||
|
+ LightProperty is still used by constants (the correct enum is LightParameter).
|
||||||
|
+ I think I should contact someone at the Khronos group about these. For the time being I worked around them, by adding a special case for LightProperty in the translator, and adding the SGIX enum to the missing parameters.
|
||||||
|
+ See also: http://www.haskell.org/HOpenGL/spec_bugs.html (lots of useful information on that site).
|
||||||
+ Laid the foundation for X (Linux, Unix, MacOS) support.
|
+ Laid the foundation for X (Linux, Unix, MacOS) support.
|
||||||
+ Added bindings to some glx functions.
|
+ Added bindings to some glx functions.
|
||||||
+ Added the OpenTK.Platform.X class.
|
+ Added the OpenTK.Platform.X class.
|
||||||
|
|
Loading…
Reference in a new issue