无法在'OpenGL32.dll中找到入口点'glCreateShader'

时间:2015-12-03 20:47:16

标签: c# opengl dll graphics

我收到错误“无法在DLL'opengl32.dll'中找到名为'glCreateShader'的入口点。”

有谁知道造成这些错误的原因是什么?

这是导致错误的类

class PixelBlocks
{

    private static ShaderProgram program;

    public static void generateBlock(ref objStructs.Block Block)
    {
        Texture blockTex = Block.Texture;
        VBO<Vector3> square;
        VBO<int> elements;
        float Scale = clientInfo.curScale;
        Matrix4 trans;
        Matrix4 SclFct;

        program = new ShaderProgram(VertexShader, FragmentShader);

        program.Use();
        program["projection_matrix"].SetValue(Matrix4.CreatePerspectiveFieldOfView(0.45f, (float)Program.width / Program.height, 0.1f, 1000f));
        program["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(0, 0, 10), Vector3.Zero, Vector3.Up));

        program["light_direction"].SetValue(new Vector3(0, 0, 1));
        program["enable_lighting"].SetValue(Program.lighting);

        square = new VBO<Vector3>(new Vector3[] {
            new Vector3(-1, 1, 0),
            new Vector3(1, 1, 0),
            new Vector3(1, -1, 0),
            new Vector3(-1, -1, 0) });
        elements = new VBO<int>(new int[] { 0, 1, 2, 3 }, BufferTarget.ElementArrayBuffer);

        trans = Matrix4.CreateTranslation(new Vector3(Block.Blk.x, Block.Blk.y, 0));
        SclFct = Matrix4.CreateScaling(new Vector3(Scale, Scale, 0f));

        Block.corners = square;
        Block.elements = elements;
        Block.trans = trans;
        Block.Scale = SclFct;
    }
    public static bool drawBlocks(objStructs.Block[] Blocks)
    {

        for(int i = 0; i < Blocks.Length; i++)
        {
            try
            {
                Gl.UseProgram(program);

                // set up the model matrix and draw the cube
                program["model_matrix"].SetValue(Blocks[i].trans * Blocks[i].Scale);

                Gl.BindBufferToShaderAttribute(Blocks[i].corners, program, "vertexPosition");

                Gl.BindBuffer(Blocks[i].elements);

                #pragma warning disable CS0618 // Type or member is obsolete
                Gl.DrawElements(BeginMode.Quads, Blocks[i].elements.Count, DrawElementsType.UnsignedInt, IntPtr.Zero);
                #pragma warning restore CS0618 // Type or member is obsolete
            }
            catch(Exception e)
            {
                Console.WriteLine(e);
                return false;
            }
        }
        return true;
    }
    public static string VertexShader = @"
    #version 130
    in vec3 vertexPosition;
    in vec3 vertexNormal;
    in vec2 vertexUV;
    out vec3 normal;
    out vec2 uv;
    uniform mat4 projection_matrix;
    uniform mat4 view_matrix;
    uniform mat4 model_matrix;
    void main(void)
    {
       normal = normalize((model_matrix * vec4(floor(vertexNormal), 0)).xyz);
       uv = vertexUV;
       gl_Position = projection_matrix * view_matrix * model_matrix * vec4(vertexPosition, 1);
    }
    ";

    public static string FragmentShader = @"
    #version 130
    uniform sampler2D texture;
    uniform vec3 light_direction;
    uniform bool enable_lighting;
    in vec3 normal;
    in vec2 uv;
    out vec4 fragment;
    void main(void)
    {
       float diffuse = max(dot(normal, light_direction), 0);
float ambient = 0.3;
float lighting = (enable_lighting ? max(diffuse, ambient) : 1);
fragment = lighting * texture2D(texture, uv);
}
";
}

我知道这是很多代码,但我不知道导致此错误的原因。

我正在使用这个库:https://github.com/giawa/opengl4csharp这就是为什么它不像其他任何问题

图形:Intel Iris Pro图形实验版和推荐版本都试过 处理器:Intel i5 IDE:Visual Studio 2015社区

0 个答案:

没有答案