runtime/gfx: Fix linking, update code to C++11 and formatting

This commit is contained in:
Michael Fabian 'Xaymar' Dirks
2019-01-18 19:05:43 +01:00
parent 420744efd4
commit 077776b704
42 changed files with 227 additions and 324 deletions
+8 -9
View File
@@ -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}
+2 -7
View File
@@ -4,14 +4,11 @@
// testroutine for asmcoder class
// see asmcoder.h for readme
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "asmcoder.hpp"
#include <Windows.h>
#include <stdio.h>
#include <time.h>
#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 {
+1 -4
View File
@@ -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
+24 -25
View File
@@ -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 <freeimage.h>
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)
+3 -7
View File
@@ -1,8 +1,6 @@
#ifndef DDUTIL_H
#define DDUTIL_H
#include "GraphicsRuntime.hpp"
#pragma once
#include <string>
#include "graphicsruntime.hpp"
class gxGraphics;
@@ -64,5 +62,3 @@ class PixelFormat {
return point(p);
}
};
#endif
+1 -1
View File
@@ -1,5 +1,5 @@
#pragma once
#include <windows.h>
#include <Windows.h>
// Direct Draw
#define DIRECTDRAW_VERSION 0x0700
+22 -13
View File
@@ -1,7 +1,15 @@
#include "gxaudio.hpp"
#include "gxchannel.hpp"
#include "gxsound.hpp"
#include <set>
#include <vector>
#include <map>
#include <stdutil.hpp>
extern "C" {
#include <fmod.h>
#include "std.hpp"
}
struct StaticChannel : public gxChannel {
virtual void play() = 0;
@@ -162,13 +170,13 @@ struct MusicChannel : public StaticChannel {
FMUSIC_MODULE* module;
};
static set<gxSound*> sound_set;
static vector<gxChannel*> channels;
static map<string, StaticChannel*> songs;
static std::set<gxSound*> sound_set;
static std::vector<gxChannel*> channels;
static std::map<std::string, StaticChannel*> songs;
static CDChannel* cdChannel;
static int next_chan;
static vector<SoundChannel*> soundChannels;
static std::vector<SoundChannel*> 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<string, StaticChannel*>::iterator it = songs.find(f);
std::map<std::string, StaticChannel*>::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;
+4 -8
View File
@@ -1,12 +1,10 @@
#ifndef GXAUDIO_H
#define GXAUDIO_H
#pragma once
#include <string>
#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
+2 -3
View File
@@ -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)
+2 -6
View File
@@ -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
-2
View File
@@ -1,5 +1,3 @@
#include "gxchannel.hpp"
#include "std.hpp"
gxChannel::~gxChannel() {}
+1 -5
View File
@@ -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
-2
View File
@@ -1,7 +1,5 @@
#include "gxdevice.hpp"
#include "gxruntime.hpp"
#include "std.hpp"
gxDevice::gxDevice()
{
+1 -5
View File
@@ -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
+2 -4
View File
@@ -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;
+2 -7
View File
@@ -1,9 +1,6 @@
#ifndef GXDIR_H
#define GXDIR_H
#pragma once
#include <string>
#include <windows.h>
#include <Windows.h>
class gxDir {
public:
@@ -18,5 +15,3 @@ class gxDir {
public:
std::string getNextFile();
};
#endif
+7 -7
View File
@@ -1,8 +1,7 @@
#include "gxfilesystem.hpp"
#include "std.hpp"
#include <set>
static set<gxDir*> dir_set;
static std::set<gxDir*> 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;
+1 -7
View File
@@ -1,9 +1,5 @@
#ifndef GXFILESYSTEM_H
#define GXFILESYSTEM_H
#pragma once
#include <string>
#include "gxdir.hpp"
class gxFileSystem {
@@ -31,5 +27,3 @@ class gxFileSystem {
gxDir* verifyDir(gxDir* d);
void closeDir(gxDir* dir);
};
#endif
+2 -4
View File
@@ -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) {
+2 -5
View File
@@ -1,6 +1,5 @@
#ifndef GXFONT_H
#define GXFONT_H
#pragma once
#include <string>
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
+18 -14
View File
@@ -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 <stdutil.hpp>
extern gxRuntime* gx_runtime;
@@ -52,7 +56,7 @@ gxGraphics::~gxGraphics()
while (canvas_set.size())
freeCanvas(*canvas_set.begin());
set<string>::iterator it;
std::set<std::string>::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<gxCanvas*>::iterator it;
std::set<gxCanvas*>::iterator it;
for (it = canvas_set.begin(); it != canvas_set.end(); ++it) {
(*it)->restore();
}
//restore all meshes (b3d surfaces)
set<gxMesh*>::iterator mesh_it;
std::set<gxMesh*>::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<TexFmt> tex_fmts;
static std::vector<TexFmt> 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);
+8 -16
View File
@@ -1,23 +1,17 @@
#ifndef GXGRAPHICS_H
#define GXGRAPHICS_H
#pragma once
#include <set>
#include <string>
#include <d3d.h>
#include <windows.h>
#include "GraphicsRuntime.hpp"
#include <Windows.h>
#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
+5 -4
View File
@@ -1,8 +1,9 @@
#pragma once
#include "gxinput.hpp"
#include "gxdevice.hpp"
#include "gxruntime.hpp"
#include "std.hpp"
#include "gxgraphics.hpp"
#include <mmsystem.h>
static const int QUE_SIZE = 32;
@@ -149,7 +150,7 @@ class Joystick : public Device {
static Keyboard* keyboard;
static Mouse* mouse;
static vector<Joystick*> joysticks;
static std::vector<Joystick*> joysticks;
static Keyboard* createKeyboard(gxInput* input)
{
+2 -4
View File
@@ -1,9 +1,7 @@
#pragma once
#include "graphicsruntime.hpp"
#include "GraphicsRuntime.hpp"
#include "gxdevice.hpp"
#include "std.hpp"
class gxDevice;
class gxRuntime;
class gxInput {
-2
View File
@@ -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
+10 -10
View File
@@ -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
-3
View File
@@ -1,8 +1,5 @@
#include "gxmesh.hpp"
#include "gxgraphics.hpp"
#include "std.hpp"
#include "gxruntime.hpp"
extern gxRuntime* gx_runtime;
+3 -8
View File
@@ -1,10 +1,7 @@
#ifndef GXMESH_H
#define GXMESH_H
#pragma once
#include <d3d.h>
#include <windows.h>
#include "GraphicsRuntime.hpp"
#include <Windows.h>
#include "graphicsruntime.hpp"
class gxGraphics;
@@ -81,5 +78,3 @@ class gxMesh {
tri_indices[n * 3 + 2] = v2;
}
};
#endif
-2
View File
@@ -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)
{
+10 -14
View File
@@ -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 <amstream.h> // DirectShow multimedia stream interfaces
#include <ddstream.h> // DirectDraw multimedia stream interfaces
#include <mmstream.h> // 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
+4 -5
View File
@@ -1,7 +1,8 @@
#include "gxmusic.hpp"
extern "C" {
#include <fmod.h>
#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;
}
+5 -5
View File
@@ -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
+45 -34
View File
@@ -1,12 +1,23 @@
#pragma once
#include "gxruntime.hpp"
#include <fmod.h>
#include <algorithm>
#include <map>
#include "graphicsruntime.hpp"
#include "gxaudio.hpp"
#include "gxcanvas.hpp"
#include "gxfilesystem.hpp"
#include "gxgraphics.hpp"
#include "gxinput.hpp"
#include "gxtimer.hpp"
#include <stdutil.hpp>
#include <Windows.h>
#include <mmsystem.h>
#include <shellapi.h>
#include <windows.h>
#include <zmouse.h>
#include "GraphicsRuntime.hpp"
#include "std.hpp"
extern "C" {
#include <fmod.h>
}
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<string, LibFunc> funcs;
HINSTANCE hinst;
std::map<std::string, LibFunc> funcs;
};
static map<string, gxDll*> libs;
static std::map<std::string, gxDll*> 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<gxTimer*> timers;
static std::set<gxTimer*> 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<string, gxDll*>::const_iterator it;
std::map<std::string, gxDll*>::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<gxRuntime::GfxDriver*>* drivers = (vector<gxRuntime::GfxDriver*>*)context;
std::vector<gxRuntime::GfxDriver*>* drivers = (std::vector<gxRuntime::GfxDriver*>*)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<string, gxDll*>::const_iterator lib_it = libs.find(dll);
std::map<std::string, gxDll*>::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<string, LibFunc>::const_iterator fun_it = t->funcs.find(func);
gxDll* t = lib_it->second;
std::map<std::string, LibFunc>::const_iterator fun_it = t->funcs.find(func);
if (fun_it == t->funcs.end()) {
LibFunc f = (LibFunc)GetProcAddress(t->hinst, func.c_str());
+9 -12
View File
@@ -1,16 +1,15 @@
#ifndef GXRUNTIME_H
#define GXRUNTIME_H
#pragma once
#include "graphicsruntime.hpp"
#include <string>
#include <vector>
#include <windows.h>
#include "gxaudio.hpp"
#include "gxfilesystem.hpp"
#include "gxgraphics.hpp"
#include "gxinput.hpp"
#include "gxtimer.hpp"
#include <Windows.h>
class gxAudio;
class gxInput;
class gxGraphics;
class gxFileSystem;
class gxTimer;
class gxRuntime {
/***** INTERNAL INTERFACE *****/
@@ -139,5 +138,3 @@ class gxRuntime {
OSVERSIONINFO osinfo;
};
#endif
+4 -3
View File
@@ -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<gxLight*>& lights)
bool gxScene::begin(const std::vector<gxLight*>& lights)
{
if (dir3dDev->BeginScene() != D3D_OK)
return false;
+6 -12
View File
@@ -1,21 +1,17 @@
#ifndef GXSCENE_H
#define GXSCENE_H
#pragma once
#include <d3d.h>
#include <map>
#include <windows.h>
#include "GraphicsRuntime.hpp"
#include "gxlight.hpp"
#include <Windows.h>
#include "graphicsruntime.hpp"
#include <vector>
#include <set>
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
+4 -3
View File
@@ -1,8 +1,9 @@
#include "gxsound.hpp"
#include <fmod.h>
#include "gxaudio.hpp"
#include "std.hpp"
extern "C" {
#include <fmod.h>
}
gxSound::gxSound(gxAudio* a, FSOUND_SAMPLE* s) : audio(a), sample(s), defs_valid(true)
{
+3 -7
View File
@@ -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
+2 -2
View File
@@ -1,7 +1,7 @@
#include "gxtimer.hpp"
#include "gxruntime.hpp"
#include "std.hpp"
#include <mmsystem.h>
gxTimer::gxTimer(gxRuntime* rt, int hertz) : runtime(rt), ticks_get(0), ticks_put(0)
{
+2 -6
View File
@@ -1,7 +1,5 @@
#ifndef GXTIMER_H
#define GXTIMER_H
#pragma once
#include <Windows.h>
#include <mmsyscom.h>
class gxRuntime;
@@ -23,5 +21,3 @@ class gxTimer {
public:
int wait();
};
#endif
-2
View File
@@ -1,2 +0,0 @@
#include "std.hpp"
-25
View File
@@ -1,25 +0,0 @@
#ifndef STD_H
#define STD_H
#include "stdutil.hpp"
#pragma warning(disable : 4786)
#define DIRECTSOUND_VERSION 0x700
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <math.h>
#include <windows.h>
#include "GraphicsRuntime.hpp"
using namespace std;
#endif