X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fgpu-gles%2FgpuDraw.c;h=b6191046aaa14a73bc213b899be2e7d7dc53c5e9;hp=3842503faa84f049183a0540bcfb2a2074d9e815;hb=6f6fe96900374d8744473ce240279e66d1260191;hpb=13326d3e8422568b7f5528e7b8878b2f496ea652 diff --git a/plugins/gpu-gles/gpuDraw.c b/plugins/gpu-gles/gpuDraw.c index 3842503f..b6191046 100644 --- a/plugins/gpu-gles/gpuDraw.c +++ b/plugins/gpu-gles/gpuDraw.c @@ -175,8 +175,7 @@ void SetExtGLFuncs(void) if(bAdvancedBlend) bUseMultiPass=TRUE; // -> pseudo-advanced with 2 passes else bUseMultiPass=FALSE; // -> or simple 'bright color' mode // bGLBlend=FALSE; // -> no ext blending! - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glError(); } if(bOpaquePass) // opaque mode? @@ -193,13 +192,15 @@ void SetExtGLFuncs(void) } TCF[1]=XP8RGBA_1; - glAlphaFuncx(GL_GREATER,0.49f); + glAlphaFuncx(GL_GREATER,0.49f); glError(); + } else // no opaque mode? { TCF[0]=TCF[1]=P8RGBA; PalTexturedColourFn=P8RGBA; // -> init col func - glAlphaFuncx(GL_NOTEQUAL,0); // --> set alpha func + glAlphaFuncx(GL_NOTEQUAL,0); glError(); // --> set alpha func + } //----------------------------------------------------// @@ -207,7 +208,8 @@ void SetExtGLFuncs(void) LoadSubTexFn=LoadSubTexturePageSort; // init load tex ptr bBlendEnable=FALSE; // init blending: off - glDisable(GL_BLEND); + glDisable(GL_BLEND); glError(); + SetScanTrans(); // init scan lines (if wanted) } @@ -289,15 +291,17 @@ bool TestEGLError(const char* pszLocation) EGLint iErr = eglGetError(); if (iErr != EGL_SUCCESS) { - printf("%s failed (%d).\n", pszLocation, iErr); + printf("%s failed (0x%x).\n", pszLocation, iErr); return FALSE; } return TRUE; } -static void initEGL(void) +static int initEGL(void) { + NativeWindowType window = 0; + printf ("GL init\n"); EGLint numConfigs; @@ -334,9 +338,10 @@ static void initEGL(void) if (!x11Display) { printf("GLES Error: Unable to open X display\n"); + return -1; } x11Screen = XDefaultScreen( x11Display ); - + // Gets the display parameters so we can pass the same parameters to the window to be created. sRootWindow = RootWindow(x11Display, x11Screen); i32Depth = DefaultDepth(x11Display, x11Screen); @@ -345,7 +350,8 @@ static void initEGL(void) if (!px11Visual) { printf("GLES Error: Unable to acquire visual\n"); - } + return -1; + } // Colormap of the specified visual type for the display. x11Colormap = XCreateColormap( x11Display, sRootWindow, px11Visual->visual, AllocNone ); sWA.colormap = x11Colormap; @@ -355,7 +361,7 @@ static void initEGL(void) // Display capabilities list. ui32Mask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap; - + // Creates the X11 window x11Window = XCreateWindow( x11Display, RootWindow(x11Display, x11Screen), 0, 0, iResX, iResY, 0, CopyFromParent, InputOutput, CopyFromParent, ui32Mask, &sWA); @@ -383,6 +389,7 @@ static void initEGL(void) XSendEvent(x11Display, DefaultRootWindow(x11Display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); display = eglGetDisplay( (EGLNativeDisplayType)x11Display ); + window = x11Window; #else display = eglGetDisplay( (EGLNativeDisplayType)0 ); #endif @@ -390,86 +397,99 @@ static void initEGL(void) if( display == EGL_NO_DISPLAY ) { printf( "GLES EGL Error: GL No Display\n" ); + return -1; } if( !eglInitialize( display, &majorVersion, &minorVersion ) ) { printf( "GLES EGL Error: eglInitialize failed\n" ); + return -1; } if( !eglChooseConfig( display, attribList, &config, 1, &numConfigs ) ) { printf( "GLES EGL Error: eglChooseConfig failed\n" ); + return -1; } context = eglCreateContext( display, config, NULL, NULL ); if( context==0 ) { printf( "GLES EGL Error: eglCreateContext failed\n" ); + return -1; } -#if defined(USE_X11) - surface = eglCreateWindowSurface( display, config, (EGLNativeDisplayType)x11Window, NULL ); -#else - surface = eglCreateWindowSurface( display, config, (EGLNativeDisplayType)0, NULL ); +#ifdef FAKE_WINDOW + // broken Caanoo libs won't accept NULL window + window = (NativeWindowType)1; #endif + surface = eglCreateWindowSurface( display, config, window, NULL ); + if (!TestEGLError("eglCreateWindowSurface")) + return -1; + + eglMakeCurrent( display, surface, surface, context ); + if (!TestEGLError("eglMakeCurrent")) + return -1; - eglMakeCurrent( display, surface, surface, context ); - if (!TestEGLError("eglMakeCurrent")) - printf("error eglMakeCurrent"); - else - printf("GLES Window Opened\n"); + printf("GLES init ok\n"); + return 0; } int GLinitialize() { - initEGL(); + if(initEGL()!=0) + return -1; //----------------------------------------------------// + glDepthRangef(0.0f, 1.0f);glError(); + glViewport(rRatioRect.left, // init viewport by ratio rect iResY-(rRatioRect.top+rRatioRect.bottom), rRatioRect.right, - rRatioRect.bottom); + rRatioRect.bottom); glError(); - glScissor(0, 0, iResX, iResY); // init clipping (fullscreen) - glEnable(GL_SCISSOR_TEST); + 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(); - glMatrixMode(GL_PROJECTION); // init projection with psx resolution - glLoadIdentity(); glOrtho(0,PSXDisplay.DisplayMode.x, - PSXDisplay.DisplayMode.y, 0, -1, 1); + PSXDisplay.DisplayMode.y, 0, -1, 1); glError(); if(iZBufferDepth) // zbuffer? { uiBufferBits=GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT; - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_ALWAYS); + glEnable(GL_DEPTH_TEST); glError(); + glDepthFunc(GL_ALWAYS); glError(); iDepthFunc=1; } else // no zbuffer? { uiBufferBits=GL_COLOR_BUFFER_BIT; - glDisable(GL_DEPTH_TEST); + glDisable(GL_DEPTH_TEST); glError(); } - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // first buffer clear - glClear(uiBufferBits); + 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); // wanna alpha test + glEnable(GL_ALPHA_TEST); glError(); // wanna alpha test { - glDisable(GL_LINE_SMOOTH); - glDisable(GL_POINT_SMOOTH); + glDisable(GL_LINE_SMOOTH); glError(); + glDisable(GL_POINT_SMOOTH); glError(); } ubGloAlpha=127; // init some drawing vars @@ -482,15 +502,15 @@ int GLinitialize() 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); + 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(); // we are done... - glFinish(); + glFlush(); glError(); // we are done... + glFinish(); glError(); CreateScanLines(); // setup scanline stuff (if wanted) @@ -1055,8 +1075,8 @@ void assignTextureSprite(void) { if(gLastTex!=gTexName || gLastFMode!=0) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glError(); gLastTex=gTexName;gLastFMode=0; } } @@ -1115,8 +1135,8 @@ void assignTexture3(void) { if(gLastTex!=gTexName || gLastFMode!=1) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glError(); gLastTex=gTexName;gLastFMode=1; } } @@ -1185,8 +1205,8 @@ void assignTexture4(void) { if(gLastTex!=gTexName || gLastFMode!=1) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glError(); gLastTex=gTexName;gLastFMode=1; } } @@ -1257,7 +1277,8 @@ void SetOGLDisplaySettings(BOOL DisplaySet) if(bSetClip || !EqualRect(&rC,&rX)) { rC=rX; - glScissor(rC.left,rC.top,rC.right,rC.bottom); + glScissor(rC.left,rC.top,rC.right,rC.bottom); glError(); + //LOGE("glscissor:%d %d %d %d",rC.left,rC.top,rC.right,rC.bottom); bSetClip=FALSE; } return; @@ -1348,7 +1369,8 @@ void SetOGLDisplaySettings(BOOL DisplaySet) if(bSetClip || !EqualRect(&r,&rC)) { - glScissor(r.left,r.top,r.right,r.bottom); + glScissor(r.left,r.top,r.right,r.bottom); glError(); + rC=r; bSetClip=FALSE; }