X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=plugins%2Fgpu-gles%2FgpuPrim.c;h=5d17f2de33106f4ac0da0c258c927935a86556e9;hb=9f58cabba9806e2c365c64f7a3701efa6282aa72;hp=7772dba1ac5f8efefc1d3cd4d6928bb6782701b0;hpb=677ea10304049d6f7aae48317fe32cfea060d209;p=pcsx_rearmed.git diff --git a/plugins/gpu-gles/gpuPrim.c b/plugins/gpu-gles/gpuPrim.c index 7772dba1..5d17f2de 100644 --- a/plugins/gpu-gles/gpuPrim.c +++ b/plugins/gpu-gles/gpuPrim.c @@ -26,13 +26,6 @@ #define _IN_PRIMDRAW -#ifdef _WINDOWS -#include "stdafx.h" -#include "externals.h" -#include "gpu.h" -#include "draw.h" -#include "texture.h" -#else #include "gpuStdafx.h" #include "gpuExternals.h" #include "gpuPlugin.h" @@ -40,8 +33,6 @@ #include "gpuTexture.h" #include "gpuPrim.h" -#endif - //////////////////////////////////////////////////////////////////////// // defines //////////////////////////////////////////////////////////////////////// @@ -53,10 +44,9 @@ // globals //////////////////////////////////////////////////////////////////////// -//#ifndef _WINDOWS -//EGLSurface surface; -//EGLDisplay display; -//#endif +EGLSurface surface; +EGLDisplay display; + BOOL bDrawTextured; // current active drawing states BOOL bDrawSmoothShaded; @@ -146,66 +136,6 @@ void UpdateGlobalTP(unsigned short gdata) // Some ASM color convertion... Lewpy's special... //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS -#pragma warning (disable : 4035) - -unsigned long DoubleBGR2RGB (unsigned long BGR) -{ - - __asm - { - mov eax, BGR /* this can hold the G value */ - mov ebx, eax /* this can hold the R value */ - mov edx, eax /* this can hold the B value */ - and ebx, 000000ffh /* mask the R value */ - shl ebx, 1 - test ebx, 00000100h - jz RSKIP - mov ebx, 000000ffh - -RSKIP: - and eax, 0000ff00h /* mask the G value */ - shl eax, 1 - test eax, 00010000h - jz GSKIP - mov eax, 0000ff00h - -GSKIP: - and edx, 00ff0000h /* mask the B value */ - shl edx, 1 - test edx, 01000000h - jz BSKIP - mov edx, 00ff0000h - -BSKIP: - or eax, ebx /* add R to G value */ - or eax, edx /* add B to RG value */ - } - /* Result returned in EAX */ -} - -unsigned short BGR24to16 (unsigned long BGR) -{ - __asm - { - mov eax, BGR /* this can hold the G value */ - mov ebx, eax /* this can hold the R value */ - mov edx, eax /* this can hold the B value */ - shr ebx, 3 /* move the R value */ - and edx, 00f80000h /* mask the B value */ - shr edx, 9 /* move the B value */ - and eax, 00f800h /* mask the G value */ - shr eax, 6 /* move the G value */ - and ebx, 0000001fh /* mask the R value */ - or eax, ebx /* add R to G value */ - or eax, edx /* add B to RG value */ - } - /* Result returned in AX */ -} - -#pragma warning (default : 4035) - -#else unsigned long DoubleBGR2RGB (unsigned long BGR) { @@ -228,13 +158,12 @@ unsigned short BGR24to16 (unsigned long BGR) return ((BGR>>3)&0x1f)|((BGR&0xf80000)>>9)|((BGR&0xf800)>>6); } -#endif //////////////////////////////////////////////////////////////////////// // OpenGL primitive drawing commands //////////////////////////////////////////////////////////////////////// -__inline void PRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2, +void PRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4) { @@ -732,7 +661,7 @@ void SetSemiTrans(void) if(!DrawSemiTrans) // no semi trans at all? { if(bBlendEnable) - {glDisable(GL_BLEND);bBlendEnable=FALSE;} // -> don't wanna blend + {glDisable(GL_BLEND);glError();bBlendEnable=FALSE;}// -> don't wanna blend ubGloAlpha=ubGloColAlpha=255; // -> full alpha return; // -> and bye } @@ -740,7 +669,7 @@ void SetSemiTrans(void) ubGloAlpha=ubGloColAlpha=TransSets[GlobalTextABR].alpha; if(!bBlendEnable) - {glEnable(GL_BLEND);bBlendEnable=TRUE;} // wanna blend + {glEnable(GL_BLEND);glError();bBlendEnable=TRUE;} // wanna blend if(TransSets[GlobalTextABR].srcFac!=obm1 || TransSets[GlobalTextABR].dstFac!=obm2) @@ -749,7 +678,7 @@ void SetSemiTrans(void) { obm1=TransSets[GlobalTextABR].srcFac; obm2=TransSets[GlobalTextABR].dstFac; - glBlendFunc(obm1,obm2); // set blend func + glBlendFunc(obm1,obm2); glError(); // set blend func } /*else if(TransSets[GlobalTextABR].dstFac !=GL_ONE_MINUS_SRC_COLOR) @@ -780,7 +709,7 @@ void SetScanTrans(void) // blending for scan line */ obm1=TransSets[0].srcFac; obm2=TransSets[0].dstFac; - glBlendFunc(obm1,obm2); // set blend func + glBlendFunc(obm1,obm2); glError(); // set blend func } void SetScanTexTrans(void) // blending for scan mask texture @@ -793,7 +722,7 @@ void SetScanTexTrans(void) // blending for scan mask */ obm1=TransSets[2].srcFac; obm2=TransSets[2].dstFac; - glBlendFunc(obm1,obm2); // set blend func + glBlendFunc(obm1,obm2); glError(); // set blend func } //////////////////////////////////////////////////////////////////////// @@ -873,11 +802,11 @@ void SetSemiTransMulti(int Pass) } if(!bBlendEnable) - {glEnable(GL_BLEND);bBlendEnable=TRUE;} // wanna blend + {glEnable(GL_BLEND);glError();bBlendEnable=TRUE;} // wanna blend if(bm1!=obm1 || bm2!=obm2) { - glBlendFunc(bm1,bm2); // set blend func + glBlendFunc(bm1,bm2); glError(); // set blend func obm1=bm1;obm2=bm2; } } @@ -1018,14 +947,14 @@ void SetRenderMode(unsigned long DrawAttributes,BOOL bSCol) else currTex=SelectSubTextureS(GlobalTextTP,ulClutID); if(gTexName!=currTex) - {gTexName=currTex;glBindTexture(GL_TEXTURE_2D,currTex);} + {gTexName=currTex;glBindTexture(GL_TEXTURE_2D,currTex); glError();} if(!bTexEnabled) // -> turn texturing on - {bTexEnabled=TRUE;glEnable(GL_TEXTURE_2D);} + {bTexEnabled=TRUE;glEnable(GL_TEXTURE_2D); glError();} } else // no texture ? if(bTexEnabled) - {bTexEnabled=FALSE;glDisable(GL_TEXTURE_2D);} // -> turn texturing off + {bTexEnabled=FALSE;glDisable(GL_TEXTURE_2D); glError();} // -> turn texturing off if(bSCol) // also set color ? { @@ -1051,6 +980,7 @@ void SetRenderMode(unsigned long DrawAttributes,BOOL bSCol) { if(bDrawSmoothShaded) glShadeModel(GL_SMOOTH); // -> set actual shading else glShadeModel(GL_FLAT); + glError(); bOldSmoothShaded=bDrawSmoothShaded; } } @@ -1523,14 +1453,14 @@ void UploadScreenEx(long Position) if(!PSXDisplay.DisplayMode.x) return; if(!PSXDisplay.DisplayMode.y) return; - glDisable(GL_SCISSOR_TEST); - glShadeModel(GL_FLAT); + glDisable(GL_SCISSOR_TEST); glError(); + glShadeModel(GL_FLAT); glError(); bOldSmoothShaded=FALSE; - glDisable(GL_BLEND); + glDisable(GL_BLEND); glError(); bBlendEnable=FALSE; - glDisable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_2D); glError(); bTexEnabled=FALSE; - glDisable(GL_ALPHA_TEST); + glDisable(GL_ALPHA_TEST); glError(); //glPixelZoom(((float)rRatioRect.right)/((float)PSXDisplay.DisplayMode.x), // -1.0f*(((float)rRatioRect.bottom)/((float)PSXDisplay.DisplayMode.y))); @@ -1594,8 +1524,8 @@ void UploadScreenEx(long Position) // glPixelZoom(1.0F,1.0F); - glEnable(GL_ALPHA_TEST); - glEnable(GL_SCISSOR_TEST); + glEnable(GL_ALPHA_TEST); glError(); + glEnable(GL_SCISSOR_TEST); glError(); } //////////////////////////////////////////////////////////////////////// @@ -1763,13 +1693,13 @@ void cmdSTP(unsigned char * baseAddr) bCheckMask=TRUE; if(iDepthFunc==0) return; iDepthFunc=0; - glDepthFunc(GL_LESS); + glDepthFunc(GL_LESS); glError(); } else { bCheckMask=FALSE; if(iDepthFunc==1) return; - glDepthFunc(GL_ALWAYS); + glDepthFunc(GL_ALWAYS); glError(); iDepthFunc=1; } } @@ -2316,9 +2246,9 @@ void primBlkFill(unsigned char * baseAddr) b=((GLclampf)BLUE(gpuData[0]))/255.0f; r=((GLclampf)RED(gpuData[0]))/255.0f; - glDisable(GL_SCISSOR_TEST); - glClearColor(r,g,b,1.0f); - glClear(uiBufferBits); + glDisable(GL_SCISSOR_TEST); glError(); + glClearColor(r,g,b,1.0f); glError(); + glClear(uiBufferBits); glError(); gl_z=0.0f; if(gpuData[0]!=0x02000000 && @@ -2349,7 +2279,7 @@ void primBlkFill(unsigned char * baseAddr) } } - glEnable(GL_SCISSOR_TEST); + glEnable(GL_SCISSOR_TEST); glError(); } else { @@ -2359,9 +2289,9 @@ void primBlkFill(unsigned char * baseAddr) SetRenderMode((unsigned long)0x01000000, FALSE); vertex[0].c.lcol=gpuData[0]|0xff000000; SETCOL(vertex[0]); - glDisable(GL_SCISSOR_TEST); + glDisable(GL_SCISSOR_TEST); glError(); PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]); - glEnable(GL_SCISSOR_TEST); + glEnable(GL_SCISSOR_TEST); glError(); } }