12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- /******************************************************************************
- Copyright (C) 2013 by Hugh Bailey <[email protected]>
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- ******************************************************************************/
- #ifndef GL_HELPERS_H
- #define GL_HELPERS_H
- /*
- * Okay, so GL error handling is.. unclean to work with. I don't want
- * to have to keep typing out the same stuff over and over again do I'll just
- * make a bunch of helper functions to make it a bit easier to handle errors
- */
- static inline bool gl_success(const char *funcname)
- {
- GLenum errorcode = glGetError();
- if (errorcode != GL_NO_ERROR) {
- blog(LOG_ERROR, "%s failed, glGetError returned %u",
- funcname, errorcode);
- return false;
- }
- return true;
- }
- static inline bool gl_gen_textures(GLsizei num_texture, GLuint *textures)
- {
- glGenTextures(num_texture, textures);
- return gl_success("glGenTextures");
- }
- static inline bool gl_bind_texture(GLenum target, GLuint texture)
- {
- glBindTexture(target, texture);
- return gl_success("glBindTexture");
- }
- static inline bool gl_gen_buffers(GLsizei num_buffers, GLuint *buffers)
- {
- glGenBuffers(num_buffers, buffers);
- return gl_success("glGenBuffers");
- }
- static inline bool gl_bind_buffer(GLenum target, GLuint buffer)
- {
- glBindBuffer(target, buffer);
- return gl_success("glBindBuffer");
- }
- static inline bool gl_bind_renderbuffer(GLenum target, GLuint buffer)
- {
- glBindRenderbuffer(target, buffer);
- return gl_success("glBindRendebuffer");
- }
- extern bool upload_face(GLenum type, uint32_t num_levels,
- GLenum format, GLint internal_format, bool compressed,
- uint32_t width, uint32_t height, uint32_t size, void ***p_data);
- #endif
|