Beispiel #1
0
CoglHandle
cogl_create_program (void)
{
  CoglProgram *program;
  _COGL_GET_CONTEXT (ctx, 0);

  program = g_slice_new (CoglProgram);
  program->gl_handle = glCreateProgramObject ();

  return _cogl_program_handle_new (program);
}
Beispiel #2
0
//
// defaultShader constructor
//
//  This constructor actually compiles and links the GLSL shader,
// so it must be called with a current context active.
////////////////////////////////////////////////////////////////////////////////
defaultShader::defaultShader() : m_program(0), m_fShader(0), m_vShader(0) {

  if (glShadingLanguageSupport) {
  m_program = glCreateProgramObject();
  m_vShader = glCreateShaderObject( GL_VERTEX_SHADER);
  m_fShader = glCreateShaderObject( GL_FRAGMENT_SHADER);
  glAttachObject( m_program, m_vShader);
  glAttachObject( m_program, m_fShader);

  const char *temp = vShader;
  glShaderSource( m_vShader, 1, &temp, NULL);
  temp = fShader;
  glShaderSource( m_fShader, 1, &temp, NULL);

  GLint success;
  glCompileShader( m_vShader);
  glGetObjectParameteriv( m_vShader, GL_COMPILE_STATUS, &success);
  if (! success) {
    //figure out why we didn't compile
    char log[256];
    //printf("Failed to compile vertex shader\n");
    glGetInfoLog( m_vShader, 256, NULL, log);
    //printf(" Infolog: %s\n", log);
  }

  glCompileShader( m_fShader);
  glGetObjectParameteriv( m_fShader, GL_COMPILE_STATUS, &success);
  if (! success) {
    //figure out why we didn't compile
    char log[256];
    //printf("Failed to compile fragment shader\n");
    glGetInfoLog( m_fShader, 256, NULL, log);
    //printf(" Infolog: %s\n", log);
  }

  glLinkProgram( m_program);
  glGetObjectParameteriv( m_program, GL_LINK_STATUS, &success);
  if (! success) {
    //figure out why we didn't link
    char log[256];
    //printf("Failed to link\n");
    glGetInfoLog( m_program, 256, NULL, log);
    //printf(" Infolog: %s\n", log);
  }  
}
}