DXGL r72 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r71‎ | r72 | r73 >
Date:16:50, 8 January 2012
Author:admin
Status:new
Tags:
Comment:
Add GetTransform and SetTransform
Add D3DRENDERSTATE_AMBIENT
Update help image
Modified paths:
  • /Help/dxglcfg.png (modified) (history)
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.h (modified) (history)

Diff [purge]

Index: Help/dxglcfg.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: ddraw/glDirect3DDevice.cpp
@@ -115,10 +115,18 @@
116116 FALSE, //clipplaneenable
117117 };
118118
 119+D3DMATRIX identity;
 120+
119121 glDirect3DDevice7::glDirect3DDevice7(glDirect3D7 *glD3D7, glDirectDrawSurface7 *glDDS7)
120122 {
121123 memcpy(renderstate,renderstate_default,153*sizeof(DWORD));
122124 GLfloat ambient[] = {0.0,0.0,0.0,0.0};
 125+ identity._11 = identity._22 = identity._33 = identity._44 = 1.0;
 126+ identity._12 = identity._13 = identity._14 =
 127+ identity._21 = identity._23 = identity._24 =
 128+ identity._31 = identity._32 = identity._34 =
 129+ identity._41 = identity._42 = identity._43 = 0.0;
 130+ matWorld = matView = matProjection = identity;
123131 refcount = 1;
124132 this->glD3D7 = glD3D7;
125133 glD3D7->AddRef();
@@ -339,8 +347,20 @@
340348 }
341349 HRESULT WINAPI glDirect3DDevice7::GetTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix)
342350 {
343 - FIXME("glDirect3DDevice7::GetTransform: stub");
344 - ERR(DDERR_GENERIC);
 351+ switch(dtstTransformStateType)
 352+ {
 353+ case D3DTRANSFORMSTATE_WORLD:
 354+ memcpy(lpD3DMatrix,&matWorld,sizeof(D3DMATRIX));
 355+ return D3D_OK;
 356+ case D3DTRANSFORMSTATE_VIEW:
 357+ memcpy(lpD3DMatrix,&matView,sizeof(D3DMATRIX));
 358+ return D3D_OK;
 359+ case D3DTRANSFORMSTATE_PROJECTION:
 360+ memcpy(lpD3DMatrix,&matProjection,sizeof(D3DMATRIX));
 361+ return D3D_OK;
 362+ default:
 363+ ERR(DDERR_INVALIDPARAMS);
 364+ }
345365 }
346366 HRESULT WINAPI glDirect3DDevice7::GetViewport(LPD3DVIEWPORT7 lpViewport)
347367 {
@@ -373,8 +393,7 @@
374394 if(!foundlight) return D3DERR_LIGHT_SET_FAILED;
375395 lights[dwLightIndex]->SetGLLight(i);
376396 }
377 - FIXME("glDirect3DDevice7::LightEnable: stub");
378 - ERR(DDERR_GENERIC);
 397+ return D3D_OK;
379398 }
380399 HRESULT WINAPI glDirect3DDevice7::Load(LPDIRECTDRAWSURFACE7 lpDestTex, LPPOINT lpDestPoint, LPDIRECTDRAWSURFACE7 lpSrcTex,
381400 LPRECT lprcSrcRect, DWORD dwFlags)
@@ -421,7 +440,10 @@
422441
423442 inline void dwordto4float(DWORD in, GLfloat *out)
424443 {
425 -
 444+ out[0] = (GLfloat)((in>>16) & 0xff) / 255.0f;
 445+ out[1] = (GLfloat)((in>>8) & 0xff) / 255.0f;
 446+ out[2] = (GLfloat)(in& 0xff) / 255.0f;
 447+ out[3] = (GLfloat)((in>>24) & 0xff) / 255.0f;
426448 }
427449
428450 HRESULT WINAPI glDirect3DDevice7::SetRenderState(D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState)
@@ -458,7 +480,8 @@
459481 return D3D_OK;
460482 case D3DRENDERSTATE_AMBIENT:
461483 dwordto4float(dwRenderState,floats);
462 -
 484+ glLightModelfv(GL_LIGHT_MODEL_AMBIENT,floats);
 485+ return D3D_OK;
463486 default:
464487 ERR(DDERR_INVALIDPARAMS);
465488 }
@@ -485,8 +508,20 @@
486509 }
487510 HRESULT WINAPI glDirect3DDevice7::SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix)
488511 {
489 - FIXME("glDirect3DDevice7::SetTransform: stub");
490 - ERR(DDERR_GENERIC);
 512+ switch(dtstTransformStateType)
 513+ {
 514+ case D3DTRANSFORMSTATE_WORLD:
 515+ memcpy(&matWorld,lpD3DMatrix,sizeof(D3DMATRIX));
 516+ return D3D_OK;
 517+ case D3DTRANSFORMSTATE_VIEW:
 518+ memcpy(&matView,lpD3DMatrix,sizeof(D3DMATRIX));
 519+ return D3D_OK;
 520+ case D3DTRANSFORMSTATE_PROJECTION:
 521+ memcpy(&matProjection,lpD3DMatrix,sizeof(D3DMATRIX));
 522+ return D3D_OK;
 523+ default:
 524+ ERR(DDERR_INVALIDPARAMS);
 525+ }
491526 }
492527 HRESULT WINAPI glDirect3DDevice7::SetViewport(LPD3DVIEWPORT7 lpViewport)
493528 {
Index: ddraw/glDirect3DDevice.h
@@ -87,6 +87,7 @@
8888 HRESULT WINAPI ValidateDevice(LPDWORD lpdwPasses);
8989
9090 private:
 91+ D3DMATRIX matWorld,matView,matProjection;
9192 glDirect3D7 *glD3D7;
9293 glDirectDrawSurface7 *glDDS7;
9394 ULONG refcount;