DXGL r75 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r74‎ | r75 | r76 >
Date:20:16, 14 January 2012
Author:admin
Status:new
Tags:
Comment:
Begin adding vertex array support
Fix compatibility with ATI Radeon X300 cards
Modified paths:
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.h (modified) (history)
  • /ddraw/glDirectDraw.h (modified) (history)
  • /ddraw/glutil.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirect3DDevice.cpp
@@ -128,6 +128,9 @@
129129
130130 glDirect3DDevice7::glDirect3DDevice7(glDirect3D7 *glD3D7, glDirectDrawSurface7 *glDDS7)
131131 {
 132+ vertices = normals = NULL;
 133+ diffuse = specular = NULL;
 134+ ZeroMemory(texcoords,8*sizeof(GLfloat*));
132135 memcpy(renderstate,renderstate_default,153*sizeof(DWORD));
133136 GLfloat ambient[] = {0.0,0.0,0.0,0.0};
134137 identity._11 = identity._22 = identity._33 = identity._44 = 1.0;
@@ -256,9 +259,44 @@
257260 FIXME("glDirect3DDevice7::DeleteStateBlock: stub");
258261 ERR(DDERR_GENERIC);
259262 }
 263+int setdrawmode(D3DPRIMITIVETYPE d3dptPrimitiveType)
 264+{
 265+ switch(d3dptPrimitiveType)
 266+ {
 267+ case D3DPT_POINTLIST:
 268+ return GL_POINTS;
 269+ case D3DPT_LINELIST:
 270+ return GL_LINES;
 271+ case D3DPT_LINESTRIP:
 272+ return GL_LINE_STRIP;
 273+ case D3DPT_TRIANGLELIST:
 274+ return GL_TRIANGLES;
 275+ case D3DPT_TRIANGLESTRIP:
 276+ return GL_TRIANGLE_STRIP;
 277+ case D3DPT_TRIANGLEFAN:
 278+ return GL_TRIANGLE_FAN;
 279+ default:
 280+ return -1;
 281+ }
 282+}
 283+
 284+void glDirect3DDevice7::SetArraySize(DWORD size, DWORD vertex, DWORD texcoord)
 285+{
 286+ if(!vertices) vertices = (GLfloat*)malloc(size*4*sizeof(GLfloat));
 287+ else if(size > maxarray) vertices = (GLfloat*)realloc(vertices,size*4*sizeof(GLfloat));
 288+ if(!normals) normals = (GLfloat*)malloc(size*4*sizeof(GLfloat));
 289+ else if(size > maxarray) normals = (GLfloat*)realloc(normals,size*4*sizeof(GLfloat));
 290+}
 291+
260292 HRESULT WINAPI glDirect3DDevice7::DrawIndexedPrimitive(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
261293 LPVOID lpvVertices, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags)
262294 {
 295+ if(!inscene) return D3DERR_SCENE_NOT_IN_SCENE;
 296+ int drawmode = setdrawmode(d3dptPrimitiveType);
 297+ if(drawmode == -1) return DDERR_INVALIDPARAMS;
 298+ if(dwVertexTypeDesc & D3DFVF_XYZB1) ERR(DDERR_GENERIC);
 299+
 300+ //for(int i = 0; i <
263301 FIXME("glDirect3DDevice7::DrawIndexedPrimitive: stub");
264302 ERR(DDERR_GENERIC);
265303 }
Index: ddraw/glDirect3DDevice.h
@@ -85,6 +85,7 @@
8686 HRESULT WINAPI SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix);
8787 HRESULT WINAPI SetViewport(LPD3DVIEWPORT7 lpViewport);
8888 HRESULT WINAPI ValidateDevice(LPDWORD lpdwPasses);
 89+ void SetArraySize(DWORD size, DWORD vertex, DWORD texcoord);
8990
9091 private:
9192 D3DMATRIX matWorld,matView,matProjection;
@@ -98,6 +99,14 @@
99100 int gllights[8];
100101 DWORD lightsmax;
101102 bool inscene;
 103+ DWORD maxarray;
 104+ DWORD vertexsize;
 105+ DWORD texcoordsize;
 106+ GLfloat *vertices;
 107+ GLfloat *normals;
 108+ GLubyte *diffuse;
 109+ GLubyte *specular;
 110+ GLfloat *texcoords[8];
102111 };
103112
104113 #endif //__GLDIRECT3DDEVICE_H
\ No newline at end of file
Index: ddraw/glDirectDraw.h
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2011 William Feely
 3+// Copyright (C) 2011-2012 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
Index: ddraw/glutil.cpp
@@ -29,10 +29,12 @@
3030 if(GLEXT_ARB_framebuffer_object)
3131 {
3232 glGenFramebuffers(1,&fbo);
 33+ glBindFramebuffer(GL_FRAMEBUFFER,0);
3334 }
3435 else if(GLEXT_EXT_framebuffer_object)
3536 {
3637 glGenFramebuffersEXT(1,&fbo);
 38+ glBindFramebufferEXT(GL_FRAMEBUFFER,0);
3739 }
3840 }
3941