DXGL r131 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r130‎ | r131 | r132 >
Date:18:15, 23 March 2012
Author:admin
Status:new
Tags:
Comment:
Remove debug-only restriction on Direct3D7 interface, permanently this time
Remove some deprecated OpenGL calls
Modified paths:
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /dxgltest/dxgltest.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirect3DDevice.cpp
@@ -1061,7 +1061,7 @@
10621062 GLfloat tmp[16];
10631063 ZeroMemory(&worldview,sizeof(D3DMATRIX));
10641064 ZeroMemory(&tmp,sizeof(D3DMATRIX));
1065 - __gluMultMatricesf(matView,matWorld,worldview); // Get worldview
 1065+ __gluMultMatricesf(matWorld,matView,worldview); // Get worldview
10661066 if(__gluInvertMatrixf(worldview,tmp)) // Invert
10671067 memcpy(matNormal,tmp,16*sizeof(GLfloat));
10681068 else memcpy(matNormal,worldview,16*sizeof(GLfloat));
Index: ddraw/glDirectDraw.cpp
@@ -649,13 +649,8 @@
650650 }
651651 if(riid == IID_IDirect3D7)
652652 {
653 - #ifdef _DEBUG
654653 *ppvObj = new glDirect3D7(this);
655654 return DD_OK;
656 - #else
657 - FIXME("Add IDirect3D Interfaces\n");
658 - ERR(DDERR_GENERIC);
659 - #endif
660655 }
661656 if(riid == IID_IDirectDrawGammaControl)
662657 {
Index: ddraw/glDirectDrawSurface.cpp
@@ -113,7 +113,7 @@
114114 palette = palettein;
115115 palette->AddRef();
116116 }
117 - paltex = renderer->MakeTexture(GL_NEAREST,GL_NEAREST,GL_CLAMP,GL_CLAMP,256,1,GL_RGBA,GL_UNSIGNED_BYTE,GL_RGB);
 117+ paltex = renderer->MakeTexture(GL_NEAREST,GL_NEAREST,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,256,1,GL_RGBA,GL_UNSIGNED_BYTE,GL_RGB);
118118 }
119119 else paltex = 0;
120120 }
@@ -386,7 +386,7 @@
387387 return;
388388 }
389389 }
390 - texture = renderer->MakeTexture(filter,filter,GL_CLAMP,GL_CLAMP,fakex,fakey,texformat,texformat2,texformat3);
 390+ texture = renderer->MakeTexture(filter,filter,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,fakex,fakey,texformat,texformat2,texformat3);
391391 }
392392
393393 if(ddsd.ddpfPixelFormat.dwRGBBitCount > 8)
@@ -970,8 +970,8 @@
971971 }
972972 if(backbuffer) backbuffer->Restore2();
973973 if(zbuffer) zbuffer->Restore2();
974 - if(paltex) paltex = renderer->MakeTexture(GL_NEAREST,GL_NEAREST,GL_CLAMP,GL_CLAMP,256,1,GL_RGBA,GL_UNSIGNED_BYTE,GL_RGB);
975 - texture = renderer->MakeTexture(filter,filter,GL_CLAMP,GL_CLAMP,fakex,fakey,texformat,texformat2,texformat3);
 974+ if(paltex) paltex = renderer->MakeTexture(GL_NEAREST,GL_NEAREST,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,256,1,GL_RGBA,GL_UNSIGNED_BYTE,GL_RGB);
 975+ texture = renderer->MakeTexture(filter,filter,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,fakex,fakey,texformat,texformat2,texformat3);
976976 }
977977 }
978978 HRESULT WINAPI glDirectDrawSurface7::Restore()
@@ -1014,8 +1014,8 @@
10151015 if(backbuffer) backbuffer->Restore();
10161016 if(zbuffer) zbuffer->Restore();
10171017 }
1018 - if(paltex) paltex = renderer->MakeTexture(GL_NEAREST,GL_NEAREST,GL_CLAMP,GL_CLAMP,256,1,GL_RGBA,GL_UNSIGNED_BYTE,GL_RGB);
1019 - texture = renderer->MakeTexture(filter,filter,GL_CLAMP,GL_CLAMP,fakex,fakey,texformat,texformat2,texformat3);
 1018+ if(paltex) paltex = renderer->MakeTexture(GL_NEAREST,GL_NEAREST,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,256,1,GL_RGBA,GL_UNSIGNED_BYTE,GL_RGB);
 1019+ texture = renderer->MakeTexture(filter,filter,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,fakex,fakey,texformat,texformat2,texformat3);
10201020 return DD_OK;
10211021 }
10221022 else return DD_OK;
Index: ddraw/glRenderer.cpp
@@ -625,8 +625,6 @@
626626 if(dwFlags & DDBLT_COLORFILL)
627627 {
628628 SetShader(PROG_FILL,NULL,NULL,true);
629 - glDisable(GL_TEXTURE_2D);
630 - glDisable(GL_ALPHA_TEST);
631629 switch(ddInterface->GetBPP())
632630 {
633631 case 8:
@@ -663,10 +661,6 @@
664662 break;
665663 }
666664 }
667 - else
668 - {
669 - glEnable(GL_TEXTURE_2D);
670 - }
671665 if((dwFlags & DDBLT_KEYSRC) && (src && src->colorkey[0].enabled) && !(dwFlags & DDBLT_COLORFILL))
672666 {
673667 SetShader(PROG_CKEY,NULL,NULL,true);
@@ -726,7 +720,6 @@
727721 glVertexAttribPointer(stloc,2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].s);
728722 }
729723 glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
730 - glDisable(GL_TEXTURE_2D);
731724 SetFBO(0,0,false);
732725 if(((ddsd.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER)) &&
733726 (ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) ||
@@ -740,7 +733,6 @@
741734 GLuint texture;
742735 glGenTextures(1,&texture);
743736 glBindTexture(GL_TEXTURE_2D,texture);
744 - glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
745737 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,(GLfloat)min);
746738 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,(GLfloat)mag);
747739 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,(GLfloat)wraps);
@@ -755,7 +747,7 @@
756748 glActiveTexture(GL_TEXTURE0);
757749 if(!backbuffer)
758750 {
759 - backbuffer = _MakeTexture(GL_LINEAR,GL_LINEAR,GL_CLAMP,GL_CLAMP,x,y,GL_BGRA,GL_UNSIGNED_BYTE,GL_RGBA8);
 751+ backbuffer = _MakeTexture(GL_LINEAR,GL_LINEAR,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,x,y,GL_BGRA,GL_UNSIGNED_BYTE,GL_RGBA8);
760752 backx = x;
761753 backy = y;
762754 }
@@ -869,7 +861,6 @@
870862 {
871863 _DrawBackbuffer(&texture,dest->fakex,dest->fakey);
872864 SetShader(PROG_TEXTURE,NULL,NULL,true);
873 - glEnable(GL_TEXTURE_2D);
874865 glBindTexture(GL_TEXTURE_2D,texture);
875866 GLuint prog = GetProgram() & 0xFFFFFFFF;
876867 GLint texloc = glGetUniformLocation(prog,"Texture");
@@ -879,7 +870,6 @@
880871 else
881872 {
882873 SetShader(PROG_TEXTURE,NULL,NULL,true);
883 - glEnable(GL_TEXTURE_2D);
884874 glBindTexture(GL_TEXTURE_2D,texture);
885875 GLuint prog = GetProgram() & 0xFFFFFFFF;
886876 GLint texloc = glGetUniformLocation(prog,"Texture");
@@ -916,7 +906,6 @@
917907 glVertexAttribPointer(rgbloc,3,GL_UNSIGNED_BYTE,true,sizeof(BltVertex),&bltvertices[0].r);
918908 }
919909 glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
920 - glDisable(GL_TEXTURE_2D);
921910 glFlush();
922911 if(hasHWnd) SwapBuffers(hDC);
923912 else
@@ -965,8 +954,6 @@
966955 if(zbuffer) glEnable(GL_DEPTH_TEST);
967956 glDepthFunc(GL_LEQUAL);
968957 glDisable(GL_DITHER);
969 - glEnable(GL_LIGHTING);
970 - glLightModelfv(GL_LIGHT_MODEL_AMBIENT,ambient);
971958 }
972959
973960 void glRenderer::_Clear(glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil)
Index: dxgltest/dxgltest.cpp
@@ -714,15 +714,11 @@
715715 tab.pszText = _T("2D Graphics");
716716 hTab = GetDlgItem(hWnd,IDC_TABS);
717717 SendDlgItemMessage(hWnd,IDC_TABS,TCM_INSERTITEM,1,(LPARAM)&tab);
718 - #ifdef _DEBUG
719718 tab.pszText = _T("3D Graphics");
720719 SendDlgItemMessage(hWnd,IDC_TABS,TCM_INSERTITEM,2,(LPARAM)&tab);
721 - #endif
722720 tabwnd[0] = CreateDialog(hinstance,MAKEINTRESOURCE(IDD_SYSINFO),hTab,SysTabCallback);
723721 tabwnd[1] = CreateDialog(hinstance,MAKEINTRESOURCE(IDD_TESTGFX),hTab,Test2DCallback);
724 - #ifdef _DEBUG
725722 tabwnd[2] = CreateDialog(hinstance,MAKEINTRESOURCE(IDD_TESTGFX),hTab,Test3DCallback);
726 - #endif
727723 SendDlgItemMessage(hWnd,IDC_TABS,TCM_GETITEMRECT,0,(LPARAM)&tabrect);
728724 SetWindowPos(tabwnd[0],NULL,tabrect.left,tabrect.bottom+3,0,0,SWP_SHOWWINDOW|SWP_NOSIZE);
729725 ShowWindow(tabwnd[1],SW_HIDE);