Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #11 (memory leak) and #52 ("gl_" are reserved) #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions NonEuclidean/FrameBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ FrameBuffer::FrameBuffer() {
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}

FrameBuffer::~FrameBuffer()
{
glDeleteRenderbuffersEXT(1, &renderBuf);
glDeleteFramebuffersEXT(1, &fbo);
glDeleteTextures(1, &texId);
}

void FrameBuffer::Use() {
glBindTexture(GL_TEXTURE_2D, texId);
}
Expand Down
2 changes: 1 addition & 1 deletion NonEuclidean/FrameBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Portal;
class FrameBuffer {
public:
FrameBuffer();

~FrameBuffer();
void Render(const Camera& cam, GLuint curFBO, const Portal* skipPortal);
void Use();

Expand Down
4 changes: 2 additions & 2 deletions NonEuclidean/Shaders/pink.frag
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ precision highp float;
uniform sampler2D tex;

//Outputs
out vec4 gl_FragColor;
out vec4 FragColor;

void main(void) {
gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0);
FragColor = vec4(1.0, 0.0, 1.0, 1.0);
}
4 changes: 2 additions & 2 deletions NonEuclidean/Shaders/portal.frag
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ uniform sampler2D tex;
in vec4 ex_uv;

//Outputs
out vec4 gl_FragColor;
out vec4 FragColor;

void main(void) {
vec2 uv = (ex_uv.xy / ex_uv.w);
uv = uv*0.5 + 0.5;
gl_FragColor = vec4(texture2D(tex, uv).rgb, 1.0);
FragColor = vec4(texture2D(tex, uv).rgb, 1.0);
}
4 changes: 2 additions & 2 deletions NonEuclidean/Shaders/sky.frag
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ precision highp float;
in vec3 ex_normal;

//Outputs
out vec4 gl_FragColor;
out vec4 FragColor;

void main(void) {
vec3 n = normalize(ex_normal);
Expand All @@ -20,5 +20,5 @@ void main(void) {
float s = dot(n, LIGHT) - 1.0 + SUN_SIZE;
float sun = min(exp(s * SUN_SHARPNESS / SUN_SIZE), 1.0);

gl_FragColor = vec4(max(sky, sun), 1.0);
FragColor = vec4(max(sky, sun), 1.0);
}
4 changes: 2 additions & 2 deletions NonEuclidean/Shaders/texture.frag
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ in vec2 ex_uv;
in vec3 ex_normal;

//Outputs
out vec4 gl_FragColor;
out vec4 FragColor;

void main(void) {
float s = dot(ex_normal, LIGHT)*0.5 + 0.5;
gl_FragColor = vec4(texture(tex, ex_uv).rgb * s, 1.0);
FragColor = vec4(texture(tex, ex_uv).rgb * s, 1.0);
}
4 changes: 2 additions & 2 deletions NonEuclidean/Shaders/texture_array.frag
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ in vec3 ex_uv;
in vec3 ex_normal;

//Outputs
out vec4 gl_FragColor;
out vec4 FragColor;

void main(void) {
float s = dot(ex_normal, LIGHT)*0.25 + 0.75;
gl_FragColor = vec4(texture(tex, ex_uv).rgb * s, 1.0);
FragColor = vec4(texture(tex, ex_uv).rgb * s, 1.0);
}
5 changes: 5 additions & 0 deletions NonEuclidean/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ Texture::Texture(const char* fname, int rows, int cols) {
delete[] img;
}

Texture::~Texture()
{
glDeleteTextures(1, &texId);
}

void Texture::Use() {
if (is3D) {
glBindTexture(GL_TEXTURE_2D_ARRAY, texId);
Expand Down
2 changes: 1 addition & 1 deletion NonEuclidean/Texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class Texture {
public:
Texture(const char* fname, int rows, int cols);

~Texture();
void Use();

private:
Expand Down