summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-02-13 23:00:10 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-02-13 23:00:10 -0500
commit224645d1071c14b4829dbb3ae35870868fcff85a (patch)
treef84f540eee09315eb0a689c523946ffa03f4fea0 /src
parent3df19e45e737a1b9395a9a258e3263e444ebedd7 (diff)
downloadtherapy-224645d1071c14b4829dbb3ae35870868fcff85a.tar.gz
therapy-224645d1071c14b4829dbb3ae35870868fcff85a.tar.bz2
therapy-224645d1071c14b4829dbb3ae35870868fcff85a.zip
Fixed inconsistent rendering failure
The issue appears to have been caused by blending with unset alpha channels.

Also included the re-ordered player character sprite image.

The CMake file has been updated to include linking against some Apple libraries that are usually already included in GLFW3.

refs #1
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp2
-rw-r--r--src/renderer.cpp34
2 files changed, 18 insertions, 18 deletions
diff --git a/src/game.cpp b/src/game.cpp index 39bb3f1..1182689 100644 --- a/src/game.cpp +++ b/src/game.cpp
@@ -40,7 +40,7 @@ Game::Game(
40 40
41 int player = entityManager_.emplaceEntity(); 41 int player = entityManager_.emplaceEntity();
42 42
43 AnimationSet playerGraphics {"res/Starla2.bmp", 10, 12, 6}; 43 AnimationSet playerGraphics {"res/Starla.png", 10, 12, 6};
44 playerGraphics.emplaceAnimation("stillLeft", 3, 1, 1); 44 playerGraphics.emplaceAnimation("stillLeft", 3, 1, 1);
45 playerGraphics.emplaceAnimation("stillRight", 0, 1, 1); 45 playerGraphics.emplaceAnimation("stillRight", 0, 1, 1);
46 playerGraphics.emplaceAnimation("walkingLeft", 4, 2, 10); 46 playerGraphics.emplaceAnimation("walkingLeft", 4, 2, 10);
diff --git a/src/renderer.cpp b/src/renderer.cpp index 3945e09..f840180 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp
@@ -33,8 +33,6 @@ static GLuint bloom1Shader;
33static GLuint bloom2Shader; 33static GLuint bloom2Shader;
34 34
35// The buffers for the NTSC rendering process 35// The buffers for the NTSC rendering process
36static GLuint renderedTex1;
37static GLuint renderedTex2;
38static GLuint renderedTexBufs[2]; 36static GLuint renderedTexBufs[2];
39static int curBuf; 37static int curBuf;
40static GLuint artifactsTex; 38static GLuint artifactsTex;
@@ -148,6 +146,10 @@ void flipImageData(unsigned char* data, int width, int height, int comps)
148 146
149void loadMesh(const char* filename, std::vector<glm::vec3>& out_vertices, std::vector<glm::vec2>& out_uvs, std::vector<glm::vec3>& out_normals) 147void loadMesh(const char* filename, std::vector<glm::vec3>& out_vertices, std::vector<glm::vec2>& out_uvs, std::vector<glm::vec3>& out_normals)
150{ 148{
149 out_vertices.clear();
150 out_uvs.clear();
151 out_normals.clear();
152
151 FILE* file = fopen(filename, "r"); 153 FILE* file = fopen(filename, "r");
152 if (file == nullptr) 154 if (file == nullptr)
153 { 155 {
@@ -308,34 +310,33 @@ GLFWwindow* initRenderer()
308 GLenum DrawBuffers2[1] = {GL_COLOR_ATTACHMENT1}; 310 GLenum DrawBuffers2[1] = {GL_COLOR_ATTACHMENT1};
309 glDrawBuffers(1, DrawBuffers2); 311 glDrawBuffers(1, DrawBuffers2);
310 312
313 glfwGetFramebufferSize(window, &buffer_width, &buffer_height);
314
311 glGenRenderbuffers(1, &bloom_depthbuffer); 315 glGenRenderbuffers(1, &bloom_depthbuffer);
312 glBindRenderbuffer(GL_RENDERBUFFER, bloom_depthbuffer); 316 glBindRenderbuffer(GL_RENDERBUFFER, bloom_depthbuffer);
313 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, 1024, 768); 317 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, buffer_width, buffer_height);
314 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, bloom_depthbuffer); 318 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, bloom_depthbuffer);
315 319
316 // Set up the NTSC rendering buffers 320 // Set up the NTSC rendering buffers
317 glGenTextures(1, &renderedTex1); 321 glGenTextures(2, renderedTexBufs);
318 glBindTexture(GL_TEXTURE_2D, renderedTex1); 322 glBindTexture(GL_TEXTURE_2D, renderedTexBufs[0]);
319 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, GAME_WIDTH, GAME_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); 323 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, GAME_WIDTH, GAME_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
320 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 324 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
321 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 325 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
322 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 326 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
323 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 327 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
324 renderedTexBufs[0] = renderedTex1;
325 328
326 glGenTextures(1, &renderedTex2); 329 glBindTexture(GL_TEXTURE_2D, renderedTexBufs[1]);
327 glBindTexture(GL_TEXTURE_2D, renderedTex2);
328 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, GAME_WIDTH, GAME_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); 330 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, GAME_WIDTH, GAME_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
329 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 331 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
330 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 332 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
331 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 333 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
332 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 334 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
333 renderedTexBufs[1] = renderedTex2;
334 335
335 // Set up bloom rendering buffers 336 // Set up bloom rendering buffers
336 glGenTextures(1, &preBloomTex); 337 glGenTextures(1, &preBloomTex);
337 glBindTexture(GL_TEXTURE_2D, preBloomTex); 338 glBindTexture(GL_TEXTURE_2D, preBloomTex);
338 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1024, 768, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); 339 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, buffer_width, buffer_height, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
339 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 340 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
340 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 341 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
341 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 342 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@@ -343,7 +344,7 @@ GLFWwindow* initRenderer()
343 344
344 glGenTextures(1, &bloomPassTex1); 345 glGenTextures(1, &bloomPassTex1);
345 glBindTexture(GL_TEXTURE_2D, bloomPassTex1); 346 glBindTexture(GL_TEXTURE_2D, bloomPassTex1);
346 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1024/4, 768/4, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); 347 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, buffer_width/4, buffer_height/4, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
347 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 348 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
348 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 349 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
349 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 350 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@@ -351,7 +352,7 @@ GLFWwindow* initRenderer()
351 352
352 glGenTextures(1, &bloomPassTex2); 353 glGenTextures(1, &bloomPassTex2);
353 glBindTexture(GL_TEXTURE_2D, bloomPassTex2); 354 glBindTexture(GL_TEXTURE_2D, bloomPassTex2);
354 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1024/4, 768/4, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); 355 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, buffer_width/4, buffer_height/4, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
355 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 356 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
356 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 357 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
357 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 358 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@@ -370,15 +371,15 @@ GLFWwindow* initRenderer()
370 371
371 glGenBuffers(1, &mesh_vertexbuffer); 372 glGenBuffers(1, &mesh_vertexbuffer);
372 glBindBuffer(GL_ARRAY_BUFFER, mesh_vertexbuffer); 373 glBindBuffer(GL_ARRAY_BUFFER, mesh_vertexbuffer);
373 glBufferData(GL_ARRAY_BUFFER, mesh_vertices.size() * sizeof(glm::vec3), &mesh_vertices[0], GL_STATIC_DRAW); 374 glBufferData(GL_ARRAY_BUFFER, mesh_vertices.size() * sizeof(glm::vec3), mesh_vertices.data(), GL_STATIC_DRAW);
374 375
375 glGenBuffers(1, &mesh_uvbuffer); 376 glGenBuffers(1, &mesh_uvbuffer);
376 glBindBuffer(GL_ARRAY_BUFFER, mesh_uvbuffer); 377 glBindBuffer(GL_ARRAY_BUFFER, mesh_uvbuffer);
377 glBufferData(GL_ARRAY_BUFFER, mesh_uvs.size() * sizeof(glm::vec3), &mesh_uvs[0], GL_STATIC_DRAW); 378 glBufferData(GL_ARRAY_BUFFER, mesh_uvs.size() * sizeof(glm::vec2), mesh_uvs.data(), GL_STATIC_DRAW);
378 379
379 glGenBuffers(1, &mesh_normalbuffer); 380 glGenBuffers(1, &mesh_normalbuffer);
380 glBindBuffer(GL_ARRAY_BUFFER, mesh_normalbuffer); 381 glBindBuffer(GL_ARRAY_BUFFER, mesh_normalbuffer);
381 glBufferData(GL_ARRAY_BUFFER, mesh_normals.size() * sizeof(glm::vec3), &mesh_normals[0], GL_STATIC_DRAW); 382 glBufferData(GL_ARRAY_BUFFER, mesh_normals.size() * sizeof(glm::vec3), mesh_normals.data(), GL_STATIC_DRAW);
382 383
383 // Load the vertices of a flat surface 384 // Load the vertices of a flat surface
384 GLfloat g_quad_vertex_buffer_data[] = { 385 GLfloat g_quad_vertex_buffer_data[] = {
@@ -452,8 +453,7 @@ void destroyRenderer()
452 glDeleteProgram(bloom2Shader); 453 glDeleteProgram(bloom2Shader);
453 454
454 // Delete the NTSC rendering buffers 455 // Delete the NTSC rendering buffers
455 glDeleteTextures(1, &renderedTex1); 456 glDeleteTextures(2, renderedTexBufs);
456 glDeleteTextures(1, &renderedTex2);
457 glDeleteTextures(1, &artifactsTex); 457 glDeleteTextures(1, &artifactsTex);
458 glDeleteTextures(1, &scanlinesTex); 458 glDeleteTextures(1, &scanlinesTex);
459 glDeleteTextures(1, &preBloomTex); 459 glDeleteTextures(1, &preBloomTex);