Esempio n. 1
0
void OGLRender::Initialize(void)
{
    glViewportWrapper(0, windowSetting.statusBarHeightToUse, windowSetting.uDisplayWidth, windowSetting.uDisplayHeight);
    OPENGL_CHECK_ERRORS;

    COGLGraphicsContext *pcontext = (COGLGraphicsContext *)(CGraphicsContext::g_pGraphicsContext);
    if( pcontext->IsExtensionSupported("GL_IBM_texture_mirrored_repeat") )
    {
        //OGLXUVFlagMaps[TEXTURE_UV_FLAG_MIRROR].realFlag = GL_MIRRORED_REPEAT_IBM;
    }
    else if( pcontext->IsExtensionSupported("ARB_texture_mirrored_repeat") )
    {
        //OGLXUVFlagMaps[TEXTURE_UV_FLAG_MIRROR].realFlag = GL_MIRRORED_REPEAT;
    }
    else
    {
        OGLXUVFlagMaps[TEXTURE_UV_FLAG_MIRROR].realFlag = GL_MIRRORED_REPEAT;
    }

//    if( pcontext->IsExtensionSupported("GL_texture_border_clamp") || pcontext->IsExtensionSupported("GL_EXT_texture_edge_clamp") )
//    {
        m_bSupportClampToEdge = true;
        OGLXUVFlagMaps[TEXTURE_UV_FLAG_CLAMP].realFlag = GL_CLAMP_TO_EDGE;
//    }
//    else
//    {
//        m_bSupportClampToEdge = false;
//        OGLXUVFlagMaps[TEXTURE_UV_FLAG_CLAMP].realFlag = GL_CLAMP_TO_EDGE;
//    }
    hardwareType = Android_JNI_GetHardwareType();
}
Esempio n. 2
0
void FindBestDepthBias()
{
#ifdef ANDROID_EDITION
  int hardwareType = Android_JNI_GetHardwareType();
  Android_JNI_GetPolygonOffset(hardwareType, 1, &polygonOffsetFactor, &polygonOffsetUnits);
#else
  float f, bestz = 0.25f;
  int x;
  if (biasFactor) return;
  biasFactor = 64.0f; // default value
  glPushAttrib(GL_ALL_ATTRIB_BITS);
  glEnable(GL_DEPTH_TEST);
  glDepthFunc(GL_ALWAYS);
  glEnable(GL_POLYGON_OFFSET_FILL);
  glDrawBuffer(GL_BACK);
  glReadBuffer(GL_BACK);
  glDisable(GL_BLEND);
  glDisable(GL_ALPHA_TEST);
  glColor4ub(255,255,255,255);
  glDepthMask(GL_TRUE);
  for (x=0, f=1.0f; f<=65536.0f; x+=4, f*=2.0f) {
    float z;
    glPolygonOffset(0, f);
    glBegin(GL_TRIANGLE_STRIP);
    glVertex3f(float(x+4 - widtho)/(width/2), float(0 - heighto)/(height/2), 0.5);
    glVertex3f(float(x - widtho)/(width/2), float(0 - heighto)/(height/2), 0.5);
    glVertex3f(float(x+4 - widtho)/(width/2), float(4 - heighto)/(height/2), 0.5);
    glVertex3f(float(x - widtho)/(width/2), float(4 - heighto)/(height/2), 0.5);
    glEnd();
    glReadPixels(x+2, 2+viewport_offset, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z);
    z -= 0.75f + 8e-6f;
    if (z<0.0f) z = -z;
    if (z > 0.01f) continue;
    if (z < bestz) {
      bestz = z;
      biasFactor = f;
    }
    //printf("f %g z %g\n", f, z);
  }
  //printf(" --> bias factor %g\n", biasFactor);
  glPopAttrib();
#endif
}
Esempio n. 3
0
void OGLRender::Initialize(void)
{
    glMatrixMode(GL_MODELVIEW);
    OPENGL_CHECK_ERRORS;
    glLoadIdentity();
    OPENGL_CHECK_ERRORS;

    glViewportWrapper(0, windowSetting.statusBarHeightToUse, windowSetting.uDisplayWidth, windowSetting.uDisplayHeight);
    OPENGL_CHECK_ERRORS;

#if SDL_VIDEO_OPENGL
    COGLGraphicsContext *pcontext = (COGLGraphicsContext *)(CGraphicsContext::g_pGraphicsContext);
    if( pcontext->IsExtensionSupported("GL_IBM_texture_mirrored_repeat") )
    {
        OGLXUVFlagMaps[TEXTURE_UV_FLAG_MIRROR].realFlag = GL_MIRRORED_REPEAT_IBM;
    }
    else if( pcontext->IsExtensionSupported("ARB_texture_mirrored_repeat") )
    {
        OGLXUVFlagMaps[TEXTURE_UV_FLAG_MIRROR].realFlag = GL_MIRRORED_REPEAT_ARB;
    }
    else
    {
        OGLXUVFlagMaps[TEXTURE_UV_FLAG_MIRROR].realFlag = GL_REPEAT;
    }

    if( pcontext->IsExtensionSupported("GL_ARB_texture_border_clamp") || pcontext->IsExtensionSupported("GL_EXT_texture_edge_clamp") )
    {
        m_bSupportClampToEdge = true;
        OGLXUVFlagMaps[TEXTURE_UV_FLAG_CLAMP].realFlag = GL_CLAMP_TO_EDGE;
    }
    else
    {
        m_bSupportClampToEdge = false;
        OGLXUVFlagMaps[TEXTURE_UV_FLAG_CLAMP].realFlag = GL_CLAMP;
    }

    glVertexPointer( 4, GL_FLOAT, sizeof(float)*5, &(g_vtxProjected5[0][0]) );
    OPENGL_CHECK_ERRORS;
    glEnableClientState( GL_VERTEX_ARRAY );
    OPENGL_CHECK_ERRORS;

    if( m_bMultiTexture )
    {
        pglClientActiveTextureARB( GL_TEXTURE0_ARB );
        OPENGL_CHECK_ERRORS;
        glTexCoordPointer( 2, GL_FLOAT, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[0].u) );
        OPENGL_CHECK_ERRORS;
        glEnableClientState( GL_TEXTURE_COORD_ARRAY );
        OPENGL_CHECK_ERRORS;

        pglClientActiveTextureARB( GL_TEXTURE1_ARB );
        OPENGL_CHECK_ERRORS;
        glTexCoordPointer( 2, GL_FLOAT, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[1].u) );
        OPENGL_CHECK_ERRORS;
        glEnableClientState( GL_TEXTURE_COORD_ARRAY );
        OPENGL_CHECK_ERRORS;
    }
    else
    {
        glTexCoordPointer( 2, GL_FLOAT, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[0].u) );
        OPENGL_CHECK_ERRORS;
        glEnableClientState( GL_TEXTURE_COORD_ARRAY );
        OPENGL_CHECK_ERRORS;
    }

    if (m_bSupportFogCoordExt)
    {
        pglFogCoordPointerEXT( GL_FLOAT, sizeof(float)*5, &(g_vtxProjected5[0][4]) );
        OPENGL_CHECK_ERRORS;
        glEnableClientState( GL_FOG_COORDINATE_ARRAY_EXT );
        OPENGL_CHECK_ERRORS;
        glFogi( GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT );
        OPENGL_CHECK_ERRORS;
        glFogi(GL_FOG_MODE, GL_LINEAR); // Fog Mode
        OPENGL_CHECK_ERRORS;
        glFogf(GL_FOG_DENSITY, 1.0f); // How Dense Will The Fog Be
        OPENGL_CHECK_ERRORS;
        glHint(GL_FOG_HINT, GL_FASTEST); // Fog Hint Value
        OPENGL_CHECK_ERRORS;
        glFogi( GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT );
        OPENGL_CHECK_ERRORS;
        glFogf( GL_FOG_START, 0.0f );
        OPENGL_CHECK_ERRORS;
        glFogf( GL_FOG_END, 1.0f );
        OPENGL_CHECK_ERRORS;
    }

    //glColorPointer( 1, GL_UNSIGNED_BYTE, sizeof(TLITVERTEX), &g_vtxBuffer[0].r);
    glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) );
    OPENGL_CHECK_ERRORS;
    glEnableClientState( GL_COLOR_ARRAY );
    OPENGL_CHECK_ERRORS;

    if( pcontext->IsExtensionSupported("GL_NV_depth_clamp") )
    {
        glEnable(GL_DEPTH_CLAMP_NV);
        OPENGL_CHECK_ERRORS;
    }

#elif SDL_VIDEO_OPENGL_ES2
    OGLXUVFlagMaps[TEXTURE_UV_FLAG_MIRROR].realFlag = GL_MIRRORED_REPEAT;
    m_bSupportClampToEdge = true;
    OGLXUVFlagMaps[TEXTURE_UV_FLAG_CLAMP].realFlag = GL_CLAMP_TO_EDGE;
#endif

#ifdef PAULSCODE
    hardwareType = Android_JNI_GetHardwareType();
#endif
}