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/scene.cpp

    r673 r674  
    3131};
    3232
    33 #if LOL_EXPERIMENTAL
     33#if defined HAVE_GL_2X || defined HAVE_GLES_2X
    3434extern Shader *stdshader;
    3535#endif
     
    5757    float angle;
    5858
    59 #if LOL_EXPERIMENTAL
     59#if defined HAVE_GL_2X
    6060    GLuint vao;
    6161#endif
     
    8282    data->nbufs = 0;
    8383
    84 #if LOL_EXPERIMENTAL
     84#if defined HAVE_GL_2X
    8585    glGenVertexArrays(1, &data->vao);
    8686#endif
     
    9292     * Change the architecture to make sure of that. */
    9393    glDeleteBuffers(data->nbufs, data->bufs);
    94 #if LOL_EXPERIMENTAL
     94#if defined HAVE_GL_2X
    9595    glDeleteVertexArrays(1, &data->vao);
    9696#endif
     
    154154    // XXX: end of debug stuff
    155155
    156 #if LOL_EXPERIMENTAL
     156#if defined HAVE_GL_2X || defined HAVE_GLES_2X
    157157    GLuint uni, attr_pos, attr_tex;
    158158    uni = stdshader->GetUniformLocation("model_matrix");
     
    160160    attr_tex = stdshader->GetAttribLocation("in_TexCoord");
    161161
     162    stdshader->Bind();
    162163    glUniformMatrix4fv(uni, 1, GL_FALSE, &model_matrix[0][0]);
     164
    163165    glEnable(GL_DEPTH_TEST);
    164166    glDepthFunc(GL_LEQUAL);
     167#   if !defined HAVE_GLES_2X
    165168    glEnable(GL_ALPHA_TEST);
    166169    glAlphaFunc(GL_GEQUAL, 0.01f);
     170#   endif
    167171    glEnable(GL_BLEND);
    168172    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     
    205209        }
    206210
    207 #if LOL_EXPERIMENTAL
     211#if defined HAVE_GL_2X
    208212        glBindVertexArray(data->vao);
     213        glEnableVertexAttribArray(attr_pos);
     214        glEnableVertexAttribArray(attr_tex);
     215#elif defined HAVE_GLES_2X
     216        glEnableVertexAttribArray(attr_pos);
     217        glEnableVertexAttribArray(attr_tex);
    209218#else
    210219        glEnableClientState(GL_VERTEX_ARRAY);
     
    212221#endif
    213222
     223#if defined HAVE_GL_2X
    214224        glBindBuffer(GL_ARRAY_BUFFER, data->bufs[buf]);
    215225        glBufferData(GL_ARRAY_BUFFER, 18 * (n - i) * sizeof(GLfloat),
    216226                     vertex, GL_STATIC_DRAW);
    217 #if LOL_EXPERIMENTAL
    218227        glVertexAttribPointer(attr_pos, 3, GL_FLOAT, GL_FALSE, 0, 0);
    219         glEnableVertexAttribArray(attr_pos);
    220 #else
     228#elif defined HAVE_GLES_2X
     229        glBindBuffer(GL_ARRAY_BUFFER, data->bufs[buf]);
     230        glVertexAttribPointer(attr_pos, 3, GL_FLOAT, GL_FALSE, 0, vertex);
     231#elif defined HAVE_GL_1X
     232        glBindBuffer(GL_ARRAY_BUFFER, data->bufs[buf]);
     233        glBufferData(GL_ARRAY_BUFFER, 18 * (n - i) * sizeof(GLfloat),
     234                     vertex, GL_STATIC_DRAW);
    221235        glVertexPointer(3, GL_FLOAT, 0, NULL);
    222 #endif
    223 
     236#else
     237        glVertexPointer(3, GL_FLOAT, 0, vertex);
     238#endif
     239
     240#if defined HAVE_GL_2X
    224241        glBindBuffer(GL_ARRAY_BUFFER, data->bufs[buf + 1]);
    225242        glBufferData(GL_ARRAY_BUFFER, 12 * (n - i) * sizeof(GLfloat),
    226243                     texture, GL_STATIC_DRAW);
    227 #if LOL_EXPERIMENTAL
    228244        glVertexAttribPointer(attr_tex, 2, GL_FLOAT, GL_FALSE, 0, 0);
    229         glEnableVertexAttribArray(attr_tex);
    230 #else
     245#elif defined HAVE_GLES_2X
     246        glBindBuffer(GL_ARRAY_BUFFER, data->bufs[buf + 1]);
     247        glVertexAttribPointer(attr_tex, 2, GL_FLOAT, GL_FALSE, 0, texture);
     248#elif defined HAVE_GL_1X
     249        glBindBuffer(GL_ARRAY_BUFFER, data->bufs[buf + 1]);
     250        glBufferData(GL_ARRAY_BUFFER, 12 * (n - i) * sizeof(GLfloat),
     251                     texture, GL_STATIC_DRAW);
    231252        glTexCoordPointer(2, GL_FLOAT, 0, NULL);
    232 #endif
    233 
    234 #if LOL_EXPERIMENTAL
     253#else
     254        glTexCoordPointer(2, GL_FLOAT, 0, texture);
     255#endif
     256
     257#if defined HAVE_GL_2X || defined HAVE_GLES_2X
    235258        stdshader->Bind();
    236259#endif
     
    239262        glDrawArrays(GL_TRIANGLES, 0, (n - i) * 6);
    240263
    241 #if LOL_EXPERIMENTAL
     264#if defined HAVE_GL_2X
    242265        glBindVertexArray(0);
     266        glDisableVertexAttribArray(attr_pos);
     267        glDisableVertexAttribArray(attr_tex);
     268#elif defined HAVE_GLES_2X
     269        glDisableVertexAttribArray(attr_pos);
     270        glDisableVertexAttribArray(attr_tex);
    243271#else
    244272        glDisableClientState(GL_VERTEX_ARRAY);
Note: See TracChangeset for help on using the changeset viewer.