Exemple #1
0
void
initShader(void)
{
  loadETC1FragProg();
  const GLsizei vertexShaderLines = sizeof(vertexShaderSource) / sizeof(char*);
  GLuint vertexShader = compileShaderSource(GL_VERTEX_SHADER, vertexShaderLines,
                                            vertexShaderSource);

  GLuint fragmentShader =
    compileShaderSource(GL_FRAGMENT_SHADER, fragmentShaderSourceETC1LineCount,
                        (const char**)fragmentShaderSourceETC1);

  GLuint program = createProgram(vertexShader, fragmentShader);

  glUseProgram(program);

  u_Texture = glGetUniformLocation(program, "u_Texture");
  u_width = glGetUniformLocation(program, "u_width");
  u_height = glGetUniformLocation(program, "u_height");

  a_Position = glGetAttribLocation(program, "a_Position");
  glEnableVertexAttribArray(a_Position);

  checkError("initShader");
}
Exemple #2
0
void
initShader(void)
{
  int maxImageUnits;
  loadETC1FragProg();
  const GLsizei vertexShaderLines = sizeof(vertexShaderSource) / sizeof(char*);
  GLuint vertexShader = compileShaderSource(GL_VERTEX_SHADER, vertexShaderLines,
                                            vertexShaderSource);

  const GLsizei fragmentShaderLines =
    sizeof(fragmentShaderSource) / sizeof(char*);
  GLuint fragmentShader = compileShaderSource(
    GL_FRAGMENT_SHADER, fragmentShaderLines, fragmentShaderSource);

  GLuint program = createProgram(vertexShader, fragmentShader);

  checkError("createProgram");

  u_TextureRender = glGetUniformLocation(program, "myt");
  checkError("GetRenderUniform");

  a_Position = glGetAttribLocation(program, "a_Position");
  glEnableVertexAttribArray(a_Position);
  checkError("initRender");

  computeProgramETC1 =
    glCreateShaderProgramv(GL_COMPUTE_SHADER, computeShaderSourceETC1LineCount,
                           (const char**)computeShaderSourceETC1);
  if (!checkProgram(computeProgramETC1, "computeProgramETC1")) {
    exit(1);
  }
  renderProgram = program;
  u_TextureComputeETC1 = glGetUniformLocation(computeProgramETC1, "u_Texture");
  u_OutComputeETC1 = glGetUniformLocation(computeProgramETC1, "u_Output");
  printf(
    "u_TextureRender: %u, u_TextureComputeETC1: %u, u_OutComputeETC1: %u.\n",
    u_TextureRender, u_TextureComputeETC1, u_OutComputeETC1);

  computeProgramS3TC =
    glCreateShaderProgramv(GL_COMPUTE_SHADER, computeShaderSourceS3TCLineCount,
                           (const char**)computeShaderSourceS3TC);
  if (!checkProgram(computeProgramS3TC, "computeProgramS3TC")) {
    exit(1);
  }
  u_TextureComputeS3TC = glGetUniformLocation(computeProgramS3TC, "u_Texture");
  printf("u_TextureComputeS3TC: %u.\n", u_TextureComputeS3TC);

  glGetIntegerv(GL_MAX_IMAGE_UNITS, &maxImageUnits);
  printf("maxImageUnits: %d.\n", maxImageUnits);
  checkError("initCompute");
}
void initShader(void)
{
   const GLsizei vertexShaderLines = sizeof(vertexShaderSource) / sizeof(ourGLchar*);
   GLuint vertexShader =
     compileShaderSource (GL_VERTEX_SHADER, vertexShaderLines, vertexShaderSource);

   const GLsizei fragmentShaderLines = sizeof(fragmentShaderSource) / sizeof(ourGLchar*);
   GLuint fragmentShader =
     compileShaderSource (GL_FRAGMENT_SHADER, fragmentShaderLines, fragmentShaderSource);

   GLuint program = createProgram (vertexShader, fragmentShader);

   gl_UseProgram (program);

   fgProjectionMatrixIndex = gl_GetUniformLocation(program, "fg_ProjectionMatrix");

   fgColorIndex = gl_GetAttribLocation(program, "fg_Color");
   gl_EnableVertexAttribArray (fgColorIndex);

   fgVertexIndex = gl_GetAttribLocation(program, "fg_Vertex");
   gl_EnableVertexAttribArray (fgVertexIndex);

   checkError ("initShader");
}