OpenTK.OpenGL.Bind 0.7.5.1 -> 0.7.5.2 (out char[] -> StringBuilder)

Updated the GLSL.Lesson01 example.
Full Mono support under Windows.
Api.Message and Api.PeekMessage updates (no longer crashes in release mode).
This commit is contained in:
the_fiddler 2006-10-09 23:58:30 +00:00
parent da968d0eb2
commit 3319e79696
10 changed files with 67 additions and 41 deletions

View file

@ -13,17 +13,17 @@ namespace OpenTK.Examples.OpenGL.GLSL
public partial class Cube : GLForm
{
#region Shaders
string[] vertex_shader =
string[] vertex_shader_source =
{
"void main() { ",
"void main() {",
"gl_FrontColor = gl_Color;",
"gl_Position = ftransform();",
"}"
"}",
};
string[] fragment_shader =
string[] fragment_shader_source =
{
"void main() { gl_FragColor = gl_Color; }"
"void main() { gl_FragColor = gl_Color; }\0"
};
#endregion
@ -49,17 +49,27 @@ namespace OpenTK.Examples.OpenGL.GLSL
vertex_shader_object = GL.CreateShader(Enums.VERSION_2_0.VERTEX_SHADER);
fragment_shader_object = GL.CreateShader(Enums.VERSION_2_0.FRAGMENT_SHADER);
GL.ShaderSource(vertex_shader_object, 1, vertex_shader, null);
GL.ShaderSource(vertex_shader_object, vertex_shader_source.Length, vertex_shader_source, IntPtr.Zero);
GL.CompileShader(vertex_shader_object);
GL.GetShaderiv(vertex_shader_object, Enums.VERSION_2_0.COMPILE_STATUS, status);
//if (status[0] != GL._TRUE)
// throw new Exception("Could not compile vertex shader");
if (status[0] != (int)Enums.Boolean.TRUE)
{
StringBuilder info = new StringBuilder(1024);
GL.GetShaderInfoLog(vertex_shader_object, 1024, null, info);
GL.ShaderSource(fragment_shader_object, 1, fragment_shader, null);
throw new Exception(info.ToString());
}
GL.ShaderSource(fragment_shader_object, fragment_shader_source.Length, fragment_shader_source, IntPtr.Zero);
GL.CompileShader(fragment_shader_object);
GL.GetShaderiv(fragment_shader_object, Enums.VERSION_2_0.COMPILE_STATUS, status);
//if (status[0] != GL._TRUE)
// throw new Exception("Could not compile fragment shader");
if (status[0] != (int)Enums.Boolean.TRUE)
{
StringBuilder info = new StringBuilder(1024);
GL.GetShaderInfoLog(fragment_shader_object, 1024, null, info);
throw new Exception(info.ToString());
}
shader_program = GL.CreateProgram();
GL.AttachShader(shader_program, fragment_shader_object);
@ -183,14 +193,7 @@ namespace OpenTK.Examples.OpenGL.GLSL
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
try
{
Application.Run(new Cube());
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
Application.Run(new Cube());
}
#endregion
}

View file

@ -5,10 +5,12 @@
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{46980D11-67FA-4B33-903F-BC9D8A4FE60F}</ProjectGuid>
<OutputType>WinExe</OutputType>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OpenTK.Examples.OpenGL.GLSL</RootNamespace>
<AssemblyName>GLSL.Lesson01</AssemblyName>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

View file

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("0.7.5.1")]
[assembly: AssemblyFileVersion("0.7.5.1")]
[assembly: AssemblyVersion("0.7.5.2")]
[assembly: AssemblyFileVersion("0.7.5.2")]

View file

@ -267,14 +267,23 @@ namespace OpenTK.OpenGL.Bind
p.Array = false;
//p.UnmanagedType = System.Runtime.InteropServices.UnmanagedType.LPArray;
}
if (p.Array &&
if ( p.Array &&
!p.Type.Contains("void") &&
!p.Type.Contains("char") &&
(p.Flow == Parameter.FlowDirection.Out))
{
p.UnmanagedType = System.Runtime.InteropServices.UnmanagedType.LPArray;
//f.NeedsWrapper = true;
//f.WrapperType = WrapperTypes.ArrayOut;
}
else if (p.Array &&
p.Type.Contains("char") &&
(p.Flow == Parameter.FlowDirection.Out))
{
p.Type = "StringBuilder";
p.Array = false;
p.Flow = Parameter.FlowDirection.Undefined;
}
else if (p.Array &&
p.Type.Contains("void") &&
(p.Flow == Parameter.FlowDirection.In || p.Flow == Parameter.FlowDirection.Undefined))

View file

@ -30,6 +30,7 @@ namespace OpenTK.OpenGL.Bind
sw.WriteLine("using System;");
sw.WriteLine("using System.Runtime.InteropServices;");
sw.WriteLine("using System.Text;");
sw.WriteLine();
sw.WriteLine("namespace {0}", Settings.OutputNamespace);
sw.WriteLine("{");
@ -66,7 +67,7 @@ namespace OpenTK.OpenGL.Bind
}
#endregion
#region WriteTypes
#region Write types
private static void WriteTypes(StreamWriter sw)
{
sw.WriteLine(" #region Types");

View file

@ -1,3 +1,7 @@
OpenTK.OpenGL.Bind 0.7.5.1 -> 0.7.5.2
+ Added translation for out char[] parameters (they are treated as StringBuilders, as specified in MSDN).
+ Added System.Text using directive.
OpenTK.OpenGL.Bind 0.7.5 -> 0.7.5.1
+ Added license information to the generated bindings.
+ Changed the name of the main Context class to GLContext (Context is used in the BCL).

View file

@ -5,6 +5,7 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace OpenTK.OpenGL
{
@ -5650,15 +5651,15 @@ namespace OpenTK.OpenGL
public delegate void DetachShader(GLuint program, GLuint shader);
public delegate void DisableVertexAttribArray(GLuint index);
public delegate void EnableVertexAttribArray(GLuint index);
public delegate void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLint[] size, [MarshalAs(UnmanagedType.LPArray)] Enums.VERSION_2_0[] type, [MarshalAs(UnmanagedType.LPArray)] GLchar[] name);
public delegate void GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLint[] size, [MarshalAs(UnmanagedType.LPArray)] Enums.VERSION_2_0[] type, [MarshalAs(UnmanagedType.LPArray)] GLchar[] name);
public delegate void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLint[] size, [MarshalAs(UnmanagedType.LPArray)] Enums.VERSION_2_0[] type, StringBuilder name);
public delegate void GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLint[] size, [MarshalAs(UnmanagedType.LPArray)] Enums.VERSION_2_0[] type, StringBuilder name);
public delegate void GetAttachedShaders(GLuint program, GLsizei maxCount, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] count, [MarshalAs(UnmanagedType.LPArray)] GLuint[] obj);
public delegate GLint GetAttribLocation_(GLuint program, IntPtr name);
public delegate void GetProgramiv(GLuint program, Enums.VERSION_2_0 pname, [MarshalAs(UnmanagedType.LPArray)] GLint[] parameters);
public delegate void GetProgramInfoLog(GLuint program, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLchar[] infoLog);
public delegate void GetProgramInfoLog(GLuint program, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, StringBuilder infoLog);
public delegate void GetShaderiv(GLuint shader, Enums.VERSION_2_0 pname, [MarshalAs(UnmanagedType.LPArray)] GLint[] parameters);
public delegate void GetShaderInfoLog(GLuint shader, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLchar[] infoLog);
public delegate void GetShaderSource(GLuint shader, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLchar[] source);
public delegate void GetShaderInfoLog(GLuint shader, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, StringBuilder infoLog);
public delegate void GetShaderSource(GLuint shader, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, StringBuilder source);
public delegate GLint GetUniformLocation_(GLuint program, IntPtr name);
public delegate void GetUniformfv(GLuint program, GLint location, [MarshalAs(UnmanagedType.LPArray)] GLfloat[] parameters);
public delegate void GetUniformiv(GLuint program, GLint location, [MarshalAs(UnmanagedType.LPArray)] GLint[] parameters);
@ -5920,15 +5921,15 @@ namespace OpenTK.OpenGL
public delegate void UniformMatrix4fvARB_(GLint location, GLsizei count, Enums.Boolean transpose, IntPtr value);
public delegate void GetObjectParameterfvARB(GLhandleARB obj, Enums.ARB_shader_objects pname, [MarshalAs(UnmanagedType.LPArray)] GLfloat[] parameters);
public delegate void GetObjectParameterivARB(GLhandleARB obj, Enums.ARB_shader_objects pname, [MarshalAs(UnmanagedType.LPArray)] GLint[] parameters);
public delegate void GetInfoLogARB(GLhandleARB obj, GLsizei maxLength, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLcharARB[] infoLog);
public delegate void GetInfoLogARB(GLhandleARB obj, GLsizei maxLength, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, StringBuilder infoLog);
public delegate void GetAttachedObjectsARB(GLhandleARB containerObj, GLsizei maxCount, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] count, [MarshalAs(UnmanagedType.LPArray)] GLhandleARB[] obj);
public delegate GLint GetUniformLocationARB_(GLhandleARB programObj, IntPtr name);
public delegate void GetActiveUniformARB(GLhandleARB programObj, GLuint index, GLsizei maxLength, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLint[] size, [MarshalAs(UnmanagedType.LPArray)] Enums.ARB_shader_objects[] type, [MarshalAs(UnmanagedType.LPArray)] GLcharARB[] name);
public delegate void GetActiveUniformARB(GLhandleARB programObj, GLuint index, GLsizei maxLength, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLint[] size, [MarshalAs(UnmanagedType.LPArray)] Enums.ARB_shader_objects[] type, StringBuilder name);
public delegate void GetUniformfvARB(GLhandleARB programObj, GLint location, [MarshalAs(UnmanagedType.LPArray)] GLfloat[] parameters);
public delegate void GetUniformivARB(GLhandleARB programObj, GLint location, [MarshalAs(UnmanagedType.LPArray)] GLint[] parameters);
public delegate void GetShaderSourceARB(GLhandleARB obj, GLsizei maxLength, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLcharARB[] source);
public delegate void GetShaderSourceARB(GLhandleARB obj, GLsizei maxLength, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, StringBuilder source);
public delegate void BindAttribLocationARB_(GLhandleARB programObj, GLuint index, IntPtr name);
public delegate void GetActiveAttribARB(GLhandleARB programObj, GLuint index, GLsizei maxLength, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLint[] size, [MarshalAs(UnmanagedType.LPArray)] Enums.ARB_vertex_shader[] type, [MarshalAs(UnmanagedType.LPArray)] GLcharARB[] name);
public delegate void GetActiveAttribARB(GLhandleARB programObj, GLuint index, GLsizei maxLength, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLint[] size, [MarshalAs(UnmanagedType.LPArray)] Enums.ARB_vertex_shader[] type, StringBuilder name);
public delegate GLint GetAttribLocationARB_(GLhandleARB programObj, IntPtr name);
public delegate void DrawBuffersARB_(GLsizei n, IntPtr bufs);
public delegate void ClampColorARB(GLenum target, GLenum clamp);
@ -7579,9 +7580,9 @@ namespace OpenTK.OpenGL
[DllImport("opengl32.dll", EntryPoint = "glEnableVertexAttribArray")]
public static extern void EnableVertexAttribArray(GLuint index);
[DllImport("opengl32.dll", EntryPoint = "glGetActiveAttrib")]
public static extern void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLint[] size, [MarshalAs(UnmanagedType.LPArray)] Enums.VERSION_2_0[] type, [MarshalAs(UnmanagedType.LPArray)] GLchar[] name);
public static extern void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLint[] size, [MarshalAs(UnmanagedType.LPArray)] Enums.VERSION_2_0[] type, StringBuilder name);
[DllImport("opengl32.dll", EntryPoint = "glGetActiveUniform")]
public static extern void GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLint[] size, [MarshalAs(UnmanagedType.LPArray)] Enums.VERSION_2_0[] type, [MarshalAs(UnmanagedType.LPArray)] GLchar[] name);
public static extern void GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLint[] size, [MarshalAs(UnmanagedType.LPArray)] Enums.VERSION_2_0[] type, StringBuilder name);
[DllImport("opengl32.dll", EntryPoint = "glGetAttachedShaders")]
public static extern void GetAttachedShaders(GLuint program, GLsizei maxCount, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] count, [MarshalAs(UnmanagedType.LPArray)] GLuint[] obj);
[DllImport("opengl32.dll", EntryPoint = "glGetAttribLocation")]
@ -7589,13 +7590,13 @@ namespace OpenTK.OpenGL
[DllImport("opengl32.dll", EntryPoint = "glGetProgramiv")]
public static extern void GetProgramiv(GLuint program, Enums.VERSION_2_0 pname, [MarshalAs(UnmanagedType.LPArray)] GLint[] parameters);
[DllImport("opengl32.dll", EntryPoint = "glGetProgramInfoLog")]
public static extern void GetProgramInfoLog(GLuint program, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLchar[] infoLog);
public static extern void GetProgramInfoLog(GLuint program, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, StringBuilder infoLog);
[DllImport("opengl32.dll", EntryPoint = "glGetShaderiv")]
public static extern void GetShaderiv(GLuint shader, Enums.VERSION_2_0 pname, [MarshalAs(UnmanagedType.LPArray)] GLint[] parameters);
[DllImport("opengl32.dll", EntryPoint = "glGetShaderInfoLog")]
public static extern void GetShaderInfoLog(GLuint shader, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLchar[] infoLog);
public static extern void GetShaderInfoLog(GLuint shader, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, StringBuilder infoLog);
[DllImport("opengl32.dll", EntryPoint = "glGetShaderSource")]
public static extern void GetShaderSource(GLuint shader, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, [MarshalAs(UnmanagedType.LPArray)] GLchar[] source);
public static extern void GetShaderSource(GLuint shader, GLsizei bufSize, [MarshalAs(UnmanagedType.LPArray)] GLsizei[] length, StringBuilder source);
[DllImport("opengl32.dll", EntryPoint = "glGetUniformLocation")]
public static extern GLint GetUniformLocation_(GLuint program, IntPtr name);
[DllImport("opengl32.dll", EntryPoint = "glGetUniformfv")]

View file

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.3.3.0")]
[assembly: AssemblyFileVersion("0.3.3.0")]
[assembly: AssemblyVersion("0.3.4.0")]
[assembly: AssemblyFileVersion("0.3.4.0")]

View file

@ -1,3 +1,10 @@
OpenTK 0.3.3 -> 0.3.4
+ Corrected the crash error in Release mode (it was caused by trying to Marshal the System.Windows.Forms.Message struct to PeekMessage - adding my own Message struct corrected the issue).
+ Corrected the call to glShaderSource GLSL.Lesson01. Now the correct number is passed to the count parameter, while the null parameter was changed to IntPtr.Zero (Mono now no longers fails in this call).
+ Updated the GLSL.Lesson01 example to use GetShaderInfoLog on compilation failure.
+ OpenTK.OpenGL.Bind 0.7.5.1 -> 0.7.5.2 (see Bind changelog for more information)
+ Full Mono support under windows.
OpenTK 0.3.2 -> 0.3.3
+ OpenTK.OpenGL.Bind 0.7.5 -> 0.7.5.1 (see Bind changelog for more information)
+ Added the GLForm class which sets the base for cross-platform screen, context and keyboard handling.

View file

@ -1,5 +1,4 @@
Todo:
+ + + Find out why many examples crash when compiled in release mode, but only when run outside the editor.
+ + Add cross-platform way for overriding the Application.Idle handler.
+ Add more examples.
+ + Change the hierarchy of the WindowsContext and WindowsVistaContext classes. The should have a common ancestor who manages the windows creation (it should be the same for both).