Ignore:
Timestamp:
2010-05-28 07:39:52 (2 years ago)
Author:
kpoole
Message:

Episode 5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Classes/SDL/src/video/SDL_renderer_gles.c

    r19 r26  
    3333// KP: render queue and automatic z-order support 
    3434#include "RenderQueue.h" 
     35 
     36extern unsigned char gFlippedGL; 
     37extern unsigned char gInitializedGL; 
     38 
     39unsigned char gInitializedGL = 0; 
    3540 
    3641#if defined(__QNXNTO__) 
     
    343348*/ 
    344349     
     350    glClearDepthf(1.0f); 
     351     
    345352    data->glDisable(GL_CULL_FACE); 
    346353    data->updateSize = SDL_TRUE; 
     
    358365    data->glEnableClientState(GL_TEXTURE_COORD_ARRAY); 
    359366    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);  
    360     data->glClearColor(0.0f,0.0f,0.5f,1.0f); 
     367    data->glClearColor(0.0f,0.0f,0.0f,1.0f); 
     368    glClearStencil(0); 
    361369     
    362370    // KP: multitexture support used for effects like greyscale 
     
    368376    GLuint texID; 
    369377    glGenTextures(1, &texID); 
    370     glBindTexture(GL_TEXTURE_2D, texID); 
     378    //glBindTexture(GL_TEXTURE_2D, texID); 
     379    cacheBindTexture(GL_TEXTURE_2D, texID, 1); 
    371380    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 
    372381    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 
     
    396405        glMatrixMode(GL_MODELVIEW); 
    397406        glLoadIdentity(); 
     407    #ifdef __IPAD__ 
     408        glViewport(0, 0, 768, 1024); 
     409        if (gFlippedGL) 
     410            glRotatef(90, 0, 0, 1); 
     411        else 
     412            glRotatef(-90, 0, 0, 1); 
     413        glOrthof(0.0, (GLfloat) 1024, (GLfloat) 768, 0.0, 0, 100.0f); 
     414    #else 
    398415        glViewport(0, 0, 320, 480); 
    399         glRotatef(-90, 0, 0, 1); 
    400         glOrthof(0.0, (GLfloat) 480, (GLfloat) 320, 0.0, 400, -400); 
    401          
     416        if (gFlippedGL) 
     417            glRotatef(90, 0, 0, 1); 
     418        else 
     419            glRotatef(-90, 0, 0, 1); 
     420        glOrthof(0.0, (GLfloat) 480, (GLfloat) 320, 0.0, 0, 100.0f); 
     421    #endif   
    402422#else 
    403423        data->glMatrixMode(GL_PROJECTION); 
     
    411431        data->updateSize = SDL_FALSE; 
    412432    } 
     433     
     434    gInitializedGL = 1; 
    413435    return 0; 
    414436} 
     
    631653    GLenum result; 
    632654 
    633     renderdata->glGetError(); 
     655//    renderdata->glGetError(); 
    634656//    renderdata->glEnable(data->type); 
    635657    SetupTextureUpdate(renderdata, texture, pitch); 
     
    638660                                pixels); 
    639661//    renderdata->glDisable(data->type); 
     662     
     663#ifndef NDEBUG   
    640664    result = renderdata->glGetError(); 
    641665    if (result != GL_NO_ERROR) { 
     
    643667        return -1; 
    644668    } 
     669#endif 
    645670    return 0; 
    646671} 
     
    720745    GLES_SetBlendMode(data, renderer->blendMode); 
    721746 
    722     data->glColor4f((GLfloat) renderer->r * inv255f, 
     747    cacheColor4f((GLfloat) renderer->r * inv255f, 
    723748                    (GLfloat) renderer->g * inv255f, 
    724749                    (GLfloat) renderer->b * inv255f, 
     
    746771    GLES_SetBlendMode(data, renderer->blendMode); 
    747772 
    748     data->glColor4f((GLfloat) renderer->r * inv255f, 
     773    cacheColor4f((GLfloat) renderer->r * inv255f, 
    749774                    (GLfloat) renderer->g * inv255f, 
    750775                    (GLfloat) renderer->b * inv255f, 
     
    797822    GLshort maxy = rect->y + rect->h; 
    798823 
    799     GLshort vertices[8]; 
     824    GLshort vertices[12]; 
    800825    vertices[0] = minx; 
    801826    vertices[1] = miny; 
    802     vertices[2] = maxx; 
    803     vertices[3] = miny; 
    804     vertices[4] = minx; 
    805     vertices[5] = maxy; 
    806     vertices[6] = maxx; 
     827    vertices[2] = 0; 
     828    vertices[3] = maxx; 
     829    vertices[4] = miny; 
     830    vertices[5] = 0; 
     831    vertices[6] = minx; 
    807832    vertices[7] = maxy; 
     833    vertices[8] = 0; 
     834    vertices[9] = maxx; 
     835    vertices[10] = maxy; 
     836    vertices[11] = 0; 
    808837/*   
    809838    data->glVertexPointer(3, GL_SHORT, 0, vertices); 
     
    964993        maxv *= texturedata->texh; 
    965994 
    966         GLshort vertices[8]; 
     995        GLshort vertices[12]; 
    967996        GLfloat texCoords[8]; 
    968997         
    969998        vertices[0] = minx; 
    970999        vertices[1] = miny; 
    971         vertices[2] = maxx; 
    972         vertices[3] = miny; 
    973         vertices[4] = minx; 
    974         vertices[5] = maxy; 
    975         vertices[6] = maxx; 
     1000        vertices[2] = 0; 
     1001        vertices[3] = maxx; 
     1002        vertices[4] = miny; 
     1003        vertices[5] = 0; 
     1004        vertices[6] = minx; 
    9761005        vertices[7] = maxy; 
     1006        vertices[8] = 0; 
     1007        vertices[9] = maxx; 
     1008        vertices[10] = maxy; 
     1009        vertices[11] = 0; 
    9771010                 
    9781011        texCoords[0] = minu; 
     
    10301063    // KP: clear the buffer after rendering 
    10311064    //GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; 
    1032     glClear( /*GL_COLOR_BUFFER_BIT |*/ GL_DEPTH_BUFFER_BIT ); 
     1065//  glClear( /*GL_COLOR_BUFFER_BIT |*/ GL_DEPTH_BUFFER_BIT ); 
     1066    glClear(GL_DEPTH_BUFFER_BIT); 
    10331067} 
    10341068 
Note: See TracChangeset for help on using the changeset viewer.