mathgenius
mathgenius

Reputation: 165

SharpGL: Setting the version to 4.0 or a replacement for GLEW

Currently I'm stuck making a C#-WPF-OpenGL application. I followed this http://www.codeproject.com/Articles/265903/Using-OpenGL-in-a-WPF-Application tutorial and was able to run the sample project. However, the first call to a function that's not part of OpenGL 1.1.0 Fails, i.e my code Looks like this

private void OpenGLControl_OpenGLInitialized(object Sender, OpenGLEventArgs args)
{
OpenGL gl = args.OpenGL;

GLuint glError;
while ( (glError = gl.GetError()) != OpenGL.GL_NO_ERROR )
{
    Console.WriteLine( gl.GetErrorDescription(glError) );
}

Console.WriteLine( gl.GetString(OpenGL.Version) ); //Prints out 1.1.0

GLuint hVertexShader;
hVertexShader = gl.CreateShader(OpenGL.GL_VERTEX_SHADER);//Compiles, but raises an exception, also would gl.CreateProgramm() or other functions



}

Somehow this link https://github.com/dwmkerr/sharpgl/wiki/Specifying-OpenGL-Version can't help me to set the Version to 4.2. So how can I achieve that?

Upvotes: 2

Views: 1425

Answers (1)

mathgenius
mathgenius

Reputation: 165

Solved! I was missing RenderingContext="FBO" in MainWindow.xaml, like so

<sharpGL:OpenGLControl 
        Name="openGLControl" 
        OpenGLDraw="OpenGLControl_OpenGLDraw"
        OpenGLInitialized="openGLControl_OpenGLInitialized" 
        Resized="openGLControl_Resized"
        KeyDown="OnKeyDownHandler"
        Mouse.MouseWheel="MouseWheelEventHandler"
        DrawFPS="True" RenderContextType="FBO" FrameRate="20"/>

Upvotes: 4

Related Questions