| Index: ddraw/ddraw.cpp |
| — | — | @@ -1,5 +1,5 @@ |
| 2 | 2 | // DXGL
|
| 3 | | -// Copyright (C) 2011-2015 William Feely
|
| | 3 | +// Copyright (C) 2011-2016 William Feely
|
| 4 | 4 |
|
| 5 | 5 | // This library is free software; you can redistribute it and/or
|
| 6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
| — | — | @@ -29,6 +29,7 @@ |
| 30 | 30 | #include <intrin.h>
|
| 31 | 31 |
|
| 32 | 32 | extern "C" {DXGLCFG dxglcfg; }
|
| | 33 | +glDirectDraw7 *glDD7 = NULL;
|
| 33 | 34 | DWORD gllock = 0;
|
| 34 | 35 | HMODULE sysddraw = NULL;
|
| 35 | 36 | HRESULT (WINAPI *sysddrawcreate)(GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter) = NULL;
|
| — | — | @@ -167,9 +168,11 @@ |
| 168 | 169 | HRESULT error;
|
| 169 | 170 | myddraw7 = new glDirectDraw7(lpGUID,pUnkOuter);
|
| 170 | 171 | error = myddraw7->err();
|
| | 172 | + glDD7 = myddraw7;
|
| 171 | 173 | if(error != DD_OK)
|
| 172 | 174 | {
|
| 173 | 175 | delete myddraw7;
|
| | 176 | + glDD7 = NULL;
|
| 174 | 177 | LeaveCriticalSection(&dll_cs);
|
| 175 | 178 | TRACE_EXIT(23, error);
|
| 176 | 179 | return error;
|
| — | — | @@ -561,7 +564,6 @@ |
| 562 | 565 | * this function to test whether your program should run or not. This
|
| 563 | 566 | * function may be changed or removed in case of abuse.
|
| 564 | 567 | */
|
| 565 | | -
|
| 566 | 568 | DDRAW_API BOOL IsDXGLDDraw()
|
| 567 | 569 | {
|
| 568 | 570 | TRACE_ENTER(0);
|
| — | — | @@ -568,3 +570,28 @@ |
| 569 | 571 | TRACE_EXIT(0,0);
|
| 570 | 572 | return TRUE;
|
| 571 | 573 | }
|
| | 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 @@ |
| 2 | 2 | ; DXGL
|
| 3 | | -; Copyright (C) 2011 William Feely
|
| | 3 | +; Copyright (C) 2011-2016 William Feely
|
| 4 | 4 |
|
| 5 | 5 | ; This library is free software; you can redistribute it and/or
|
| 6 | 6 | ; modify it under the terms of the GNU Lesser General Public
|
| — | — | @@ -39,4 +39,5 @@ |
| 40 | 40 | RegisterSpecialCase
|
| 41 | 41 | ReleaseDDThreadLock
|
| 42 | 42 | 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 @@ |
| 2 | 2 | // DXGL
|
| 3 | | -// Copyright (C) 2011-2015 William Feely
|
| | 3 | +// Copyright (C) 2011-2016 William Feely
|
| 4 | 4 |
|
| 5 | 5 | // This library is free software; you can redistribute it and/or
|
| 6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
| — | — | @@ -56,6 +56,7 @@ |
| 57 | 57 | DDRAW_API void WINAPI ReleaseDDThreadLock();
|
| 58 | 58 | DDRAW_API BOOL IsDXGLDDraw();
|
| 59 | 59 |
|
| | 60 | +void DeleteDirectDraw();
|
| 60 | 61 | extern "C" {extern DXGLCFG dxglcfg; }
|
| 61 | 62 | extern DWORD gllock;
|
| 62 | 63 | extern const GUID device_template;
|
| Index: ddraw/glDirectDraw.cpp |
| — | — | @@ -667,6 +667,7 @@ |
| 668 | 668 | if (glD3D3) delete glD3D3;
|
| 669 | 669 | if (glD3D2) delete glD3D2;
|
| 670 | 670 | if (glD3D1) delete glD3D1;
|
| | 671 | + DeleteDirectDraw();
|
| 671 | 672 | TRACE_EXIT(-1,0);
|
| 672 | 673 | }
|
| 673 | 674 |
|
| Index: ddraw/glExtensions.c |
| — | — | @@ -1,5 +1,5 @@ |
| 2 | 2 | // DXGL
|
| 3 | | -// Copyright (C) 2011-2014 William Feely
|
| | 3 | +// Copyright (C) 2011-2016 William Feely
|
| 4 | 4 |
|
| 5 | 5 | // This library is free software; you can redistribute it and/or
|
| 6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
| — | — | @@ -119,6 +119,8 @@ |
| 120 | 120 | else ext->GLEXT_ARB_sampler_objects = 0;
|
| 121 | 121 | if(strstr((char*)glextensions,"GL_EXT_gpu_shader4")) ext->GLEXT_EXT_gpu_shader4 = 1;
|
| 122 | 122 | 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;
|
| 123 | 125 | broken_fbo = TRUE;
|
| 124 | 126 | if(ext->GLEXT_ARB_framebuffer_object)
|
| 125 | 127 | {
|
| — | — | @@ -181,6 +183,10 @@ |
| 182 | 184 | ext->glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC)wglGetProcAddress("glSamplerParameterfv");
|
| 183 | 185 | ext->glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC)wglGetProcAddress("glSamplerParameteriv");
|
| 184 | 186 | }
|
| | 187 | + if (ext->GLEXT_GREMEDY_frame_terminator)
|
| | 188 | + {
|
| | 189 | + ext->glFrameTerminatorGREMEDY = (PFNGLFRAMETERMINATORGREMEDYPROC)wglGetProcAddress("glFrameTerminatorGREMEDY");
|
| | 190 | + }
|
| 185 | 191 | if(broken_fbo)
|
| 186 | 192 | {
|
| 187 | 193 | MessageBox(NULL,_T("DXGL requires support for OpenGL Framebuffer Objects to function. \
|
| Index: ddraw/glExtensions.h |
| — | — | @@ -1,5 +1,5 @@ |
| 2 | 2 | // DXGL
|
| 3 | | -// Copyright (C) 2011-2014 William Feely
|
| | 3 | +// Copyright (C) 2011-2016 William Feely
|
| 4 | 4 |
|
| 5 | 5 | // This library is free software; you can redistribute it and/or
|
| 6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
| — | — | @@ -137,6 +137,8 @@ |
| 138 | 138 | void (APIENTRY *glSamplerParameterfv)(GLuint sampler, GLenum pname, const GLfloat *params);
|
| 139 | 139 | void (APIENTRY *glSamplerParameteriv)(GLuint sampler, GLenum pname, const GLint *params);
|
| 140 | 140 |
|
| | 141 | + void (APIENTRY *glFrameTerminatorGREMEDY)();
|
| | 142 | +
|
| 141 | 143 | int GLEXT_ARB_framebuffer_object;
|
| 142 | 144 | int GLEXT_EXT_framebuffer_object;
|
| 143 | 145 | int GLEXT_NV_packed_depth_stencil;
|
| — | — | @@ -150,6 +152,7 @@ |
| 151 | 153 | int GLEXT_ARB_direct_state_access;
|
| 152 | 154 | int GLEXT_ARB_sampler_objects;
|
| 153 | 155 | int GLEXT_EXT_gpu_shader4;
|
| | 156 | + int GLEXT_GREMEDY_frame_terminator;
|
| 154 | 157 | int glver_major;
|
| 155 | 158 | int glver_minor;
|
| 156 | 159 | BOOL atimem;
|
| Index: ddraw/glRenderer.cpp |
| — | — | @@ -1,5 +1,5 @@ |
| 2 | 2 | // DXGL
|
| 3 | | -// Copyright (C) 2012-2015 William Feely
|
| | 3 | +// Copyright (C) 2012-2016 William Feely
|
| 4 | 4 |
|
| 5 | 5 | // This library is free software; you can redistribute it and/or
|
| 6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
| — | — | @@ -769,16 +769,16 @@ |
| 770 | 770 | }
|
| 771 | 771 |
|
| 772 | 772 | /**
|
| 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 | + */
|
| 783 | 783 | HRESULT glRenderer_DepthFill(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *dest, LPDDBLTFX lpDDBltFx)
|
| 784 | 784 | {
|
| 785 | 785 | EnterCriticalSection(&This->cs);
|
| — | — | @@ -793,14 +793,14 @@ |
| 794 | 794 | }
|
| 795 | 795 |
|
| 796 | 796 | /**
|
| 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 | + */
|
| 805 | 805 | void glRenderer_SetRenderState(glRenderer *This, D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState)
|
| 806 | 806 | {
|
| 807 | 807 | EnterCriticalSection(&This->cs);
|
| — | — | @@ -813,14 +813,14 @@ |
| 814 | 814 | }
|
| 815 | 815 |
|
| 816 | 816 | /**
|
| 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 | + */
|
| 825 | 825 | void glRenderer_SetTexture(glRenderer *This, DWORD dwStage, glDirectDrawSurface7 *Texture)
|
| 826 | 826 | {
|
| 827 | 827 | EnterCriticalSection(&This->cs);
|
| — | — | @@ -833,16 +833,16 @@ |
| 834 | 834 | }
|
| 835 | 835 |
|
| 836 | 836 | /**
|
| 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 | + */
|
| 847 | 847 | void glRenderer_SetTextureStageState(glRenderer *This, DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue)
|
| 848 | 848 | {
|
| 849 | 849 | EnterCriticalSection(&This->cs);
|
| — | — | @@ -856,14 +856,14 @@ |
| 857 | 857 | }
|
| 858 | 858 |
|
| 859 | 859 | /**
|
| 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 | + */
|
| 868 | 868 | void glRenderer_SetTransform(glRenderer *This, D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix)
|
| 869 | 869 | {
|
| 870 | 870 | EnterCriticalSection(&This->cs);
|
| — | — | @@ -876,12 +876,12 @@ |
| 877 | 877 | }
|
| 878 | 878 |
|
| 879 | 879 | /**
|
| 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 | + */
|
| 886 | 886 | void glRenderer_SetMaterial(glRenderer *This, LPD3DMATERIAL7 lpMaterial)
|
| 887 | 887 | {
|
| 888 | 888 | EnterCriticalSection(&This->cs);
|
| — | — | @@ -893,16 +893,16 @@ |
| 894 | 894 | }
|
| 895 | 895 |
|
| 896 | 896 | /**
|
| 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 | + */
|
| 907 | 907 |
|
| 908 | 908 | void glRenderer_SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove)
|
| 909 | 909 | {
|
| — | — | @@ -917,12 +917,12 @@ |
| 918 | 918 | }
|
| 919 | 919 |
|
| 920 | 920 | /**
|
| 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 | + */
|
| 927 | 927 | void glRenderer_SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport)
|
| 928 | 928 | {
|
| 929 | 929 | EnterCriticalSection(&This->cs);
|
| — | — | @@ -934,6 +934,21 @@ |
| 935 | 935 | }
|
| 936 | 936 |
|
| 937 | 937 | /**
|
| | 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 | +/**
|
| 938 | 953 | * Main loop for glRenderer class
|
| 939 | 954 | * @param This
|
| 940 | 955 | * Pointer to glRenderer object
|
| — | — | @@ -1073,6 +1088,9 @@ |
| 1074 | 1089 | case OP_SETVIEWPORT:
|
| 1075 | 1090 | glRenderer__SetViewport(This, (LPD3DVIEWPORT7)This->inputs[0]);
|
| 1076 | 1091 | break;
|
| | 1092 | + case OP_DXGLBREAK:
|
| | 1093 | + glRenderer__DXGLBreak(This);
|
| | 1094 | + break;
|
| 1077 | 1095 | }
|
| 1078 | 1096 | }
|
| 1079 | 1097 | return 0;
|
| — | — | @@ -2977,4 +2995,10 @@ |
| 2978 | 2996 | }
|
| 2979 | 2997 | }
|
| 2980 | 2998 |
|
| | 2999 | +void glRenderer__DXGLBreak(glRenderer *This)
|
| | 3000 | +{
|
| | 3001 | + if (This->ext->GLEXT_GREMEDY_frame_terminator) This->ext->glFrameTerminatorGREMEDY();
|
| | 3002 | + SetEvent(This->busy);
|
| | 3003 | +}
|
| | 3004 | +
|
| 2981 | 3005 | } |
| \ No newline at end of file |
| Index: ddraw/glRenderer.h |
| — | — | @@ -1,5 +1,5 @@ |
| 2 | 2 | // DXGL
|
| 3 | | -// Copyright (C) 2012-2015 William Feely
|
| | 3 | +// Copyright (C) 2012-2016 William Feely
|
| 4 | 4 |
|
| 5 | 5 | // This library is free software; you can redistribute it and/or
|
| 6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
| — | — | @@ -101,6 +101,7 @@ |
| 102 | 102 | #define OP_SETMATERIAL 20
|
| 103 | 103 | #define OP_SETLIGHT 21
|
| 104 | 104 | #define OP_SETVIEWPORT 22
|
| | 105 | +#define OP_DXGLBREAK 23
|
| 105 | 106 |
|
| 106 | 107 | extern const DWORD renderstate_default[153];
|
| 107 | 108 | extern const TEXTURESTAGE texstagedefault0;
|
| — | — | @@ -191,6 +192,7 @@ |
| 192 | 193 | void glRenderer_SetMaterial(glRenderer *This, LPD3DMATERIAL7 lpMaterial);
|
| 193 | 194 | void glRenderer_SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove);
|
| 194 | 195 | void glRenderer_SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
|
| | 196 | +void glRenderer_DXGLBreak(glRenderer *This);
|
| 195 | 197 | // In-thread APIs
|
| 196 | 198 | DWORD glRenderer__Entry(glRenderer *This);
|
| 197 | 199 | BOOL glRenderer__InitGL(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7);
|
| — | — | @@ -226,6 +228,7 @@ |
| 227 | 229 | void glRenderer__SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove);
|
| 228 | 230 | void glRenderer__SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
|
| 229 | 231 | void glRenderer__SetDepthComp(glRenderer *This);
|
| | 232 | +void glRenderer__DXGLBreak(glRenderer *This);
|
| 230 | 233 |
|
| 231 | 234 | #ifdef __cplusplus
|
| 232 | 235 | }
|