void CGGD::OpenGL::ErrorTest(const ErrorCode& errorCode) { if(!IsSuccessful(errorCode)) { throw OpenGL::Exception(errorCode); } }
//---------------------------------------------------------------------------- GLuint OpenGL::CreateBuffer (GLenum type, int numElements, int stride, GLenum usage, const GLvoid* initialData) { GLuint buffer = 0; glGenBuffers(1, &buffer); glBindBuffer(type, buffer); glBufferData(type, numElements*stride, initialData, usage); glBindBuffer(type, 0); if (!IsSuccessful()) { glDeleteBuffers(1, &buffer); assertion(false, "CreateBuffer failed.\n"); return 0; } return buffer; }
//---------------------------------------------------------------------------- GLuint OpenGL::CreateTexture2D (int width, int height, GLenum format, GLint internalFormat, GLenum type, const GLvoid* initialData) { GLuint texture = 0; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, type, initialData); glBindTexture(GL_TEXTURE_2D, 0); if (!IsSuccessful()) { glDeleteTextures(1, &texture); assertion(false, "CreateTexture2D failed.\n"); return 0; } return texture; }