Skip to content

Commit

Permalink
Remove remains of Direct3D support
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Tim Blume authored and isilkor committed Nov 2, 2013
1 parent 1204d7d commit 240193a
Show file tree
Hide file tree
Showing 33 changed files with 112 additions and 2,259 deletions.
31 changes: 1 addition & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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})
Expand Down
6 changes: 0 additions & 6 deletions config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 0 additions & 5 deletions src/config/C4Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ));
Expand Down Expand Up @@ -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)
{
Expand Down
1 change: 0 additions & 1 deletion src/config/C4Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ class C4ConfigGraphics
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
Expand Down
16 changes: 0 additions & 16 deletions src/editor/C4ConsoleWin32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -372,13 +369,11 @@ class C4ToolsDlg::State: public C4ConsoleGUI::InternalState<class C4ToolsDlg>
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;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1083,22 +1076,13 @@ 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())
//{
// 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;
}

Expand Down
3 changes: 1 addition & 2 deletions src/editor/C4ToolsDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/game/C4Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 6 additions & 14 deletions src/graphics/C4Draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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))
Expand Down
18 changes: 4 additions & 14 deletions src/graphics/C4Draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand All @@ -146,7 +138,7 @@ class C4GammaControl
void SetClrChannel(WORD *pBuf, BYTE c1, BYTE c2, int c3); // set color channel ramp

protected:
D3DGAMMARAMP ramp;
GAMMARAMP ramp;

public:
C4GammaControl() { Default(); } // ctor
Expand Down Expand Up @@ -212,7 +204,6 @@ class C4Draw
#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; }
Expand Down Expand Up @@ -325,7 +316,6 @@ class C4Draw
friend class C4Surface;
friend class C4TexRef;
friend class C4Pattern;
friend class CStdD3DShader;
};

struct ZoomDataStackItem: public ZoomData
Expand All @@ -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
Loading

0 comments on commit 240193a

Please sign in to comment.