DXGL r651 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r650‎ | r651 | r652 >
Date:03:18, 9 February 2016
Author:admin
Status:new
Tags:
Comment:
Add a function to generate a glFrameTerminatorGREMEDY command for debugging.
Modified paths:
  • /ddraw/ddraw.cpp (modified) (history)
  • /ddraw/ddraw.def (modified) (history)
  • /ddraw/ddraw.h (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glExtensions.c (modified) (history)
  • /ddraw/glExtensions.h (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glRenderer.h (modified) (history)

Diff [purge]

Index: ddraw/ddraw.cpp
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2011-2015 William Feely
 3+// Copyright (C) 2011-2016 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
@@ -29,6 +29,7 @@
3030 #include <intrin.h>
3131
3232 extern "C" {DXGLCFG dxglcfg; }
 33+glDirectDraw7 *glDD7 = NULL;
3334 DWORD gllock = 0;
3435 HMODULE sysddraw = NULL;
3536 HRESULT (WINAPI *sysddrawcreate)(GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter) = NULL;
@@ -167,9 +168,11 @@
168169 HRESULT error;
169170 myddraw7 = new glDirectDraw7(lpGUID,pUnkOuter);
170171 error = myddraw7->err();
 172+ glDD7 = myddraw7;
171173 if(error != DD_OK)
172174 {
173175 delete myddraw7;
 176+ glDD7 = NULL;
174177 LeaveCriticalSection(&dll_cs);
175178 TRACE_EXIT(23, error);
176179 return error;
@@ -561,7 +564,6 @@
562565 * this function to test whether your program should run or not. This
563566 * function may be changed or removed in case of abuse.
564567 */
565 -
566568 DDRAW_API BOOL IsDXGLDDraw()
567569 {
568570 TRACE_ENTER(0);
@@ -568,3 +570,28 @@
569571 TRACE_EXIT(0,0);
570572 return TRUE;
571573 }
 574+
 575+/**
 576+ * Deletes the known instance of DirectDraw from the ddraw module.
 577+ */
 578+void DeleteDirectDraw()
 579+{
 580+ glDD7 = NULL;
 581+}
 582+
 583+/**
 584+ * Generates a glFrameTerminatorGREMEDY command in OpenGL if the renderer
 585+ * is active and the glFrameTerminatorGREMEDY command is available (i.e.
 586+ * running under gDebugger).
 587+ * Do not link to this entry point. Use LoadLibrary and GetProcAddress instead.
 588+ */
 589+DDRAW_API void DXGLBreak()
 590+{
 591+ if (glDD7)
 592+ {
 593+ if (glDD7->renderer)
 594+ {
 595+ glRenderer_DXGLBreak(glDD7->renderer);
 596+ }
 597+ }
 598+}
\ No newline at end of file
Index: ddraw/ddraw.def
@@ -1,5 +1,5 @@
22 ; DXGL
3 -; Copyright (C) 2011 William Feely
 3+; Copyright (C) 2011-2016 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
@@ -39,4 +39,5 @@
4040 RegisterSpecialCase
4141 ReleaseDDThreadLock
4242 SetAppCompatData
43 - IsDXGLDDraw
\ No newline at end of file
 43+ IsDXGLDDraw
 44+ DXGLBreak
\ No newline at end of file
Index: ddraw/ddraw.h
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2011-2015 William Feely
 3+// Copyright (C) 2011-2016 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
@@ -56,6 +56,7 @@
5757 DDRAW_API void WINAPI ReleaseDDThreadLock();
5858 DDRAW_API BOOL IsDXGLDDraw();
5959
 60+void DeleteDirectDraw();
6061 extern "C" {extern DXGLCFG dxglcfg; }
6162 extern DWORD gllock;
6263 extern const GUID device_template;
Index: ddraw/glDirectDraw.cpp
@@ -667,6 +667,7 @@
668668 if (glD3D3) delete glD3D3;
669669 if (glD3D2) delete glD3D2;
670670 if (glD3D1) delete glD3D1;
 671+ DeleteDirectDraw();
671672 TRACE_EXIT(-1,0);
672673 }
673674
Index: ddraw/glExtensions.c
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2011-2014 William Feely
 3+// Copyright (C) 2011-2016 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
@@ -119,6 +119,8 @@
120120 else ext->GLEXT_ARB_sampler_objects = 0;
121121 if(strstr((char*)glextensions,"GL_EXT_gpu_shader4")) ext->GLEXT_EXT_gpu_shader4 = 1;
122122 else ext->GLEXT_EXT_gpu_shader4 = 0;
 123+ if(strstr((char*)glextensions,"GL_GREMEDY_frame_terminator")) ext->GLEXT_GREMEDY_frame_terminator = 1;
 124+ else ext->GLEXT_GREMEDY_frame_terminator = 0;
123125 broken_fbo = TRUE;
124126 if(ext->GLEXT_ARB_framebuffer_object)
125127 {
@@ -181,6 +183,10 @@
182184 ext->glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC)wglGetProcAddress("glSamplerParameterfv");
183185 ext->glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC)wglGetProcAddress("glSamplerParameteriv");
184186 }
 187+ if (ext->GLEXT_GREMEDY_frame_terminator)
 188+ {
 189+ ext->glFrameTerminatorGREMEDY = (PFNGLFRAMETERMINATORGREMEDYPROC)wglGetProcAddress("glFrameTerminatorGREMEDY");
 190+ }
185191 if(broken_fbo)
186192 {
187193 MessageBox(NULL,_T("DXGL requires support for OpenGL Framebuffer Objects to function. \
Index: ddraw/glExtensions.h
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2011-2014 William Feely
 3+// Copyright (C) 2011-2016 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
@@ -137,6 +137,8 @@
138138 void (APIENTRY *glSamplerParameterfv)(GLuint sampler, GLenum pname, const GLfloat *params);
139139 void (APIENTRY *glSamplerParameteriv)(GLuint sampler, GLenum pname, const GLint *params);
140140
 141+ void (APIENTRY *glFrameTerminatorGREMEDY)();
 142+
141143 int GLEXT_ARB_framebuffer_object;
142144 int GLEXT_EXT_framebuffer_object;
143145 int GLEXT_NV_packed_depth_stencil;
@@ -150,6 +152,7 @@
151153 int GLEXT_ARB_direct_state_access;
152154 int GLEXT_ARB_sampler_objects;
153155 int GLEXT_EXT_gpu_shader4;
 156+ int GLEXT_GREMEDY_frame_terminator;
154157 int glver_major;
155158 int glver_minor;
156159 BOOL atimem;
Index: ddraw/glRenderer.cpp
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2012-2015 William Feely
 3+// Copyright (C) 2012-2016 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
@@ -769,16 +769,16 @@
770770 }
771771
772772 /**
773 -* Fills a depth surface with a specified value.
774 -* @param This
775 -* Pointer to glRenderer object
776 -* @param lpDestRect
777 -* Pointer to bounding rectangle for depth fill. If NULL, then fill entire surface
778 -* @param dest
779 -* Destination surface to depth fill
780 -* @param lpDDBltFx
781 -* Pointer to DDBLTFX structure with dwFillDepth defining the depth value.
782 -*/
 773+ * Fills a depth surface with a specified value.
 774+ * @param This
 775+ * Pointer to glRenderer object
 776+ * @param lpDestRect
 777+ * Pointer to bounding rectangle for depth fill. If NULL, then fill entire surface
 778+ * @param dest
 779+ * Destination surface to depth fill
 780+ * @param lpDDBltFx
 781+ * Pointer to DDBLTFX structure with dwFillDepth defining the depth value.
 782+ */
783783 HRESULT glRenderer_DepthFill(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *dest, LPDDBLTFX lpDDBltFx)
784784 {
785785 EnterCriticalSection(&This->cs);
@@ -793,14 +793,14 @@
794794 }
795795
796796 /**
797 -* Sets a render state within the renderer.
798 -* @param This
799 -* Pointer to glRenderer object
800 -* @param dwRendStateType
801 -* Render state to change
802 -* @param dwRenderState
803 -* New render state value
804 -*/
 797+ * Sets a render state within the renderer.
 798+ * @param This
 799+ * Pointer to glRenderer object
 800+ * @param dwRendStateType
 801+ * Render state to change
 802+ * @param dwRenderState
 803+ * New render state value
 804+ */
805805 void glRenderer_SetRenderState(glRenderer *This, D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState)
806806 {
807807 EnterCriticalSection(&This->cs);
@@ -813,14 +813,14 @@
814814 }
815815
816816 /**
817 -* Binds a surface to a texture stage in the renderer.
818 -* @param This
819 -* Pointer to glRenderer object
820 -* @param dwStage
821 -* Texture stage to bind
822 -* @param Texture
823 -* Texture to bind to the stage; old texture will be released; NULL to unbind
824 -*/
 817+ * Binds a surface to a texture stage in the renderer.
 818+ * @param This
 819+ * Pointer to glRenderer object
 820+ * @param dwStage
 821+ * Texture stage to bind
 822+ * @param Texture
 823+ * Texture to bind to the stage; old texture will be released; NULL to unbind
 824+ */
825825 void glRenderer_SetTexture(glRenderer *This, DWORD dwStage, glDirectDrawSurface7 *Texture)
826826 {
827827 EnterCriticalSection(&This->cs);
@@ -833,16 +833,16 @@
834834 }
835835
836836 /**
837 -* Sets a texture stage state within the renderer.
838 -* @param This
839 -* Pointer to glRenderer object
840 -* @param dwStage
841 -* Texture stage to modify
842 -* @param dwState
843 -* Texture stage state to modify
844 -* @param dwValue
845 -* New value for texture stage state.
846 -*/
 837+ * Sets a texture stage state within the renderer.
 838+ * @param This
 839+ * Pointer to glRenderer object
 840+ * @param dwStage
 841+ * Texture stage to modify
 842+ * @param dwState
 843+ * Texture stage state to modify
 844+ * @param dwValue
 845+ * New value for texture stage state.
 846+ */
847847 void glRenderer_SetTextureStageState(glRenderer *This, DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue)
848848 {
849849 EnterCriticalSection(&This->cs);
@@ -856,14 +856,14 @@
857857 }
858858
859859 /**
860 -* Sets a transform matrix in the renderer.
861 -* @param This
862 -* Pointer to glRenderer object
863 -* @param dtstTransformStateType
864 -* Transform matrix to replace
865 -* @param lpD3DMatrix
866 -* New transform matrix
867 -*/
 860+ * Sets a transform matrix in the renderer.
 861+ * @param This
 862+ * Pointer to glRenderer object
 863+ * @param dtstTransformStateType
 864+ * Transform matrix to replace
 865+ * @param lpD3DMatrix
 866+ * New transform matrix
 867+ */
868868 void glRenderer_SetTransform(glRenderer *This, D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix)
869869 {
870870 EnterCriticalSection(&This->cs);
@@ -876,12 +876,12 @@
877877 }
878878
879879 /**
880 -* Sets the material in the renderer.
881 -* @param This
882 -* Pointer to glRenderer object
883 -* @param lpMaterial
884 -* New material parameters
885 -*/
 880+ * Sets the material in the renderer.
 881+ * @param This
 882+ * Pointer to glRenderer object
 883+ * @param lpMaterial
 884+ * New material parameters
 885+ */
886886 void glRenderer_SetMaterial(glRenderer *This, LPD3DMATERIAL7 lpMaterial)
887887 {
888888 EnterCriticalSection(&This->cs);
@@ -893,16 +893,16 @@
894894 }
895895
896896 /**
897 -* Sets a light in the renderer.
898 -* @param This
899 -* Pointer to glRenderer object
900 -* @param index
901 -* Index of light to set
902 -* @param light
903 -* Pointer to light to change, ignored if remove is TRUE
904 -* @param remove
905 -* TRUE to clear a light from the renderer.
906 -*/
 897+ * Sets a light in the renderer.
 898+ * @param This
 899+ * Pointer to glRenderer object
 900+ * @param index
 901+ * Index of light to set
 902+ * @param light
 903+ * Pointer to light to change, ignored if remove is TRUE
 904+ * @param remove
 905+ * TRUE to clear a light from the renderer.
 906+ */
907907
908908 void glRenderer_SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove)
909909 {
@@ -917,12 +917,12 @@
918918 }
919919
920920 /**
921 -* Sets the viewport for the renderer.
922 -* @param This
923 -* Pointer to glRenderer object
924 -* @param lpViewport
925 -* New viewport parameters for renderer.
926 -*/
 921+ * Sets the viewport for the renderer.
 922+ * @param This
 923+ * Pointer to glRenderer object
 924+ * @param lpViewport
 925+ * New viewport parameters for renderer.
 926+ */
927927 void glRenderer_SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport)
928928 {
929929 EnterCriticalSection(&This->cs);
@@ -934,6 +934,21 @@
935935 }
936936
937937 /**
 938+ * Generates a glFrameTerminatorGREMEDY command in OpenGL if the
 939+ * glFrameTerminatorGREMEDY command is available (i.e. running under gDebugger).
 940+ * @param This
 941+ * Pointer to glRenderer object
 942+ */
 943+void glRenderer_DXGLBreak(glRenderer *This)
 944+{
 945+ EnterCriticalSection(&This->cs);
 946+ This->opcode = OP_DXGLBREAK;
 947+ SetEvent(This->start);
 948+ WaitForSingleObject(This->busy, INFINITE);
 949+ LeaveCriticalSection(&This->cs);
 950+}
 951+
 952+/**
938953 * Main loop for glRenderer class
939954 * @param This
940955 * Pointer to glRenderer object
@@ -1073,6 +1088,9 @@
10741089 case OP_SETVIEWPORT:
10751090 glRenderer__SetViewport(This, (LPD3DVIEWPORT7)This->inputs[0]);
10761091 break;
 1092+ case OP_DXGLBREAK:
 1093+ glRenderer__DXGLBreak(This);
 1094+ break;
10771095 }
10781096 }
10791097 return 0;
@@ -2977,4 +2995,10 @@
29782996 }
29792997 }
29802998
 2999+void glRenderer__DXGLBreak(glRenderer *This)
 3000+{
 3001+ if (This->ext->GLEXT_GREMEDY_frame_terminator) This->ext->glFrameTerminatorGREMEDY();
 3002+ SetEvent(This->busy);
 3003+}
 3004+
29813005 }
\ No newline at end of file
Index: ddraw/glRenderer.h
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2012-2015 William Feely
 3+// Copyright (C) 2012-2016 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
@@ -101,6 +101,7 @@
102102 #define OP_SETMATERIAL 20
103103 #define OP_SETLIGHT 21
104104 #define OP_SETVIEWPORT 22
 105+#define OP_DXGLBREAK 23
105106
106107 extern const DWORD renderstate_default[153];
107108 extern const TEXTURESTAGE texstagedefault0;
@@ -191,6 +192,7 @@
192193 void glRenderer_SetMaterial(glRenderer *This, LPD3DMATERIAL7 lpMaterial);
193194 void glRenderer_SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove);
194195 void glRenderer_SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
 196+void glRenderer_DXGLBreak(glRenderer *This);
195197 // In-thread APIs
196198 DWORD glRenderer__Entry(glRenderer *This);
197199 BOOL glRenderer__InitGL(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7);
@@ -226,6 +228,7 @@
227229 void glRenderer__SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove);
228230 void glRenderer__SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
229231 void glRenderer__SetDepthComp(glRenderer *This);
 232+void glRenderer__DXGLBreak(glRenderer *This);
230233
231234 #ifdef __cplusplus
232235 }