DXGL r698 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r697‎ | r698 | r699 >
Date:05:21, 12 March 2017
Author:admin
Status:new
Tags:
Comment:
Some progress on new DrawPrimitives function.
Fix a mistake with RHW vertex attribute.
Modified paths:
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glRenderer.h (modified) (history)

Diff [purge]

Index: ddraw/glRenderer.cpp
@@ -3813,12 +3813,12 @@
38143814 }
38153815
38163816 void glRenderer__DrawPrimitives(glRenderer *This, RenderTarget *target, GLenum mode, DWORD fvf,
3817 - void *vertices, BOOL strided, DWORD count, LPWORD indices, DWORD indexcount, DWORD flags)
 3817+ BYTE *vertices, BOOL strided, DWORD count, LPWORD indices, DWORD indexcount, DWORD flags)
38183818 {
38193819 BOOL transformed;
38203820 int i;
38213821 glTexture *ztexture = NULL;
3822 - GLint zleve = 0;
 3822+ GLint zlevel = 0;
38233823 if (!vertices)
38243824 {
38253825 This->outputs[0] = (void*)DDERR_INVALIDPARAMS;
@@ -3826,7 +3826,40 @@
38273827 return;
38283828 }
38293829 if (fvf != This->last_fvf) glRenderer__UpdateFVF(This, fvf);
3830 -
 3830+ glRenderer__SetDepthComp(This);
 3831+ glUtil_DepthTest(This->util, This->renderstate[D3DRENDERSTATE_ZENABLE]);
 3832+ glUtil_DepthWrite(This->util, This->renderstate[D3DRENDERSTATE_ZWRITEENABLE]);
 3833+ _GENSHADER *prog = &This->shaders->gen3d->current_genshader->shader;
 3834+ switch (fvf & D3DFVF_POSITION_MASK)
 3835+ {
 3836+ case 0: // Missing vertex position
 3837+ This->outputs[0] = (void*)DDERR_INVALIDPARAMS;
 3838+ SetEvent(This->busy);
 3839+ return;
 3840+ case D3DFVF_XYZ:
 3841+ glUtil_EnableArray(This->util, prog->attribs[0], TRUE);
 3842+ This->ext->glVertexAttribPointer(prog->attribs[0], 3, GL_FLOAT, GL_FALSE, This->fvf_stride, vertices);
 3843+ break;
 3844+ case D3DFVF_XYZRHW:
 3845+ glUtil_EnableArray(This->util, prog->attribs[0], TRUE);
 3846+ This->ext->glVertexAttribPointer(prog->attribs[0], 3, GL_FLOAT, GL_FALSE, This->fvf_stride, vertices);
 3847+ if (prog->attribs[1] != -1)
 3848+ {
 3849+ glUtil_EnableArray(This->util, prog->attribs[1], TRUE);
 3850+ This->ext->glVertexAttribPointer(prog->attribs[1], 1, GL_FLOAT, GL_FALSE, This->fvf_stride, vertices+(3*sizeof(float)));
 3851+ }
 3852+ break;
 3853+ case D3DFVF_XYZB1:
 3854+ case D3DFVF_XYZB2:
 3855+ case D3DFVF_XYZB3:
 3856+ case D3DFVF_XYZB4:
 3857+ case D3DFVF_XYZB5:
 3858+ FIXME("glRenderer__DrawPrimitives: Blend weights not yet supported");
 3859+ This->outputs[0] = (void*)DDERR_INVALIDPARAMS;
 3860+ SetEvent(This->busy);
 3861+ return;
 3862+ break;
 3863+ }
38313864 }
38323865
38333866 void glRenderer__DrawPrimitivesOld(glRenderer *This, RenderTarget *target, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
@@ -3879,7 +3912,7 @@
38803913 if(prog->attribs[1] != -1)
38813914 {
38823915 glUtil_EnableArray(This->util, prog->attribs[1], TRUE);
3883 - This->ext->glVertexAttribPointer(prog->attribs[1],4,GL_FLOAT,GL_FALSE,vertices[1].stride,vertices[1].data);
 3916+ This->ext->glVertexAttribPointer(prog->attribs[1],1,GL_FLOAT,GL_FALSE,vertices[1].stride,vertices[1].data);
38843917 }
38853918 }
38863919 for(i = 0; i < 5; i++)
Index: ddraw/glRenderer.h
@@ -157,6 +157,7 @@
158158 RenderState state;
159159 size_t scenesize, scenesizevertex, scenesizeindex;
160160 DWORD last_fvf;
 161+ GLsizei fvf_stride;
161162 BOOL mode_3d;
162163 } glRenderer;
163164
@@ -211,7 +212,7 @@
212213 void glRenderer__Clear(glRenderer *This, ClearCommand *cmd);
213214 void glRenderer__UpdateFVF(glRenderer *This, DWORD fvf);
214215 void glRenderer__DrawPrimitives(glRenderer *This, RenderTarget *target, GLenum mode, DWORD fvf,
215 - void *vertices, BOOL strided, DWORD count, LPWORD indices, DWORD indexcount, DWORD flags);
 216+ BYTE *vertices, BOOL strided, DWORD count, LPWORD indices, DWORD indexcount, DWORD flags);
216217 void glRenderer__DrawPrimitivesOld(glRenderer *This, RenderTarget *target, GLenum mode, GLVERTEX *vertices, int *texcormats, DWORD count, LPWORD indices,
217218 DWORD indexcount, DWORD flags);
218219 void glRenderer__Flush(glRenderer *This);