1 /**************************************************************************
3 * Copyright 2010 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 **************************************************************************/
26 #ifndef _GL_HELPERS_HPP_
27 #define _GL_HELPERS_HPP_
32 #include "glimports.hpp"
36 __gl_calllists_size(GLsizei n, GLenum type)
41 case GL_UNSIGNED_BYTE:
46 case GL_UNSIGNED_SHORT:
67 __gl_image_size(GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth, GLint border) {
76 case GL_DEPTH_COMPONENT:
77 case GL_STENCIL_INDEX:
80 case GL_LUMINANCE_ALPHA:
97 size_t bits_per_pixel;
103 case GL_UNSIGNED_BYTE:
104 bits_per_pixel = 8 * num_channels;
107 case GL_UNSIGNED_SHORT:
108 bits_per_pixel = 16 * num_channels;
111 case GL_UNSIGNED_INT:
113 bits_per_pixel = 32 * num_channels;
115 case GL_UNSIGNED_BYTE_3_3_2:
116 case GL_UNSIGNED_BYTE_2_3_3_REV:
117 case GL_UNSIGNED_SHORT_5_6_5:
118 case GL_UNSIGNED_SHORT_5_6_5_REV:
121 case GL_UNSIGNED_SHORT_4_4_4_4:
122 case GL_UNSIGNED_SHORT_4_4_4_4_REV:
123 case GL_UNSIGNED_SHORT_5_5_5_1:
124 case GL_UNSIGNED_SHORT_1_5_5_5_REV:
127 case GL_UNSIGNED_INT_8_8_8_8:
128 case GL_UNSIGNED_INT_8_8_8_8_REV:
129 case GL_UNSIGNED_INT_10_10_10_2:
130 case GL_UNSIGNED_INT_2_10_10_10_REV:
139 /* FIXME: consider glPixelStore settings */
141 size_t row_stride = (width*bits_per_pixel + 7)/8;
143 size_t slice_stride = height*row_stride;
145 return depth*slice_stride;
149 __gl_bitmap_size(GLsizei width, GLsizei height) {
150 return __gl_image_size(GL_COLOR_INDEX, GL_BITMAP, width, height, 1, 0);
153 #endif /* _GL_HELPERS_HPP_ */