GLES2N64: Enabled Framebuffer (and lowres) rendering
authorptitSeb <sebastien.chev@gmail.com>
Tue, 22 Oct 2013 16:16:47 +0000 (18:16 +0200)
committerptitSeb <sebastien.chev@gmail.com>
Tue, 22 Oct 2013 16:16:47 +0000 (18:16 +0200)
source/gles2n64/src/Config.cpp
source/gles2n64/src/OpenGL.cpp
source/gles2n64/src/OpenGL.h [changed mode: 0644->0755]
source/gles2n64/src/eglport.cpp

index 469f350..99d3d69 100755 (executable)
@@ -64,7 +64,7 @@ Option configOptions[] =
     {"", NULL, 0},
 
     {"#Framebuffer Settings:",NULL,0},
-//    {"framebuffer enable", &config.framebuffer.enable, 0},
+    {"framebuffer enable", &config.framebuffer.enable, 0},
     {"framebuffer bilinear", &config.framebuffer.bilinear, 0},
     {"framebuffer width", &config.framebuffer.width, 400},
     {"framebuffer height", &config.framebuffer.height, 240},
@@ -99,8 +99,8 @@ Option configOptions[] =
     {"", NULL, 0},
 
     {"#Frame skip:", NULL, 0},
-    {"auto frameskip", &config.autoFrameSkip, 0},
-    {"max frameskip", &config.maxFrameSkip, 0},
+    {"auto frameskip", &config.autoFrameSkip, 1},
+    {"max frameskip", &config.maxFrameSkip, 3},
     {"target FPS", &config.targetFPS, 20},
     {"frame render rate", &config.frameRenderRate, 1},
     {"vertical sync", &config.verticalSync, 0},
index c9c029f..6a386f9 100755 (executable)
@@ -81,6 +81,7 @@ const char _default_fsh[] = "                           \n\t" \
 "gl_FragColor = texture2D(uTex, vTexCoord);             \n\t" \
 "}                                                      \n\t";
 
+
 void OGL_EnableRunfast()
 {
 #ifdef ARM_ASM
@@ -224,10 +225,12 @@ void OGL_ResizeWindow(int x, int y, int width, int height)
     config.window.width = width;
     config.window.height = height;
 
-    config.framebuffer.xpos = x;
-    config.framebuffer.ypos = y;
-    config.framebuffer.width = width;
-    config.framebuffer.height = height;
+       if (config.framebuffer.enable!=1) {
+               config.framebuffer.xpos = x;
+               config.framebuffer.ypos = y;
+               config.framebuffer.width = width;
+               config.framebuffer.height = height;
+       }
     OGL_UpdateScale();
 
     glViewport(config.framebuffer.xpos, config.framebuffer.ypos,
@@ -305,20 +308,23 @@ else*/
     //set xpos and ypos
     config.window.xpos = x;
     config.window.ypos = y;
-    config.framebuffer.xpos = x;
-    config.framebuffer.ypos = y;
     
     //set width and height
     config.window.width = (int)videoWidth;
     config.window.height = (int)videoHeight;
-    config.framebuffer.width = (int)videoWidth;
-    config.framebuffer.height = (int)videoHeight;
+       if (config.framebuffer.enable!=1) {
+               config.framebuffer.xpos = x;
+               config.framebuffer.ypos = y;
+               config.framebuffer.width = (int)videoWidth;
+               config.framebuffer.height = (int)videoHeight;
+       }
        
        EGL_Open(800, 480);
 ////
     return true;
 }
 #endif
+
 //////
 
 #ifdef USE_SDL
@@ -328,7 +334,6 @@ void Android_JNI_SwapWindow()
 }
 #endif
 
-
 bool OGL_Start()
 {
 // paulscode, initialize SDL
@@ -368,13 +373,18 @@ bool OGL_Start()
         }
 
         glGenFramebuffers(1, &OGL.framebuffer.fb);
-        glGenRenderbuffers(1, &OGL.framebuffer.depth_buffer);
         glGenTextures(1, &OGL.framebuffer.color_buffer);
-        glBindRenderbuffer(GL_RENDERBUFFER, OGL.framebuffer.depth_buffer);
-        glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24_OES, config.framebuffer.width, config.framebuffer.height);
         glBindTexture(GL_TEXTURE_2D, OGL.framebuffer.color_buffer);
         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, config.framebuffer.width, config.framebuffer.height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL);
-        glBindFramebuffer(GL_FRAMEBUFFER, OGL.framebuffer.fb);
+                       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+                       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+                       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+                       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+                       glBindTexture(GL_TEXTURE_2D, 0);
+        glGenRenderbuffers(1, &OGL.framebuffer.depth_buffer);
+        glBindRenderbuffer(GL_RENDERBUFFER, OGL.framebuffer.depth_buffer);
+        glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24_OES, config.framebuffer.width, config.framebuffer.height);
+               glBindFramebuffer(GL_FRAMEBUFFER, OGL.framebuffer.fb);
         glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, OGL.framebuffer.color_buffer, 0);
         glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, OGL.framebuffer.depth_buffer);
 
@@ -1271,15 +1281,20 @@ void OGL_SwapBuffers()
     }
 #endif
 
+    // if emulator defined a render callback function, call it before
+       // buffer swap
+    if (renderCallback) (*renderCallback)();
+
     if (config.framebuffer.enable)
     {
         glBindFramebuffer(GL_FRAMEBUFFER, 0);
-        glClearColor( 0, 0, 0, 1 );
+        glClearColor( 0, 0, 0, 1 );    
         glClear( GL_COLOR_BUFFER_BIT );
 
         glUseProgram(OGL.defaultProgram);
         glDisable(GL_SCISSOR_TEST);
         glDisable(GL_DEPTH_TEST);
+               glDisable(GL_CULL_FACE);        //*SEB*
         glViewport(config.window.xpos, config.window.ypos, config.window.width, config.window.height);
 
         static const float vert[] =
@@ -1313,6 +1328,7 @@ void OGL_SwapBuffers()
 
         glBindFramebuffer(GL_FRAMEBUFFER, OGL.framebuffer.fb);
         OGL_UpdateViewport();
+               OGL_UpdateCullFace();
         if (scProgramCurrent) glUseProgram(scProgramCurrent->program);
         OGL.renderState = RS_NONE;
     }
@@ -1321,10 +1337,6 @@ void OGL_SwapBuffers()
         Android_JNI_SwapWindow(); // paulscode, fix for black-screen bug
     }
 
-    // if emulator defined a render callback function, call it before
-       // buffer swap
-    if (renderCallback) (*renderCallback)();
-
     OGL.screenUpdate = false;
 
     if (config.forceBufferClear)
old mode 100644 (file)
new mode 100755 (executable)
index 3db0743..b403d78
@@ -10,6 +10,9 @@
 //    #include <GLES2/gl2extimg.h>
     #include <SDL.h>
 #endif
+#ifdef USE_X11
+       #include <EGL/egl.h>
+#endif
 
 #ifndef min
 #define min(a,b) ((a) < (b) ? (a) : (b))
@@ -77,7 +80,8 @@ struct GLInfo
 #ifdef USE_SDL
 // TODO: More EGL stuff, need to do this in Java
     SDL_Surface *hScreen;  // TODO: Do we really need this?  Only using it in one place AFAICT..
-/*
+#endif
+#ifdef USE_X11
     struct
     {
         EGLint                     version_major, version_minor;
@@ -88,7 +92,6 @@ struct GLInfo
         EGLNativeDisplayType    device;
         EGLNativeWindowType     handle;
     } EGL;
-*/
 #endif
 
     bool    screenUpdate;
index b6c5e2a..9895cc2 100755 (executable)
@@ -341,12 +341,12 @@ void OpenCfg ( const char* file )
     eglSettings[CFG_VSYNC]          = 0;
     eglSettings[CFG_FSAA]           = 0;
     eglSettings[CFG_FPS]            = 0;
-    eglSettings[CFG_RED_SIZE]       = 5;
-    eglSettings[CFG_GREEN_SIZE]     = 6;
-    eglSettings[CFG_BLUE_SIZE]      = 5;
+    eglSettings[CFG_RED_SIZE]       = 0;
+    eglSettings[CFG_GREEN_SIZE]     = 0;
+    eglSettings[CFG_BLUE_SIZE]      = 0;
     eglSettings[CFG_ALPHA_SIZE]     = 0;
     eglSettings[CFG_DEPTH_SIZE]     = 16;
-    eglSettings[CFG_BUFFER_SIZE]    = 16;
+    eglSettings[CFG_BUFFER_SIZE]    = 0;
     eglSettings[CFG_STENCIL_SIZE]   = 0;
 
     /* Parse INI file */
@@ -382,7 +382,7 @@ int8_t FindEGLConfigs( void )
 {
     EGLBoolean result;
     int attrib = 0;
-    EGLint ConfigAttribs[23];
+    EGLint ConfigAttribs[27];
 
     ConfigAttribs[attrib++] = EGL_RED_SIZE;                         /* 1 */
     ConfigAttribs[attrib++] = eglSettings[CFG_RED_SIZE];            /* 2 */
@@ -412,7 +412,11 @@ int8_t FindEGLConfigs( void )
     ConfigAttribs[attrib++] = (eglSettings[CFG_FSAA] > 0) ? 1 : 0;  /* 20 */
     ConfigAttribs[attrib++] = EGL_SAMPLES;                          /* 21 */
     ConfigAttribs[attrib++] = eglSettings[CFG_FSAA];                /* 22 */
-    ConfigAttribs[attrib++] = EGL_NONE;                             /* 23 */
+    ConfigAttribs[attrib++] = EGL_NATIVE_RENDERABLE;                /* 23 */
+    ConfigAttribs[attrib++] = EGL_FALSE;                            /* 24 */
+    ConfigAttribs[attrib++] = EGL_LEVEL;                            /* 25 */
+    ConfigAttribs[attrib++] = 0;                                    /* 26 */
+    ConfigAttribs[attrib++] = EGL_NONE;                             /* 27 */
 
     result = peglChooseConfig( eglDisplay, ConfigAttribs, eglConfigs, totalConfigsIn, &totalConfigsFound );
     if (result != EGL_TRUE || totalConfigsFound == 0)