sjoerd222's picture

how is glGetShaderiv implemented in openTK?

Hi

I'm trying to port the following C function to C#, OpenTK 1.0, OpenGL ES 2.0, Visual Studio 2008

GLuint LoadShader(GLenum type, const char *shaderSrc)
{
GLuint shader;
GLint compiled;
// Create the shader object
shader = glCreateShader(type);
if(shader == 0)
return 0;
// Load the shader source
glShaderSource(shader, 1, &shaderSrc, NULL);
// Compile the shader
glCompileShader(shader);
// Check the compile status
glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
if(!compiled)
{
GLint infoLen = 0;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
if(infoLen > 1)
{
char* infoLog = malloc(sizeof(char) * infoLen);
glGetShaderInfoLog(shader, infoLen, NULL, infoLog);
esLogMessage("Error compiling shader:\n%s\n", infoLog);
free(infoLog);
}
glDeleteShader(shader);
return 0;
}
return shader;

And currently I'm struggling with "glGetShaderiv", for all prior function i could find the corresponding OpenTK call.
But how is glGetShaderiv implemented in OpenTK?

Thx!


Comments

Comment viewing options

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

From the function reference:

static void GetShader(int shader, ShaderParameter pname, int[] @params);
static void GetShader(int shader, ShaderParameter pname, out int @params);
unsafe static void GetShader(int shader, ShaderParameter pname, int* @params);
Quote:

Returns a parameter from a shader object.

Parameters:

  • shader Specifies the shader object to be queried.
  • pname Specifies the object parameter. Accepted symbolic names are GL_SHADER_TYPE, GL_DELETE_STATUS, GL_COMPILE_STATUS, GL_INFO_LOG_LENGTH, GL_SHADER_SOURCE_LENGTH.
  • params Returns the requested object parameter.

(Edit)
Usage is pretty straightforward:

// C code
int compiled;
glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
// OpenTK code
int compiled;
GL.GetShader(shader, ShaderParameter.CompileStatus, out compiled);