Beispiel #1
0
int GLinitialize()
{
//----------------------------------------------------//
#ifdef _WINDOWS
    HGLRC objectRC;
// init
    dcGlobal = GetDC(hWWindow);                           // FIRST: dc/rc stuff
    objectRC = wglCreateContext(dcGlobal);
    GLCONTEXT=objectRC;
    wglMakeCurrent(dcGlobal, objectRC);
// CheckWGLExtensions(dcGlobal);
    if(bWindowMode) ReleaseDC(hWWindow,dcGlobal);         // win mode: release dc again
#endif
#ifdef MAEMO_CHANGES
    maemoGLinit();
#endif
//----------------------------------------------------//

    glViewport(rRatioRect.left,                           // init viewport by ratio rect
               iResY-(rRatioRect.top+rRatioRect.bottom),
               rRatioRect.right,
               rRatioRect.bottom);

    glScissor(0, 0, iResX, iResY);                        // init clipping (fullscreen)
    glEnable(GL_SCISSOR_TEST);

#ifndef OWNSCALE
    glMatrixMode(GL_TEXTURE);                             // init psx tex sow and tow if not "ownscale"
    glLoadIdentity();
    glScalef(1.0f/255.99f,1.0f/255.99f,1.0f);             // geforce precision hack
#endif

    glMatrixMode(GL_PROJECTION);                          // init projection with psx resolution
    glLoadIdentity();
    glOrtho(0,PSXDisplay.DisplayMode.x,
            PSXDisplay.DisplayMode.y, 0, -1, 1);

    if(iZBufferDepth)                                     // zbuffer?
    {
        uiBufferBits=GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT;
        glEnable(GL_DEPTH_TEST);
        glDepthFunc(GL_ALWAYS);
        iDepthFunc=1;
    }
    else                                                  // no zbuffer?
    {
        uiBufferBits=GL_COLOR_BUFFER_BIT;
        glDisable(GL_DEPTH_TEST);
    }

    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);                 // first buffer clear
    glClear(uiBufferBits);

    GetExtInfos();                                        // get ext infos
    SetExtGLFuncs();                                      // init all kind of stuff (tex function pointers)

    glEnable(GL_ALPHA_TEST);                              // wanna alpha test

    {
        glDisable(GL_LINE_SMOOTH);
        glDisable(GL_POINT_SMOOTH);
    }

    ubGloAlpha=127;                                       // init some drawing vars
    ubGloColAlpha=127;
    TWin.UScaleFactor = 1;
    TWin.VScaleFactor = 1;
    bDrawMultiPass=FALSE;
    bTexEnabled=FALSE;
    bUsingTWin=FALSE;

    if(bDrawDither)  glEnable(GL_DITHER);                 // dither mode
    else             glDisable(GL_DITHER);

    glDisable(GL_FOG);                                    // turn all (currently) unused modes off
    glDisable(GL_LIGHTING);
    glDisable(GL_STENCIL_TEST);
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_CULL_FACE);

    glFlush();                                            // we are done...
    glFinish();

    CreateScanLines();                                    // setup scanline stuff (if wanted)

    CheckTextureMemory();                                 // check available tex memory

    if(bKeepRatio) SetAspectRatio();                      // set ratio


    bIsFirstFrame = FALSE;                                // we have survived the first frame :)

    return 0;
}
Beispiel #2
0
int GLinitialize() 
{
 glViewport(rRatioRect.left,                           // init viewport by ratio rect
            iResY-(rRatioRect.top+rRatioRect.bottom),
            rRatioRect.right, 
            rRatioRect.bottom);         
                                                      
 glScissor(0, 0, iResX, iResY);                        // init clipping (fullscreen)
 glEnable(GL_SCISSOR_TEST);                       

#ifndef OWNSCALE
 glMatrixMode(GL_TEXTURE);                             // init psx tex sow and tow if not "ownscale"
 glLoadIdentity();
 glScalef(1.0f/255.99f,1.0f/255.99f,1.0f);             // geforce precision hack
#endif 

 glMatrixMode(GL_PROJECTION);                          // init projection with psx resolution
 glLoadIdentity();
 glOrtho(0,PSXDisplay.DisplayMode.x,
         PSXDisplay.DisplayMode.y, 0, -1, 1);

 if(iZBufferDepth)                                     // zbuffer?
  {
   uiBufferBits=GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT;
   glEnable(GL_DEPTH_TEST);    
   glDepthFunc(GL_ALWAYS);
   iDepthFunc=1;
  }
 else                                                  // no zbuffer?
  {
   uiBufferBits=GL_COLOR_BUFFER_BIT;
   glDisable(GL_DEPTH_TEST);
  }

 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);                 // first buffer clear
 glClear(uiBufferBits);

 if(bUseLines)                                         // funny lines 
  {
   glPolygonMode(GL_FRONT, GL_LINE); 
   glPolygonMode(GL_BACK, GL_LINE); 
  }
 else                                                  // or the real filled thing
  {
   glPolygonMode(GL_FRONT, GL_FILL);
   glPolygonMode(GL_BACK, GL_FILL);
  }

 MakeDisplayLists();                                   // lists for menu/opaque
 GetExtInfos();                                        // get ext infos
 SetExtGLFuncs();                                      // init all kind of stuff (tex function pointers)
 
 glEnable(GL_ALPHA_TEST);                              // wanna alpha test

 if(!bUseAntiAlias)                                    // no anti-alias (default)
  {
   glDisable(GL_LINE_SMOOTH);
   glDisable(GL_POLYGON_SMOOTH);
   glDisable(GL_POINT_SMOOTH);
  }
 else                                                  // wanna try it? glitches galore...
  {                    
   glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
   glEnable(GL_LINE_SMOOTH);
   glEnable(GL_POLYGON_SMOOTH);
   glEnable(GL_POINT_SMOOTH);
   glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
   glHint(GL_POINT_SMOOTH_HINT,GL_NICEST);
   glHint(GL_POLYGON_SMOOTH_HINT,GL_NICEST);
  }

 ubGloAlpha=127;                                       // init some drawing vars
 ubGloColAlpha=127;
 TWin.UScaleFactor = 1;
 TWin.VScaleFactor = 1;
 bDrawMultiPass=FALSE;
 bTexEnabled=FALSE;
 bUsingTWin=FALSE;
      
 if(bDrawDither)  glEnable(GL_DITHER);                 // dither mode
 else             glDisable(GL_DITHER); 

 glDisable(GL_FOG);                                    // turn all (currently) unused modes off
 glDisable(GL_LIGHTING);  
 glDisable(GL_LOGIC_OP);
 glDisable(GL_STENCIL_TEST);  
 glDisable(GL_TEXTURE_1D);
 glDisable(GL_TEXTURE_2D);
 glDisable(GL_CULL_FACE);

 glPixelTransferi(GL_RED_SCALE, 1);                    // to be sure:
 glPixelTransferi(GL_RED_BIAS, 0);                     // init more OGL vals
 glPixelTransferi(GL_GREEN_SCALE, 1);
 glPixelTransferi(GL_GREEN_BIAS, 0);
 glPixelTransferi(GL_BLUE_SCALE, 1);
 glPixelTransferi(GL_BLUE_BIAS, 0);
 glPixelTransferi(GL_ALPHA_SCALE, 1);
 glPixelTransferi(GL_ALPHA_BIAS, 0);                                                  

 printf(glGetString(GL_VENDOR));                       // linux: tell user what is getting used
 printf("\n");
 printf(glGetString(GL_RENDERER));
 printf("\n");

 glFlush();                                            // we are done...
 glFinish();                           

 CreateScanLines();                                    // setup scanline stuff (if wanted)

 CheckTextureMemory();                                 // check available tex memory

 if(bKeepRatio) SetAspectRatio();                      // set ratio

 if(iShowFPS)                                          // user wants FPS display on startup?
  {
   ulKeybits|=KEY_SHOWFPS;                             // -> ok, turn display on
   szDispBuf[0]=0;
   BuildDispMenu(0);
  }
 
 bIsFirstFrame = FALSE;                                // we have survived the first frame :)

 return 0;
}
int GLinitialize(void *ext_gles_display, void *ext_gles_surface)
{
 if(ext_gles_display != NULL && ext_gles_surface != NULL) { 
  display = (EGLDisplay)ext_gles_display;
  surface = (EGLSurface)ext_gles_surface;
 }
 else {
  if(initEGL()!=0)
   return -1;
  created_gles_context=1;
 }

 //----------------------------------------------------// 

 glDepthRangef(0.0f, 1.0f);glError();

 glViewport(rRatioRect.left,                           // init viewport by ratio rect
            iResY-(rRatioRect.top+rRatioRect.bottom),
            rRatioRect.right, 
            rRatioRect.bottom); glError();

 glScissor(0, 0, iResX, iResY); glError();             // init clipping (fullscreen)
 glEnable(GL_SCISSOR_TEST); glError();

#ifndef OWNSCALE
 glMatrixMode(GL_TEXTURE);                             // init psx tex sow and tow if not "ownscale"
 glLoadIdentity();
 glScalef(1.0f/255.99f,1.0f/255.99f,1.0f);             // geforce precision hack
#endif 
 
 //glPolygonOffset( -0.2f, -0.2f );glError();

 glMatrixMode(GL_PROJECTION); glError();               // init projection with psx resolution
 glLoadIdentity(); glError();

 glOrtho(0,PSXDisplay.DisplayMode.x,
         PSXDisplay.DisplayMode.y, 0, -1, 1); glError();

 if(iZBufferDepth)                                     // zbuffer?
  {
   uiBufferBits=GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT;
   glEnable(GL_DEPTH_TEST); glError();
   glDepthFunc(GL_ALWAYS); glError();
   iDepthFunc=1;
  }
 else                                                  // no zbuffer?
  {
   uiBufferBits=GL_COLOR_BUFFER_BIT;
   glDisable(GL_DEPTH_TEST); glError();
  }

 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glError();      // first buffer clear
 glClear(uiBufferBits); glError();

 GetExtInfos();                                        // get ext infos
 SetExtGLFuncs();                                      // init all kind of stuff (tex function pointers)
 
 glEnable(GL_ALPHA_TEST); glError();                   // wanna alpha test

  {
   glDisable(GL_LINE_SMOOTH); glError();
   glDisable(GL_POINT_SMOOTH); glError();
  }

 ubGloAlpha=127;                                       // init some drawing vars
 ubGloColAlpha=127;
 TWin.UScaleFactor = 1;
 TWin.VScaleFactor = 1;
 bDrawMultiPass=FALSE;
 bTexEnabled=FALSE;
 bUsingTWin=FALSE;
      
 if(bDrawDither)  glEnable(GL_DITHER);                 // dither mode
 else             glDisable(GL_DITHER); 
 glError(); 
 glDisable(GL_FOG); glError();                          // turn all (currently) unused modes off
 glDisable(GL_LIGHTING); glError();  
 glDisable(GL_STENCIL_TEST); glError();  
 glDisable(GL_TEXTURE_2D); glError();
 glDisable(GL_CULL_FACE);

 glFlush(); glError();                                 // we are done...
 glFinish(); glError();                           

 CreateScanLines();                                    // setup scanline stuff (if wanted)

 CheckTextureMemory();                                 // check available tex memory

 if(bKeepRatio) SetAspectRatio();                      // set ratio

 
 bIsFirstFrame = FALSE;                                // we have survived the first frame :)

 return 0;
}