dolphin-emu: Solve CHAR_WIDTH conflict with limits.h

This commit is contained in:
Lazaros Koromilas 2017-04-20 13:23:36 +03:00
parent 7ce1a18568
commit f71e75fccf
1 changed files with 112 additions and 0 deletions

View File

@ -0,0 +1,112 @@
--- Source/Core/VideoBackends/OGL/RasterFont.cpp.orig 2017-04-20 13:02:30.087390930 +0300
+++ Source/Core/VideoBackends/OGL/RasterFont.cpp 2017-04-20 13:02:49.036390127 +0300
@@ -15,12 +15,12 @@
namespace OGL
{
-static const int CHAR_WIDTH = 8;
-static const int CHAR_HEIGHT = 13;
-static const int CHAR_OFFSET = 32;
-static const int CHAR_COUNT = 95;
+static const int CHARACTER_WIDTH = 8;
+static const int CHARACTER_HEIGHT = 13;
+static const int CHARACTER_OFFSET = 32;
+static const int CHARACTER_COUNT = 95;
-static const u8 rasters[CHAR_COUNT][CHAR_HEIGHT] = {
+static const u8 rasters[CHARACTER_COUNT][CHARACTER_HEIGHT] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36},
@@ -146,27 +146,27 @@
glGenTextures(1, &texture);
glActiveTexture(GL_TEXTURE8);
glBindTexture(GL_TEXTURE_2D, texture);
- std::vector<u32> texture_data(CHAR_WIDTH * CHAR_COUNT * CHAR_HEIGHT);
- for (int y = 0; y < CHAR_HEIGHT; y++)
+ std::vector<u32> texture_data(CHARACTER_WIDTH * CHARACTER_COUNT * CHARACTER_HEIGHT);
+ for (int y = 0; y < CHARACTER_HEIGHT; y++)
{
- for (int c = 0; c < CHAR_COUNT; c++)
+ for (int c = 0; c < CHARACTER_COUNT; c++)
{
- for (int x = 0; x < CHAR_WIDTH; x++)
+ for (int x = 0; x < CHARACTER_WIDTH; x++)
{
- bool pixel = (0 != (rasters[c][y] & (1 << (CHAR_WIDTH - x - 1))));
- texture_data[CHAR_WIDTH * CHAR_COUNT * y + CHAR_WIDTH * c + x] = pixel ? -1 : 0;
+ bool pixel = (0 != (rasters[c][y] & (1 << (CHARACTER_WIDTH - x - 1))));
+ texture_data[CHARACTER_WIDTH * CHARACTER_COUNT * y + CHARACTER_WIDTH * c + x] = pixel ? -1 : 0;
}
}
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, CHAR_WIDTH * CHAR_COUNT, CHAR_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture_data.data());
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, CHARACTER_WIDTH * CHARACTER_COUNT, CHARACTER_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture_data.data());
// generate shader
ProgramShaderCache::CompileShader(s_shader, s_vertexShaderSrc, s_fragmentShaderSrc);
s_shader.Bind();
// bound uniforms
- glUniform2f(glGetUniformLocation(s_shader.glprogid,"charSize"), 1.0f / GLfloat(CHAR_COUNT), 1.0f);
+ glUniform2f(glGetUniformLocation(s_shader.glprogid,"charSize"), 1.0f / GLfloat(CHARACTER_COUNT), 1.0f);
uniform_color_id = glGetUniformLocation(s_shader.glprogid,"color");
glUniform4f(uniform_color_id, 1.0f, 1.0f, 1.0f, 1.0f);
uniform_offset_id = glGetUniformLocation(s_shader.glprogid, "offset");
@@ -196,8 +196,8 @@
std::vector<GLfloat> vertices(text.length() * 6 * 4);
int usage = 0;
- GLfloat delta_x = GLfloat(2 * CHAR_WIDTH) / GLfloat(bbWidth);
- GLfloat delta_y = GLfloat(2 * CHAR_HEIGHT) / GLfloat(bbHeight);
+ GLfloat delta_x = GLfloat(2 * CHARACTER_WIDTH) / GLfloat(bbWidth);
+ GLfloat delta_y = GLfloat(2 * CHARACTER_HEIGHT) / GLfloat(bbHeight);
GLfloat border_x = 2.0f / GLfloat(bbWidth);
GLfloat border_y = 4.0f / GLfloat(bbHeight);
@@ -220,37 +220,37 @@
continue;
}
- if (c < CHAR_OFFSET || c >= CHAR_COUNT + CHAR_OFFSET)
+ if (c < CHARACTER_OFFSET || c >= CHARACTER_COUNT + CHARACTER_OFFSET)
continue;
vertices[usage++] = x;
vertices[usage++] = y;
- vertices[usage++] = GLfloat(c - CHAR_OFFSET);
+ vertices[usage++] = GLfloat(c - CHARACTER_OFFSET);
vertices[usage++] = 0.0f;
vertices[usage++] = x + delta_x;
vertices[usage++] = y;
- vertices[usage++] = GLfloat(c - CHAR_OFFSET + 1);
+ vertices[usage++] = GLfloat(c - CHARACTER_OFFSET + 1);
vertices[usage++] = 0.0f;
vertices[usage++] = x + delta_x;
vertices[usage++] = y + delta_y;
- vertices[usage++] = GLfloat(c - CHAR_OFFSET + 1);
+ vertices[usage++] = GLfloat(c - CHARACTER_OFFSET + 1);
vertices[usage++] = 1.0f;
vertices[usage++] = x;
vertices[usage++] = y;
- vertices[usage++] = GLfloat(c - CHAR_OFFSET);
+ vertices[usage++] = GLfloat(c - CHARACTER_OFFSET);
vertices[usage++] = 0.0f;
vertices[usage++] = x + delta_x;
vertices[usage++] = y + delta_y;
- vertices[usage++] = GLfloat(c - CHAR_OFFSET + 1);
+ vertices[usage++] = GLfloat(c - CHARACTER_OFFSET + 1);
vertices[usage++] = 1.0f;
vertices[usage++] = x;
vertices[usage++] = y + delta_y;
- vertices[usage++] = GLfloat(c - CHAR_OFFSET);
+ vertices[usage++] = GLfloat(c - CHARACTER_OFFSET);
vertices[usage++] = 1.0f;
x += delta_x + border_x;