Ignore:
Timestamp:
Feb 21, 2011, 1:08:46 AM (9 years ago)
Author:
sam
Message:

The engine now builds for GL and GL ES 1.x and 2.x, and runs for each
one except GL ES 2.x for now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/shader.cpp

    r673 r674  
    3333
    3434private:
     35#if defined HAVE_GL_2X || defined HAVE_GLES_2X
    3536    GLuint prog_id, vert_id, frag_id;
     37#endif
    3638    uint32_t vert_crc, frag_crc;
    3739
     
    7577  : data(new ShaderData())
    7678{
     79#if defined HAVE_GL_2X || defined HAVE_GLES_2X
    7780    char buf[4096];
    7881    GLsizei len;
     82#endif
    7983
    8084    data->vert_crc = Hash::Crc32(vert);
     85#if defined HAVE_GL_2X || defined HAVE_GLES_2X
    8186    data->vert_id = glCreateShader(GL_VERTEX_SHADER);
    8287    glShaderSource(data->vert_id, 1, &vert, NULL);
     
    8691    if (len > 0)
    8792        fprintf(stderr, "ERROR: failed to compile vertex shader: %s", buf);
     93#endif
    8894
    8995    data->frag_crc = Hash::Crc32(frag);
     96#if defined HAVE_GL_2X || defined HAVE_GLES_2X
    9097    data->frag_id = glCreateShader(GL_FRAGMENT_SHADER);
    9198    glShaderSource(data->frag_id, 1, &frag, NULL);
     
    102109    glLinkProgram(data->prog_id);
    103110    glValidateProgram(data->prog_id);
     111#endif
    104112}
    105113
    106114int Shader::GetAttribLocation(char const *attr) const
    107115{
     116#if defined HAVE_GL_2X || defined HAVE_GLES_2X
    108117    return glGetAttribLocation(data->prog_id, attr);
     118#else
     119    (void)attr;
     120    return -1;
     121#endif
    109122}
    110123
    111124int Shader::GetUniformLocation(char const *uni) const
    112125{
     126#if defined HAVE_GL_2X || defined HAVE_GLES_2X
    113127    return glGetUniformLocation(data->prog_id, uni);
     128#else
     129    (void)uni;
     130    return -1;
     131#endif
    114132}
    115133
    116134void Shader::Bind() const
    117135{
     136#if defined HAVE_GL_2X || defined HAVE_GLES_2X
    118137    glUseProgram(data->prog_id);
     138#endif
    119139}
    120140
    121141Shader::~Shader()
    122142{
     143#if defined HAVE_GL_2X || defined HAVE_GLES_2X
    123144    glDetachShader(data->prog_id, data->vert_id);
    124145    glDetachShader(data->prog_id, data->frag_id);
     
    126147    glDeleteShader(data->frag_id);
    127148    glDeleteProgram(data->prog_id);
     149#endif
    128150    delete data;
    129151}
Note: See TracChangeset for help on using the changeset viewer.