소스 검색

got rid of a memory leak

naelstrof 7 년 전
부모
커밋
2fbfd34067
3개의 변경된 파일1개의 추가작업 그리고 25개의 파일을 삭제
  1. 0
    20
      src/shader.cpp
  2. 0
    1
      src/shader.hpp
  3. 1
    4
      src/window.cpp

+ 0
- 20
src/shader.cpp 파일 보기

@@ -3,7 +3,6 @@
3 3
 Shader::Shader( std::string vert, std::string frag) {
4 4
     vert = resource->getRealPath(vert);
5 5
     frag = resource->getRealPath(frag);
6
-    m_good = false;
7 6
     // Create the program to link to.
8 7
     m_program = glCreateProgram();
9 8
 
@@ -64,7 +63,6 @@ Shader::Shader( std::string vert, std::string frag) {
64 63
     // Clean up :)
65 64
     glDeleteShader( vertShader );
66 65
     glDeleteShader( fragShader );
67
-    m_good = true;
68 66
     glUseProgram( 0 );
69 67
 }
70 68
 
@@ -119,45 +117,27 @@ int Shader::link( unsigned int vertshader, unsigned int fragshader, std::string&
119 117
 }
120 118
 
121 119
 unsigned int Shader::getUniformLocation( std::string name ) {
122
-    if ( !m_good ) {
123
-        return 0;
124
-    }
125 120
     glUseProgram( m_program );
126 121
     return glGetUniformLocation( m_program, name.c_str() );
127 122
 }
128 123
 
129 124
 void Shader::setParameter( std::string name, int foo ) {
130
-    if ( !m_good ) {
131
-        return;
132
-    }
133 125
     glUniform1i( getUniformLocation( name ), foo );
134 126
 }
135 127
 
136 128
 void Shader::setParameter( std::string name, float foo ) {
137
-    if ( !m_good ) {
138
-        return;
139
-    }
140 129
     glUniform1f( getUniformLocation( name ), foo );
141 130
 }
142 131
 
143 132
 void Shader::setParameter( std::string name, glm::mat4& foo ) {
144
-    if ( !m_good ) {
145
-        return;
146
-    }
147 133
     glUniformMatrix4fv( getUniformLocation( name ), 1, GL_FALSE, glm::value_ptr( foo ) );
148 134
 }
149 135
 
150 136
 void Shader::setParameter( std::string name, glm::vec4 foo ) {
151
-    if ( !m_good ) {
152
-        return;
153
-    }
154 137
     glUniform4f( getUniformLocation( name ), foo.x, foo.y, foo.z, foo.w );
155 138
 }
156 139
 
157 140
 void Shader::setParameter( std::string name, glm::vec2 foo ) {
158
-    if ( !m_good ) {
159
-        return;
160
-    }
161 141
     glUniform2f( getUniformLocation( name ), foo.x, foo.y );
162 142
 }
163 143
 

+ 0
- 1
src/shader.hpp 파일 보기

@@ -49,7 +49,6 @@ public:
49 49
     void            setAttribute( std::string name, unsigned int buffer, unsigned int stepsize );
50 50
 private:
51 51
     std::vector<unsigned int>   m_activeattribs;
52
-    bool                        m_good;
53 52
     unsigned int                getUniformLocation( std::string );
54 53
     int                         compile( unsigned int shader, std::string& error );
55 54
     int                         link( unsigned int vert, unsigned int frag, std::string& error );

+ 1
- 4
src/window.cpp 파일 보기

@@ -62,12 +62,8 @@ SlopWindow::SlopWindow() {
62 62
     }
63 63
     framebuffer = new Framebuffer( WidthOfScreen( x11->screen ), HeightOfScreen( x11->screen ) );
64 64
 
65
-    // Then we do a basic double clear (double buffered).
66 65
     glViewport( 0, 0, WidthOfScreen( x11->screen ), HeightOfScreen( x11->screen ) );
67 66
     camera = glm::ortho( 0.0f, (float)WidthOfScreen( x11->screen ), (float)HeightOfScreen( x11->screen ), 0.0f, -1.0f, 1.0f);
68
-    glClearColor( 0, 0, 0, 0 );
69
-    glClear( GL_COLOR_BUFFER_BIT );
70
-    display();
71 67
 
72 68
     // Make it so all input falls through
73 69
     XRectangle rect;
@@ -87,6 +83,7 @@ SlopWindow::~SlopWindow() {
87 83
     glClearColor( 0, 0, 0, 0 );
88 84
     glClear( GL_COLOR_BUFFER_BIT );
89 85
     display();
86
+    glXDestroyContext( x11->display, context );
90 87
     XDestroyWindow( x11->display, window );
91 88
 }
92 89