Change Media folder to Assets folder.

Naming variable convention.
Command line change -crosshair-style = vector|bmp.
Config ini variable change CrosshairStyle = vector|bmp.
CCrosshair::DrawCrosshair optimisation.
Modifying UpdateCrosshairs() to eliminate global variable.
This commit is contained in:
CapitaineSheridan 2023-03-12 11:15:27 +01:00 committed by trzy
parent 1b066fe4b3
commit b19fdb6a77
11 changed files with 160 additions and 176 deletions

View file

Before

Width:  |  Height:  |  Size: 289 KiB

After

Width:  |  Height:  |  Size: 289 KiB

View file

Before

Width:  |  Height:  |  Size: 289 KiB

After

Width:  |  Height:  |  Size: 289 KiB

View file

@ -32,7 +32,7 @@
namespace FileSystemPath namespace FileSystemPath
{ {
enum PathType { Analysis, Config, Log, NVRAM, Saves, Screenshots, Media }; // Filesystem path types enum PathType { Analysis, Config, Log, NVRAM, Saves, Screenshots, Assets }; // Filesystem path types
bool PathExists(std::string fileSystemPath); // Checks if a directory exists (returns true if exists, false if it doesn't) bool PathExists(std::string fileSystemPath); // Checks if a directory exists (returns true if exists, false if it doesn't)
std::string GetPath(PathType pathType); // Generates a path to be used by Supermodel files std::string GetPath(PathType pathType); // Generates a path to be used by Supermodel files
} }

View file

@ -41,8 +41,8 @@ namespace FileSystemPath
return "Saves/"; return "Saves/";
case Screenshots: case Screenshots:
return ""; return "";
case Media: case Assets:
return "Media/"; return "Assets/";
} }
} }
} }

View file

@ -27,81 +27,81 @@
#include <GL/glew.h> #include <GL/glew.h>
#include <vector> #include <vector>
bool CCrosshair::init() bool CCrosshair::Init()
{ {
const std::string P1CrosshairFile = Util::Format() << FileSystemPath::GetPath(FileSystemPath::Media) << "p1crosshair.bmp"; const std::string p1CrosshairFile = Util::Format() << FileSystemPath::GetPath(FileSystemPath::Assets) << "p1crosshair.bmp";
const std::string P2CrosshairFile = Util::Format() << FileSystemPath::GetPath(FileSystemPath::Media) << "p2crosshair.bmp"; const std::string p2CrosshairFile = Util::Format() << FileSystemPath::GetPath(FileSystemPath::Assets) << "p2crosshair.bmp";
IsBitmapCrosshair = m_config["BitmapCrosshair"].ValueAs<bool>(); m_isBitmapCrosshair = m_config["CrosshairStyle"].ValueAs<std::string>();
xRes = m_config["XResolution"].ValueAs<unsigned>(); m_xRes = m_config["XResolution"].ValueAs<unsigned>();
yRes = m_config["YResolution"].ValueAs<unsigned>(); m_yRes = m_config["YResolution"].ValueAs<unsigned>();
a = (float)xRes / (float)yRes; m_a = (float)m_xRes / (float)m_yRes;
SDL_Surface* SurfaceCrosshairP1 = SDL_LoadBMP(P1CrosshairFile.c_str()); SDL_Surface* surfaceCrosshairP1 = SDL_LoadBMP(p1CrosshairFile.c_str());
SDL_Surface* SurfaceCrosshairP2 = SDL_LoadBMP(P2CrosshairFile.c_str()); SDL_Surface* surfaceCrosshairP2 = SDL_LoadBMP(p2CrosshairFile.c_str());
if (SurfaceCrosshairP1 == NULL || SurfaceCrosshairP2 == NULL) if (surfaceCrosshairP1 == NULL || surfaceCrosshairP2 == NULL)
return FAIL; return FAIL;
P1CrosshairW = SurfaceCrosshairP1->w; m_p1CrosshairW = surfaceCrosshairP1->w;
P1CrosshairH = SurfaceCrosshairP1->h; m_p1CrosshairH = surfaceCrosshairP1->h;
P2CrosshairW = SurfaceCrosshairP2->w; m_p2CrosshairW = surfaceCrosshairP2->w;
P2CrosshairH = SurfaceCrosshairP2->h; m_p2CrosshairH = surfaceCrosshairP2->h;
glGenTextures(2, CrosshairtxID); glGenTextures(2, m_crosshairTexId);
glBindTexture(GL_TEXTURE_2D, CrosshairtxID[0]); glBindTexture(GL_TEXTURE_2D, m_crosshairTexId[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, P1CrosshairW, P1CrosshairH, 0, GL_BGRA, GL_UNSIGNED_BYTE, SurfaceCrosshairP1->pixels); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_p1CrosshairW, m_p1CrosshairH, 0, GL_BGRA, GL_UNSIGNED_BYTE, surfaceCrosshairP1->pixels);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, CrosshairtxID[1]); glBindTexture(GL_TEXTURE_2D, m_crosshairTexId[1]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, P1CrosshairW, P1CrosshairH, 0, GL_BGRA, GL_UNSIGNED_BYTE, SurfaceCrosshairP2->pixels); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_p1CrosshairW, m_p1CrosshairH, 0, GL_BGRA, GL_UNSIGNED_BYTE, surfaceCrosshairP2->pixels);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
SDL_FreeSurface(SurfaceCrosshairP1); SDL_FreeSurface(surfaceCrosshairP1);
SDL_FreeSurface(SurfaceCrosshairP2); SDL_FreeSurface(surfaceCrosshairP2);
// Get DPI // Get DPI
SDL_GetDisplayDPI(0, &diagdpi, &hdpi, &vdpi); SDL_GetDisplayDPI(0, &m_diagDpi, &m_hDpi, &m_vDpi);
dpiMultiplicator = hdpi / standardDpi; // note : on linux VM diagdpi returns 0 m_dpiMultiplicator = m_hDpi / m_standardDpi; // note : on linux VM diagdpi returns 0
// 3d obj // 3d obj
UVCoord.emplace_back(0.0f, 0.0f); m_uvCoord.emplace_back(0.0f, 0.0f);
UVCoord.emplace_back(1.0f, 0.0f); m_uvCoord.emplace_back(1.0f, 0.0f);
UVCoord.emplace_back(1.0f, 1.0f); m_uvCoord.emplace_back(1.0f, 1.0f);
UVCoord.emplace_back(0.0f, 0.0f); m_uvCoord.emplace_back(0.0f, 0.0f);
UVCoord.emplace_back(1.0f, 1.0f); m_uvCoord.emplace_back(1.0f, 1.0f);
UVCoord.emplace_back(0.0f, 1.0f); m_uvCoord.emplace_back(0.0f, 1.0f);
if (!IsBitmapCrosshair) if (m_isBitmapCrosshair != "bmp")
{ {
verts.emplace_back(0.0f, dist); // bottom triangle m_verts.emplace_back(0.0f, m_dist); // bottom triangle
verts.emplace_back(base / 2.0f, (dist + height) * a); m_verts.emplace_back(m_base / 2.0f, (m_dist + m_height) * m_a);
verts.emplace_back(-base / 2.0f, (dist + height) * a); m_verts.emplace_back(-m_base / 2.0f, (m_dist + m_height) * m_a);
verts.emplace_back(0.0f, -dist); // top triangle m_verts.emplace_back(0.0f, -m_dist); // top triangle
verts.emplace_back(-base / 2.0f, -(dist + height) * a); m_verts.emplace_back(-m_base / 2.0f, -(m_dist + m_height) * m_a);
verts.emplace_back(base / 2.0f, -(dist + height) * a); m_verts.emplace_back(m_base / 2.0f, -(m_dist + m_height) * m_a);
verts.emplace_back(-dist, 0.0f); // left triangle m_verts.emplace_back(-m_dist, 0.0f); // left triangle
verts.emplace_back(-dist - height, (base / 2.0f) * a); m_verts.emplace_back(-m_dist - m_height, (m_base / 2.0f) * m_a);
verts.emplace_back(-dist - height, -(base / 2.0f) * a); m_verts.emplace_back(-m_dist - m_height, -(m_base / 2.0f) * m_a);
verts.emplace_back(dist, 0.0f); // right triangle m_verts.emplace_back(m_dist, 0.0f); // right triangle
verts.emplace_back(dist + height, -(base / 2.0f) * a); m_verts.emplace_back(m_dist + m_height, -(m_base / 2.0f) * m_a);
verts.emplace_back(dist + height, (base / 2.0f) * a); m_verts.emplace_back(m_dist + m_height, (m_base / 2.0f) * m_a);
} }
else else
{ {
verts.emplace_back(-squareSize / 2.0f, -squareSize / 2.0f * a); m_verts.emplace_back(-m_squareSize / 2.0f, -m_squareSize / 2.0f * m_a);
verts.emplace_back(squareSize / 2.0f, -squareSize / 2.0f * a); m_verts.emplace_back(m_squareSize / 2.0f, -m_squareSize / 2.0f * m_a);
verts.emplace_back(squareSize / 2.0f, squareSize / 2.0f * a); m_verts.emplace_back(m_squareSize / 2.0f, m_squareSize / 2.0f * m_a);
verts.emplace_back(-squareSize / 2.0f, -squareSize / 2.0f * a); m_verts.emplace_back(-m_squareSize / 2.0f, -m_squareSize / 2.0f * m_a);
verts.emplace_back(squareSize / 2.0f, squareSize / 2.0f * a); m_verts.emplace_back(m_squareSize / 2.0f, m_squareSize / 2.0f * m_a);
verts.emplace_back(-squareSize / 2.0f, squareSize / 2.0f * a); m_verts.emplace_back(-m_squareSize / 2.0f, m_squareSize / 2.0f * m_a);
} }
vertexShader = R"glsl( m_vertexShader = R"glsl(
#version 410 core #version 410 core
@ -117,7 +117,7 @@ bool CCrosshair::init()
} }
)glsl"; )glsl";
fragmentShader = R"glsl( m_fragmentShader = R"glsl(
#version 410 core #version 410 core
@ -136,7 +136,7 @@ bool CCrosshair::init()
} }
)glsl"; )glsl";
m_shader.LoadShaders(vertexShader, fragmentShader); m_shader.LoadShaders(m_vertexShader, m_fragmentShader);
m_shader.GetUniformLocationMap("mvp"); m_shader.GetUniformLocationMap("mvp");
m_shader.GetUniformLocationMap("CrosshairTexture"); m_shader.GetUniformLocationMap("CrosshairTexture");
m_shader.GetUniformLocationMap("colour"); m_shader.GetUniformLocationMap("colour");
@ -144,7 +144,7 @@ bool CCrosshair::init()
m_vbo.Create(GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW, sizeof(BasicVertex) * (MaxVerts)); m_vbo.Create(GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW, sizeof(BasicVertex) * (MaxVerts));
m_vbo.Bind(true); m_vbo.Bind(true);
m_textvbo.Create(GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW, sizeof(UVCoords) * (int)UVCoord.size()); m_textvbo.Create(GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW, sizeof(UVCoords) * (int)m_uvCoord.size());
m_textvbo.Bind(true); m_textvbo.Bind(true);
glGenVertexArrays(1, &m_vao); glGenVertexArrays(1, &m_vao);
@ -166,18 +166,35 @@ bool CCrosshair::init()
return OKAY; return OKAY;
} }
void CCrosshair::DrawCrosshair(New3D::Mat4 matrix, float x, float y, float r, float g, float b) void CCrosshair::DrawCrosshair(New3D::Mat4 matrix, float x, float y, int player)
{ {
int count = (int)verts.size(); float r=0.0f, g=0.0f, b=0.0f;
int count = (int)m_verts.size();
if (count > MaxVerts) { if (count > MaxVerts) {
count = MaxVerts; // maybe we could error out somehow count = MaxVerts; // maybe we could error out somehow
} }
m_shader.EnableShader(); m_shader.EnableShader();
matrix.Translate(x, y, 0); matrix.Translate(x, y, 0);
matrix.Scale(dpiMultiplicator, dpiMultiplicator, 0);
if (m_isBitmapCrosshair != "bmp")
{
switch (player)
{
case 0:
r = 1.0f;
g = 0.0f;
b = 0.0f;
break;
case 1:
r = 0.0f;
g = 1.0f;
b = 0.0f;
break;
}
matrix.Scale(m_dpiMultiplicator, m_dpiMultiplicator, 0);
// update uniform memory // update uniform memory
glUniformMatrix4fv(m_shader.uniformLocMap["mvp"], 1, GL_FALSE, matrix); glUniformMatrix4fv(m_shader.uniformLocMap["mvp"], 1, GL_FALSE, matrix);
@ -186,31 +203,16 @@ void CCrosshair::DrawCrosshair(New3D::Mat4 matrix, float x, float y, float r, fl
// update vbo mem // update vbo mem
m_vbo.Bind(true); m_vbo.Bind(true);
m_vbo.BufferSubData(0, count * sizeof(BasicVertex), verts.data()); m_vbo.BufferSubData(0, count * sizeof(BasicVertex), m_verts.data());
glBindVertexArray(m_vao);
glDrawArrays(GL_TRIANGLES, 0, count);
glBindVertexArray(0);
m_shader.DisableShader();
}
void CCrosshair::DrawBitmapCrosshair(New3D::Mat4 matrix, float x, float y, int TextureNum)
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, CrosshairtxID[TextureNum]);
int count = (int)verts.size();
if (count > MaxVerts) {
count = MaxVerts; // maybe we could error out somehow
} }
m_TextureCoordsCount = (int)UVCoord.size(); else
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_crosshairTexId[player]);
m_shader.EnableShader(); m_textureCoordsCount = (int)m_uvCoord.size();
matrix.Translate(x, y, 0); matrix.Scale(m_dpiMultiplicator * m_scaleBitmap, m_dpiMultiplicator * m_scaleBitmap, 0);
matrix.Scale(dpiMultiplicator * ScaleBitmap, dpiMultiplicator * ScaleBitmap, 0);
// update uniform memory // update uniform memory
glUniformMatrix4fv(m_shader.uniformLocMap["mvp"], 1, GL_FALSE, matrix); glUniformMatrix4fv(m_shader.uniformLocMap["mvp"], 1, GL_FALSE, matrix);
@ -220,11 +222,12 @@ void CCrosshair::DrawBitmapCrosshair(New3D::Mat4 matrix, float x, float y, int T
// update vbo mem // update vbo mem
m_vbo.Bind(true); m_vbo.Bind(true);
m_vbo.BufferSubData(0, count * sizeof(BasicVertex), verts.data()); m_vbo.BufferSubData(0, count * sizeof(BasicVertex), m_verts.data());
m_vbo.Bind(false); m_vbo.Bind(false);
m_textvbo.Bind(true); m_textvbo.Bind(true);
m_textvbo.BufferSubData(0, m_TextureCoordsCount * sizeof(UVCoords), UVCoord.data()); m_textvbo.BufferSubData(0, m_textureCoordsCount * sizeof(UVCoords), m_uvCoord.data());
m_textvbo.Bind(false); m_textvbo.Bind(false);
}
glBindVertexArray(m_vao); glBindVertexArray(m_vao);
glDrawArrays(GL_TRIANGLES, 0, count); glDrawArrays(GL_TRIANGLES, 0, count);
@ -233,10 +236,10 @@ void CCrosshair::DrawBitmapCrosshair(New3D::Mat4 matrix, float x, float y, int T
m_shader.DisableShader(); m_shader.DisableShader();
} }
CCrosshair::CCrosshair(const Util::Config::Node& config) : m_config(config),xRes(0),yRes(0) CCrosshair::CCrosshair(const Util::Config::Node& config) : m_config(config),m_xRes(0),m_yRes(0)
{ {
vertexShader = nullptr; m_vertexShader = nullptr;
fragmentShader = nullptr; m_fragmentShader = nullptr;
} }
CCrosshair::~CCrosshair() CCrosshair::~CCrosshair()

View file

@ -29,19 +29,19 @@ class CCrosshair
{ {
private: private:
const Util::Config::Node& m_config; const Util::Config::Node& m_config;
bool IsBitmapCrosshair=false; std::string m_isBitmapCrosshair = "";
GLuint CrosshairtxID[2] = { 0 }; GLuint m_crosshairTexId[2] = { 0 };
int P1CrosshairW = 0, P1CrosshairH = 0, P2CrosshairW = 0, P2CrosshairH = 0; int m_p1CrosshairW = 0, m_p1CrosshairH = 0, m_p2CrosshairW = 0, m_p2CrosshairH = 0;
float diagdpi = 0.0f, hdpi = 0.0f, vdpi = 0.0f; float m_diagDpi = 0.0f, m_hDpi = 0.0f, m_vDpi = 0.0f;
unsigned int xRes=0; unsigned int m_xRes=0;
unsigned int yRes=0; unsigned int m_yRes=0;
const float base = 0.01f, height = 0.02f; // geometric parameters of each triangle const float m_base = 0.01f, m_height = 0.02f; // geometric parameters of each triangle
const float dist = 0.004f; // distance of triangle tip from center const float m_dist = 0.004f; // distance of triangle tip from center
float a = 0.0f; // aspect ratio (to square the crosshair) float m_a = 0.0f; // aspect ratio (to square the crosshair)
const float squareSize = 1.0f; const float m_squareSize = 1.0f;
const float standardDpi = 96.0f; // normal dpi for usual monitor (full hd) const float m_standardDpi = 96.0f; // normal dpi for usual monitor (full hd)
float dpiMultiplicator = 0.0f; float m_dpiMultiplicator = 0.0f;
const float ScaleBitmap = 0.1f; const float m_scaleBitmap = 0.1f;
struct BasicVertex struct BasicVertex
{ {
@ -56,25 +56,24 @@ private:
float x, y; float x, y;
}; };
std::vector<BasicVertex> verts; std::vector<BasicVertex> m_verts;
std::vector<UVCoords> UVCoord; std::vector<UVCoords> m_uvCoord;
GLSLShader m_shader; GLSLShader m_shader;
VBO m_vbo; VBO m_vbo;
VBO m_textvbo; VBO m_textvbo;
GLuint m_vao = 0; GLuint m_vao = 0;
int m_TextureCoordsCount = 0; int m_textureCoordsCount = 0;
const char* vertexShader; const char* m_vertexShader;
const char* fragmentShader; const char* m_fragmentShader;
const int MaxVerts = 1024; // per draw call const int MaxVerts = 1024; // per draw call
public: public:
CCrosshair(const Util::Config::Node& config); CCrosshair(const Util::Config::Node& config);
~CCrosshair(); ~CCrosshair();
bool init(); bool Init();
void DrawCrosshair(New3D::Mat4 matrix, float x, float y, float r, float g, float b); void DrawCrosshair(New3D::Mat4 matrix, float x, float y, int player);
void DrawBitmapCrosshair(New3D::Mat4 matrix, float x, float y, int TextureNum);
}; };
#endif #endif

View file

@ -109,8 +109,7 @@ static unsigned totalXRes, totalYRes; // total resolution (the whole GL viewpo
/* /*
* Crosshair stuff * Crosshair stuff
*/ */
static bool IsBitmapCrosshair = false; static CCrosshair* s_crosshair = nullptr;
CCrosshair* Crosshair = nullptr;
static bool SetGLGeometry(unsigned *xOffsetPtr, unsigned *yOffsetPtr, unsigned *xResPtr, unsigned *yResPtr, unsigned *totalXResPtr, unsigned *totalYResPtr, bool keepAspectRatio) static bool SetGLGeometry(unsigned *xOffsetPtr, unsigned *yOffsetPtr, unsigned *xResPtr, unsigned *yResPtr, unsigned *totalXResPtr, unsigned *totalYResPtr, bool keepAspectRatio)
{ {
@ -812,7 +811,7 @@ static void PrintGLError(GLenum error)
} }
*/ */
static void UpdateCrosshairs(uint32_t currentInputs, CInputs *Inputs, unsigned crosshairs) static void UpdateCrosshairs(uint32_t currentInputs, CInputs *Inputs, unsigned crosshairs, std::string crosshairStyle)
{ {
bool offscreenTrigger[2]; bool offscreenTrigger[2];
float x[2], y[2]; float x[2], y[2];
@ -826,7 +825,7 @@ static void UpdateCrosshairs(uint32_t currentInputs, CInputs *Inputs, unsigned c
glViewport(xOffset, yOffset, xRes, yRes); glViewport(xOffset, yOffset, xRes, yRes);
glDisable(GL_DEPTH_TEST); // no Z-buffering needed glDisable(GL_DEPTH_TEST); // no Z-buffering needed
if (!IsBitmapCrosshair) if(crosshairStyle != "bmp")
{ {
glDisable(GL_BLEND); // no blending glDisable(GL_BLEND); // no blending
} }
@ -869,27 +868,14 @@ static void UpdateCrosshairs(uint32_t currentInputs, CInputs *Inputs, unsigned c
} }
// Draw visible crosshairs // Draw visible crosshairs
if (!IsBitmapCrosshair)
{
if ((crosshairs & 1) && !offscreenTrigger[0]) // Player 1 if ((crosshairs & 1) && !offscreenTrigger[0]) // Player 1
{ {
Crosshair->DrawCrosshair(m, x[0], y[0], 1.0f, 0.0f, 0.0f); s_crosshair->DrawCrosshair(m, x[0], y[0], 0);
} }
if ((crosshairs & 2) && !offscreenTrigger[1]) // Player 2 if ((crosshairs & 2) && !offscreenTrigger[1]) // Player 2
{ {
Crosshair->DrawCrosshair(m, x[1], y[1], 0.0f, 1.0f, 0.0f); s_crosshair->DrawCrosshair(m, x[1], y[1], 1);
}
}
else
{
if ((crosshairs & 1) && !offscreenTrigger[0]) // Player 1
{
Crosshair->DrawBitmapCrosshair(m, x[0], y[0], 0);
}
if ((crosshairs & 2) && !offscreenTrigger[1]) // Player 2
{
Crosshair->DrawBitmapCrosshair(m, x[1], y[1], 1);
}
} }
//PrintGLError(glGetError()); //PrintGLError(glGetError());
@ -912,7 +898,7 @@ void EndFrameVideo()
{ {
// Show crosshairs for light gun games // Show crosshairs for light gun games
if (videoInputs) if (videoInputs)
UpdateCrosshairs(currentInputs, videoInputs, s_runtime_config["Crosshairs"].ValueAs<unsigned>()); UpdateCrosshairs(currentInputs, videoInputs, s_runtime_config["Crosshairs"].ValueAs<unsigned>(), s_runtime_config["CrosshairStyle"].ValueAs<std::string>());
// Swap the buffers // Swap the buffers
SDL_GL_SwapWindow(s_window); SDL_GL_SwapWindow(s_window);
@ -1566,7 +1552,7 @@ static Util::Config::Node DefaultConfig()
config.Set("RefreshRate", 60.0f); config.Set("RefreshRate", 60.0f);
config.Set("ShowFrameRate", false); config.Set("ShowFrameRate", false);
config.Set("Crosshairs", int(0)); config.Set("Crosshairs", int(0));
config.Set("BitmapCrosshair", false); config.Set("CrosshairStyle", "vector");
config.Set("FlipStereo", false); config.Set("FlipStereo", false);
#ifdef SUPERMODEL_WIN32 #ifdef SUPERMODEL_WIN32
config.Set("InputSystem", "dinput"); config.Set("InputSystem", "dinput");
@ -1652,8 +1638,7 @@ static void Help(void)
puts(" -show-fps Display frame rate in window title bar"); puts(" -show-fps Display frame rate in window title bar");
puts(" -crosshairs=<n> Crosshairs configuration for gun games:"); puts(" -crosshairs=<n> Crosshairs configuration for gun games:");
puts(" 0=none [Default], 1=P1 only, 2=P2 only, 3=P1 & P2"); puts(" 0=none [Default], 1=P1 only, 2=P2 only, 3=P1 & P2");
puts(" -vectorcrosshair Use built-in crosshair [Default]"); puts(" -crosshair-style=<s> Crosshair style: vector or bmp. [Default: vector]");
puts(" -bitmapcrosshair Use image (.bmp) as crosshair (only for lost world)");
puts(" -new3d New 3D engine by Ian Curtis [Default]"); puts(" -new3d New 3D engine by Ian Curtis [Default]");
puts(" -quad-rendering Enable proper quad rendering"); puts(" -quad-rendering Enable proper quad rendering");
puts(" -legacy3d Legacy 3D engine (faster but less accurate)"); puts(" -legacy3d Legacy 3D engine (faster but less accurate)");
@ -1739,6 +1724,7 @@ static ParsedCommandLine ParseCommandLine(int argc, char **argv)
{ "-load-state", "InitStateFile" }, { "-load-state", "InitStateFile" },
{ "-ppc-frequency", "PowerPCFrequency" }, { "-ppc-frequency", "PowerPCFrequency" },
{ "-crosshairs", "Crosshairs" }, { "-crosshairs", "Crosshairs" },
{ "-crosshair-style", "CrosshairStyle" },
{ "-vert-shader", "VertexShader" }, { "-vert-shader", "VertexShader" },
{ "-frag-shader", "FragmentShader" }, { "-frag-shader", "FragmentShader" },
{ "-vert-shader-fog", "VertexShaderFog" }, { "-vert-shader-fog", "VertexShaderFog" },
@ -1789,8 +1775,6 @@ static ParsedCommandLine ParseCommandLine(int argc, char **argv)
{ "-no-dsb", { "EmulateDSB", false } }, { "-no-dsb", { "EmulateDSB", false } },
{ "-legacy-scsp", { "LegacySoundDSP", true } }, { "-legacy-scsp", { "LegacySoundDSP", true } },
{ "-new-scsp", { "LegacySoundDSP", false } }, { "-new-scsp", { "LegacySoundDSP", false } },
{ "-bitmapcrosshair", { "BitmapCrosshair", true } },
{ "-vectorcrosshair", { "BitmapCrosshair", false } },
#ifdef NET_BOARD #ifdef NET_BOARD
{ "-net", { "Network", true } }, { "-net", { "Network", true } },
{ "-no-net", { "Network", false } }, { "-no-net", { "Network", false } },
@ -2052,11 +2036,9 @@ int main(int argc, char **argv)
goto Exit; goto Exit;
} }
IsBitmapCrosshair = s_runtime_config["BitmapCrosshair"].ValueAs<bool>(); // Create Crosshair
s_crosshair = new CCrosshair(s_runtime_config);
// Create Bitmap Crosshair if (s_crosshair->Init() != OKAY)
Crosshair = new CCrosshair(s_runtime_config);
if (Crosshair->init() != OKAY)
{ {
ErrorLog("Unable to load bitmap crosshair texture\n"); ErrorLog("Unable to load bitmap crosshair texture\n");
exitCode = 1; exitCode = 1;
@ -2164,8 +2146,8 @@ Exit:
delete InputSystem; delete InputSystem;
if (Outputs != NULL) if (Outputs != NULL)
delete Outputs; delete Outputs;
if (Crosshair != NULL) if (s_crosshair != NULL)
delete Crosshair; delete s_crosshair;
DestroyGLScreen(); DestroyGLScreen();
SDL_Quit(); SDL_Quit();

View file

@ -73,8 +73,8 @@ namespace FileSystemPath
case Screenshots: case Screenshots:
strPathType = "Screenshots"; strPathType = "Screenshots";
break; break;
case Media: case Assets:
strPathType = "Media/"; strPathType = "Assets/";
break; break;
} }

View file

@ -41,8 +41,8 @@ namespace FileSystemPath
return "Saves/"; return "Saves/";
case Screenshots: case Screenshots:
return ""; return "";
case Media: case Assets:
return "Media/"; return "Assets/";
} }
return ""; return "";

View file

@ -114,10 +114,10 @@
<Command>if not exist "$(TargetDir)Config" mkdir "$(TargetDir)Config" <Command>if not exist "$(TargetDir)Config" mkdir "$(TargetDir)Config"
if not exist "$(TargetDir)NVRAM" mkdir "$(TargetDir)NVRAM" if not exist "$(TargetDir)NVRAM" mkdir "$(TargetDir)NVRAM"
if not exist "$(TargetDir)Saves" mkdir "$(TargetDir)Saves" if not exist "$(TargetDir)Saves" mkdir "$(TargetDir)Saves"
if not exist "$(TargetDir)Media" mkdir "$(TargetDir)Media" if not exist "$(TargetDir)Assets" mkdir "$(TargetDir)Assets"
xcopy /D /Y "$(ProjectDir)..\Docs\*" "$(TargetDir)" xcopy /D /Y "$(ProjectDir)..\Docs\*" "$(TargetDir)"
xcopy /D /Y "$(ProjectDir)..\Config\*" "$(TargetDir)Config" xcopy /D /Y "$(ProjectDir)..\Config\*" "$(TargetDir)Config"
xcopy /D /Y "$(ProjectDir)..\Media\*" "$(TargetDir)Media"</Command> xcopy /D /Y "$(ProjectDir)..\Assets\*" "$(TargetDir)Assets"</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -147,10 +147,10 @@ xcopy /D /Y "$(ProjectDir)..\Media\*" "$(TargetDir)Media"</Command>
<Command>if not exist "$(TargetDir)Config" mkdir "$(TargetDir)Config" <Command>if not exist "$(TargetDir)Config" mkdir "$(TargetDir)Config"
if not exist "$(TargetDir)NVRAM" mkdir "$(TargetDir)NVRAM" if not exist "$(TargetDir)NVRAM" mkdir "$(TargetDir)NVRAM"
if not exist "$(TargetDir)Saves" mkdir "$(TargetDir)Saves" if not exist "$(TargetDir)Saves" mkdir "$(TargetDir)Saves"
if not exist "$(TargetDir)Media" mkdir "$(TargetDir)Media" if not exist "$(TargetDir)Assets" mkdir "$(TargetDir)Assets"
xcopy /D /Y "$(ProjectDir)..\Docs\*" "$(TargetDir)" xcopy /D /Y "$(ProjectDir)..\Docs\*" "$(TargetDir)"
xcopy /D /Y "$(ProjectDir)..\Config\*" "$(TargetDir)Config" xcopy /D /Y "$(ProjectDir)..\Config\*" "$(TargetDir)Config"
xcopy /D /Y "$(ProjectDir)..\Media\*" "$(TargetDir)Media"</Command> xcopy /D /Y "$(ProjectDir)..\Assets\*" "$(TargetDir)Assets"</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -179,10 +179,10 @@ xcopy /D /Y "$(ProjectDir)..\Media\*" "$(TargetDir)Media"</Command>
<Command>if not exist "$(TargetDir)Config" mkdir "$(TargetDir)Config" <Command>if not exist "$(TargetDir)Config" mkdir "$(TargetDir)Config"
if not exist "$(TargetDir)NVRAM" mkdir "$(TargetDir)NVRAM" if not exist "$(TargetDir)NVRAM" mkdir "$(TargetDir)NVRAM"
if not exist "$(TargetDir)Saves" mkdir "$(TargetDir)Saves" if not exist "$(TargetDir)Saves" mkdir "$(TargetDir)Saves"
if not exist "$(TargetDir)Media" mkdir "$(TargetDir)Media" if not exist "$(TargetDir)Assets" mkdir "$(TargetDir)Assets"
xcopy /D /Y "$(ProjectDir)..\Docs\*" "$(TargetDir)" xcopy /D /Y "$(ProjectDir)..\Docs\*" "$(TargetDir)"
xcopy /D /Y "$(ProjectDir)..\Config\*" "$(TargetDir)Config" xcopy /D /Y "$(ProjectDir)..\Config\*" "$(TargetDir)Config"
xcopy /D /Y "$(ProjectDir)..\Media\*" "$(TargetDir)Media"</Command> xcopy /D /Y "$(ProjectDir)..\Assets\*" "$(TargetDir)Assets"</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -215,10 +215,10 @@ xcopy /D /Y "$(ProjectDir)..\Media\*" "$(TargetDir)Media"</Command>
<Command>if not exist "$(TargetDir)Config" mkdir "$(TargetDir)Config" <Command>if not exist "$(TargetDir)Config" mkdir "$(TargetDir)Config"
if not exist "$(TargetDir)NVRAM" mkdir "$(TargetDir)NVRAM" if not exist "$(TargetDir)NVRAM" mkdir "$(TargetDir)NVRAM"
if not exist "$(TargetDir)Saves" mkdir "$(TargetDir)Saves" if not exist "$(TargetDir)Saves" mkdir "$(TargetDir)Saves"
if not exist "$(TargetDir)Media" mkdir "$(TargetDir)Media" if not exist "$(TargetDir)Assets" mkdir "$(TargetDir)Assets"
xcopy /D /Y "$(ProjectDir)..\Docs\*" "$(TargetDir)" xcopy /D /Y "$(ProjectDir)..\Docs\*" "$(TargetDir)"
xcopy /D /Y "$(ProjectDir)..\Config\*" "$(TargetDir)Config" xcopy /D /Y "$(ProjectDir)..\Config\*" "$(TargetDir)Config"
xcopy /D /Y "$(ProjectDir)..\Media\*" "$(TargetDir)Media"</Command> xcopy /D /Y "$(ProjectDir)..\Assets\*" "$(TargetDir)Assets"</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>