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=d7d6761925045389c21d7c13bf17e51f6a41f3ab;hp=2eaa8254c5b31e149186850e02aedfd176f62583;hb=edee4a7fc46dd881c2a45d14ce569fbfd8336516;hpb=07f75e28d81b8acc64cfb6dee9302fb0eba8774a diff --git a/plugins/gpu-gles/gpuDraw.c b/plugins/gpu-gles/gpuDraw.c index 2eaa8254..d7d67619 100644 --- a/plugins/gpu-gles/gpuDraw.c +++ b/plugins/gpu-gles/gpuDraw.c @@ -27,17 +27,7 @@ #define _IN_DRAW -#ifdef _WINDOWS -#include "stdafx.h" -#include -#include -#include -#include "externals.h" -#include "gpu.h" -#include "draw.h" -#include "prim.h" -#include "texture.h" -#else + #include "gpuExternals.h" #include "gpuPlugin.h" #include "gpuDraw.h" @@ -48,7 +38,6 @@ #include #include #include -#endif //#include "menu.h" //////////////////////////////////////////////////////////////////////////////////// @@ -102,13 +91,8 @@ //////////////////////////////////////////////////////////////////////////////////// // draw globals -#ifdef _WINDOWS -HDC dcGlobal=NULL; -HWND hWWindow; -#else void glBlendEquationEXT(GLenum mode); void glColorTableEXT(GLenum target, GLenum internalFormat, GLsizei width, GLenum format,GLenum type, const GLvoid *data); -#endif // draw globals; most will be initialized again later (by config or checks) @@ -158,50 +142,6 @@ GLbitfield uiBufferBits=GL_COLOR_BUFFER_BIT; // Set OGL pixel format //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS -BOOL bSetupPixelFormat(HDC hDC) -{ - int pixelformat; - static PIXELFORMATDESCRIPTOR pfd = - { - sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd - 1, // version number - PFD_DRAW_TO_WINDOW | // support window - PFD_SUPPORT_OPENGL | // support OpenGL - PFD_DOUBLEBUFFER, // double buffered - PFD_TYPE_RGBA, // RGBA type - 16, // 16-bit color depth (adjusted later) - 0, 0, 0, 0, 0, 0, // color bits ignored - 0, // no alpha buffer - 0, // shift bit ignored - 0, // no accumulation buffer - 0, 0, 0, 0, // accum bits ignored - 0, // z-buffer - 0, - 0, // no auxiliary buffer - PFD_MAIN_PLANE, // main layer - 0, // reserved - 0, 0, 0 // layer masks ignored - }; - - pfd.cColorBits=iColDepth; // set user color depth - pfd.cDepthBits=iZBufferDepth; // set user zbuffer (by psx mask) - - if((pixelformat=ChoosePixelFormat(hDC,&pfd))==0) - { - MessageBox(NULL,"ChoosePixelFormat failed","Error",MB_OK); - return FALSE; - } - - if(SetPixelFormat(hDC,pixelformat, &pfd)==FALSE) - { - MessageBox(NULL,"SetPixelFormat failed","Error",MB_OK); - return FALSE; - } - - return TRUE; -} -#endif //////////////////////////////////////////////////////////////////////// // Get extension infos (f.e. pal textures / packed pixels) @@ -216,11 +156,7 @@ void GetExtInfos(void) bPacked=TRUE; // -> ok - #ifdef _WINDOWS - iClampType=GL_CLAMP; -#else iClampType=GL_CLAMP_TO_EDGE; -#endif } //////////////////////////////////////////////////////////////////////// @@ -239,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? @@ -257,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 + } //----------------------------------------------------// @@ -271,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) } @@ -304,10 +242,6 @@ void CreateScanLines(void) // Initialize OGL //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS -HGLRC GLCONTEXT=NULL; -#endif - #define MODE_RAW 0 #define MODE_X11 1 #define MODE_SDL 2 @@ -491,17 +425,6 @@ static void initEGL(void) 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 initEGL(); //----------------------------------------------------// @@ -509,46 +432,50 @@ int GLinitialize() 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 + glDepthRangef(0.0f, 1.0f);glError(); + + 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 @@ -561,15 +488,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) @@ -591,13 +518,6 @@ void GLcleanup() { CleanupTextureStore(); // bye textures -#ifdef _WINDOWS - wglMakeCurrent(NULL, NULL); // bye context - if(GLCONTEXT) wglDeleteContext(GLCONTEXT); - if(!bWindowMode && dcGlobal) - ReleaseDC(hWWindow,dcGlobal); -#endif - eglMakeCurrent( display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); eglDestroySurface( display, surface ); eglDestroyContext( display, context ); @@ -1141,8 +1061,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; } } @@ -1201,8 +1121,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; } } @@ -1271,8 +1191,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; } } @@ -1307,9 +1227,7 @@ void assignTexture4(void) // render pos / buffers //////////////////////////////////////////////////////////////////////// -#ifndef _WINDOWS #define EqualRect(pr1,pr2) ((pr1)->left==(pr2)->left && (pr1)->top==(pr2)->top && (pr1)->right==(pr2)->right && (pr1)->bottom==(pr2)->bottom) -#endif //////////////////////////////////////////////////////////////////////// // SetDisplaySettings: "simply" calcs the new drawing area and updates @@ -1345,7 +1263,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; @@ -1436,7 +1355,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; }