Supermodel/Src/OSD/SDL/Crosshair.h
CapitaineSheridan b19fdb6a77 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.
2023-03-13 20:18:51 -07:00

80 lines
2.3 KiB
C++

/**
** Supermodel
** A Sega Model 3 Arcade Emulator.
** Copyright 2003-2022 The Supermodel Team
**
** This file is part of Supermodel.
**
** Supermodel is free software: you can redistribute it and/or modify it under
** the terms of the GNU General Public License as published by the Free
** Software Foundation, either version 3 of the License, or (at your option)
** any later version.
**
** Supermodel is distributed in the hope that it will be useful, but WITHOUT
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
** more details.
**
** You should have received a copy of the GNU General Public License along
** with Supermodel. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef INCLUDED_CROSSHAIR_H
#define INCLUDED_CROSSHAIR_H
#include "Supermodel.h"
#include "Graphics/New3D/New3D.h"
class CCrosshair
{
private:
const Util::Config::Node& m_config;
std::string m_isBitmapCrosshair = "";
GLuint m_crosshairTexId[2] = { 0 };
int m_p1CrosshairW = 0, m_p1CrosshairH = 0, m_p2CrosshairW = 0, m_p2CrosshairH = 0;
float m_diagDpi = 0.0f, m_hDpi = 0.0f, m_vDpi = 0.0f;
unsigned int m_xRes=0;
unsigned int m_yRes=0;
const float m_base = 0.01f, m_height = 0.02f; // geometric parameters of each triangle
const float m_dist = 0.004f; // distance of triangle tip from center
float m_a = 0.0f; // aspect ratio (to square the crosshair)
const float m_squareSize = 1.0f;
const float m_standardDpi = 96.0f; // normal dpi for usual monitor (full hd)
float m_dpiMultiplicator = 0.0f;
const float m_scaleBitmap = 0.1f;
struct BasicVertex
{
BasicVertex(float x, float y, float z) : x(x), y(y), z(z) {}
BasicVertex(float x, float y) : x(x), y(y), z(0.0f) {}
float x, y, z;
};
struct UVCoords
{
UVCoords(float x, float y) : x(x), y(y) {}
float x, y;
};
std::vector<BasicVertex> m_verts;
std::vector<UVCoords> m_uvCoord;
GLSLShader m_shader;
VBO m_vbo;
VBO m_textvbo;
GLuint m_vao = 0;
int m_textureCoordsCount = 0;
const char* m_vertexShader;
const char* m_fragmentShader;
const int MaxVerts = 1024; // per draw call
public:
CCrosshair(const Util::Config::Node& config);
~CCrosshair();
bool Init();
void DrawCrosshair(New3D::Mat4 matrix, float x, float y, int player);
};
#endif