diff --git a/Runtime/gfx/CMakeLists.txt b/Runtime/gfx/CMakeLists.txt index 67caeb8..c5e7d71 100644 --- a/Runtime/gfx/CMakeLists.txt +++ b/Runtime/gfx/CMakeLists.txt @@ -40,18 +40,17 @@ add_library(${PROJECT_NAME} STATIC "gxsound.cpp" "gxtimer.hpp" "gxtimer.cpp" - "std.hpp" - "std.cpp" ) target_link_libraries(${PROJECT_NAME} - PRIVATE - stdutil - PUBLIC - shell32 - winmm - ${fmod_LIBRARIES} - ${FreeImage_LIBRARIES} + stdutil + shell32 + winmm + ${fmod_LIBRARIES} + ${FreeImage_LIBRARIES} + ddraw + dxguid + dinput8 ) target_include_directories(${PROJECT_NAME} diff --git a/Runtime/gfx/asmcoder.cpp b/Runtime/gfx/asmcoder.cpp index dba8ea9..ba28759 100644 --- a/Runtime/gfx/asmcoder.cpp +++ b/Runtime/gfx/asmcoder.cpp @@ -4,14 +4,11 @@ // testroutine for asmcoder class // see asmcoder.h for readme -#define WIN32_LEAN_AND_MEAN -#include - +#include "asmcoder.hpp" +#include #include #include -#include "asmcoder.hpp" - void(__fastcall* plot)(void* s, int argb); int(__fastcall* point)(void* s); void(__fastcall* span)(void* s, int* argb, int n); @@ -63,8 +60,6 @@ void main() return; } -// void (__fastcall *plot)(int x,int y,int argb,Surface *s)=(void (__fastcall *)(int,int,int,Surface*))code; - void ortest() { __asm { diff --git a/Runtime/gfx/asmcoder.hpp b/Runtime/gfx/asmcoder.hpp index e987b1a..8321cf8 100644 --- a/Runtime/gfx/asmcoder.hpp +++ b/Runtime/gfx/asmcoder.hpp @@ -43,8 +43,7 @@ ToDo: */ -#ifndef ASMCODER_H -#define ASMCODER_H +#pragma once class IA32 { public: @@ -524,5 +523,3 @@ class AsmCoder : IA32 { return off; } }; - -#endif diff --git a/Runtime/gfx/ddutil.cpp b/Runtime/gfx/ddutil.cpp index 75ac9cd..8107bbd 100644 --- a/Runtime/gfx/ddutil.cpp +++ b/Runtime/gfx/ddutil.cpp @@ -1,12 +1,11 @@ - #include "ddutil.hpp" -#include "GraphicsRuntime.hpp" +#include "graphicsruntime.hpp" #include "asmcoder.hpp" #include "gxcanvas.hpp" #include "gxruntime.hpp" -#include "std.hpp" +#include "gxgraphics.hpp" -#define FREEIMAGE_LIB +//#define FREEIMAGE_LIB #include extern gxRuntime* gx_runtime; @@ -100,7 +99,7 @@ static void adjustTexSize(int* width, int* height, IDirect3DDevice7* dir3dDev, b } //check aspect ratio - if (max = ddDesc.dwMaxTextureAspectRatio) { + if ((max = ddDesc.dwMaxTextureAspectRatio) && max > 0) { int asp = w > h ? w / h : h / w; if (asp > max) { if (w > h) @@ -267,33 +266,33 @@ void ddUtil::buildMipMaps(IDirectDrawSurface7* surf) } } -void ddUtil::copy(IDirectDrawSurface7* dest, int dx, int dy, int dw, int dh, IDirectDrawSurface7* src, int sx, int sy, - int sw, int sh) +void ddUtil::copy(IDirectDrawSurface7* dst_surface, int dx, int dy, int dw, int dh, IDirectDrawSurface7* src_surface, + int sx, int sy, int sw, int sh) { DDSURFACEDESC2 src_desc = {sizeof(src_desc)}; - src->Lock(0, &src_desc, DDLOCK_WAIT, 0); - PixelFormat src_fmt(src_desc.ddpfPixelFormat); - unsigned char* src_p = (unsigned char*)src_desc.lpSurface; - src_p += src_desc.lPitch * sy + src_fmt.getPitch() * sx; + src_surface->Lock(0, &src_desc, DDLOCK_WAIT, 0); + PixelFormat src_format(src_desc.ddpfPixelFormat); + unsigned char* src_memory = (unsigned char*)src_desc.lpSurface; + src_memory += src_desc.lPitch * sy + src_format.getPitch() * sx; - DDSURFACEDESC2 dest_desc = {sizeof(dest_desc)}; - dest->Lock(0, &dest_desc, DDLOCK_WAIT, 0); - PixelFormat dest_fmt(dest_desc.ddpfPixelFormat); - unsigned char* dest_p = (unsigned char*)dest_desc.lpSurface; - dest_p += dest_desc.lPitch * dy + dest_fmt.getPitch() * dx; + DDSURFACEDESC2 dst_desc = {sizeof(dst_desc)}; + dst_surface->Lock(0, &dst_desc, DDLOCK_WAIT, 0); + PixelFormat dst_format(dst_desc.ddpfPixelFormat); + unsigned char* dst_memory = (unsigned char*)dst_desc.lpSurface; + dst_memory += dst_desc.lPitch * dy + dst_format.getPitch() * dx; for (int y = 0; y < dh; ++y) { - unsigned char* dest = dest_p; - unsigned char* src = src_p + src_desc.lPitch * (y * sh / dh); + unsigned char* dst = dst_memory; + unsigned char* src = src_memory + src_desc.lPitch * (y * sh / dh); for (int x = 0; x < dw; ++x) { - dest_fmt.setPixel(dest, src_fmt.getPixel(src + src_fmt.getPitch() * (x * sw / dw))); - dest += dest_fmt.getPitch(); + dst_format.setPixel(dst, src_format.getPixel(src + src_format.getPitch() * (x * sw / dw))); + dst += dst_format.getPitch(); } - dest_p += dest_desc.lPitch; + dst_memory += dst_desc.lPitch; } - src->Unlock(0); - dest->Unlock(0); + src_surface->Unlock(0); + dst_surface->Unlock(0); } IDirectDrawSurface7* ddUtil::createSurface(int w, int h, int flags, gxGraphics* gfx) @@ -524,7 +523,7 @@ IDirectDrawSurface7* loadDXTC(const char* filename, gxGraphics* gfx) IDirectDrawSurface7* ddUtil::loadSurface(const std::string& f, int flags, gxGraphics* gfx) { int i = f.find(".dds"); - if (i != string::npos && i + 4 == f.size()) { + if (i != std::string::npos && i + 4 == f.size()) { //dds file! IDirectDrawSurface7* surf = loadDXTC(f.c_str(), gfx); return surf; @@ -534,7 +533,7 @@ IDirectDrawSurface7* ddUtil::loadSurface(const std::string& f, int flags, gxGrap FREE_IMAGE_FORMAT fmt = FreeImage_GetFileType(f.c_str(), f.size()); if (fmt == FIF_UNKNOWN) { int n = f.find("."); - if (n == string::npos) + if (n == std::string::npos) return 0; fmt = FreeImage_GetFileType(f.c_str()); if (fmt == FIF_UNKNOWN) diff --git a/Runtime/gfx/ddutil.hpp b/Runtime/gfx/ddutil.hpp index cd3eabb..e587413 100644 --- a/Runtime/gfx/ddutil.hpp +++ b/Runtime/gfx/ddutil.hpp @@ -1,8 +1,6 @@ - -#ifndef DDUTIL_H -#define DDUTIL_H - -#include "GraphicsRuntime.hpp" +#pragma once +#include +#include "graphicsruntime.hpp" class gxGraphics; @@ -64,5 +62,3 @@ class PixelFormat { return point(p); } }; - -#endif \ No newline at end of file diff --git a/Runtime/gfx/graphicsruntime.hpp b/Runtime/gfx/graphicsruntime.hpp index 7a9355f..6284021 100644 --- a/Runtime/gfx/graphicsruntime.hpp +++ b/Runtime/gfx/graphicsruntime.hpp @@ -1,5 +1,5 @@ #pragma once -#include +#include // Direct Draw #define DIRECTDRAW_VERSION 0x0700 diff --git a/Runtime/gfx/gxaudio.cpp b/Runtime/gfx/gxaudio.cpp index 1c13b8c..07da1b0 100644 --- a/Runtime/gfx/gxaudio.cpp +++ b/Runtime/gfx/gxaudio.cpp @@ -1,7 +1,15 @@ - #include "gxaudio.hpp" +#include "gxchannel.hpp" +#include "gxsound.hpp" +#include +#include +#include + +#include + +extern "C" { #include -#include "std.hpp" +} struct StaticChannel : public gxChannel { virtual void play() = 0; @@ -162,13 +170,13 @@ struct MusicChannel : public StaticChannel { FMUSIC_MODULE* module; }; -static set sound_set; -static vector channels; -static map songs; +static std::set sound_set; +static std::vector channels; +static std::map songs; static CDChannel* cdChannel; static int next_chan; -static vector soundChannels; +static std::vector soundChannels; static gxChannel* allocSoundChannel(int n) { @@ -245,7 +253,7 @@ void gxAudio::pause() {} void gxAudio::resume() {} -gxSound* gxAudio::loadSound(const string& f, bool use3d) +gxSound* gxAudio::loadSound(const std::string& f, bool use3d) { int flags = FSOUND_NORMAL | (use3d ? FSOUND_FORCEMONO : FSOUND_2D); @@ -289,18 +297,19 @@ void gxAudio::set3dListener(const float pos[3], const float vel[3], const float FSOUND_Update(); } -gxChannel* gxAudio::playFile(const string& t, bool use_3d) +gxChannel* gxAudio::playFile(const std::string& t, bool use_3d) { - string f = tolower(t); + std::string f = tolower(t); StaticChannel* chan = 0; - map::iterator it = songs.find(f); + std::map::iterator it = songs.find(f); if (it != songs.end()) { chan = it->second; chan->play(); return chan; - } else if (f.find(".raw") != string::npos || f.find(".wav") != string::npos || f.find(".mp2") != string::npos - || f.find(".mp3") != string::npos || f.find(".ogg") != string::npos || f.find(".wma") != string::npos - || f.find(".asf") != string::npos) { + } else if (f.find(".raw") != std::string::npos || f.find(".wav") != std::string::npos + || f.find(".mp2") != std::string::npos || f.find(".mp3") != std::string::npos + || f.find(".ogg") != std::string::npos || f.find(".wma") != std::string::npos + || f.find(".asf") != std::string::npos) { FSOUND_STREAM* stream = FSOUND_Stream_Open(f.c_str(), use_3d, 0, 0); if (!stream) return 0; diff --git a/Runtime/gfx/gxaudio.hpp b/Runtime/gfx/gxaudio.hpp index 2be9d85..7a89e8b 100644 --- a/Runtime/gfx/gxaudio.hpp +++ b/Runtime/gfx/gxaudio.hpp @@ -1,12 +1,10 @@ - -#ifndef GXAUDIO_H -#define GXAUDIO_H - +#pragma once #include -#include "gxsound.hpp" - class gxRuntime; +class gxChannel; +class gxSound; + struct FSOUND_SAMPLE; class gxAudio { @@ -41,5 +39,3 @@ class gxAudio { gxChannel* playCDTrack(int track, int mode); gxChannel* playFile(const std::string& filename, bool use_3d); }; - -#endif \ No newline at end of file diff --git a/Runtime/gfx/gxcanvas.cpp b/Runtime/gfx/gxcanvas.cpp index 4fc663b..3445e82 100644 --- a/Runtime/gfx/gxcanvas.cpp +++ b/Runtime/gfx/gxcanvas.cpp @@ -1,9 +1,8 @@ - #include "gxcanvas.hpp" #include "asmcoder.hpp" #include "gxgraphics.hpp" #include "gxruntime.hpp" -#include "std.hpp" +#include "gxfont.hpp" #define DEBUG_BITMASK @@ -662,7 +661,7 @@ void gxCanvas::blit(int x, int y, gxCanvas* src, int src_x, int src_y, int src_w damage(dest_r); } -void gxCanvas::text(int x, int y, const string& t) +void gxCanvas::text(int x, int y, const std::string& t) { int ty = y + origin_y; if (ty >= viewport.bottom) diff --git a/Runtime/gfx/gxcanvas.hpp b/Runtime/gfx/gxcanvas.hpp index aefe78e..efc31ad 100644 --- a/Runtime/gfx/gxcanvas.hpp +++ b/Runtime/gfx/gxcanvas.hpp @@ -1,7 +1,5 @@ - -#ifndef GXCANVAS_H -#define GXCANVAS_H - +#pragma once +#include "graphicsruntime.hpp" #include "ddutil.hpp" class gxFont; @@ -140,5 +138,3 @@ class gxCanvas { unsigned getColor() const; unsigned getClsColor() const; }; - -#endif \ No newline at end of file diff --git a/Runtime/gfx/gxchannel.cpp b/Runtime/gfx/gxchannel.cpp index 2bfc9dc..5eaf737 100644 --- a/Runtime/gfx/gxchannel.cpp +++ b/Runtime/gfx/gxchannel.cpp @@ -1,5 +1,3 @@ - #include "gxchannel.hpp" -#include "std.hpp" gxChannel::~gxChannel() {} diff --git a/Runtime/gfx/gxchannel.hpp b/Runtime/gfx/gxchannel.hpp index 894dbf1..35f76d4 100644 --- a/Runtime/gfx/gxchannel.hpp +++ b/Runtime/gfx/gxchannel.hpp @@ -1,6 +1,4 @@ - -#ifndef GXCHANNEL_H -#define GXCHANNEL_H +#pragma once class gxChannel { /***** GX INTERFACE *****/ @@ -16,5 +14,3 @@ class gxChannel { virtual bool isPlaying() = 0; }; - -#endif \ No newline at end of file diff --git a/Runtime/gfx/gxdevice.cpp b/Runtime/gfx/gxdevice.cpp index e69625b..e2dd1e1 100644 --- a/Runtime/gfx/gxdevice.cpp +++ b/Runtime/gfx/gxdevice.cpp @@ -1,7 +1,5 @@ - #include "gxdevice.hpp" #include "gxruntime.hpp" -#include "std.hpp" gxDevice::gxDevice() { diff --git a/Runtime/gfx/gxdevice.hpp b/Runtime/gfx/gxdevice.hpp index 0586d56..984fe64 100644 --- a/Runtime/gfx/gxdevice.hpp +++ b/Runtime/gfx/gxdevice.hpp @@ -1,6 +1,4 @@ - -#ifndef GXDEVICE_H -#define GXDEVICE_H +#pragma once class gxDevice { public: @@ -34,5 +32,3 @@ class gxDevice { float getAxisState(int axis); }; - -#endif \ No newline at end of file diff --git a/Runtime/gfx/gxdir.cpp b/Runtime/gfx/gxdir.cpp index fb70d81..b53e2b9 100644 --- a/Runtime/gfx/gxdir.cpp +++ b/Runtime/gfx/gxdir.cpp @@ -1,6 +1,4 @@ - #include "gxdir.hpp" -#include "std.hpp" gxDir::gxDir(HANDLE h, const WIN32_FIND_DATA& f) : handle(h), findData(f) {} @@ -10,11 +8,11 @@ gxDir::~gxDir() FindClose(handle); } -string gxDir::getNextFile() +std::string gxDir::getNextFile() { if (handle == INVALID_HANDLE_VALUE) return ""; - string t = findData.cFileName; + std::string t = findData.cFileName; if (!FindNextFile(handle, &findData)) { FindClose(handle); handle = INVALID_HANDLE_VALUE; diff --git a/Runtime/gfx/gxdir.hpp b/Runtime/gfx/gxdir.hpp index 5c75187..6898fd8 100644 --- a/Runtime/gfx/gxdir.hpp +++ b/Runtime/gfx/gxdir.hpp @@ -1,9 +1,6 @@ - -#ifndef GXDIR_H -#define GXDIR_H - +#pragma once #include -#include +#include class gxDir { public: @@ -18,5 +15,3 @@ class gxDir { public: std::string getNextFile(); }; - -#endif \ No newline at end of file diff --git a/Runtime/gfx/gxfilesystem.cpp b/Runtime/gfx/gxfilesystem.cpp index d10c8da..f246cde 100644 --- a/Runtime/gfx/gxfilesystem.cpp +++ b/Runtime/gfx/gxfilesystem.cpp @@ -1,8 +1,7 @@ - #include "gxfilesystem.hpp" -#include "std.hpp" +#include -static set dir_set; +static std::set dir_set; gxFileSystem::gxFileSystem() { @@ -35,7 +34,7 @@ bool gxFileSystem::deleteFile(const std::string& file) return DeleteFile(file.c_str()) ? true : false; } -bool gxFileSystem::copyFile(const std::string& src, const string& dest) +bool gxFileSystem::copyFile(const std::string& src, const std::string& dest) { return CopyFile(src.c_str(), dest.c_str(), false) ? true : false; } @@ -50,12 +49,12 @@ bool gxFileSystem::setCurrentDir(const std::string& dir) return SetCurrentDirectory(dir.c_str()) ? true : false; } -string gxFileSystem::getCurrentDir() const +std::string gxFileSystem::getCurrentDir() const { char buff[MAX_PATH]; if (!GetCurrentDirectory(MAX_PATH, buff)) return ""; - string t = buff; + std::string t = buff; if (t.size() && t[t.size() - 1] != '\\') t += '\\'; return t; @@ -80,7 +79,7 @@ int gxFileSystem::getFileType(const std::string& name) const gxDir* gxFileSystem::openDir(const std::string& name, int flags) { - string t = name; + std::string t = name; if (t[t.size() - 1] == '\\') t += "*"; else @@ -94,6 +93,7 @@ gxDir* gxFileSystem::openDir(const std::string& name, int flags) } return 0; } + gxDir* gxFileSystem::verifyDir(gxDir* d) { return dir_set.count(d) ? d : 0; diff --git a/Runtime/gfx/gxfilesystem.hpp b/Runtime/gfx/gxfilesystem.hpp index 1fc8edd..8e4d135 100644 --- a/Runtime/gfx/gxfilesystem.hpp +++ b/Runtime/gfx/gxfilesystem.hpp @@ -1,9 +1,5 @@ - -#ifndef GXFILESYSTEM_H -#define GXFILESYSTEM_H - +#pragma once #include - #include "gxdir.hpp" class gxFileSystem { @@ -31,5 +27,3 @@ class gxFileSystem { gxDir* verifyDir(gxDir* d); void closeDir(gxDir* dir); }; - -#endif \ No newline at end of file diff --git a/Runtime/gfx/gxfont.cpp b/Runtime/gfx/gxfont.cpp index df63380..799357a 100644 --- a/Runtime/gfx/gxfont.cpp +++ b/Runtime/gfx/gxfont.cpp @@ -1,8 +1,6 @@ - #include "gxfont.hpp" #include "gxcanvas.hpp" #include "gxgraphics.hpp" -#include "std.hpp" gxFont::gxFont(gxGraphics* g, gxCanvas* c, int w, int h, int b, int e, int d, int* os, int* ws) : graphics(g), canvas(c), width(w), height(h), begin_char(b), end_char(e), def_char(d), offs(os), widths(ws) @@ -26,7 +24,7 @@ int gxFont::charWidth(int c) const return widths[c - begin_char]; } -void gxFont::render(gxCanvas* dest, unsigned color_argb, int x, int y, const string& t) +void gxFont::render(gxCanvas* dest, unsigned color_argb, int x, int y, const std::string& t) { int width = getWidth(t); if (width > t_canvas->getWidth()) { @@ -63,7 +61,7 @@ int gxFont::getHeight() const return height; } -int gxFont::getWidth(const string& t) const +int gxFont::getWidth(const std::string& t) const { int w = 0; for (int k = 0; k < t.size(); ++k) { diff --git a/Runtime/gfx/gxfont.hpp b/Runtime/gfx/gxfont.hpp index f19284a..14c17a8 100644 --- a/Runtime/gfx/gxfont.hpp +++ b/Runtime/gfx/gxfont.hpp @@ -1,6 +1,5 @@ - -#ifndef GXFONT_H -#define GXFONT_H +#pragma once +#include class gxCanvas; class gxGraphics; @@ -30,5 +29,3 @@ class gxFont { int getWidth(const std::string& text) const; //width of string bool isPrintable(int chr) const; //printable char? }; - -#endif \ No newline at end of file diff --git a/Runtime/gfx/gxgraphics.cpp b/Runtime/gfx/gxgraphics.cpp index a145c7e..b94f058 100644 --- a/Runtime/gfx/gxgraphics.cpp +++ b/Runtime/gfx/gxgraphics.cpp @@ -1,7 +1,11 @@ - #include "gxgraphics.hpp" #include "gxruntime.hpp" -#include "std.hpp" +#include "gxcanvas.hpp" +#include "gxmesh.hpp" +#include "gxfont.hpp" +#include "gxscene.hpp" + +#include extern gxRuntime* gx_runtime; @@ -52,7 +56,7 @@ gxGraphics::~gxGraphics() while (canvas_set.size()) freeCanvas(*canvas_set.begin()); - set::iterator it; + std::set::iterator it; for (it = font_res.begin(); it != font_res.end(); ++it) RemoveFontResource((*it).c_str()); font_res.clear(); @@ -104,13 +108,13 @@ bool gxGraphics::restore() dirDraw->RestoreAllSurfaces(); //restore all canvases - set::iterator it; + std::set::iterator it; for (it = canvas_set.begin(); it != canvas_set.end(); ++it) { (*it)->restore(); } //restore all meshes (b3d surfaces) - set::iterator mesh_it; + std::set::iterator mesh_it; for (mesh_it = mesh_set.begin(); mesh_it != mesh_set.end(); ++mesh_it) { (*mesh_it)->restore(); } @@ -173,7 +177,7 @@ int gxGraphics::getAvailVidmem() const return caps.dwVidMemFree; } -gxMovie* gxGraphics::openMovie(const string& file, int flags) +gxMovie* gxGraphics::openMovie(const std::string& file, int flags) { /*IAMMultiMediaStream *iam_stream; @@ -226,7 +230,7 @@ gxCanvas* gxGraphics::createCanvas(int w, int h, int flags) return c; } -gxCanvas* gxGraphics::loadCanvas(const string& f, int flags) +gxCanvas* gxGraphics::loadCanvas(const std::string& f, int flags) { IDirectDrawSurface7* s = ddUtil::loadSurface(f, flags, this); if (!s) @@ -262,16 +266,16 @@ int gxGraphics::getDepth() const return front_canvas->getDepth(); } -gxFont* gxGraphics::loadFont(const string& f, int height, int flags) +gxFont* gxGraphics::loadFont(const std::string& f, int height, int flags) { int bold = flags & gxFont::FONT_BOLD ? FW_BOLD : FW_REGULAR; int italic = flags & gxFont::FONT_ITALIC ? 1 : 0; int underline = flags & gxFont::FONT_UNDERLINE ? 1 : 0; int strikeout = 0; - string t; + std::string t; int n = f.find('.'); - if (n != string::npos) { + if (n != std::string::npos) { t = fullfilename(f); if (!font_res.count(t) && AddFontResource(t.c_str())) font_res.insert(t); @@ -459,7 +463,7 @@ static int cntBits(int mask) return n; } -static vector tex_fmts; +static std::vector tex_fmts; static HRESULT CALLBACK enumTextureFormat(DDPIXELFORMAT* fmt, void* p) { @@ -474,9 +478,9 @@ static HRESULT CALLBACK enumTextureFormat(DDPIXELFORMAT* fmt, void* p) return D3DENUMRET_OK; } -static string itobin(int n) +static std::string itobin(int n) { - string t; + std::string t; for (int k = 0; k < 32; n <<= 1, ++k) { t += (n & 0x80000000) ? '1' : '0'; } @@ -485,7 +489,7 @@ static string itobin(int n) static void debugPF(const DDPIXELFORMAT& pf) { - string t; + std::string t; t = "Bits:" + itoa(pf.dwRGBBitCount); gx_runtime->debugLog(t.c_str()); t = "R Mask:" + itobin(pf.dwRBitMask); diff --git a/Runtime/gfx/gxgraphics.hpp b/Runtime/gfx/gxgraphics.hpp index 1dbc4a2..d3184d4 100644 --- a/Runtime/gfx/gxgraphics.hpp +++ b/Runtime/gfx/gxgraphics.hpp @@ -1,23 +1,17 @@ - -#ifndef GXGRAPHICS_H -#define GXGRAPHICS_H - +#pragma once #include #include - #include -#include -#include "GraphicsRuntime.hpp" - +#include +#include "graphicsruntime.hpp" #include "ddutil.hpp" -#include "gxcanvas.hpp" -#include "gxfont.hpp" -#include "gxmesh.hpp" -#include "gxmovie.hpp" -#include "gxscene.hpp" - +class gxCanvas; +class gxFont; +class gxMesh; +class gxMovie; class gxRuntime; +class gxScene; class gxGraphics { private: @@ -122,5 +116,3 @@ class gxGraphics { gxMesh* verifyMesh(gxMesh* mesh); void freeMesh(gxMesh* mesh); }; - -#endif \ No newline at end of file diff --git a/Runtime/gfx/gxinput.cpp b/Runtime/gfx/gxinput.cpp index 8df7d05..6d64668 100644 --- a/Runtime/gfx/gxinput.cpp +++ b/Runtime/gfx/gxinput.cpp @@ -1,8 +1,9 @@ -#pragma once - #include "gxinput.hpp" +#include "gxdevice.hpp" #include "gxruntime.hpp" -#include "std.hpp" +#include "gxgraphics.hpp" + +#include static const int QUE_SIZE = 32; @@ -149,7 +150,7 @@ class Joystick : public Device { static Keyboard* keyboard; static Mouse* mouse; -static vector joysticks; +static std::vector joysticks; static Keyboard* createKeyboard(gxInput* input) { diff --git a/Runtime/gfx/gxinput.hpp b/Runtime/gfx/gxinput.hpp index 0114248..d02ec14 100644 --- a/Runtime/gfx/gxinput.hpp +++ b/Runtime/gfx/gxinput.hpp @@ -1,9 +1,7 @@ #pragma once +#include "graphicsruntime.hpp" -#include "GraphicsRuntime.hpp" -#include "gxdevice.hpp" -#include "std.hpp" - +class gxDevice; class gxRuntime; class gxInput { diff --git a/Runtime/gfx/gxlight.cpp b/Runtime/gfx/gxlight.cpp index 7ea119c..cba5529 100644 --- a/Runtime/gfx/gxlight.cpp +++ b/Runtime/gfx/gxlight.cpp @@ -1,8 +1,6 @@ - #include "gxlight.hpp" #include "gxgraphics.hpp" #include "gxscene.hpp" -#include "std.hpp" const float PI = 3.14159265359f; //180 degrees const float TWOPI = PI * 2.0f; //360 degrees diff --git a/Runtime/gfx/gxlight.hpp b/Runtime/gfx/gxlight.hpp index d7b3934..1990530 100644 --- a/Runtime/gfx/gxlight.hpp +++ b/Runtime/gfx/gxlight.hpp @@ -1,11 +1,10 @@ - -#include "GraphicsRuntime.hpp" - -#ifndef GXLIGHT_H -#define GXLIGHT_H +#pragma once +#include "graphicsruntime.hpp" class gxScene; +enum { LIGHT_DISTANT = 1, LIGHT_POINT = 2, LIGHT_SPOT = 3 }; + class gxLight { public: gxLight(gxScene* scene, int type); @@ -18,20 +17,21 @@ class gxLight { /***** GX INTERFACE *****/ public: - enum { LIGHT_DISTANT = 1, LIGHT_POINT = 2, LIGHT_SPOT = 3 }; void setRange(float range); - void setColor(const float rgb[3]) + + inline void setColor(const float rgb[3]) { memcpy(&d3d_light.dcvDiffuse, rgb, 12); } + void setPosition(const float pos[3]); + void setDirection(const float dir[3]); + void setConeAngles(float inner, float outer); - void getColor(float rgb[3]) + inline void getColor(float rgb[3]) { memcpy(rgb, &d3d_light.dcvDiffuse, 12); } }; - -#endif \ No newline at end of file diff --git a/Runtime/gfx/gxmesh.cpp b/Runtime/gfx/gxmesh.cpp index b1e1b72..33eb072 100644 --- a/Runtime/gfx/gxmesh.cpp +++ b/Runtime/gfx/gxmesh.cpp @@ -1,8 +1,5 @@ - #include "gxmesh.hpp" #include "gxgraphics.hpp" -#include "std.hpp" - #include "gxruntime.hpp" extern gxRuntime* gx_runtime; diff --git a/Runtime/gfx/gxmesh.hpp b/Runtime/gfx/gxmesh.hpp index 386fa42..178c0fc 100644 --- a/Runtime/gfx/gxmesh.hpp +++ b/Runtime/gfx/gxmesh.hpp @@ -1,10 +1,7 @@ - -#ifndef GXMESH_H -#define GXMESH_H - +#pragma once #include -#include -#include "GraphicsRuntime.hpp" +#include +#include "graphicsruntime.hpp" class gxGraphics; @@ -81,5 +78,3 @@ class gxMesh { tri_indices[n * 3 + 2] = v2; } }; - -#endif \ No newline at end of file diff --git a/Runtime/gfx/gxmovie.cpp b/Runtime/gfx/gxmovie.cpp index 4b1666d..7cd38c0 100644 --- a/Runtime/gfx/gxmovie.cpp +++ b/Runtime/gfx/gxmovie.cpp @@ -1,7 +1,5 @@ - #include "gxmovie.hpp" #include "gxgraphics.hpp" -#include "std.hpp" gxMovie::gxMovie(gxGraphics* g, IMultiMediaStream* mm) : gfx(g), mm_stream(mm), playing(true) { diff --git a/Runtime/gfx/gxmovie.hpp b/Runtime/gfx/gxmovie.hpp index f2b304d..50ba1e5 100644 --- a/Runtime/gfx/gxmovie.hpp +++ b/Runtime/gfx/gxmovie.hpp @@ -1,14 +1,10 @@ - -#ifndef GXMOVIE_H -#define GXMOVIE_H - -#include "amstream.h" // DirectShow multimedia stream interfaces -#include "ddstream.h" // DirectDraw multimedia stream interfaces -#include "mmstream.h" // multimedia stream interfaces - -#include "gxcanvas.hpp" +#pragma once +#include // DirectShow multimedia stream interfaces +#include // DirectDraw multimedia stream interfaces +#include // multimedia stream interfaces class gxGraphics; +class gxCanvas; class gxMovie { public: @@ -30,18 +26,18 @@ class gxMovie { public: bool draw(gxCanvas* dest, int x, int y, int w, int h); - bool isPlaying() const + inline bool isPlaying() const { return playing; } - int getWidth() const + + inline int getWidth() const { return src_rect.right; } - int getHeight() const + + inline int getHeight() const { return src_rect.bottom; } }; - -#endif \ No newline at end of file diff --git a/Runtime/gfx/gxmusic.cpp b/Runtime/gfx/gxmusic.cpp index 3bc4878..c5cb597 100644 --- a/Runtime/gfx/gxmusic.cpp +++ b/Runtime/gfx/gxmusic.cpp @@ -1,7 +1,8 @@ - #include "gxmusic.hpp" + +extern "C" { #include -#include "std.hpp" +} gxMusic::gxMusic(gxAudio* a, FMUSIC_MODULE* m, FSOUND_STREAM* s) : audio(a), module(m), stream(s), stream_channel(-1) {} @@ -54,8 +55,6 @@ bool gxMusic::isPlaying() const { if (module) { return FMUSIC_IsPlaying(module) ? true : false; - } else { - return FSOUND_IsPlaying(stream_channel) ? true : false; } - return false; + return FSOUND_IsPlaying(stream_channel) ? true : false; } diff --git a/Runtime/gfx/gxmusic.hpp b/Runtime/gfx/gxmusic.hpp index 8dc4c6f..c7fac86 100644 --- a/Runtime/gfx/gxmusic.hpp +++ b/Runtime/gfx/gxmusic.hpp @@ -1,6 +1,4 @@ - -#ifndef GXMUSIC_H -#define GXMUSIC_H +#pragma once class gxAudio; @@ -21,14 +19,16 @@ class gxMusic { /***** GX INTERFACE *****/ public: + //modifiers void play(); + void stop(); + void setPaused(bool paused); + void setVolume(float volume); //accessors bool isPlaying() const; }; - -#endif \ No newline at end of file diff --git a/Runtime/gfx/gxruntime.cpp b/Runtime/gfx/gxruntime.cpp index 922c3aa..9e1a539 100644 --- a/Runtime/gfx/gxruntime.cpp +++ b/Runtime/gfx/gxruntime.cpp @@ -1,12 +1,23 @@ -#pragma once - #include "gxruntime.hpp" -#include +#include +#include +#include "graphicsruntime.hpp" +#include "gxaudio.hpp" +#include "gxcanvas.hpp" +#include "gxfilesystem.hpp" +#include "gxgraphics.hpp" +#include "gxinput.hpp" +#include "gxtimer.hpp" + +#include +#include +#include #include -#include #include -#include "GraphicsRuntime.hpp" -#include "std.hpp" + +extern "C" { +#include +} struct gxRuntime::GfxMode { DDSURFACEDESC2 desc; @@ -21,8 +32,8 @@ struct gxRuntime::GfxDriver { static const int static_ws = WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; static const int scaled_ws = WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_SIZEBOX | WS_MINIMIZEBOX | WS_MAXIMIZEBOX; -static string app_title; -static string app_close; +static std::string app_title; +static std::string app_close; static gxRuntime* runtime; static bool busy, suspended; static volatile bool run_flag; @@ -31,11 +42,11 @@ static DDSURFACEDESC2 desktop_desc; typedef int(_stdcall* LibFunc)(const void* in, int in_sz, void* out, int out_sz); struct gxDll { - HINSTANCE hinst; - map funcs; + HINSTANCE hinst; + std::map funcs; }; -static map libs; +static std::map libs; static LRESULT CALLBACK windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); @@ -57,14 +68,14 @@ static IDirectDrawClipper* clipper; static IDirectDrawSurface7* primSurf; //static Debugger *debugger; -static set timers; +static std::set timers; enum { WM_STOP = WM_USER + 1, WM_RUN, WM_END }; //////////////////// // STATIC STARTUP // //////////////////// -gxRuntime* gxRuntime::openRuntime(HINSTANCE hinst, const string& cmd_line, void* d) +gxRuntime* gxRuntime::openRuntime(HINSTANCE hinst, const std::string& cmd_line, void* d) { if (runtime) return 0; @@ -105,7 +116,7 @@ void gxRuntime::closeRuntime(gxRuntime* r) if (!runtime || runtime != r) return; - map::const_iterator it; + std::map::const_iterator it; for (it = libs.begin(); it != libs.end(); ++it) { FreeLibrary(it->second->hinst); } @@ -120,7 +131,7 @@ void gxRuntime::closeRuntime(gxRuntime* r) ////////////////////////// typedef int(_stdcall* SetAppCompatDataFunc)(int x, int y); -gxRuntime::gxRuntime(HINSTANCE hi, const string& cl, HWND hw) +gxRuntime::gxRuntime(HINSTANCE hi, const std::string& cl, HWND hw) : hinst(hi), cmd_line(cl), hwnd(hw), curr_driver(0), enum_all(false), pointer_visible(true), audio(0), input(0), graphics(0), fileSystem(0), use_di(false) { @@ -338,7 +349,7 @@ void gxRuntime::flip(bool vwait) } if (n >= 0) return; - string t = "Flip Failed! Return code:" + itoa(n & 0x7fff); + std::string t = "Flip Failed! Return code:" + itoa(n & 0x7fff); debugLog(t.c_str()); break; } @@ -677,7 +688,7 @@ void gxRuntime::debugLog(const char* t) ///////////////////////// // RETURN COMMAND LINE // ///////////////////////// -string gxRuntime::commandLine() +std::string gxRuntime::commandLine() { return cmd_line; } @@ -685,24 +696,24 @@ string gxRuntime::commandLine() ///////////// // EXECUTE // ///////////// -bool gxRuntime::execute(const string& cmd_line) +bool gxRuntime::execute(const std::string& cmd_line) { if (!cmd_line.size()) return false; //convert cmd_line to cmd and params - string cmd = cmd_line, params; + std::string cmd = cmd_line, params; while (cmd.size() && cmd[0] == ' ') cmd = cmd.substr(1); if (cmd.find('\"') == 0) { int n = cmd.find('\"', 1); - if (n != string::npos) { + if (n != std::string::npos) { params = cmd.substr(n + 1); cmd = cmd.substr(1, n - 1); } } else { int n = cmd.find(' '); - if (n != string::npos) { + if (n != std::string::npos) { params = cmd.substr(n + 1); cmd = cmd.substr(0, n); } @@ -720,7 +731,7 @@ bool gxRuntime::execute(const string& cmd_line) /////////////// // APP TITLE // /////////////// -void gxRuntime::setTitle(const string& t, const string& e) +void gxRuntime::setTitle(const std::string& t, const std::string& e) { app_title = t; app_close = e; @@ -1165,7 +1176,7 @@ static BOOL WINAPI enumDriver(GUID FAR* guid, LPSTR desc, LPSTR name, LPVOID con dir3d->EnumDevices(enumDevice, d); dir3d->Release(); } - vector* drivers = (vector*)context; + std::vector* drivers = (std::vector*)context; drivers->push_back(d); dd->EnumDisplayModes(0, 0, d, enumMode); dd->Release(); @@ -1203,7 +1214,7 @@ int gxRuntime::enumerateGraphicsDrivers() return drivers.size(); } -void gxRuntime::graphicsDriverInfo(int driver, string* name, int* c) +void gxRuntime::graphicsDriverInfo(int driver, std::string* name, int* c) { GfxDriver* g = drivers[driver]; int caps = 0; @@ -1278,26 +1289,26 @@ void gxRuntime::freeTimer(gxTimer* t) delete t; } -static string toDir(string t) +static std::string toDir(std::string t) { if (t.size() && t[t.size() - 1] != '\\') t += '\\'; return t; } -string gxRuntime::systemProperty(const std::string& p) +std::string gxRuntime::systemProperty(const std::string& p) { - char buff[MAX_PATH + 1]; - string t = tolower(p); + char buff[MAX_PATH + 1]; + std::string t = tolower(p); if (t == "cpu") { return "Intel"; } else if (t == "os") { return "Windows"; } else if (t == "appdir") { if (GetModuleFileName(0, buff, MAX_PATH)) { - string t = buff; - int n = t.find_last_of('\\'); - if (n != string::npos) + std::string t = buff; + int n = t.find_last_of('\\'); + if (n != std::string::npos) t = t.substr(0, n); return toDir(t); } @@ -1342,7 +1353,7 @@ void gxRuntime::enableDirectInput(bool enable) int gxRuntime::callDll(const std::string& dll, const std::string& func, const void* in, int in_sz, void* out, int out_sz) { - map::const_iterator lib_it = libs.find(dll); + std::map::const_iterator lib_it = libs.find(dll); if (lib_it == libs.end()) { HINSTANCE h = LoadLibrary(dll.c_str()); @@ -1353,8 +1364,8 @@ int gxRuntime::callDll(const std::string& dll, const std::string& func, const vo lib_it = libs.insert(make_pair(dll, t)).first; } - gxDll* t = lib_it->second; - map::const_iterator fun_it = t->funcs.find(func); + gxDll* t = lib_it->second; + std::map::const_iterator fun_it = t->funcs.find(func); if (fun_it == t->funcs.end()) { LibFunc f = (LibFunc)GetProcAddress(t->hinst, func.c_str()); diff --git a/Runtime/gfx/gxruntime.hpp b/Runtime/gfx/gxruntime.hpp index 1fc2b85..623cf44 100644 --- a/Runtime/gfx/gxruntime.hpp +++ b/Runtime/gfx/gxruntime.hpp @@ -1,16 +1,15 @@ - -#ifndef GXRUNTIME_H -#define GXRUNTIME_H - +#pragma once +#include "graphicsruntime.hpp" #include #include -#include -#include "gxaudio.hpp" -#include "gxfilesystem.hpp" -#include "gxgraphics.hpp" -#include "gxinput.hpp" -#include "gxtimer.hpp" +#include + +class gxAudio; +class gxInput; +class gxGraphics; +class gxFileSystem; +class gxTimer; class gxRuntime { /***** INTERNAL INTERFACE *****/ @@ -139,5 +138,3 @@ class gxRuntime { OSVERSIONINFO osinfo; }; - -#endif \ No newline at end of file diff --git a/Runtime/gfx/gxscene.cpp b/Runtime/gfx/gxscene.cpp index 74de63b..5f771cf 100644 --- a/Runtime/gfx/gxscene.cpp +++ b/Runtime/gfx/gxscene.cpp @@ -1,8 +1,9 @@ - #include "gxscene.hpp" #include "gxgraphics.hpp" #include "gxruntime.hpp" -#include "std.hpp" +#include "gxcanvas.hpp" +#include "gxlight.hpp" +#include "gxmesh.hpp" static bool can_wb; static int hw_tex_stages, tex_stages; @@ -627,7 +628,7 @@ void gxScene::setRenderState(const RenderState& rs) } } -bool gxScene::begin(const vector& lights) +bool gxScene::begin(const std::vector& lights) { if (dir3dDev->BeginScene() != D3D_OK) return false; diff --git a/Runtime/gfx/gxscene.hpp b/Runtime/gfx/gxscene.hpp index 2f7ff70..ba4fed0 100644 --- a/Runtime/gfx/gxscene.hpp +++ b/Runtime/gfx/gxscene.hpp @@ -1,21 +1,17 @@ - - -#ifndef GXSCENE_H -#define GXSCENE_H - +#pragma once #include #include -#include -#include "GraphicsRuntime.hpp" - -#include "gxlight.hpp" +#include +#include "graphicsruntime.hpp" +#include +#include class gxCanvas; - class gxMesh; class gxLight; class gxGraphics; class gxTexture; +class gxLight; class gxScene { public: @@ -142,5 +138,3 @@ class gxScene { void setTriCull(); void setTexState(int index, const TexState& state, bool set_blend); }; - -#endif \ No newline at end of file diff --git a/Runtime/gfx/gxsound.cpp b/Runtime/gfx/gxsound.cpp index 32955f4..c06ee87 100644 --- a/Runtime/gfx/gxsound.cpp +++ b/Runtime/gfx/gxsound.cpp @@ -1,8 +1,9 @@ - #include "gxsound.hpp" -#include #include "gxaudio.hpp" -#include "std.hpp" + +extern "C" { +#include +} gxSound::gxSound(gxAudio* a, FSOUND_SAMPLE* s) : audio(a), sample(s), defs_valid(true) { diff --git a/Runtime/gfx/gxsound.hpp b/Runtime/gfx/gxsound.hpp index ac06b90..52d45d2 100644 --- a/Runtime/gfx/gxsound.hpp +++ b/Runtime/gfx/gxsound.hpp @@ -1,10 +1,8 @@ - -#ifndef GXSOUND_H -#define GXSOUND_H - -#include "gxchannel.hpp" +#pragma once; class gxAudio; +class gxChannel; + struct FSOUND_SAMPLE; class gxSound { @@ -34,5 +32,3 @@ class gxSound { void setVolume(float volume); void setPan(float pan); }; - -#endif diff --git a/Runtime/gfx/gxtimer.cpp b/Runtime/gfx/gxtimer.cpp index 13f325a..f86d32e 100644 --- a/Runtime/gfx/gxtimer.cpp +++ b/Runtime/gfx/gxtimer.cpp @@ -1,7 +1,7 @@ - #include "gxtimer.hpp" #include "gxruntime.hpp" -#include "std.hpp" + +#include gxTimer::gxTimer(gxRuntime* rt, int hertz) : runtime(rt), ticks_get(0), ticks_put(0) { diff --git a/Runtime/gfx/gxtimer.hpp b/Runtime/gfx/gxtimer.hpp index be693d6..585dd31 100644 --- a/Runtime/gfx/gxtimer.hpp +++ b/Runtime/gfx/gxtimer.hpp @@ -1,7 +1,5 @@ - -#ifndef GXTIMER_H -#define GXTIMER_H - +#pragma once +#include #include class gxRuntime; @@ -23,5 +21,3 @@ class gxTimer { public: int wait(); }; - -#endif \ No newline at end of file diff --git a/Runtime/gfx/std.cpp b/Runtime/gfx/std.cpp deleted file mode 100644 index d5f561b..0000000 --- a/Runtime/gfx/std.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -#include "std.hpp" diff --git a/Runtime/gfx/std.hpp b/Runtime/gfx/std.hpp deleted file mode 100644 index 1fdc1bc..0000000 --- a/Runtime/gfx/std.hpp +++ /dev/null @@ -1,25 +0,0 @@ - -#ifndef STD_H -#define STD_H - -#include "stdutil.hpp" - -#pragma warning(disable : 4786) - -#define DIRECTSOUND_VERSION 0x700 - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "GraphicsRuntime.hpp" - -using namespace std; - -#endif \ No newline at end of file