Quantcast
Channel: Visual Leak Detector for Visual C++ 2008-2015
Viewing all articles
Browse latest Browse all 704

New Post: leak in GLSL shader...

$
0
0
Hi!

Been getting 2 leaks because of vertexShaderSource and fragmentShaderSource but have been able to delete them using:
delete[] vertexShaderSource;
delete[] fragmentShaderSource;
Been getting HEAP CORRUPTION despite by best efforts.

Is this a known problem with shaders because of glDeleteShader? Please, let me know.

Thank you !
bool Shader::loadShader(std::string shaderName, ShaderType shaderType, const char* vertexShaderFile, const char* fragmentShaderFile) {

GLuint vertexShaderID, fragmentShaderID;

m_shaderType = shaderType;

m_shaderID = glCreateProgram();

seekShader(vertexShaderFile);
char* vertexShaderSource = new char[m_shaderCodeLenght + 1];
readShader(vertexShaderFile, vertexShaderSource);

seekShader(fragmentShaderFile);
char* fragmentShaderSource = new char[m_shaderCodeLenght + 1];
readShader(fragmentShaderFile, fragmentShaderSource);

compileShader(vertexShaderID, GL_VERTEX_SHADER, vertexShaderSource);
compileShader(fragmentShaderID, GL_FRAGMENT_SHADER, fragmentShaderSource);

linkShader(m_shaderID, vertexShaderID, fragmentShaderID);

glDeleteShader(vertexShaderID);
glDeleteShader(fragmentShaderID);

delete[] vertexShaderSource;    // ???
delete[] fragmentShaderSource;    // ???

glUseProgram(0);

return true;
}

Viewing all articles
Browse latest Browse all 704

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>