kishorDgupta's picture

Unable to find an entry point named 'glGenVertexArrays' in DLL 'opengl32.dll'.

i tried to use a sample from opentk documentation i got this error in bolded line
void CreateVAOs()
{

GL.GenVertexArrays(1, out vaoHandle);.

full code is below any help

 public class HelloGL3 : GameWindow
    {
        string vertexShaderSource = @"
#version 130
 
precision highp float;
 
uniform mat4 projection_matrix;
uniform mat4 modelview_matrix;
 
in vec3 in_position;
in vec3 in_normal;
 
out vec3 normal;
 
void main(void)
{
  //works only for orthogonal modelview
  normal = (modelview_matrix * vec4(in_normal, 0)).xyz;
 
  gl_Position = projection_matrix * modelview_matrix * vec4(in_position, 1);
}";
 
        string fragmentShaderSource = @"
#version 130
 
precision highp float;
 
const vec3 ambient = vec3(0.1, 0.1, 0.1);
const vec3 lightVecNormalized = normalize(vec3(0.5, 0.5, 2.0));
const vec3 lightColor = vec3(0.9, 0.9, 0.7);
 
in vec3 normal;
 
out vec4 out_frag_color;
 
void main(void)
{
  float diffuse = clamp(dot(lightVecNormalized, normalize(normal)), 0.0, 1.0);
  out_frag_color = vec4(ambient + diffuse * lightColor, 1.0);
}";
 
        int vertexShaderHandle,
            fragmentShaderHandle,
            shaderProgramHandle,
            modelviewMatrixLocation,
            projectionMatrixLocation,
            vaoHandle,
            positionVboHandle,
            normalVboHandle,
            eboHandle;
 
        Vector3[] positionVboData = new Vector3[]{
            new Vector3(-1.0f, -1.0f,  1.0f),
            new Vector3( 1.0f, -1.0f,  1.0f),
            new Vector3( 1.0f,  1.0f,  1.0f),
            new Vector3(-1.0f,  1.0f,  1.0f),
            new Vector3(-1.0f, -1.0f, -1.0f),
            new Vector3( 1.0f, -1.0f, -1.0f), 
            new Vector3( 1.0f,  1.0f, -1.0f),
            new Vector3(-1.0f,  1.0f, -1.0f) };
 
        int[] indicesVboData = new int[]{
             // front face
                0, 1, 2, 2, 3, 0,
                // top face
                3, 2, 6, 6, 7, 3,
                // back face
                7, 6, 5, 5, 4, 7,
                // left face
                4, 0, 3, 3, 7, 4,
                // bottom face
                0, 1, 5, 5, 4, 0,
                // right face
                1, 5, 6, 6, 2, 1, };
 
        Matrix4 projectionMatrix, modelviewMatrix;
 
        public HelloGL3()
            : base(640, 480,
            new GraphicsMode(), "OpenGL 3 Example", 0,
            DisplayDevice.Default, 3, 0,
            GraphicsContextFlags.ForwardCompatible | GraphicsContextFlags.Debug)
        { }
 
        protected override void OnLoad (System.EventArgs e)
        {
            VSync = VSyncMode.On;
 
            CreateShaders();
            CreateVBOs();
            CreateVAOs();
 
            // Other state
            GL.Enable(EnableCap.DepthTest);
            GL.ClearColor(System.Drawing.Color.MidnightBlue);
        }
 
        void CreateShaders()
        {
            vertexShaderHandle = GL.CreateShader(ShaderType.VertexShader);
            fragmentShaderHandle = GL.CreateShader(ShaderType.FragmentShader);
 
            GL.ShaderSource(vertexShaderHandle, vertexShaderSource);
            GL.ShaderSource(fragmentShaderHandle, fragmentShaderSource);
 
            GL.CompileShader(vertexShaderHandle);
            GL.CompileShader(fragmentShaderHandle);
 
            Debug.WriteLine(GL.GetShaderInfoLog(vertexShaderHandle));
            Debug.WriteLine(GL.GetShaderInfoLog(fragmentShaderHandle));
 
            // Create program
            shaderProgramHandle = GL.CreateProgram();
 
            GL.AttachShader(shaderProgramHandle, vertexShaderHandle);
            GL.AttachShader(shaderProgramHandle, fragmentShaderHandle);
 
            GL.LinkProgram(shaderProgramHandle);
 
            Debug.WriteLine(GL.GetProgramInfoLog(shaderProgramHandle));
 
            GL.UseProgram(shaderProgramHandle);
 
            // Set uniforms
            projectionMatrixLocation = GL.GetUniformLocation(shaderProgramHandle, "projection_matrix");
            modelviewMatrixLocation = GL.GetUniformLocation(shaderProgramHandle, "modelview_matrix");
 
            float aspectRatio = ClientSize.Width / (float)(ClientSize.Height);
            Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4, aspectRatio, 1, 100, out projectionMatrix);
            modelviewMatrix = Matrix4.LookAt(new Vector3(0, 3, 5), new Vector3(0, 0, 0), new Vector3(0, 1, 0));
 
            GL.UniformMatrix4(projectionMatrixLocation, false, ref projectionMatrix);
            GL.UniformMatrix4(modelviewMatrixLocation, false, ref modelviewMatrix);
        }
 
        void CreateVBOs()
        {
            GL.GenBuffers(1, out positionVboHandle);
            GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle);
            GL.BufferData<Vector3>(BufferTarget.ArrayBuffer,
                new IntPtr(positionVboData.Length * Vector3.SizeInBytes),
                positionVboData, BufferUsageHint.StaticDraw);
 
            GL.GenBuffers(1, out normalVboHandle);
            GL.BindBuffer(BufferTarget.ArrayBuffer, normalVboHandle);
            GL.BufferData<Vector3>(BufferTarget.ArrayBuffer,
                new IntPtr(positionVboData.Length * Vector3.SizeInBytes),
                positionVboData, BufferUsageHint.StaticDraw);
 
            GL.GenBuffers(1, out eboHandle);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, eboHandle);
            GL.BufferData(BufferTarget.ElementArrayBuffer,
                new IntPtr(sizeof(uint) * indicesVboData.Length),
                indicesVboData, BufferUsageHint.StaticDraw);
 
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
        }
 
        void CreateVAOs()
        {
            // GL3 allows us to store the vertex layout in a "vertex array object" (VAO).
            // This means we do not have to re-issue VertexAttribPointer calls
            // every time we try to use a different vertex layout - these calls are
            // stored in the VAO so we simply need to bind the correct VAO.
            GL.GenVertexArrays(1, out vaoHandle);
            GL.BindVertexArray(vaoHandle);
 
            GL.EnableVertexAttribArray(0);
            GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle);
            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, true, Vector3.SizeInBytes, 0);
            GL.BindAttribLocation(shaderProgramHandle, 0, "in_position");
 
            GL.EnableVertexAttribArray(1);
            GL.BindBuffer(BufferTarget.ArrayBuffer, normalVboHandle);
            GL.VertexAttribPointer(1, 3, VertexAttribPointerType.Float, true, Vector3.SizeInBytes, 0);
            GL.BindAttribLocation(shaderProgramHandle, 1, "in_normal");
 
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, eboHandle);
 
            GL.BindVertexArray(0);
        }
 
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            Matrix4 rotation = Matrix4.CreateRotationY((float)e.Time);
            Matrix4.Mult(ref rotation, ref modelviewMatrix, out modelviewMatrix);
            GL.UniformMatrix4(modelviewMatrixLocation, false, ref modelviewMatrix);
 
            if (Keyboard[OpenTK.Input.Key.Escape])
                Exit();
        }
 
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            GL.Viewport(0, 0, Width, Height);
 
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
 
            GL.BindVertexArray(vaoHandle);
            GL.DrawElements(BeginMode.Triangles, indicesVboData.Length,
                DrawElementsType.UnsignedInt, IntPtr.Zero);
 
            SwapBuffers();
        }
 
        [STAThread]
        public static void Main()
        {
            using (HelloGL3 example = new HelloGL3())
            {
                Utilities.SetWindowTitle(example);
                example.Run(30);
            }
        }
    }
}

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

What is the exact version of the context? (Use GL.GetInteger(Major/Minor) to check). What video card/drivers are you using?

A quick search shows other people having similar issues. Some report that requesting a 3.1 context works but a 3.2 doesn't. This might indicate a driver bug (try upgrading your drivers).

kishorDgupta's picture

i m using intel grphics media accelerator hd i3.

my driver is updated as latest whql certified

thank u

the Fiddler's picture

According to wikipedia, this chip does not support OpenGL 3.0. The new Sandy Bridge processors are supposed to be GL3-compatible once they are released.

kishorDgupta's picture

oops
are there any way to do it in my current config. any how :( :(

Mike O's picture
kishorDgupta wrote:

oops
are there any way to do it in my current config. any how :( :(

Not likely.. If the cards hardware cant support it, thats the way it is. This is a hardware feature as the arrays are stored in the cards memory... or at least thats the plan.. the hardware will store them or part of them in regular ram if there is no room.
Best thing... is get a new hardware.. Next option.. Dont use VertexArrays. Use GLGenLists.. Yeah.. I know.. its obsolete.
Good luck...

kishorDgupta's picture

thank u Mike O,
can u please explain GLGenLists or give some resource / reference about it?

kishorDgupta's picture

i have to make a 3d analog clock in opentk is it impossible in current config?

the Fiddler's picture
kishorDgupta wrote:

i have to make a 3d analog clock in opentk is it impossible in current config?

Of course it is possible, but you'll have to fall back to OpenGL 2.1 rather than 3.0.

The main difference is that you will use Vertex Buffer Objects without Vertex Attrib Arrays. The difference to your current code is minimal - the documentation has a section on vertex buffer objects under the graphics chapter.

kishorDgupta's picture

thank u very much i m working on that

Mike O's picture
kishorDgupta wrote:

thank u Mike O,
can u please explain GLGenLists or give some resource / reference about it?

Well.. its goes like this
Make a global variable.. you will need it to store the ID of the list name. List names are nothing more then integers that are returned from OpenGL.
Heres some code:

        surface = GL.GenLists(1)
        GL.NewList(surface, ListMode.Compile)
        make_surface()
        GL.EndList()

'surface' is just a global integer.
once the list is created, you use like this:
GL.CallList(surface)

The cool thing is, you can have all kinds of math and stuff in the make_surface() sub.. OpenGL (TK) will only care about actual Opengl statements!
Heres the code for the make_surface().. It will created a UV mapped surface of (Mesh_size*2)^2 .. double this if you want the poly count. there are 2 per mesh segment.

    Private Sub make_surface()
        poly_count = 0
        Dim x1, x2, x3, y1, y2, y3, z1, z2, z3 As Single
        Dim u1, v1, u2, v2, u3, v3 As Single
        Dim cnt As Single = mesh_size
        Dim q, r As Integer
 
        Dim w As Single = (cnt + cnt) / step_
        q = 0 : r = 0
        GL.Begin(BeginMode.Triangles)
        For y = -cnt To cnt - step_ Step step_
            For x = -cnt To cnt - step_ Step step_
 
                'If point_set(q, r + 1).hit Then
 
                'tri 1
                'p1
                x1 = x 'point_set(q, r + 1).x
                y1 = y + step_ 'point_set(q, r + 1).y
                z1 = 0 'point_set(q, r + 1).z
                'p2
                x2 = x + step_ 'oint_set(q + 1, r).x
                y2 = y 'point_set(q + 1, r).y
                z2 = 0 'point_set(q + 1, r).z
                'p3
                x3 = x 'point_set(q, r).x
                y3 = y 'point_set(q, r).y
                z3 = 0 'point_set(q, r).z
                'texture coords
                u1 = q / w
                v3 = -r / w
                u2 = (q + 1) / w
                v2 = -r / w
                u3 = q / w
                v1 = (-r - 1) / w
 
 
                GL.TexCoord2(u1, v1)
                GL.Vertex3(x1, y1, z1)
 
                GL.TexCoord2(u2, v2)
                GL.Vertex3(x2, y2, z2)
 
                GL.TexCoord2(u3, v3)
                GL.Vertex3(x3, y3, z3)
                '------------
                'tri 2
                'p1
                x3 = x + step_ 'point_set(q + 1, r).x
                y3 = y 'point_set(q + 1, r).y
                z3 = 0 'point_set(q + 1, r).z
                'p2
                x2 = x + step_ 'point_set(q + 1, r + 1).x
                y2 = y + step_ 'point_set(q + 1, r + 1).y
                z2 = 0 'point_set(q + 1, r + 1).z
                'p3
                x1 = x 'point_set(q, r + 1).x
                y1 = y + step_ 'point_set(q, r + 1).y
                z1 = 0 'point_set(q, r + 1).z
                ''texture coords
 
 
                GL.TexCoord2(u1, v1)
                GL.Vertex3(x1, y1, z1)
 
 
                GL.TexCoord2(u2, v1)
                GL.Vertex3(x2, y2, z2)
 
                GL.TexCoord2(u2, v2)
                GL.Vertex3(x3, y3, z3)
                 poly_count += 2
                q += 1
            Next x
            q = 0
            r += 1
        Next y
        GL.End()
    End Sub

Looks like direct mode dont it? Well,, the only difference is, all the OpenGL statements will be intercepted because make_surface is called between

GL.NewList(surface, ListMode.Compile)
        make_surface()
        GL.EndList()

OpenGL could care less about all the math.. It wont compile it! SWEEEEET huh?

You can make MANY lists.. the trick is keeping track of the IDs that OpenGL returns.
You can over write any list at any time as long as it IS a valid list ID your using.
You can NOT create a list until you get the ID.
I KISS it.. Keep It Simple Stupid.. I define a variable for each and every list ID im going to use.. Its the safe way to do it but you could all so
use an array of integers. Problem is.. if you overwrite the wrong ID.. that list is.. "SeeYa!"
I hope this helps you some.
If you have any problems.. send me a PM and I can help you with it more..
Oh.. GlList are absolete.. I heard that OpenGL 4.0 wont work using them. 1.5 to 3.0 is fine for sure. This isnt an issue to much yet.

EDIT: Forget anything about point_list in the above code.. Its rem'ed and was from a different project. Just delete it after yo copy/paste the code(if you use it)..

EDIT2: Make sure you delete the list when the app closes.. Grab the on_closing event and put this there

 GL.DeleteLists(1, 2)

means: starting at list 1, delete 2 lists.. You can of couse do it like this:

GL.DeleteLists(surface, 1)
GL.DeleteLists(sphere, 1)