OpenGL ES IOS glCreateProgram()失败

时间:2014-04-08 06:59:07

标签: ios xcode opengl-es shader objective-c++

我目前正在创建一个Objective-c ++ IOS OpenGL ES 3.0 3D游戏引擎,但当我尝试加载着色器时,glCreateProgram()会返回0。 我使用#include <OpenGLES/ES3/gl.h>作为我的OpenGL基础。

这是我的代码:

m_program = glCreateProgram(); //ERROR

if (m_program == 0) 
{
    fprintf(stderr, "Error creating shader program\n"); //Catches ERROR
    exit(1);
}

std::string vertexShaderText = LoadShader(fileName + ".vs"); //Returns file contents.
std::string fragmentShaderText = LoadShader(fileName + ".fs"); //Returns file contents.

AddVertexShader(vertexShaderText); //Creates and attaches shader to program
AddFragmentShader(fragmentShaderText); //Creates and attaches shader to program

AddAllAttributes(vertexShaderText); //Identifies all attributes in shader and adds them.

CompileShader(); //Compile the program, link the program and use the program

AddShaderUniforms(vertexShaderText); //Identifies all uniforms and adds them.
AddShaderUniforms(fragmentShaderText); //Identifies all uniforms and adds them.

0 个答案:

没有答案
相关问题