|
From: Andreas R. <and...@us...> - 2002-05-29 11:43:07
|
Update of /cvsroot/squeak/squeak/platforms/win32/plugins/B3DAcceleratorPlugin
In directory usw-pr-cvs1:/tmp/cvs-serv9866
Modified Files:
sqWin32D3D.c sqWin32OpenGL.c
Log Message:
Moved property handling from platform to cross code
Index: sqWin32D3D.c
===================================================================
RCS file: /cvsroot/squeak/squeak/platforms/win32/plugins/B3DAcceleratorPlugin/sqWin32D3D.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** sqWin32D3D.c 6 May 2002 10:36:25 -0000 1.5
--- sqWin32D3D.c 29 May 2002 11:43:03 -0000 1.6
***************
*** 584,588 ****
--- 584,590 ----
int d3dInitializePrimary(void) {
HRESULT hRes;
+ DPRINTF(5,(fp, "[Initializing primary surface]\n"));
if(!lpDD) {
+ DPRINTF(5,(fp, "[Creating DDraw object]\n"));
hRes = CoCreateInstance(&CLSID_DirectDraw,
NULL,
***************
*** 592,598 ****
--- 594,606 ----
ERROR_CHECK;
if(FAILED(hRes)) return 0;
+ if(!lpDD) {
+ DPRINTF(1,(fp,"ERROR: Could not create IDirectDraw7\n"));
+ return 0;
+ }
+ DPRINTF(5,(fp, "[Initializing DDraw object]\n"));
hRes = lpDD->lpVtbl->Initialize(lpDD, NULL);
ERROR_CHECK;
if(FAILED(hRes)) return 0;
+ DPRINTF(5,(fp, "[Setting cooperation level]\n"));
hRes = lpDD->lpVtbl->
SetCooperativeLevel(lpDD, *theSTWindow,
***************
*** 603,609 ****
--- 611,622 ----
if(!lpD3D) {
/* query for the direct3d object */
+ DPRINTF(5,(fp, "[Querying for IDirect3D7]\n"));
hRes = lpDD->lpVtbl->QueryInterface(lpDD,&IID_IDirect3D7, (LPVOID*)&lpD3D);
ERROR_CHECK;
if(FAILED(hRes)) return 0;
+ if(!lpD3D) {
+ DPRINTF(1,(fp,"ERROR: Could not retrieve IDirect3D7\n"));
+ return 0;
+ }
}
if(!lpddPrimary) {
***************
*** 615,621 ****
--- 628,639 ----
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+ DPRINTF(5,(fp, "[Creating primary surface]\n"));
hRes = lpDD->lpVtbl->CreateSurface( lpDD, &ddsd, &lpddPrimary, NULL );
ERROR_CHECK;
if (FAILED(hRes)) return 0;
+ if(!lpddPrimary) {
+ DPRINTF(1,(fp,"ERROR: Could not create primary surface\n"));
+ return 0;
+ }
}
***************
*** 627,633 ****
--- 645,656 ----
*/
if(!lpddClipper) {
+ DPRINTF(5,(fp, "[Creating clipper]\n"));
hRes = lpDD->lpVtbl->CreateClipper(lpDD, 0UL, &lpddClipper, NULL);
ERROR_CHECK;
if(FAILED(hRes)) return 0;
+ if(!lpddClipper) {
+ DPRINTF(1,(fp,"ERROR: Could not create clipper\n"));
+ return 0;
+ }
hRes = lpddClipper->lpVtbl->SetHWnd(lpddClipper, 0UL, *theSTWindow);
ERROR_CHECK;
***************
*** 694,697 ****
--- 717,723 ----
}
+ DPRINTF(3, (fp, "### Using %s\n(%s)\n",
+ renderer->szDeviceName, renderer->szDeviceDesc));
+
/* enumerate z-buffer formats and find a nice one */
memset(&ddpfZBuffer, 0, sizeof(ddpfZBuffer));
***************
*** 823,827 ****
int i, index;
d3dRenderer *renderer;
!
for(i=0; i < MAX_RENDERER; i++) {
if(allRenderer[i].fUsed == 0) break;
--- 849,853 ----
int i, index;
d3dRenderer *renderer;
! DPRINTF(3, (fp, "---- Initializing D3D ----\n"));
for(i=0; i < MAX_RENDERER; i++) {
if(allRenderer[i].fUsed == 0) break;
***************
*** 983,986 ****
--- 1009,1041 ----
case 4: /* line width */
return 1;
+ case 5: /* blend enable */
+ hRes = lpDevice->lpVtbl->
+ GetRenderState(lpDevice, D3DRENDERSTATE_ALPHABLENDENABLE, &dwState);
+ ERROR_CHECK;
+ return dwState;
+ case 6: /* blend source factor */
+ case 7: /* blend dest factor */
+ if(prop == 6) {
+ hRes = lpDevice->lpVtbl->
+ GetRenderState(lpDevice, D3DRENDERSTATE_SRCBLEND, &dwState);
+ } else {
+ hRes = lpDevice->lpVtbl->
+ GetRenderState(lpDevice, D3DRENDERSTATE_DESTBLEND, &dwState);
+ }
+ ERROR_CHECK;
+ switch(dwState) {
+ case D3DBLEND_ZERO: return 0;
+ case D3DBLEND_ONE: return 1;
+ case D3DBLEND_SRCCOLOR: return 2;
+ case D3DBLEND_INVSRCCOLOR: return 3;
+ case D3DBLEND_DESTCOLOR: return 4;
+ case D3DBLEND_INVDESTCOLOR: return 5;
+ case D3DBLEND_SRCALPHA: return 6;
+ case D3DBLEND_INVSRCALPHA: return 7;
+ case D3DBLEND_DESTALPHA: return 8;
+ case D3DBLEND_INVDESTALPHA: return 9;
+ case D3DBLEND_SRCALPHASAT: return 10;
+ default: return -1;
+ }
}
return 0;
***************
*** 1019,1022 ****
--- 1074,1108 ----
case 4: /* line width */
return 1;
+ case 5: /* blend enable */
+ dwState = value ? TRUE : FALSE;
+ hRes = lpDevice->lpVtbl->
+ SetRenderState(lpDevice, D3DRENDERSTATE_ALPHABLENDENABLE, dwState);
+ ERROR_CHECK;
+ return 1;
+ case 6: /* blend source factor */
+ case 7: /* blend dest factor */
+ switch(value) {
+ case 0: dwState = D3DBLEND_ZERO; break;
+ case 1: dwState = D3DBLEND_ONE; break;
+ case 2: dwState = D3DBLEND_SRCCOLOR; break;
+ case 3: dwState = D3DBLEND_INVSRCCOLOR; break;
+ case 4: dwState = D3DBLEND_DESTCOLOR; break;
+ case 5: dwState = D3DBLEND_INVDESTCOLOR; break;
+ case 6: dwState = D3DBLEND_SRCALPHA; break;
+ case 7: dwState = D3DBLEND_INVSRCALPHA; break;
+ case 8: dwState = D3DBLEND_DESTALPHA; break;
+ case 9: dwState = D3DBLEND_INVDESTALPHA; break;
+ case 10: dwState = D3DBLEND_SRCALPHASAT; break;
+ default: return 0;
+ }
+ if(prop == 6) {
+ hRes = lpDevice->lpVtbl->
+ SetRenderState(lpDevice, D3DRENDERSTATE_SRCBLEND, dwState);
+ } else {
+ hRes = lpDevice->lpVtbl->
+ SetRenderState(lpDevice, D3DRENDERSTATE_DESTBLEND, dwState);
+ }
+ ERROR_CHECK;
+ return 1;
}
return 0;
Index: sqWin32OpenGL.c
===================================================================
RCS file: /cvsroot/squeak/squeak/platforms/win32/plugins/B3DAcceleratorPlugin/sqWin32OpenGL.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** sqWin32OpenGL.c 26 May 2002 18:54:28 -0000 1.5
--- sqWin32OpenGL.c 29 May 2002 11:43:03 -0000 1.6
***************
*** 619,683 ****
/*****************************************************************************/
! int glGetIntProperty(int handle, int prop)
{
! GLint v;
! glRenderer *renderer = glRendererFromHandle(handle);
! if(!renderer || !glMakeCurrentRenderer(renderer)) return 0;
!
! switch(prop) {
! case 1: /* backface culling */
! if(!glIsEnabled(GL_CULL_FACE)) return 0;
! glGetIntegerv(GL_FRONT_FACE, &v);
! if(v == GL_CW) return 1;
! if(v == GL_CCW) return -1;
! return 0;
! case 2: /* polygon mode */
! glGetIntegerv(GL_POLYGON_MODE, &v);
! ERROR_CHECK;
! return v;
! case 3: /* point size */
! glGetIntegerv(GL_POINT_SIZE, &v);
! ERROR_CHECK;
! return v;
! case 4: /* line width */
! glGetIntegerv(GL_LINE_WIDTH, &v);
! ERROR_CHECK;
! return v;
! }
return 0;
}
! int glSetIntProperty(int handle, int prop, int value)
{
! glRenderer *renderer = glRendererFromHandle(handle);
! if(!renderer || !glMakeCurrentRenderer(renderer)) return 0;
!
! switch(prop) {
! case 1: /* backface culling */
! if(!value) {
! glDisable(GL_CULL_FACE);
! ERROR_CHECK;
! return 1;
! }
! glEnable(GL_CULL_FACE);
! glFrontFace(value == 1 ? GL_CCW : GL_CW);
! ERROR_CHECK;
! return 1;
! case 2: /* polygon mode */
! if(value == 0) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
! else if(value == 1) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
! else if(value == 2) glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
! else return 0;
! ERROR_CHECK;
! return 1;
! case 3: /* point size */
! glPointSize(value);
! ERROR_CHECK;
! return 1;
! case 4: /* line width */
! glLineWidth(value);
! ERROR_CHECK;
! return 1;
! }
return 0;
}
--- 619,631 ----
/*****************************************************************************/
! int glGetIntPropertyOS(int handle, int prop)
{
! /* No platform-specific properties supported */
return 0;
}
! int glSetIntPropertyOS(int handle, int prop, int value)
{
! /* No platform-specific properties supported */
return 0;
}
***************
*** 780,781 ****
--- 728,730 ----
#endif /* defined(B3DX_GL) */
+
|