forked from Mirrors/openclonk
Remove remains of Direct3D support
Direct3D hasn't worked for more than a year now, and there don't seem to be any efforts to revive it. Remove it and concentrate on better OpenGL support.stable-5.4
parent
1204d7d2d9
commit
240193ad5a
|
@ -53,9 +53,6 @@ endfunction()
|
|||
include(CMakeDependentOption)
|
||||
option(PROJECT_FOLDERS "Put source files into subfolders in project file" ON)
|
||||
option(USE_CONSOLE "Build dedicated server" OFF)
|
||||
CMAKE_DEPENDENT_OPTION(USE_GL "Enable OpenGL support" ON "NOT USE_CONSOLE" OFF)
|
||||
# DirectX is disabled because it misses essential features
|
||||
CMAKE_DEPENDENT_OPTION(USE_DIRECTX "Enable DirectX support" OFF "WIN32 AND NOT USE_CONSOLE" OFF)
|
||||
CMAKE_DEPENDENT_OPTION(USE_SDL_MAINLOOP "Use SDL to create windows etc." OFF "NOT USE_CONSOLE" OFF)
|
||||
CMAKE_DEPENDENT_OPTION(USE_X11 "Use X11 to create windows etc." ON
|
||||
"UNIX AND NOT APPLE AND NOT USE_SDL_MAINLOOP AND NOT USE_CONSOLE" OFF)
|
||||
|
@ -220,10 +217,6 @@ set(OC_CLONK_SOURCES
|
|||
src/graphics/Bitmap256.cpp
|
||||
src/graphics/Bitmap256.h
|
||||
src/graphics/C4Draw.cpp
|
||||
src/graphics/C4DrawD3D.cpp
|
||||
src/graphics/C4DrawD3D.h
|
||||
src/graphics/C4DrawD3DShader.cpp
|
||||
src/graphics/C4DrawD3DShader.h
|
||||
src/graphics/C4DrawGL.cpp
|
||||
src/graphics/C4DrawGLCtx.cpp
|
||||
src/graphics/C4DrawGL.h
|
||||
|
@ -1310,7 +1303,7 @@ if(WIN32)
|
|||
set(HAVE_DBGHELP ${DBGHELP_FOUND})
|
||||
endif()
|
||||
|
||||
if(USE_GL)
|
||||
if(NOT USE_CONSOLE)
|
||||
include(FindOpenGL)
|
||||
FINDLIB(GLEW_LIBRARIES NAMES GLEW glew32 glew32s)
|
||||
FIND_PATH(GLEW_INCLUDE_DIR NAMES GL/glew.h)
|
||||
|
@ -1320,28 +1313,6 @@ if(USE_GL)
|
|||
)
|
||||
include_directories(${GLEW_INCLUDE_DIR})
|
||||
endif()
|
||||
if(USE_DIRECTX)
|
||||
if(EXISTS $ENV{DXSDK_DIR})
|
||||
list(APPEND CMAKE_INCLUDE_PATH $ENV{DXSDK_DIR}/Include)
|
||||
if(CMAKE_CL_64)
|
||||
list(APPEND CMAKE_LIBRARY_PATH $ENV{DXSDK_DIR}/Lib/x64)
|
||||
else()
|
||||
list(APPEND CMAKE_LIBRARY_PATH $ENV{DXSDK_DIR}/Lib/x86)
|
||||
endif()
|
||||
endif()
|
||||
FINDLIB(DIRECT3D_LIBRARIES d3d9)
|
||||
FINDLIB(DIRECT3DX_LIBRARIES d3dx9)
|
||||
FIND_PATH(DIRECT3D_INCLUDE_DIR NAMES d3d9.h)
|
||||
FIND_PATH(DIRECT3DX_INCLUDE_DIR NAMES d3dx9.h)
|
||||
target_link_libraries(openclonk
|
||||
${DIRECT3D_LIBRARIES}
|
||||
${DIRECT3DX_LIBRARIES}
|
||||
)
|
||||
include_directories(
|
||||
${DIRECT3D_INCLUDE_DIR}
|
||||
${DIRECT3DX_INCLUDE_DIR}
|
||||
)
|
||||
endif()
|
||||
if(USE_GTK)
|
||||
SET(WITH_DEVELOPER_MODE ${GTK_FOUND})
|
||||
SET(WITH_GLIB ${GTK_FOUND})
|
||||
|
|
|
@ -157,12 +157,6 @@
|
|||
/* dedicated server mode */
|
||||
#cmakedefine USE_CONSOLE 1
|
||||
|
||||
/* DirectX graphics */
|
||||
#cmakedefine USE_DIRECTX 1
|
||||
|
||||
/* OpenGL graphics */
|
||||
#cmakedefine USE_GL 1
|
||||
|
||||
/* MP3 music */
|
||||
#cmakedefine USE_MP3 1
|
||||
|
||||
|
|
|
@ -111,7 +111,6 @@ void C4ConfigGraphics::CompileFunc(StdCompiler *pComp)
|
|||
pComp->Value(mkNamingAdapt(BitDepth, "BitDepth", 32 ,false, true));
|
||||
pComp->Value(mkNamingAdapt(Windowed, "Windowed", 0 ,false, true));
|
||||
pComp->Value(mkNamingAdapt(PXSGfx, "PXSGfx" , 1 ));
|
||||
pComp->Value(mkNamingAdapt(Engine, "Engine" , 1 ,false, true));
|
||||
pComp->Value(mkNamingAdapt(Gamma1, "Gamma1" , 0 ));
|
||||
pComp->Value(mkNamingAdapt(Gamma2, "Gamma2" , 0x808080 ));
|
||||
pComp->Value(mkNamingAdapt(Gamma3, "Gamma3" , 0xffffff ));
|
||||
|
@ -357,10 +356,6 @@ bool C4Config::Load(const char *szConfigFile)
|
|||
if (fWinSock) WSACleanup();
|
||||
#endif
|
||||
General.DefaultLanguage();
|
||||
#if defined USE_GL && !defined USE_DIRECTX
|
||||
if (Graphics.Engine == GFXENGN_DIRECTX || Graphics.Engine == GFXENGN_DIRECTXS)
|
||||
Graphics.Engine = GFXENGN_OPENGL;
|
||||
#endif
|
||||
// bit depth sanity check (might be corrupted by resolution check bug in old version)
|
||||
if (Graphics.BitDepth < 16)
|
||||
{
|
||||
|
|
|
@ -112,7 +112,6 @@ public:
|
|||
int32_t ShowCrewCNames; // show clonk names above clonks?
|
||||
int32_t BitDepth; // used bit depth for newgfx
|
||||
int32_t PXSGfx; // show PXS-graphics (instead of sole pixels)
|
||||
int32_t Engine; // 0: D3D; 1: OpenGL;
|
||||
int32_t Gamma1, Gamma2, Gamma3; // gamma ramps
|
||||
int32_t Currency; // default wealth symbolseb
|
||||
int32_t RenderInactiveEM; // draw vieports even if inactive in CPEM
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <C4AppWin32Impl.h>
|
||||
#include "C4ConsoleGUI.h"
|
||||
#include <C4DrawGL.h>
|
||||
#include <C4DrawD3D.h>
|
||||
#include <C4Landscape.h>
|
||||
#include <C4Object.h>
|
||||
#include <C4PlayerList.h>
|
||||
|
@ -309,9 +308,7 @@ class C4ToolsDlg::State: public C4ConsoleGUI::InternalState<class C4ToolsDlg>
|
|||
{
|
||||
public:
|
||||
HWND hDialog;
|
||||
#ifdef USE_GL
|
||||
CStdGLCtx* pGLCtx;
|
||||
#endif
|
||||
friend INT_PTR CALLBACK ToolsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
HBITMAP hbmBrush,hbmBrush2;
|
||||
HBITMAP hbmLine,hbmLine2;
|
||||
|
@ -372,13 +369,11 @@ public:
|
|||
if (hbmFill) DeleteObject(hbmFill);
|
||||
if (hbmIFT) DeleteObject(hbmIFT);
|
||||
if (hbmNoIFT) DeleteObject(hbmNoIFT);
|
||||
#ifdef USE_GL
|
||||
if (pGLCtx)
|
||||
{
|
||||
delete pGLCtx;
|
||||
pGLCtx = NULL;
|
||||
}
|
||||
#endif
|
||||
if (hDialog) DestroyWindow(hDialog); hDialog=NULL;
|
||||
}
|
||||
|
||||
|
@ -954,10 +949,8 @@ bool C4ConsoleGUI::ToolsDlgOpen(C4ToolsDlg *dlg)
|
|||
// Load bitmaps if necessary
|
||||
dlg->state->LoadBitmaps(Application.GetInstance());
|
||||
// create target ctx for OpenGL rendering
|
||||
#ifdef USE_GL
|
||||
if (pDraw && !dlg->state->pGLCtx)
|
||||
dlg->state->pGLCtx = pDraw->CreateContext(GetDlgItem(dlg->state->hDialog,IDC_PREVIEW), &Application);
|
||||
#endif
|
||||
// Show window
|
||||
RestoreWindowPosition(dlg->state->hDialog, "Property", Config.GetSubkeyPath("Console"));
|
||||
SetWindowPos(dlg->state->hDialog,Console.hWindow,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE);
|
||||
|
@ -1083,14 +1076,6 @@ void C4ToolsDlg::NeedPreviewUpdate()
|
|||
|
||||
//Application.DDraw->AttachPrimaryPalette(sfcPreview);
|
||||
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
pD3D->BlitSurface2Window( sfcPreview,
|
||||
0,0,iPrvWdt,iPrvHgt,
|
||||
GetDlgItem(state->hDialog,IDC_PREVIEW),
|
||||
rect.left,rect.top,rect.right,rect.bottom);
|
||||
#endif
|
||||
#ifdef USE_GL
|
||||
// FIXME: This activates the wrong GL context. To avoid breaking the main window display,
|
||||
// FIXME: it has been disabled for the moment
|
||||
//if (pGLCtx->Select())
|
||||
|
@ -1098,7 +1083,6 @@ void C4ToolsDlg::NeedPreviewUpdate()
|
|||
// pGL->Blit(sfcPreview, 0,0,(float)iPrvWdt,(float)iPrvHgt, Application.pWindow->pSurface, rect.left,rect.top, iPrvWdt,iPrvHgt);
|
||||
// Application.pWindow->pSurface->PageFlip();
|
||||
//}
|
||||
#endif
|
||||
delete sfcPreview;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@
|
|||
#include <C4Game.h>
|
||||
#include <C4GameControl.h>
|
||||
#include <StdRegistry.h>
|
||||
#include <C4DrawD3D.h>
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
#include <C4DrawGL.h>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -172,8 +172,8 @@ bool C4Application::DoInit(int argc, char * argv[])
|
|||
Log(C4ENGINEINFOLONG);
|
||||
LogF("Version: %s %s (%s)", C4VERSION, C4_OS, Revision.getData());
|
||||
|
||||
// Initialize D3D/OpenGL
|
||||
bool success = DDrawInit(this, !!isEditor, false, GetConfigWidth(), GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.Engine, Config.Graphics.Monitor);
|
||||
// Initialize OpenGL
|
||||
bool success = DDrawInit(this, !!isEditor, false, GetConfigWidth(), GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.Monitor);
|
||||
if (!success) { LogFatal(LoadResStr("IDS_ERR_DDRAW")); Clear(); ShowGfxErrorDialog(); return false; }
|
||||
|
||||
if (!isEditor)
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "C4App.h"
|
||||
#include <C4FontLoader.h>
|
||||
#include <C4Window.h>
|
||||
#include <C4DrawD3D.h>
|
||||
#include <C4DrawGL.h>
|
||||
#include <C4DrawT.h>
|
||||
#include <C4Markup.h>
|
||||
|
@ -1189,21 +1188,14 @@ void C4Draw::RemoveZoom(float & X, float & Y)
|
|||
Y = (Y - ZoomY) / Zoom + ZoomY;
|
||||
}
|
||||
|
||||
bool DDrawInit(C4AbstractApp * pApp, bool Editor, bool fUsePageLock, unsigned int iXRes, unsigned int iYRes, int iBitDepth, int Engine, unsigned int iMonitor)
|
||||
bool DDrawInit(C4AbstractApp * pApp, bool Editor, bool fUsePageLock, unsigned int iXRes, unsigned int iYRes, int iBitDepth, unsigned int iMonitor)
|
||||
{
|
||||
// create engine
|
||||
switch (Engine)
|
||||
{
|
||||
default: // Use the first engine possible if none selected
|
||||
#ifdef USE_DIRECTX
|
||||
case GFXENGN_DIRECTX: pDraw = new CStdD3D(false); break;
|
||||
case GFXENGN_DIRECTXS: pDraw = new CStdD3D(true); break;
|
||||
#endif
|
||||
#ifdef USE_GL
|
||||
case GFXENGN_OPENGL: pDraw = new CStdGL(); break;
|
||||
#endif
|
||||
case GFXENGN_NOGFX: pDraw = new CStdNoGfx(); break;
|
||||
}
|
||||
#ifndef USE_CONSOLE
|
||||
pDraw = new CStdGL();
|
||||
#else
|
||||
pDraw = new CStdNoGfx();
|
||||
#endif
|
||||
if (!pDraw) return false;
|
||||
// init it
|
||||
if (!pDraw->Init(pApp, Editor, fUsePageLock, iXRes, iYRes, iBitDepth, iMonitor))
|
||||
|
|
|
@ -30,12 +30,6 @@
|
|||
#include <C4windowswrapper.h>
|
||||
#endif
|
||||
|
||||
// engines
|
||||
#define GFXENGN_DIRECTX 0
|
||||
#define GFXENGN_OPENGL 1
|
||||
#define GFXENGN_DIRECTXS 2
|
||||
#define GFXENGN_NOGFX 3
|
||||
|
||||
// Global Draw access pointer
|
||||
extern C4Draw *pDraw;
|
||||
|
||||
|
@ -130,14 +124,12 @@ struct C4BltData
|
|||
|
||||
|
||||
// This structure is used by StdGL, too
|
||||
#ifndef USE_DIRECTX
|
||||
typedef struct _D3DGAMMARAMP
|
||||
typedef struct _GAMMARAMP
|
||||
{
|
||||
WORD red [256];
|
||||
WORD green[256];
|
||||
WORD blue [256];
|
||||
} D3DGAMMARAMP;
|
||||
#endif
|
||||
} GAMMARAMP;
|
||||
|
||||
// gamma ramp control
|
||||
class C4GammaControl
|
||||
|
@ -146,7 +138,7 @@ private:
|
|||
void SetClrChannel(WORD *pBuf, BYTE c1, BYTE c2, int c3); // set color channel ramp
|
||||
|
||||
protected:
|
||||
D3DGAMMARAMP ramp;
|
||||
GAMMARAMP ramp;
|
||||
|
||||
public:
|
||||
C4GammaControl() { Default(); } // ctor
|
||||
|
@ -212,7 +204,6 @@ public:
|
|||
#ifdef _WIN32
|
||||
virtual CStdGLCtx *CreateContext(HWND, C4AbstractApp *) { return NULL; }
|
||||
#endif
|
||||
virtual int GetEngine() = 0; // get indexed engine
|
||||
virtual bool OnResolutionChanged(unsigned int iXRes, unsigned int iYRes) = 0; // reinit clipper for new resolution
|
||||
virtual bool IsOpenGL() { return false; }
|
||||
virtual bool IsShaderific() { return false; }
|
||||
|
@ -325,7 +316,6 @@ protected:
|
|||
friend class C4Surface;
|
||||
friend class C4TexRef;
|
||||
friend class C4Pattern;
|
||||
friend class CStdD3DShader;
|
||||
};
|
||||
|
||||
struct ZoomDataStackItem: public ZoomData
|
||||
|
@ -340,5 +330,5 @@ bool UnLockSurfaceGlobal(C4Surface * sfcTarget);
|
|||
bool DLineSPix(int32_t x, int32_t y, int32_t col);
|
||||
bool DLineSPixDw(int32_t x, int32_t y, int32_t dwClr);
|
||||
|
||||
bool DDrawInit(C4AbstractApp * pApp, bool Editor, bool fUsePageLock, unsigned int iXRes, unsigned int iYRes, int iBitDepth, int Engine, unsigned int iMonitor);
|
||||
bool DDrawInit(C4AbstractApp * pApp, bool Editor, bool fUsePageLock, unsigned int iXRes, unsigned int iYRes, int iBitDepth, unsigned int iMonitor);
|
||||
#endif // INC_STDDDRAW2
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,176 +0,0 @@
|
|||
/*
|
||||
* OpenClonk, http://www.openclonk.org
|
||||
*
|
||||
* Copyright (c) 2002, 2005 Sven Eberhardt
|
||||
* Copyright (c) 2005, 2009, 2011 Günther Brammer
|
||||
* Copyright (c) 2009 Nicolas Hake
|
||||
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
|
||||
*
|
||||
* Portions might be copyrighted by other authors who have contributed
|
||||
* to OpenClonk.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
* See isc_license.txt for full license and disclaimer.
|
||||
*
|
||||
* "Clonk" is a registered trademark of Matthes Bender.
|
||||
* See clonk_trademark_license.txt for full license.
|
||||
*/
|
||||
|
||||
/* Direct3D implementation of NewGfx */
|
||||
|
||||
#if defined(USE_DIRECTX) && !defined(INC_STDD3D)
|
||||
#define INC_STDD3D
|
||||
|
||||
// debug memmgmt off
|
||||
#ifdef _DEBUG
|
||||
#ifdef _MSC_VER
|
||||
#undef new
|
||||
#endif // _MSC_VER
|
||||
#endif // _DEBUG
|
||||
|
||||
#include <C4windowswrapper.h>
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9tex.h>
|
||||
#undef DrawText
|
||||
#include <StdDDraw2.h>
|
||||
|
||||
// debug memmgmt on
|
||||
#ifdef _DEBUG
|
||||
#ifdef _MSC_VER
|
||||
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
|
||||
#endif // _MSC_VER
|
||||
#endif // _DEBUG
|
||||
|
||||
// check version
|
||||
#if (DIRECT3D_VERSION > 0x0900)
|
||||
#error "Using DirectX > 9.0 headers! Program won't run on computers using DX 9.0!"
|
||||
#endif
|
||||
|
||||
// default Clonk vertex format
|
||||
struct C4VERTEX
|
||||
{
|
||||
FLOAT x, y, z, rhw; // transformed vertex pos
|
||||
FLOAT tu, tv; // texture offsets
|
||||
};
|
||||
|
||||
// vertex format for solid blits
|
||||
struct C4CLRVERTEX
|
||||
{
|
||||
FLOAT x, y, z, rhw; // transformed vertex pos
|
||||
DWORD color; // blit color
|
||||
};
|
||||
|
||||
// vertex format for ColorByOwner-blits
|
||||
struct C4CTVERTEX
|
||||
{
|
||||
FLOAT x, y, z, rhw; // transformed vertex pos
|
||||
DWORD color; // overlay color
|
||||
FLOAT tu, tv; // texture offsets
|
||||
};
|
||||
|
||||
#define D3DFVF_C4VERTEX (D3DFVF_XYZRHW|D3DFVF_TEX1)
|
||||
#define D3DFVF_C4CLRVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)
|
||||
#define D3DFVF_C4CTVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1)
|
||||
|
||||
typedef C4VERTEX C4VERTEXQUAD[4];
|
||||
typedef C4CLRVERTEX C4CLRVERTEXQUAD[4];
|
||||
typedef C4CTVERTEX C4CTVERTEXQUAD[4];
|
||||
|
||||
class CStdD3DShader;
|
||||
|
||||
// direct draw encapsulation
|
||||
class CStdD3D : public C4Draw
|
||||
{
|
||||
public:
|
||||
CStdD3D(bool fSoftware);
|
||||
~CStdD3D();
|
||||
protected:
|
||||
IDirect3D9 *lpD3D;
|
||||
IDirect3DDevice9 *lpDevice;
|
||||
IDirect3DVertexBuffer9 *pVB; // prepared vertex buffer for blitting
|
||||
IDirect3DVertexBuffer9 *pVBClr; // prepared vertex buffer for drawing in solid color
|
||||
IDirect3DVertexBuffer9 *pVBClrTex;// prepared vertex buffer for blitting iwth color/tex-modulation
|
||||
C4VERTEX bltVertices[8]; // prepared vertex data; need to insert x/y and u/v
|
||||
C4CLRVERTEX clrVertices[8]; // prepared vertex data; need to insert x/y and color
|
||||
C4CTVERTEX bltClrVertices[8]; // prepared vertex data; need to insert x/y, color and u/v
|
||||
IDirect3DStateBlock9 *bltState[3]; // saved state block for blitting (0: copy; 1: blit; 2: blit additive)
|
||||
IDirect3DStateBlock9 *bltBaseState[4]; // saved state block for blitting with a base face (0: normal; 1: additive; 2: mod2; 3: mod2+additive)
|
||||
IDirect3DStateBlock9 *drawSolidState[2]; // saved state block for drawing in solid color (0: normal; 1: additive)
|
||||
IDirect3DStateBlock9 *pSavedState; // state block to backup current state
|
||||
D3DVIEWPORT9 WindowClipper;
|
||||
D3DDISPLAYMODE dspMode;
|
||||
D3DPRESENT_PARAMETERS d3dpp; // device present parameters
|
||||
D3DFORMAT dwSurfaceType;// surface format for new textures
|
||||
D3DFORMAT PrimarySrfcFormat;// surace format of primary surface
|
||||
bool fSoftware; // software rendering
|
||||
enum ShaderIndex
|
||||
{
|
||||
SHIDX_Mod2 = 1,
|
||||
SHIDX_ColoredFoW = 2,
|
||||
SHIDX_Size = 4,
|
||||
};
|
||||
CStdD3DShader *pShaders[SHIDX_Size];
|
||||
BITMAPINFO sfcBmpInfo; // surface bits as bitmap bits info
|
||||
bool SceneOpen; // set if a scene has begun
|
||||
public:
|
||||
// General
|
||||
void Clear();
|
||||
void Default();
|
||||
bool PageFlip(C4Rect *pSrcRt=NULL, C4Rect *pDstRt=NULL, C4Window * pWindow = NULL);
|
||||
bool BeginScene(); // prepare device for drawing
|
||||
void EndScene(); // prepare device for surface locking, flipping etc.
|
||||
virtual int GetEngine() { return fSoftware ? 2 : 0; } // get indexed engine
|
||||
void TaskOut(); // user taskswitched the app away
|
||||
void TaskIn(); // user tasked back
|
||||
bool SetVideoMode(unsigned int iXRes, unsigned int iYRes, unsigned int iColorDepth, unsigned int iMonitor, bool fFullScreen);
|
||||
virtual bool OnResolutionChanged(unsigned int iXRes, unsigned int iYRes); // reinit clipper for new resolution
|
||||
// Clipper
|
||||
bool UpdateClipper(); // set current clipper to render target
|
||||
virtual bool PrepareMaterial(StdMeshMaterial &mat);
|
||||
// Surface
|
||||
bool PrepareRendering(C4Surface * sfcToSurface); // check if/make rendering possible to given surface
|
||||
// Blit
|
||||
virtual void PerformMesh(StdMeshInstance &instance, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, C4BltTransform* pTransform);
|
||||
void PerformBlt(C4BltData &rBltData, C4TexRef *pTex, DWORD dwModClr, bool fMod2, bool fExact);
|
||||
bool BlitTex2Window(C4TexRef *pTexRef, HDC hdcTarget, RECT &rtFrom, RECT &rtTo);
|
||||
bool BlitSurface2Window(C4Surface * sfcSource, int fX, int fY, int fWdt, int fHgt, HWND hWnd, int tX, int tY, int tWdt, int tHgt);
|
||||
void FillBG(DWORD dwClr=0);
|
||||
// Drawing
|
||||
void DrawQuadDw(C4Surface * sfcTarget, float *ipVtx, DWORD dwClr1, DWORD dwClr2, DWORD dwClr3, DWORD dwClr4);
|
||||
void PerformLine(C4Surface * sfcTarget, float x1, float y1, float x2, float y2, DWORD dwClr, float width);
|
||||
void PerformPix(C4Surface * sfcDest, float tx, float ty, DWORD dwCol);
|
||||
void DrawPixPrimary(C4Surface * sfcDest, int tx, int ty, DWORD dwCol);
|
||||
// Gamma
|
||||
bool ApplyGammaRamp(D3DGAMMARAMP &ramp, bool fForce);
|
||||
bool SaveDefaultGammaRamp(D3DGAMMARAMP &ramp);
|
||||
// device objects
|
||||
bool InitDeviceObjects(); // init device dependent objects
|
||||
bool InitShaders(); // parse and set shaders
|
||||
bool RestoreDeviceObjects(); // restore device dependent objects
|
||||
bool InvalidateDeviceObjects(); // free device dependent objects
|
||||
bool DeleteDeviceObjects(); // free device dependent objects
|
||||
void SetTexture();
|
||||
void ResetTexture();
|
||||
bool DeviceReady() { return !!lpDevice; }
|
||||
|
||||
bool CreateStateBlock(IDirect3DStateBlock9 **pBlock, bool fTransparent, bool fSolid, bool fBaseTex, bool fAdditive, bool fMod2); // capture state blocks for blitting
|
||||
|
||||
protected:
|
||||
bool FindDisplayMode(unsigned int iXRes, unsigned int iYRes, unsigned int iColorDepth, unsigned int iMonitor);
|
||||
bool FindDisplayMode(unsigned int iXRes, unsigned int iYRes, D3DFORMAT format, unsigned int iMonitor);
|
||||
virtual bool CreatePrimarySurfaces(bool Editor, unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor);
|
||||
bool SetOutputAdapter(unsigned int iMonitor);
|
||||
inline bool HasShaders() const { return !!pShaders[0]; }
|
||||
|
||||
|
||||
friend class C4Surface;
|
||||
friend class C4TexRef;
|
||||
friend class C4Pattern;
|
||||
};
|
||||
|
||||
// Global D3D access pointer
|
||||
extern CStdD3D *pD3D;
|
||||
|
||||
#endif // defined(USE_DIRECTX) && !defined(INC_STDD3D)
|
|
@ -1,192 +0,0 @@
|
|||
/*
|
||||
* OpenClonk, http://www.openclonk.org
|
||||
*
|
||||
* Copyright (c) 2009 Sven Eberhardt
|
||||
* Copyright (c) 2009, RedWolf Design GmbH, http://www.clonk.de
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* "Clonk" is a registered trademark of Matthes Bender. */
|
||||
|
||||
/* Direct3D shader used for FoW-modulated blitting */
|
||||
|
||||
#include "C4Include.h"
|
||||
|
||||
#ifdef USE_DIRECTX
|
||||
#include <StdD3DShader.h>
|
||||
|
||||
static const char *szShaderCode =
|
||||
"sampler in_tex; /* Blitted input texture */"
|
||||
"\n" "sampler fow_tex; /* FogOfWar modulation texture */"
|
||||
"\n" ""
|
||||
"\n" "float4 fow_proj; /* Projection of FogOfWar-texture into screen space: xy=scale, zw=offset */"
|
||||
"\n" ""
|
||||
"\n" "struct PS_INPUT"
|
||||
"\n" "{"
|
||||
"\n" " float4 Color : COLOR0; /* Per-vertex modulation color */"
|
||||
"\n" " float2 TexPos : TEXCOORD0; /* Texture position */"
|
||||
"\n" " float2 ScreenPos : VPOS; /* Output screen position */"
|
||||
"\n" "};"
|
||||
"\n" ""
|
||||
"\n" "struct PS_OUTPUT"
|
||||
"\n" "{"
|
||||
"\n" " float4 Color : COLOR; /* Calculated output color */"
|
||||
"\n" "};"
|
||||
"\n" ""
|
||||
"\n" "/* Main shader function */"
|
||||
"\n" "PS_OUTPUT MainExec(PS_INPUT In)"
|
||||
"\n" "{"
|
||||
"\n" " PS_OUTPUT Out;"
|
||||
"\n" " /* Sample source texture */"
|
||||
"\n" " float4 in_tex_color = tex2D(in_tex,In.TexPos);"
|
||||
"\n" " /* Sample FoW texture */"
|
||||
"\n" " float4 fow_tex_color = tex2D(fow_tex,(In.ScreenPos-fow_proj.zw)*fow_proj.xy);"
|
||||
"\n" "#ifdef MOD2"
|
||||
"\n" " /* Apply Mod2-modulation (x2 scale input color and signed add modulation color) */"
|
||||
"\n" " Out.Color.rgb = saturate(in_tex_color.rgb*2 + In.Color.rgb - 0.5);"
|
||||
"\n" "#else"
|
||||
"\n" " /* Apply regular modulation */"
|
||||
"\n" " Out.Color.rgb = In.Color.rgb * in_tex_color.rgb;"
|
||||
"\n" "#endif"
|
||||
"\n" " /* Apply FoW */"
|
||||
"\n" "#ifdef COLORED_FOW"
|
||||
"\n" " /* Colored FoW: Mix source color and FoW color */"
|
||||
"\n" " Out.Color.rgb = Out.Color.rgb * fow_tex_color.a + fow_tex_color.rgb * (1.0 - fow_tex_color.a);"
|
||||
"\n" "#else"
|
||||
"\n" " /* Black FoW: Just darken */"
|
||||
"\n" " Out.Color.rgb *= fow_tex_color.a;"
|
||||
"\n" "#endif"
|
||||
"\n" " /* Alpha values modulated */"
|
||||
"\n" " Out.Color.a = In.Color.a * in_tex_color.a;"
|
||||
"\n" " return Out;"
|
||||
"\n" "}";
|
||||
|
||||
|
||||
CStdD3DShader::CStdD3DShader() : pDevice(NULL), pInterface(NULL), pConstTable(NULL), pCodeBuffer(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
CStdD3DShader::~CStdD3DShader()
|
||||
{
|
||||
Discard();
|
||||
}
|
||||
|
||||
void CStdD3DShader::Release()
|
||||
{
|
||||
// properly release interface
|
||||
ReleaseCode();
|
||||
if (pInterface) { pInterface->Release(); pInterface = NULL; }
|
||||
pDevice = NULL;
|
||||
}
|
||||
|
||||
void CStdD3DShader::ReleaseCode()
|
||||
{
|
||||
// release init-time temp values
|
||||
if (pConstTable) { pConstTable->Release(); pConstTable = NULL; }
|
||||
if (pCodeBuffer) { pCodeBuffer->Release(); pCodeBuffer = NULL; }
|
||||
}
|
||||
|
||||
void CStdD3DShader::Discard()
|
||||
{
|
||||
// discard interface without deleting
|
||||
pCodeBuffer = NULL;
|
||||
pConstTable = NULL;
|
||||
pInterface = NULL;
|
||||
pDevice = NULL;
|
||||
}
|
||||
|
||||
bool CStdD3DShader::Error(const char *szMsg)
|
||||
{
|
||||
return pDraw->Error(FormatString("Direct3D Shader error: %s", szMsg).getData());
|
||||
}
|
||||
|
||||
bool CStdD3DShader::Compile(bool fMod2, bool fColoredFoW)
|
||||
{
|
||||
ID3DXBuffer *pErrMsg=NULL;
|
||||
// load and compile shader
|
||||
D3DXMACRO defines[3]; int i=0;
|
||||
if (fMod2)
|
||||
{
|
||||
defines[i].Name = "MOD2";
|
||||
defines[i].Definition = "1";
|
||||
i++;
|
||||
}
|
||||
if (fColoredFoW)
|
||||
{
|
||||
defines[i].Name = "COLORED_FOW";
|
||||
defines[i].Definition = "1";
|
||||
i++;
|
||||
}
|
||||
defines[i].Name = 0;
|
||||
defines[i].Definition = 0;
|
||||
HRESULT hr = D3DXCompileShader(szShaderCode, strlen(szShaderCode), i?defines:NULL, NULL, "MainExec", D3DXGetPixelShaderProfile(pDevice), 0, &pCodeBuffer, &pErrMsg, &pConstTable);
|
||||
if (hr != D3D_OK)
|
||||
{
|
||||
StdStrBuf errmsg;
|
||||
errmsg.Format("D3DXCompileShaderFromFile error %x", static_cast<unsigned int>(hr));
|
||||
if (pErrMsg)
|
||||
{
|
||||
errmsg.AppendFormat(": %*s", static_cast<int>(pErrMsg->GetBufferSize()), static_cast<char*>(pErrMsg->GetBufferPointer()));
|
||||
pErrMsg->Release();
|
||||
}
|
||||
return Error(errmsg.getData());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int CStdD3DShader::GetConstRegister(const char *szName, D3DXREGISTER_SET eRegType)
|
||||
{
|
||||
// get named register index for shader input
|
||||
// errors are not fatal; shader will probably just not need this input
|
||||
if (!pConstTable) return 0;
|
||||
D3DXHANDLE hConstant = pConstTable->GetConstantByName(NULL, szName);
|
||||
if (!hConstant) return 0;
|
||||
D3DXCONSTANT_DESC constDesc;
|
||||
UINT c=1;
|
||||
HRESULT hr = pConstTable->GetConstantDesc(hConstant, &constDesc, &c);
|
||||
if (hr != D3D_OK) return 0;
|
||||
if (constDesc.RegisterSet != eRegType) return 0;
|
||||
return constDesc.RegisterIndex;
|
||||
}
|
||||
|
||||
bool CStdD3DShader::CreateShader()
|
||||
{
|
||||
// creating actual DX shader!
|
||||
HRESULT hr = pDevice->CreatePixelShader((const DWORD *)pCodeBuffer->GetBufferPointer(), &pInterface);
|
||||
if (hr != D3D_OK) return Error(FormatString("CreatePixelShader error %x", static_cast<unsigned int>(hr)).getData());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CStdD3DShader::Init(IDirect3DDevice9 *pDevice, bool fMod2, bool fColoredFoW)
|
||||
{
|
||||
// re-init?
|
||||
if (pInterface) Release();
|
||||
// store device for easy acccess
|
||||
this->pDevice = pDevice;
|
||||
// compile code
|
||||
if (!Compile(fMod2, fColoredFoW)) { Release(); return false; }
|
||||
// get const registers
|
||||
iInTexIndex = GetConstRegister("in_tex", D3DXRS_SAMPLER);
|
||||
iFoWTexIndex = GetConstRegister("fow_tex", D3DXRS_SAMPLER);
|
||||
iFoWTransformIndex = GetConstRegister("fow_proj", D3DXRS_FLOAT4);
|
||||
// create actual shader on device
|
||||
if (!CreateShader()) { Release(); return false; }
|
||||
// del temp objects
|
||||
ReleaseCode();
|
||||
// done, success!
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* OpenClonk, http://www.openclonk.org
|
||||
*
|
||||
* Copyright (c) 2009 Sven Eberhardt
|
||||
* Copyright (c) 2009, RedWolf Design GmbH, http://www.clonk.de
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* "Clonk" is a registered trademark of Matthes Bender. */
|
||||
|
||||
/* Direct3D shader used for FoW-modulated blitting */
|
||||
|
||||
#if defined(USE_DIRECTX) && !defined(INC_STDD3DSHADER)
|
||||
#define INC_STDD3DSHADER
|
||||
|
||||
#include <StdD3D.h>
|
||||
|
||||
class CStdD3DShader
|
||||
{
|
||||
private:
|
||||
IDirect3DDevice9 *pDevice; // DX device parenting shader
|
||||
IDirect3DPixelShader9 *pInterface; // DX interface
|
||||
ID3DXConstantTable *pConstTable; // offsets of shader inputs
|
||||
ID3DXBuffer *pCodeBuffer; // buffer containing shader bytecode
|
||||
|
||||
void ReleaseCode(); // release init-time members only
|
||||
|
||||
bool Compile(bool fMod22, bool fColoredFoW); // create shader byte code
|
||||
int GetConstRegister(const char *szName, D3DXREGISTER_SET eRegType); // get named register index for shader input
|
||||
bool CreateShader(); // create actual DX pixel shader object
|
||||
|
||||
bool Error(const char *szMsg); // error to ddraw; always return false
|
||||
|
||||
public:
|
||||
// todo: Make those constants in the shader
|
||||
int iInTexIndex, iFoWTexIndex, iFoWTransformIndex; // constant indices used to pass data to the shader
|
||||
|
||||
CStdD3DShader();
|
||||
~CStdD3DShader();
|
||||
|
||||
void Release(); // properly release interfaces
|
||||
void Discard(); // zero members (e.g. after device has been destroyed)
|
||||
|
||||
bool Init(IDirect3DDevice9 *pDevice, bool fMod2, bool fColoredFoW);
|
||||
|
||||
IDirect3DPixelShader9 *GetInterface() const { return pInterface; }
|
||||
};
|
||||
|
||||
#endif // defined(USE_DIRECTX) && !defined(INC_STDD3DSHADER)
|
|
@ -36,7 +36,7 @@
|
|||
#include "C4Config.h"
|
||||
#include "C4Application.h"
|
||||
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
|
||||
// MSVC doesn't define M_PI in math.h unless requested
|
||||
#ifdef _MSC_VER
|
||||
|
@ -995,4 +995,4 @@ void CStdGL::Default()
|
|||
iClrDpt=0;
|
||||
}
|
||||
|
||||
#endif // USE_GL
|
||||
#endif // USE_CONSOLE
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
|
||||
/* OpenGL implementation of NewGfx */
|
||||
|
||||
#if !defined(INC_StdGL) && defined(USE_GL)
|
||||
|
||||
#if !defined(INC_StdGL) && !defined(USE_CONSOLE)
|
||||
#define INC_StdGL
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -106,7 +107,6 @@ public:
|
|||
// General
|
||||
void Clear();
|
||||
void Default();
|
||||
virtual int GetEngine() { return 1; } // get indexed engine
|
||||
virtual bool IsOpenGL() { return true; }
|
||||
virtual bool IsShaderific() { return shaders[0] != 0; }
|
||||
virtual bool OnResolutionChanged(unsigned int iXRes, unsigned int iYRes); // reinit clipper for new resolution
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <C4Window.h>
|
||||
#include <C4Config.h>
|
||||
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
|
||||
void CStdGLCtx::SelectCommon()
|
||||
{
|
||||
|
@ -565,4 +565,4 @@ bool CStdGLCtx::PageFlip()
|
|||
|
||||
#endif //USE_X11/USE_SDL_MAINLOOP
|
||||
|
||||
#endif // USE_GL
|
||||
#endif // USE_CONSOLE
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "StdMesh.h"
|
||||
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -1038,4 +1038,4 @@ void CStdGL::PerformMesh(StdMeshInstance &instance, float tx, float ty, float tw
|
|||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
#endif // USE_GL
|
||||
#endif // USE_CONSOLE
|
||||
|
|
|
@ -21,16 +21,6 @@
|
|||
#include <C4DrawT.h>
|
||||
#include <StdMeshMaterial.h>
|
||||
|
||||
CStdNoGfx::CStdNoGfx()
|
||||
{
|
||||
Default();
|
||||
}
|
||||
|
||||
CStdNoGfx::~CStdNoGfx()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
bool CStdNoGfx::CreatePrimarySurfaces(bool Fullscreen, unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor)
|
||||
{
|
||||
Log("Graphics disabled.");
|
||||
|
|
|
@ -25,13 +25,9 @@
|
|||
|
||||
class CStdNoGfx : public C4Draw
|
||||
{
|
||||
public:
|
||||
CStdNoGfx();
|
||||
virtual ~CStdNoGfx();
|
||||
public:
|
||||
virtual bool BeginScene() { return true; }
|
||||
virtual void EndScene() { }
|
||||
virtual int GetEngine() { return GFXENGN_NOGFX; }
|
||||
virtual void TaskOut() { }
|
||||
virtual void TaskIn() { }
|
||||
virtual bool UpdateClipper() { return true; }
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <C4Facet.h>
|
||||
#include <C4GraphicsResource.h>
|
||||
|
||||
#include <C4DrawD3D.h>
|
||||
#include <StdAdaptors.h>
|
||||
|
||||
#ifdef WITH_GLIB
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <C4Window.h>
|
||||
#include <StdRegistry.h>
|
||||
#include <C4Draw.h>
|
||||
#include <C4DrawD3D.h>
|
||||
#include <Bitmap256.h>
|
||||
#include <StdPNG.h>
|
||||
#include <C4Config.h>
|
||||
|
@ -68,9 +67,8 @@ C4Surface::C4Surface(C4AbstractApp * pApp, C4Window * pWindow):
|
|||
fPrimary=true;
|
||||
this->pWindow=pWindow;
|
||||
// create rendering context
|
||||
#ifdef USE_GL
|
||||
if (pGL)
|
||||
pCtx = pGL->CreateContext(pWindow, pApp);
|
||||
#ifndef USE_CONSOLE
|
||||
pCtx = pGL->CreateContext(pWindow, pApp);
|
||||
#endif
|
||||
// reset clipping
|
||||
NoClip();
|
||||
|
@ -93,12 +91,9 @@ void C4Surface::Default()
|
|||
Locked=0;
|
||||
Attached=false;
|
||||
fPrimary=false;
|
||||
#ifdef USE_DIRECTX
|
||||
pSfc=NULL;
|
||||
#endif
|
||||
ppTex=NULL;
|
||||
pMainSfc=NULL;
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
pCtx=NULL;
|
||||
#endif
|
||||
pWindow=NULL;
|
||||
|
@ -136,11 +131,7 @@ void C4Surface::MoveFrom(C4Surface *psfcFrom)
|
|||
iTexSize=psfcFrom->iTexSize;
|
||||
iTexX=psfcFrom->iTexX; iTexY=psfcFrom->iTexY;
|
||||
byBytesPP=psfcFrom->byBytesPP;
|
||||
#ifdef USE_DIRECTX
|
||||
dwClrFormat=psfcFrom->dwClrFormat;
|
||||
pSfc=psfcFrom->pSfc;
|
||||
#endif
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
Format=psfcFrom->Format;
|
||||
#endif
|
||||
fIsBackground = psfcFrom->fIsBackground;
|
||||
|
@ -153,14 +144,7 @@ void C4Surface::Clear()
|
|||
// Undo all locks
|
||||
while (Locked) Unlock();
|
||||
// release surface
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
{
|
||||
if (pSfc) pSfc->Release();
|
||||
}
|
||||
pSfc=NULL;
|
||||
#endif
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
if (pCtx)
|
||||
{
|
||||
delete pCtx;
|
||||
|
@ -178,14 +162,7 @@ void C4Surface::Clear()
|
|||
bool C4Surface::IsRenderTarget()
|
||||
{
|
||||
// primary is always OK...
|
||||
return fPrimary
|
||||
// other surfaces may be used as render targets, if offscreen rendertargets are not disabled by config,
|
||||
// or the surface is split (large sfcs) or locked (landscape)
|
||||
// (only D3D for now)
|
||||
#ifdef USE_DIRECTX
|
||||
|| (!Locked && !Config.Graphics.NoOffscreenBlits && pD3D && fIsRenderTarget)
|
||||
#endif
|
||||
;
|
||||
return fPrimary;
|
||||
}
|
||||
|
||||
void C4Surface::NoClip()
|
||||
|
@ -210,17 +187,9 @@ bool C4Surface::Create(int iWdt, int iHgt, bool, bool fIsRenderTarget, int MaxTe
|
|||
if (!pDraw->DeviceReady()) return false;
|
||||
|
||||
// store color format that will be used
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
dwClrFormat=pD3D->dwSurfaceType;
|
||||
else
|
||||
#ifndef USE_CONSOLE
|
||||
Format=pGL->sfcFmt;
|
||||
#endif
|
||||
#ifdef USE_GL
|
||||
if (pGL)
|
||||
Format=pGL->sfcFmt;
|
||||
else
|
||||
#endif
|
||||
{/* nothing to do */}
|
||||
byBytesPP=pDraw->byByteCnt;
|
||||
this->fIsRenderTarget = fIsRenderTarget;
|
||||
// create textures
|
||||
|
@ -252,7 +221,7 @@ namespace
|
|||
{
|
||||
int iNeedSize = Size;
|
||||
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
if (!pGL || !GLEW_ARB_texture_non_power_of_two)
|
||||
#endif
|
||||
{
|
||||
|
@ -295,14 +264,6 @@ bool C4Surface::CreateTextures(int MaxTextureSize)
|
|||
|
||||
if (fIsBackground && ppCTex) (*ppCTex)->FillBlack();
|
||||
|
||||
#ifdef USE_DIRECTX
|
||||
if (!(*ppCTex)->pTex && pD3D)
|
||||
{
|
||||
// error creating texture
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
++ppCTex;
|
||||
}
|
||||
}
|
||||
|
@ -316,7 +277,7 @@ bool C4Surface::CreateTextures(int MaxTextureSize)
|
|||
{
|
||||
// last texture might be smaller
|
||||
iNeedSize=Max(Wdt%iTexSize, Hgt%iTexSize);
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
if (!pGL || !GLEW_ARB_texture_non_power_of_two)
|
||||
#endif
|
||||
{
|
||||
|
@ -327,13 +288,6 @@ bool C4Surface::CreateTextures(int MaxTextureSize)
|
|||
*ppCTex = new C4TexRef(iNeedSize, fIsRenderTarget);
|
||||
}
|
||||
if (fIsBackground && ppCTex) (*ppCTex)->FillBlack();
|
||||
#ifdef USE_DIRECTX
|
||||
if (!(*ppCTex)->pTex && pD3D)
|
||||
{
|
||||
// error creating texture
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -480,32 +434,6 @@ bool C4Surface::SetAsClrByOwnerOf(C4Surface *pOfSurface)
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifdef USE_GL
|
||||
/*bool C4Surface::CreatePrimaryGLTextures()
|
||||
{
|
||||
if (!pGL) return false;
|
||||
// primary OpenGL-surface: ensure context is selected
|
||||
if (!pGL->pCurrCtx) if (!pGL->MainCtx.Select()) return false;
|
||||
// create texture array
|
||||
CreateTextures();
|
||||
// get from framebuffer
|
||||
C4TexRef **ppTexRef = ppTex;
|
||||
for (int iY=0; iY<Hgt; iY+=iTexSize)
|
||||
for (int iX=0; iX<Wdt; iX+=iTexSize)
|
||||
{
|
||||
// get tex size
|
||||
int txWdt=Min(Wdt-iX, iTexSize), txHgt=Min(Hgt-iY, iTexSize);
|
||||
// copy surface into texture
|
||||
glBindTexture(GL_TEXTURE_2D, (*ppTexRef)->texName);
|
||||
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, iX, iY, txWdt, txHgt, 0);
|
||||
// next texture reference
|
||||
++ppTexRef;
|
||||
}
|
||||
// done, success
|
||||
return true;
|
||||
}*/
|
||||
#endif
|
||||
|
||||
bool C4Surface::UpdateSize(int wdt, int hgt)
|
||||
{
|
||||
assert(fPrimary);
|
||||
|
@ -522,39 +450,12 @@ bool C4Surface::PageFlip(C4Rect *pSrcRt, C4Rect *pDstRt)
|
|||
return false;
|
||||
// call from gfx thread only!
|
||||
if (!pDraw->pApp || !pDraw->pApp->AssertMainThread()) return false;
|
||||
#ifdef USE_GL
|
||||
if (pGL)
|
||||
return pCtx->PageFlip();
|
||||
#endif
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
return pD3D->PageFlip(pSrcRt, pDstRt);
|
||||
#ifndef USE_CONSOLE
|
||||
return pCtx->PageFlip();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef USE_DIRECTX
|
||||
IDirect3DSurface9 *C4Surface::GetSurface()
|
||||
{
|
||||
// direct surface?
|
||||
if (pSfc)
|
||||
{
|
||||
pSfc->AddRef();
|
||||
return pSfc;
|
||||
}
|
||||
// surface by texture?
|
||||
if (fIsRenderTarget && ppTex)
|
||||
{
|
||||
IDirect3DTexture9 *pTex = (*ppTex)->pTex;
|
||||
IDirect3DSurface9 *pSfcResult=NULL;
|
||||
if (pTex) pTex->GetSurfaceLevel(0, &pSfcResult);
|
||||
return pSfcResult;
|
||||
}
|
||||
// split surfaces: Won't work; we're no render target anyway
|
||||
return NULL;
|
||||
}
|
||||
#endif //USE_DIRECTX
|
||||
|
||||
bool C4Surface::ReadBMP(CStdStream &hGroup)
|
||||
{
|
||||
int lcnt;
|
||||
|
@ -693,8 +594,8 @@ bool C4Surface::SavePNG(const char *szFilename, bool fSaveAlpha, bool fApplyGamm
|
|||
C4Surface *pMainSfcBackup = NULL;
|
||||
if (fSaveOverlayOnly) { pMainSfcBackup=pMainSfc; pMainSfc=NULL; }
|
||||
|
||||
#ifdef USE_GL
|
||||
if (fPrimary && pGL)
|
||||
#ifndef USE_CONSOLE
|
||||
if (fPrimary)
|
||||
{
|
||||
// Take shortcut. FIXME: Check Endian
|
||||
for (int y = 0; y < Hgt; ++y)
|
||||
|
@ -750,37 +651,9 @@ bool C4Surface::Lock()
|
|||
{
|
||||
// lock main sfc
|
||||
if (pMainSfc) if (!pMainSfc->Lock()) return false;
|
||||
// not yet locked?
|
||||
if (!Locked)
|
||||
{
|
||||
if (fPrimary)
|
||||
{
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
{
|
||||
D3DLOCKED_RECT lock;
|
||||
// locking primary
|
||||
if (!pSfc) return false;
|
||||
// lock it
|
||||
if (pSfc->LockRect(&lock, NULL, 0) != D3D_OK)
|
||||
return false;
|
||||
pDraw->LockingPrimary();
|
||||
// store pitch and pointer
|
||||
PrimarySurfaceLockPitch=lock.Pitch;
|
||||
PrimarySurfaceLockBits=(BYTE*) lock.pBits;
|
||||
}
|
||||
#endif //USE_DIRECTX
|
||||
|
||||
// OpenGL:
|
||||
// cannot really lock primary surface, but Get/SetPix will emulate it
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ppTex) return false;
|
||||
// lock texture
|
||||
// textures will be locked when needed
|
||||
}
|
||||
}
|
||||
// lock texture
|
||||
if (!Locked && !fPrimary && !ppTex)
|
||||
return false;
|
||||
// count lock
|
||||
Locked++; return true;
|
||||
}
|
||||
|
@ -791,32 +664,18 @@ bool C4Surface::Unlock()
|
|||
if (pMainSfc) pMainSfc->Unlock();
|
||||
// locked?
|
||||
if (!Locked) return false;
|
||||
// decrease lock counter; check if zeroed
|
||||
// decrease lock counter; check if zeroed and unlock then
|
||||
Locked--;
|
||||
if (!Locked)
|
||||
{
|
||||
// zeroed: unlock
|
||||
if (fPrimary)
|
||||
{
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
{
|
||||
if (!pSfc) return false;
|
||||
// unlocking primary?
|
||||
if (pSfc->UnlockRect() != D3D_OK)
|
||||
return false;
|
||||
pDraw->PrimaryUnlocked();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// if tex refs exist, free them
|
||||
/*FreeTextures();*/
|
||||
// otherwise, emulated primary locks in OpenGL
|
||||
delete[] PrimarySurfaceLockBits;
|
||||
PrimarySurfaceLockBits = 0;
|
||||
return true;
|
||||
}
|
||||
// if tex refs exist, free them
|
||||
/*FreeTextures();*/
|
||||
// otherwise, emulated primary locks in OpenGL
|
||||
delete[] PrimarySurfaceLockBits;
|
||||
PrimarySurfaceLockBits = 0;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -875,17 +734,14 @@ DWORD C4Surface::GetPixDw(int iX, int iY, bool fApplyModulation)
|
|||
// primary?
|
||||
if (fPrimary)
|
||||
{
|
||||
#ifdef USE_GL
|
||||
// OpenGL?
|
||||
if (pGL)
|
||||
#ifndef USE_CONSOLE
|
||||
if (!PrimarySurfaceLockBits)
|
||||
{
|
||||
if (!PrimarySurfaceLockBits)
|
||||
{
|
||||
PrimarySurfaceLockBits = new unsigned char[Wdt*Hgt*3 + 1];
|
||||
glReadPixels( 0, 0, Wdt, Hgt, GL_BGR, GL_UNSIGNED_BYTE, PrimarySurfaceLockBits);
|
||||
PrimarySurfaceLockPitch = Wdt*3;
|
||||
}
|
||||
return * (DWORD *) (PrimarySurfaceLockBits+(Hgt-iY-1)*PrimarySurfaceLockPitch+iX*3);
|
||||
PrimarySurfaceLockBits = new unsigned char[Wdt*Hgt*3 + 1];
|
||||
glReadPixels( 0, 0, Wdt, Hgt, GL_BGR, GL_UNSIGNED_BYTE, PrimarySurfaceLockBits);
|
||||
PrimarySurfaceLockPitch = Wdt*3;
|
||||
}
|
||||
return * (DWORD *) (PrimarySurfaceLockBits+(Hgt-iY-1)*PrimarySurfaceLockPitch+iX*3);
|
||||
|
||||
// copy content into textures
|
||||
/*if (!ppTex) if (!CreatePrimaryGLTextures()) return 0;
|
||||
|
@ -897,42 +753,6 @@ DWORD C4Surface::GetPixDw(int iX, int iY, bool fApplyModulation)
|
|||
iPitch=pTexRef->texLock.Pitch;
|
||||
// get pixel
|
||||
return *(DWORD *)(pBuf+iY*iPitch+iX*4);*/
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_DIRECTX
|
||||
if (!PrimarySurfaceLockBits)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// clip
|
||||
if (iX<0 || iY<0 || iX>=Wdt || iY>=Hgt) return 0;
|
||||
// get pixel from primary surface
|
||||
WORD pix16;
|
||||
switch (dwClrFormat)
|
||||
{
|
||||
case D3DFMT_X1R5G5B5:
|
||||
// 16 bit 5-5-5
|
||||
pix16= * (WORD *) (((BYTE *) PrimarySurfaceLockBits)+iY*PrimarySurfaceLockPitch+iX*2);
|
||||
return ((pix16 & 0x001f) << 3)
|
||||
| ((pix16 & 0x03e0) << 6)
|
||||
| ((pix16 & 0x7c00) << 9);
|
||||
|
||||
case D3DFMT_R5G6B5:
|
||||
// 16 bit 5-6-5
|
||||
pix16= * (WORD *) (((BYTE *) PrimarySurfaceLockBits)+iY*PrimarySurfaceLockPitch+iX*2);
|
||||
return ((pix16 & 0x001f) << 3)
|
||||
| ((pix16 & 0x07e0) << 5)
|
||||
| ((pix16 & 0xf800) << 8);
|
||||
break;
|
||||
|
||||
case D3DFMT_X8R8G8B8:
|
||||
// 32 bit
|
||||
return * (DWORD *) (((BYTE *) PrimarySurfaceLockBits)+iY*PrimarySurfaceLockPitch+iX*4);
|
||||
default: assert(false); return 0; // should not happen
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
@ -1018,46 +838,11 @@ bool C4Surface::IsPixTransparent(int iX, int iY)
|
|||
if ((iX<ClipX) || (iX>ClipX2) || (iY<ClipY) || (iY>ClipY2)) return true;
|
||||
// primary?
|
||||
if (fPrimary)
|
||||
{
|
||||
#ifdef USE_GL
|
||||
// OpenGL: Use OpenGL API
|
||||
if (pGL)
|
||||
{
|
||||
#ifndef USE_CONSOLE
|
||||
pGL->DrawPixInt(this, iX, iY, dwClr);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef USE_DIRECTX
|
||||
// must be locked!
|
||||
if (!Bits) return false;
|
||||
// set according to pixel format
|
||||
DWORD *pPix32; WORD *pPix16;
|
||||
switch (dwClrFormat)
|
||||
{
|
||||
case D3DFMT_X1R5G5B5:
|
||||
// 16 bit 5-5-5
|
||||
pPix16=(WORD *) (((BYTE *) Bits)+iY*Pitch+iX*2);
|
||||
*pPix16=WORD((dwClr & 0x000000f8) >> 3)
|
||||
| WORD((dwClr & 0x0000f800) >> 6)
|
||||
| WORD((dwClr & 0x00f80000) >> 9);
|
||||
break;
|
||||
|
||||
case D3DFMT_R5G6B5:
|
||||
// 16 bit 5-6-5
|
||||
pPix16=(WORD *) (((BYTE *) Bits)+iY*Pitch+iX*2);
|
||||
*pPix16=WORD((dwClr & 0x000000f8) >> 3)
|
||||
| WORD((dwClr & 0x0000fc00) >> 5)
|
||||
| WORD((dwClr & 0x00f80000) >> 8);
|
||||
break;
|
||||
|
||||
case D3DFMT_X8R8G8B8:
|
||||
// 32 bit
|
||||
pPix32=(DWORD *) (((BYTE *) Bits)+iY*Pitch+iX*4);
|
||||
*pPix32=dwClr;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1077,11 +862,11 @@ bool C4Surface::SetPixDw(int iX, int iY, DWORD dwClr)
|
|||
// if color is fully transparent, ensure it's black
|
||||
if (dwClr>>24 == 0x00) dwClr=0x00000000;
|
||||
C4TexRef *pTexRef;
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
// openGL: use glTexSubImage2D
|
||||
// This optimization was moved to LockForUpdate, as it only slows down mass updates here
|
||||
// Keep this code in case there is a need for fast single pixel updates again
|
||||
if (0 && pGL && pGL->pCurrCtx)
|
||||
if (0 && pGL->pCurrCtx)
|
||||
{
|
||||
if (!GetTexAt(&pTexRef, iX, iY))
|
||||
return false;
|
||||
|
@ -1284,10 +1069,7 @@ bool C4Surface::CopyBytes(BYTE *pImageData)
|
|||
C4TexRef::C4TexRef(int iSizeX, int iSizeY, bool fSingle)
|
||||
{
|
||||
// zero fields
|
||||
#ifdef USE_DIRECTX
|
||||
pTex=NULL;
|
||||
#endif
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
texName=0;
|
||||
#endif
|
||||
texLock.pBits=NULL; fIntLock=false;
|
||||
|
@ -1301,63 +1083,32 @@ C4TexRef::C4TexRef(int iSizeX, int iSizeY, bool fSingle)
|
|||
if (!pDraw) return;
|
||||
if (!pDraw->DeviceReady()) return;
|
||||
// create it!
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
#ifndef USE_CONSOLE
|
||||
// OpenGL
|
||||
// create mem array for texture creation
|
||||
texLock.pBits = new unsigned char[iSizeX*iSizeY*pGL->byByteCnt];
|
||||
texLock.Pitch = iSizeX*pGL->byByteCnt;
|
||||
memset(texLock.pBits, 0x00, texLock.Pitch*iSizeY);
|
||||
// turn mem array into texture
|
||||
Unlock();
|
||||
#endif
|
||||
if (pDraw)
|
||||
{
|
||||
// Direct3D
|
||||
bool fRenderTarget = fSingle && !Config.Graphics.NoOffscreenBlits;
|
||||
if (pD3D->lpDevice->CreateTexture(iSizeX, iSizeY, 1, fRenderTarget ? D3DUSAGE_RENDERTARGET : 0, pD3D->dwSurfaceType, fRenderTarget ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED, &pTex, NULL) != D3D_OK)
|
||||
{
|
||||
pDraw->Error("Error creating surface");
|
||||
return;
|
||||
}
|
||||
// empty texture
|
||||
if (!Lock()) return;
|
||||
FillMemory(texLock.pBits, texLock.Pitch*iSizeY, 0x00);
|
||||
Unlock();
|
||||
texLock.pBits = new unsigned char[iSizeX*iSizeY*pDraw->byByteCnt];
|
||||
texLock.Pitch = iSizeX*pDraw->byByteCnt;
|
||||
memset(texLock.pBits, 0x00, texLock.Pitch*iSizeY);
|
||||
// Always locked
|
||||
LockSize.x = LockSize.y = 0;
|
||||
LockSize.Wdt = iSizeX; LockSize.Hgt = iSizeY;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef USE_GL
|
||||
if (pGL)
|
||||
{
|
||||
// OpenGL
|
||||
// create mem array for texture creation
|
||||
texLock.pBits = new unsigned char[iSizeX*iSizeY*pGL->byByteCnt];
|
||||
texLock.Pitch = iSizeX*pGL->byByteCnt;
|
||||
memset(texLock.pBits, 0x00, texLock.Pitch*iSizeY);
|
||||
// turn mem array into texture
|
||||
Unlock();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (pDraw)
|
||||
{
|
||||
texLock.pBits = new unsigned char[iSizeX*iSizeY*pDraw->byByteCnt];
|
||||
texLock.Pitch = iSizeX*pDraw->byByteCnt;
|
||||
memset(texLock.pBits, 0x00, texLock.Pitch*iSizeY);
|
||||
// Always locked
|
||||
LockSize.x = LockSize.y = 0;
|
||||
LockSize.Wdt = iSizeX; LockSize.Hgt = iSizeY;
|
||||
}
|
||||
}
|
||||
|
||||
C4TexRef::~C4TexRef()
|
||||
{
|
||||
fIntLock=false;
|
||||
// free texture
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
{
|
||||
if (texLock.pBits) Unlock();
|
||||
if (pTex) pTex->Release();
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_GL
|
||||
if (pGL)
|
||||
{
|
||||
if (texName && pGL->pCurrCtx) glDeleteTextures(1, &texName);
|
||||
}
|
||||
#ifndef USE_CONSOLE
|
||||
if (texName && pGL && pGL->pCurrCtx) glDeleteTextures(1, &texName);
|
||||
#endif
|
||||
if (pDraw) delete [] static_cast<unsigned char*>(texLock.pBits); texLock.pBits = 0;
|
||||
// remove from texture manager
|
||||
|
@ -1381,36 +1132,15 @@ bool C4TexRef::LockForUpdate(C4Rect & rtUpdate)
|
|||
}
|
||||
}
|
||||
// lock
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
{
|
||||
RECT r;
|
||||
r.left = rtUpdate.x;
|
||||
r.top = rtUpdate.y;
|
||||
r.right = rtUpdate.x + rtUpdate.Wdt;
|
||||
r.bottom = rtUpdate.y + rtUpdate.Hgt;
|
||||
if (pTex)
|
||||
if (pTex->LockRect(0, &texLock, &r, D3DLOCK_DISCARD) == D3D_OK)
|
||||
{
|
||||
LockSize = rtUpdate;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef USE_GL
|
||||
if (pGL)
|
||||
#ifndef USE_CONSOLE
|
||||
if (texName)
|
||||
{
|
||||
if (texName)
|
||||
{
|
||||
// prepare texture data
|
||||
texLock.pBits = new unsigned char[rtUpdate.Wdt * rtUpdate.Hgt * pGL->byByteCnt];
|
||||
texLock.Pitch = rtUpdate.Wdt * pGL->byByteCnt;
|
||||
LockSize = rtUpdate;
|
||||
return true;
|
||||
}
|
||||
// prepare texture data
|
||||
texLock.pBits = new unsigned char[rtUpdate.Wdt * rtUpdate.Hgt * pGL->byByteCnt];
|
||||
texLock.Pitch = rtUpdate.Wdt * pGL->byByteCnt;
|
||||
LockSize = rtUpdate;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// nothing to do
|
||||
|
@ -1426,17 +1156,7 @@ bool C4TexRef::Lock()
|
|||
LockSize.Wdt = iSizeX; LockSize.Hgt = iSizeY;
|
||||
LockSize.x = LockSize.y = 0;
|
||||
// lock
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
{
|
||||
if (pTex)
|
||||
if (pTex->LockRect(0, &texLock, NULL, 0) == D3D_OK) return true;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef USE_GL
|
||||
if (pGL)
|
||||
{
|
||||
#ifndef USE_CONSOLE
|
||||
if (texName)
|
||||
{
|
||||
if (!pGL->pCurrCtx) return false;
|
||||
|
@ -1447,8 +1167,6 @@ bool C4TexRef::Lock()
|
|||
glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, pDraw->byByteCnt == 2 ? GL_UNSIGNED_SHORT_4_4_4_4_REV : GL_UNSIGNED_INT_8_8_8_8_REV, texLock.pBits);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// nothing to do
|
||||
|
@ -1461,18 +1179,7 @@ void C4TexRef::Unlock()
|
|||
{
|
||||
// locked?
|
||||
if (!texLock.pBits || fIntLock) return;
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
{
|
||||
// unlock
|
||||
if (pTex) pTex->UnlockRect(0);
|
||||
texLock.pBits=NULL;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef USE_GL
|
||||
if (pGL)
|
||||
{
|
||||
#ifndef USE_CONSOLE
|
||||
if (!pGL->pCurrCtx)
|
||||
{
|
||||
// BREAKPOINT_HERE;
|
||||
|
@ -1502,12 +1209,7 @@ void C4TexRef::Unlock()
|
|||
}
|
||||
delete[] static_cast<unsigned char*>(texLock.pBits); texLock.pBits=NULL;
|
||||
// switch back to original context
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
|
||||
bool C4TexRef::ClearRect(C4Rect &rtClear)
|
||||
|
@ -1602,7 +1304,7 @@ void C4TexMgr::IntLock()
|
|||
if (pRef->Lock() && pRef->texLock.pBits)
|
||||
{
|
||||
pRef->fIntLock = true;
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
// Release the underlying texture with GL and recreate
|
||||
// it on unlock, so that the texture survives
|
||||
// context recreation.
|
||||
|
|
|
@ -29,14 +29,9 @@
|
|||
#ifdef _WIN32
|
||||
#include <C4windowswrapper.h>
|
||||
#endif
|
||||
#ifdef USE_DIRECTX
|
||||
#include <d3d9.h>
|
||||
#undef DrawText
|
||||
#else
|
||||
typedef void* IDirect3DSurface9;
|
||||
#endif
|
||||
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
|
||||
|
@ -61,12 +56,7 @@ typedef void* IDirect3DSurface9;
|
|||
|
||||
const int ALeft=0,ACenter=1,ARight=2;
|
||||
|
||||
#ifdef USE_DIRECTX
|
||||
class CStdD3D;
|
||||
extern CStdD3D *pD3D;
|
||||
#endif
|
||||
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
class CStdGL;
|
||||
class CStdGLCtx;
|
||||
extern CStdGL *pGL;
|
||||
|
@ -95,29 +85,9 @@ public:
|
|||
#ifdef _DEBUG
|
||||
int *dbg_idx;
|
||||
#endif
|
||||
#if defined(USE_DIRECTX) && defined(USE_GL)
|
||||
union
|
||||
{
|
||||
struct // D3D values
|
||||
{
|
||||
#endif
|
||||
#ifdef USE_DIRECTX
|
||||
IDirect3DSurface9 *pSfc; // surface (primary sfc)
|
||||
D3DFORMAT dwClrFormat; // used color format in textures
|
||||
#endif
|
||||
#if defined(USE_DIRECTX) && defined(USE_GL)
|
||||
|
||||
};
|
||||
struct // OpenGL values
|
||||
{
|
||||
#endif
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
GLenum Format; // used color format in textures
|
||||
CStdGLCtx * pCtx;
|
||||
#endif
|
||||
#if defined(USE_DIRECTX) && defined(USE_GL)
|
||||
};
|
||||
};
|
||||
#endif
|
||||
C4TexRef **ppTex; // textures
|
||||
BYTE byBytesPP; // bytes per pixel (2 or 4)
|
||||
|
@ -152,7 +122,7 @@ public:
|
|||
bool Copy(C4Surface &fromSfc);
|
||||
bool CreateColorByOwner(C4Surface *pBySurface); // create ColorByOwner-surface
|
||||
bool SetAsClrByOwnerOf(C4Surface *pOfSurface); // assume that ColorByOwner-surface has been created, and just assign it; fails if the size doesn't match
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
bool CreatePrimaryGLTextures(); // create primary textures from back buffer
|
||||
#endif
|
||||
// Only for surfaces which map to a window
|
||||
|
@ -177,9 +147,6 @@ public:
|
|||
bool ReadBMP(CStdStream &hGroup);
|
||||
|
||||
bool AttachPalette();
|
||||
#ifdef USE_DIRECTX
|
||||
IDirect3DSurface9 *GetSurface(); // get internal surface
|
||||
#endif
|
||||
bool GetSurfaceSize(int &irX, int &irY); // get surface size
|
||||
void SetClr(DWORD toClr) { ClrByOwnerClr=toClr; }
|
||||
DWORD GetClr() { return ClrByOwnerClr; }
|
||||
|
@ -197,39 +164,19 @@ protected:
|
|||
friend class CStdGL;
|
||||
};
|
||||
|
||||
#ifndef USE_DIRECTX
|
||||
typedef struct _D3DLOCKED_RECT
|
||||
{
|
||||
int Pitch;
|
||||
unsigned char * pBits;
|
||||
} D3DLOCKED_RECT;
|
||||
#endif
|
||||
|
||||
// one texture encapsulation
|
||||
class C4TexRef
|
||||
{
|
||||
public:
|
||||
D3DLOCKED_RECT texLock; // current lock-data
|
||||
#if defined(USE_DIRECTX) && defined(USE_GL)
|
||||
union
|
||||
{
|
||||
struct // D3D
|
||||
{
|
||||
#endif
|
||||
#ifdef USE_DIRECTX
|
||||
IDirect3DTexture9 *pTex; // texture
|
||||
#endif
|
||||
#if defined(USE_DIRECTX) && defined(USE_GL)
|
||||
};
|
||||
struct // OpenGL
|
||||
{
|
||||
#endif
|
||||
#ifdef USE_GL
|
||||
GLuint texName;
|
||||
#endif
|
||||
#if defined(USE_DIRECTX) && defined(USE_GL)
|
||||
};
|
||||
};
|
||||
#ifndef USE_CONSOLE
|
||||
GLuint texName;
|
||||
#endif
|
||||
int iSizeX;
|
||||
int iSizeY;
|
||||
|
|
|
@ -225,7 +225,7 @@ namespace C4GUI
|
|||
{
|
||||
pSurface->Wdt = r.Wdt;
|
||||
pSurface->Hgt = r.Hgt;
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
pGL->PrepareRendering(pSurface);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
#endif
|
||||
|
|
|
@ -792,32 +792,6 @@ C4StartupOptionsDlg::C4StartupOptionsDlg() : C4StartupDlg(LoadResStrNoAmp("IDS_D
|
|||
|
||||
// --- page graphics
|
||||
C4GUI::ComponentAligner caSheetGraphics(pSheetGraphics->GetClientRect(), iIndentX1, iIndentY1, true);
|
||||
// --subgroup engine
|
||||
C4GUI::GroupBox *pGroupEngine = new C4GUI::GroupBox(caSheetGraphics.GetGridCell(0,2,0,3));
|
||||
pGroupEngine->SetTitle(LoadResStrNoAmp("IDS_CTL_GFXENGINE"));
|
||||
pGroupEngine->SetFont(pUseFont);
|
||||
pGroupEngine->SetColors(C4StartupEditBorderColor, C4StartupFontClr);
|
||||
pGroupEngine->SetToolTip(LoadResStr("IDS_MSG_GFXENGINE_DESC"));
|
||||
pSheetGraphics->AddElement(pGroupEngine);
|
||||
C4GUI::ComponentAligner caGroupEngine(pGroupEngine->GetClientRect(), iIndentX1, iIndentY2, true);
|
||||
const char *szGfxEngineNames[3] = { "DirectX", "OpenGL", "DirectX Software" };
|
||||
C4GUI::BaseCallbackHandler *pGfxEngineCheckCB = new C4GUI::CallbackHandler<C4StartupOptionsDlg>(this, &C4StartupOptionsDlg::OnGfxEngineCheck);
|
||||
for (int32_t iGfxEngine = 0; iGfxEngine<3; ++iGfxEngine)
|
||||
{
|
||||
pCheckGfxEngines[iGfxEngine] = new C4GUI::CheckBox(caGroupEngine.GetGridCell(0,1,iGfxEngine,3,-1,iCheckHgt,true), szGfxEngineNames[iGfxEngine], (Config.Graphics.Engine == iGfxEngine));
|
||||
pCheckGfxEngines[iGfxEngine]->SetFont(pUseFont, C4StartupFontClr, C4StartupFontClrDisabled);
|
||||
pCheckGfxEngines[iGfxEngine]->SetOnChecked(pGfxEngineCheckCB);
|
||||
pGroupEngine->AddElement(pCheckGfxEngines[iGfxEngine]);
|
||||
}
|
||||
#ifndef USE_DIRECTX
|
||||
pCheckGfxEngines[GFXENGN_DIRECTX]->SetEnabled(false);
|
||||
pCheckGfxEngines[GFXENGN_DIRECTXS]->SetEnabled(false);
|
||||
#endif
|
||||
#ifndef USE_GL
|
||||
pCheckGfxEngines[GFXENGN_OPENGL]->SetEnabled(false);
|
||||
#endif
|
||||
pCheckGfxEngines[GFXENGN_DIRECTX]->SetEnabled(false); // as long as DX doesnt work, its disabled
|
||||
pCheckGfxEngines[GFXENGN_DIRECTXS]->SetEnabled(false); // better not using this
|
||||
// --subgroup resolution
|
||||
C4GUI::GroupBox *pGroupResolution = new C4GUI::GroupBox(caSheetGraphics.GetGridCell(1,2,0,3));
|
||||
pGroupResolution->SetTitle(LoadResStrNoAmp("IDS_CTL_RESOLUTION"));
|
||||
|
@ -848,8 +822,8 @@ C4StartupOptionsDlg::C4StartupOptionsDlg() : C4StartupDlg(LoadResStrNoAmp("IDS_D
|
|||
C4GUI::BaseCallbackHandler *pGfxClrDepthCheckCB = new C4GUI::CallbackHandler<C4StartupOptionsDlg>(this, &C4StartupOptionsDlg::OnGfxClrDepthCheck);
|
||||
for (int32_t iBitDepthIdx = 0; iBitDepthIdx<2; ++iBitDepthIdx)
|
||||
{
|
||||
int iBitDepth = (iBitDepthIdx+1) * 16;
|
||||
pCheckGfxClrDepth[iBitDepthIdx] = new C4GUI::CheckBox(caGroupEngine.GetGridCell(iBitDepthIdx,2,2,4,-1,iCheckHgt,true), FormatString("%d Bit", (int)iBitDepth).getData(), (Config.Graphics.BitDepth == iBitDepth));
|
||||
int iBitDepth = (iBitDepthIdx+1) * 16; //WORKAROUND
|
||||
pCheckGfxClrDepth[iBitDepthIdx] = new C4GUI::CheckBox(caGroupResolution.GetGridCell(iBitDepthIdx,2,2,4,-1,iCheckHgt,true), FormatString("%d Bit", (int)iBitDepth).getData(), (Config.Graphics.BitDepth == iBitDepth));
|
||||
pCheckGfxClrDepth[iBitDepthIdx]->SetFont(pUseFont, C4StartupFontClr, C4StartupFontClrDisabled);
|
||||
pCheckGfxClrDepth[iBitDepthIdx]->SetOnChecked(pGfxClrDepthCheckCB);
|
||||
pCheckGfxClrDepth[iBitDepthIdx]->SetToolTip(LoadResStr("IDS_CTL_BITDEPTH"));
|
||||
|
@ -1093,28 +1067,6 @@ void C4StartupOptionsDlg::OnResetConfigBtn(C4GUI::Control *btn)
|
|||
Application.Quit();
|
||||
}
|
||||
|
||||
void C4StartupOptionsDlg::OnGfxEngineCheck(C4GUI::Element *pCheckBox)
|
||||
{
|
||||
C4GUI::CheckBox *pCheck = static_cast<C4GUI::CheckBox *>(pCheckBox);
|
||||
// radiogroup: do not allow unchecking!
|
||||
if (!pCheck->GetChecked())
|
||||
{
|
||||
pCheck->SetChecked(true);
|
||||
return;
|
||||
}
|
||||
// get new engine
|
||||
int i;
|
||||
for (i=0; i<3; ++i) if (pCheck == pCheckGfxEngines[i]) break;
|
||||
if (i==3 || i == Config.Graphics.Engine) return;
|
||||
// okay, engine change
|
||||
pCheckGfxEngines[Config.Graphics.Engine]->SetChecked(false);
|
||||
StdStrBuf sTitle; sTitle.Copy(LoadResStrNoAmp("IDS_CTL_GFXENGINE"));
|
||||
GetScreen()->ShowMessage(LoadResStr("IDS_MSG_RESTARTCHANGECFG"), sTitle.getData(), C4GUI::Ico_Notify, &Config.Startup.HideMsgGfxEngineChange);
|
||||
SaveGfxTroubleshoot();
|
||||
Config.Graphics.Engine = i;
|
||||
LoadGfxTroubleshoot();
|
||||
}
|
||||
|
||||
void C4StartupOptionsDlg::OnGfxMSComboFill(C4GUI::ComboBox_FillCB *pFiller)
|
||||
{
|
||||
// clear all old entries first to allow a clean refill
|
||||
|
@ -1137,38 +1089,22 @@ void C4StartupOptionsDlg::OnGfxMSComboFill(C4GUI::ComboBox_FillCB *pFiller)
|
|||
bool C4StartupOptionsDlg::OnGfxMSComboSelChange(C4GUI::ComboBox *pForCombo, int32_t idNewSelection)
|
||||
{
|
||||
if(pTexMgr) pTexMgr->IntLock();
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
pDraw->InvalidateDeviceObjects();
|
||||
// Note: This assumes there is only one GL context (the main context). This
|
||||
// is true in fullscreen mode, and since the startup dlg is only shown in
|
||||
// fullscreen mode we are safe this way.
|
||||
if(pGL) pGL->pMainCtx->Clear();
|
||||
#endif
|
||||
#ifdef USE_DIRECTX
|
||||
// It should also be possible to clear+reinit DDraw also for GL, however,
|
||||
// if ReInit() does _not_ create a new window on X11 then all rendering
|
||||
// stops until the Window is being moved again (or tasked-out and back in
|
||||
// in fullscreen mode). This does not happen when only reinitializing the
|
||||
// GL context instead of whole DDraw so that's why we do this currently.
|
||||
if(pD3D) pDraw->Clear();
|
||||
#endif
|
||||
|
||||
int32_t PrevMultiSampling = Config.Graphics.MultiSampling;
|
||||
Config.Graphics.MultiSampling = idNewSelection;
|
||||
bool success = Application.pWindow->ReInit(&Application);
|
||||
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
if(pGL) pGL->pMainCtx->Init(Application.pWindow, &Application);
|
||||
pDraw->RestoreDeviceObjects();
|
||||
#endif
|
||||
#ifdef USE_DIRECTX
|
||||
// Note: Editor is hardcoded to false at this point... I guess that's OK
|
||||
// because C4StartupOptionsDlg is never shown in editor mode anyway.
|
||||
if(pD3D) pDraw->Init(&Application, false, false, Config.Graphics.ResX, Config.Graphics.ResY, Config.Graphics.BitDepth, Config.Graphics.Monitor);
|
||||
#endif
|
||||
|
||||
if(pTexMgr) pTexMgr->IntUnlock();
|
||||
|
||||
if(!success) Config.Graphics.MultiSampling = PrevMultiSampling;
|
||||
return !success;
|
||||
}
|
||||
|
@ -1527,10 +1463,8 @@ void C4StartupOptionsDlg::SaveGfxTroubleshoot()
|
|||
{
|
||||
// get it from controls
|
||||
Config.Graphics.EnableShaders=pShaders->GetChecked();
|
||||
// get config set to be used
|
||||
bool fUseGL = (Config.Graphics.Engine == GFXENGN_OPENGL);
|
||||
// and apply them directly, if the engine is current
|
||||
if (fUseGL == pDraw->IsOpenGL())
|
||||
|
||||
if (pDraw->IsOpenGL())
|
||||
{
|
||||
pDraw->RestoreDeviceObjects();
|
||||
}
|
||||
|
|
|
@ -129,7 +129,6 @@ private:
|
|||
void OnWindowedModeComboFill(C4GUI::ComboBox_FillCB *pFiller);
|
||||
bool OnWindowedModeComboSelChange(C4GUI::ComboBox *pForCombo, int32_t idNewSelection);
|
||||
void OnGfxAllResolutionsChange(C4GUI::Element *pCheckBox);
|
||||
void OnGfxEngineCheck(C4GUI::Element *pCheckBox);
|
||||
void OnGfxTroubleCheck(C4GUI::Element *pCheckBox)
|
||||
{ SaveGfxTroubleshoot(); } // immediate save and test
|
||||
void OnGfxResComboFill(C4GUI::ComboBox_FillCB *pFiller);
|
||||
|
@ -142,7 +141,7 @@ private:
|
|||
const char * GetWindowedName(int32_t mode = -1);
|
||||
void OnEffectsSliderChange(int32_t iNewVal);
|
||||
|
||||
C4GUI::CheckBox *pCheckGfxEngines[3], *pCheckGfxClrDepth[2];
|
||||
C4GUI::CheckBox *pCheckGfxClrDepth[2];
|
||||
C4GUI::GroupBox *pGroupTrouble;
|
||||
C4GUI::CheckBox *pShaders;
|
||||
int32_t iGfxTexIndent;
|
||||
|
|
|
@ -1325,7 +1325,7 @@ bool C4Landscape::Init(C4Group &hGroup, bool fOverloadCurrent, bool fLoadSky, bo
|
|||
}
|
||||
|
||||
// Create renderer
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
if (!pLandscapeRender && ::Config.Graphics.HighResLandscape)
|
||||
pLandscapeRender = new C4LandscapeRenderGL();
|
||||
#endif
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "C4DrawGL.h"
|
||||
#include "StdColors.h"
|
||||
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
|
||||
// Automatically reload shaders when changed at runtime?
|
||||
#define AUTO_RELOAD_SHADERS
|
||||
|
|
|
@ -72,7 +72,7 @@ public:
|
|||
virtual void Draw(const C4TargetFacet &cgo) = 0;
|
||||
};
|
||||
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
class C4LandscapeRenderGL : public C4LandscapeRender
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -252,12 +252,6 @@ void C4PXSSystem::Draw(C4TargetFacet &cgo)
|
|||
C4Rect VisibleRect(cgo.TargetX, cgo.TargetY, cgo.Wdt, cgo.Hgt);
|
||||
VisibleRect.Enlarge(20);
|
||||
|
||||
// Lock primary surface
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
cgo.Surface->Lock();
|
||||
#endif
|
||||
|
||||
// First pass: draw simple PXS (lines/pixels)
|
||||
float cgox = cgo.X - cgo.TargetX, cgoy = cgo.Y - cgo.TargetY;
|
||||
unsigned int cnt;
|
||||
|
@ -289,12 +283,6 @@ void C4PXSSystem::Draw(C4TargetFacet &cgo)
|
|||
}
|
||||
}
|
||||
|
||||
// Unlock primary surface
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
cgo.Surface->Unlock();
|
||||
#endif
|
||||
|
||||
// PXS graphics disabled?
|
||||
if (!Config.Graphics.PXSGfx)
|
||||
return;
|
||||
|
|
|
@ -368,9 +368,7 @@ bool C4Network2::DoLobby()
|
|||
ChangeGameStatus(GS_Lobby, 0);
|
||||
|
||||
// determine lobby type
|
||||
bool fFullscreenLobby = !Console.Active && (pDraw->GetEngine() != GFXENGN_NOGFX);
|
||||
|
||||
if (!fFullscreenLobby)
|
||||
if (Console.Active)
|
||||
{
|
||||
// console lobby - update console
|
||||
if (Console.Active) Console.UpdateMenus();
|
||||
|
|
|
@ -97,8 +97,8 @@ public:
|
|||
bool SetVideoMode(unsigned int iXRes, unsigned int iYRes, unsigned int iColorDepth, unsigned int iRefreshRate, unsigned int iMonitor, bool fFullScreen);
|
||||
void RestoreVideoMode();
|
||||
// Gamma
|
||||
virtual bool ApplyGammaRamp(struct _D3DGAMMARAMP &ramp, bool fForce);
|
||||
virtual bool SaveDefaultGammaRamp(struct _D3DGAMMARAMP &ramp);
|
||||
virtual bool ApplyGammaRamp(struct _GAMMARAMP &ramp, bool fForce);
|
||||
virtual bool SaveDefaultGammaRamp(struct _GAMMARAMP &ramp);
|
||||
bool ScheduleProcs(int iTimeout = -1);
|
||||
bool FlushMessages();
|
||||
C4Window * pWindow;
|
||||
|
|
|
@ -93,8 +93,8 @@ bool C4AbstractApp::IsClipboardFull(bool fClipboard)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool C4AbstractApp::ApplyGammaRamp(_D3DGAMMARAMP&, bool) { return true; }
|
||||
bool C4AbstractApp::SaveDefaultGammaRamp(_D3DGAMMARAMP&) { return true; }
|
||||
bool C4AbstractApp::ApplyGammaRamp(_GAMMARAMP&, bool) { return true; }
|
||||
bool C4AbstractApp::SaveDefaultGammaRamp(_GAMMARAMP&) { return true; }
|
||||
void C4AbstractApp::MessageDialog(const char * message) {}
|
||||
|
||||
bool C4AbstractApp::FlushMessages()
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include <C4Config.h>
|
||||
#include <C4Console.h>
|
||||
#include <C4DrawGL.h>
|
||||
#include <C4DrawD3D.h>
|
||||
#include <C4FullScreen.h>
|
||||
#include <C4GraphicsSystem.h>
|
||||
#include <C4MouseControl.h>
|
||||
|
@ -114,7 +113,7 @@ LRESULT APIENTRY FullScreenWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||
// fall through to next case
|
||||
case WM_ACTIVATEAPP:
|
||||
Application.Active = wParam != 0;
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
if (pGL)
|
||||
{
|
||||
if (Application.Active)
|
||||
|
@ -139,12 +138,6 @@ LRESULT APIENTRY FullScreenWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D && Application.Active)
|
||||
pD3D->TaskIn();
|
||||
if (pD3D && !Application.Active)
|
||||
pD3D->TaskOut();
|
||||
#endif
|
||||
// redraw background
|
||||
::GraphicsSystem.InvalidateBg();
|
||||
|
@ -753,14 +746,10 @@ void C4Window::FlashWindow()
|
|||
|
||||
void C4Window::EnumerateMultiSamples(std::vector<int>& samples) const
|
||||
{
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
if(pGL && pGL->pMainCtx)
|
||||
samples = pGL->pMainCtx->EnumerateMultiSamples();
|
||||
#endif
|
||||
|
||||
#ifdef USE_DIRECTX
|
||||
// TODO: Enumerate multi samples
|
||||
#endif
|
||||
}
|
||||
|
||||
/* CStdMessageProc */
|
||||
|
@ -884,16 +873,7 @@ void C4AbstractApp::RestoreVideoMode()
|
|||
|
||||
bool C4AbstractApp::SetVideoMode(unsigned int iXRes, unsigned int iYRes, unsigned int iColorDepth, unsigned int iRefreshRate, unsigned int iMonitor, bool fFullScreen)
|
||||
{
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
{
|
||||
if (!pD3D->SetVideoMode(iXRes, iYRes, iColorDepth, iMonitor, fFullScreen))
|
||||
return false;
|
||||
OnResolutionChanged(iXRes, iYRes);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_GL
|
||||
#ifndef USE_CONSOLE
|
||||
SetWindowLong(pWindow->hWindow, GWL_EXSTYLE,
|
||||
GetWindowLong(pWindow->hWindow, GWL_EXSTYLE) | WS_EX_APPWINDOW);
|
||||
// change mode
|
||||
|
@ -995,14 +975,8 @@ bool C4AbstractApp::SetVideoMode(unsigned int iXRes, unsigned int iYRes, unsigne
|
|||
#endif
|
||||
}
|
||||
|
||||
bool C4AbstractApp::SaveDefaultGammaRamp(_D3DGAMMARAMP &ramp)
|
||||
bool C4AbstractApp::SaveDefaultGammaRamp(_GAMMARAMP &ramp)
|
||||
{
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
{
|
||||
return pD3D->SaveDefaultGammaRamp(ramp);
|
||||
}
|
||||
#endif
|
||||
HDC hDC = GetDC(pWindow->hWindow);
|
||||
if (hDC)
|
||||
{
|
||||
|
@ -1017,14 +991,8 @@ bool C4AbstractApp::SaveDefaultGammaRamp(_D3DGAMMARAMP &ramp)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool C4AbstractApp::ApplyGammaRamp(_D3DGAMMARAMP &ramp, bool fForce)
|
||||
bool C4AbstractApp::ApplyGammaRamp(_GAMMARAMP &ramp, bool fForce)
|
||||
{
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
{
|
||||
return pD3D->ApplyGammaRamp(ramp, fForce);
|
||||
}
|
||||
#endif
|
||||
if (!Active && !fForce) return false;
|
||||
HDC hDC = GetDC(pWindow->hWindow);
|
||||
if (hDC)
|
||||
|
|
Loading…
Reference in New Issue