Commits

Jason McKesson committed e9e847e

Issue #53: Delete shader objects properly.

Comments (0)

Files changed (3)

Tut 01 Hello Triangle/tut1.cpp

 
+#include <algorithm>
 #include <string>
 #include <vector>
 #include <stdio.h>
 		delete[] strInfoLog;
 	}
 
+	for(size_t iLoop = 0; iLoop < shaderList.size(); iLoop++)
+		glDetachShader(program, shaderList[iLoop]);
+
 	return program;
 }
 
 	shaderList.push_back(CreateShader(GL_FRAGMENT_SHADER, strFragmentShader));
 
 	theProgram = CreateProgram(shaderList);
+
+	std::for_each(shaderList.begin(), shaderList.end(), glDeleteShader);
 }
 
 const float vertexPositions[] = {

framework/framework.cpp

 
+#include <algorithm>
 #include <string>
 #include <vector>
 #include <fstream>
 			fprintf(stderr, e.what());
 			throw;
 		}
+
+		std::for_each(shaderList.begin(), shaderList.end(), glDeleteShader);
 	}
 
 	float DegToRad(float fAngDeg)

framework/framework.h

 	GLuint CreateShader(GLenum eShaderType,
 		const std::string &strShaderFile, const std::string &strShaderName);
 	GLuint LoadShader(GLenum eShaderType, const std::string &strShaderFilename);
+
+	//Will *delete* the shaders given.
 	GLuint CreateProgram(const std::vector<GLuint> &shaderList);
 
 	//Will find a file with the given base filename, either in the local directory or the global one.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.