Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bugzilla DB migration completed. Please report issues to Infra team via email via infra@gentoo.org or IRC
View | Details | Raw Unified | Return to bug 637986
Collapse All | Expand All

(-)dolphin-5.0-orig/Source/Core/VideoBackends/OGL/RasterFont.cpp (-22 / +22 lines)
Lines 15-26 Link Here
15
namespace OGL
15
namespace OGL
16
{
16
{
17
17
18
static const int CHAR_WIDTH = 8;
18
static const int CHARACTER_WIDTH = 8;
19
static const int CHAR_HEIGHT = 13;
19
static const int CHARACTER_HEIGHT = 13;
20
static const int CHAR_OFFSET = 32;
20
static const int CHARACTER_OFFSET = 32;
21
static const int CHAR_COUNT = 95;
21
static const int CHARACTER_COUNT = 95;
22
22
23
static const u8 rasters[CHAR_COUNT][CHAR_HEIGHT] = {
23
static const u8 rasters[CHARACTER_COUNT][CHARACTER_HEIGHT] = {
24
	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
24
	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
25
	{0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18},
25
	{0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18},
26
	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36},
26
	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36},
Lines 146-172 Link Here
146
	glGenTextures(1, &texture);
146
	glGenTextures(1, &texture);
147
	glActiveTexture(GL_TEXTURE8);
147
	glActiveTexture(GL_TEXTURE8);
148
	glBindTexture(GL_TEXTURE_2D, texture);
148
	glBindTexture(GL_TEXTURE_2D, texture);
149
	std::vector<u32> texture_data(CHAR_WIDTH * CHAR_COUNT * CHAR_HEIGHT);
149
	std::vector<u32> texture_data(CHARACTER_WIDTH * CHARACTER_COUNT * CHARACTER_HEIGHT);
150
	for (int y = 0; y < CHAR_HEIGHT; y++)
150
	for (int y = 0; y < CHARACTER_HEIGHT; y++)
151
	{
151
	{
152
		for (int c = 0; c < CHAR_COUNT; c++)
152
		for (int c = 0; c < CHARACTER_COUNT; c++)
153
		{
153
		{
154
			for (int x = 0; x < CHAR_WIDTH; x++)
154
			for (int x = 0; x < CHARACTER_WIDTH; x++)
155
			{
155
			{
156
				bool pixel = (0 != (rasters[c][y] & (1 << (CHAR_WIDTH - x - 1))));
156
				bool pixel = (0 != (rasters[c][y] & (1 << (CHARACTER_WIDTH - x - 1))));
157
				texture_data[CHAR_WIDTH * CHAR_COUNT * y + CHAR_WIDTH * c + x] = pixel ? -1 : 0;
157
				texture_data[CHARACTER_WIDTH * CHARACTER_COUNT * y + CHARACTER_WIDTH * c + x] = pixel ? -1 : 0;
158
			}
158
			}
159
		}
159
		}
160
	}
160
	}
161
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
161
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
162
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, CHAR_WIDTH * CHAR_COUNT, CHAR_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture_data.data());
162
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, CHARACTER_WIDTH * CHARACTER_COUNT, CHARACTER_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture_data.data());
163
163
164
	// generate shader
164
	// generate shader
165
	ProgramShaderCache::CompileShader(s_shader, s_vertexShaderSrc, s_fragmentShaderSrc);
165
	ProgramShaderCache::CompileShader(s_shader, s_vertexShaderSrc, s_fragmentShaderSrc);
166
	s_shader.Bind();
166
	s_shader.Bind();
167
167
168
	// bound uniforms
168
	// bound uniforms
169
	glUniform2f(glGetUniformLocation(s_shader.glprogid,"charSize"), 1.0f / GLfloat(CHAR_COUNT), 1.0f);
169
	glUniform2f(glGetUniformLocation(s_shader.glprogid,"charSize"), 1.0f / GLfloat(CHARACTER_COUNT), 1.0f);
170
	uniform_color_id = glGetUniformLocation(s_shader.glprogid,"color");
170
	uniform_color_id = glGetUniformLocation(s_shader.glprogid,"color");
171
	glUniform4f(uniform_color_id, 1.0f, 1.0f, 1.0f, 1.0f);
171
	glUniform4f(uniform_color_id, 1.0f, 1.0f, 1.0f, 1.0f);
172
	uniform_offset_id = glGetUniformLocation(s_shader.glprogid, "offset");
172
	uniform_offset_id = glGetUniformLocation(s_shader.glprogid, "offset");
Lines 196-203 Link Here
196
	std::vector<GLfloat> vertices(text.length() * 6 * 4);
196
	std::vector<GLfloat> vertices(text.length() * 6 * 4);
197
197
198
	int usage = 0;
198
	int usage = 0;
199
	GLfloat delta_x = GLfloat(2 * CHAR_WIDTH) / GLfloat(bbWidth);
199
	GLfloat delta_x = GLfloat(2 * CHARACTER_WIDTH) / GLfloat(bbWidth);
200
	GLfloat delta_y = GLfloat(2 * CHAR_HEIGHT) / GLfloat(bbHeight);
200
	GLfloat delta_y = GLfloat(2 * CHARACTER_HEIGHT) / GLfloat(bbHeight);
201
	GLfloat border_x = 2.0f / GLfloat(bbWidth);
201
	GLfloat border_x = 2.0f / GLfloat(bbWidth);
202
	GLfloat border_y = 4.0f / GLfloat(bbHeight);
202
	GLfloat border_y = 4.0f / GLfloat(bbHeight);
203
203
Lines 220-256 Link Here
220
			continue;
220
			continue;
221
		}
221
		}
222
222
223
		if (c < CHAR_OFFSET || c >= CHAR_COUNT + CHAR_OFFSET)
223
		if (c < CHARACTER_OFFSET || c >= CHARACTER_COUNT + CHARACTER_OFFSET)
224
			continue;
224
			continue;
225
225
226
		vertices[usage++] = x;
226
		vertices[usage++] = x;
227
		vertices[usage++] = y;
227
		vertices[usage++] = y;
228
		vertices[usage++] = GLfloat(c - CHAR_OFFSET);
228
		vertices[usage++] = GLfloat(c - CHARACTER_OFFSET);
229
		vertices[usage++] = 0.0f;
229
		vertices[usage++] = 0.0f;
230
230
231
		vertices[usage++] = x + delta_x;
231
		vertices[usage++] = x + delta_x;
232
		vertices[usage++] = y;
232
		vertices[usage++] = y;
233
		vertices[usage++] = GLfloat(c - CHAR_OFFSET + 1);
233
		vertices[usage++] = GLfloat(c - CHARACTER_OFFSET + 1);
234
		vertices[usage++] = 0.0f;
234
		vertices[usage++] = 0.0f;
235
235
236
		vertices[usage++] = x + delta_x;
236
		vertices[usage++] = x + delta_x;
237
		vertices[usage++] = y + delta_y;
237
		vertices[usage++] = y + delta_y;
238
		vertices[usage++] = GLfloat(c - CHAR_OFFSET + 1);
238
		vertices[usage++] = GLfloat(c - CHARACTER_OFFSET + 1);
239
		vertices[usage++] = 1.0f;
239
		vertices[usage++] = 1.0f;
240
240
241
		vertices[usage++] = x;
241
		vertices[usage++] = x;
242
		vertices[usage++] = y;
242
		vertices[usage++] = y;
243
		vertices[usage++] = GLfloat(c - CHAR_OFFSET);
243
		vertices[usage++] = GLfloat(c - CHARACTER_OFFSET);
244
		vertices[usage++] = 0.0f;
244
		vertices[usage++] = 0.0f;
245
245
246
		vertices[usage++] = x + delta_x;
246
		vertices[usage++] = x + delta_x;
247
		vertices[usage++] = y + delta_y;
247
		vertices[usage++] = y + delta_y;
248
		vertices[usage++] = GLfloat(c - CHAR_OFFSET + 1);
248
		vertices[usage++] = GLfloat(c - CHARACTER_OFFSET + 1);
249
		vertices[usage++] = 1.0f;
249
		vertices[usage++] = 1.0f;
250
250
251
		vertices[usage++] = x;
251
		vertices[usage++] = x;
252
		vertices[usage++] = y + delta_y;
252
		vertices[usage++] = y + delta_y;
253
		vertices[usage++] = GLfloat(c - CHAR_OFFSET);
253
		vertices[usage++] = GLfloat(c - CHARACTER_OFFSET);
254
		vertices[usage++] = 1.0f;
254
		vertices[usage++] = 1.0f;
255
255
256
		x += delta_x + border_x;
256
		x += delta_x + border_x;

Return to bug 637986