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_
33 __gl_calllists_size(GLsizei n, GLenum type)
38 case GL_UNSIGNED_BYTE:
43 case GL_UNSIGNED_SHORT:
64 __gl_image_size(GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth, GLint border) {
73 case GL_DEPTH_COMPONENT:
74 case GL_STENCIL_INDEX:
77 case GL_LUMINANCE_ALPHA:
94 size_t bits_per_pixel;
100 case GL_UNSIGNED_BYTE:
101 bits_per_pixel = 8 * num_channels;
104 case GL_UNSIGNED_SHORT:
105 bits_per_pixel = 16 * num_channels;
108 case GL_UNSIGNED_INT:
110 bits_per_pixel = 32 * num_channels;
112 case GL_UNSIGNED_BYTE_3_3_2:
113 case GL_UNSIGNED_BYTE_2_3_3_REV:
114 case GL_UNSIGNED_SHORT_5_6_5:
115 case GL_UNSIGNED_SHORT_5_6_5_REV:
118 case GL_UNSIGNED_SHORT_4_4_4_4:
119 case GL_UNSIGNED_SHORT_4_4_4_4_REV:
120 case GL_UNSIGNED_SHORT_5_5_5_1:
121 case GL_UNSIGNED_SHORT_1_5_5_5_REV:
124 case GL_UNSIGNED_INT_8_8_8_8:
125 case GL_UNSIGNED_INT_8_8_8_8_REV:
126 case GL_UNSIGNED_INT_10_10_10_2:
127 case GL_UNSIGNED_INT_2_10_10_10_REV:
136 /* FIXME: consider glPixelStore settings */
138 size_t row_stride = (width*bits_per_pixel + 7)/8;
140 size_t slice_stride = height*row_stride;
142 return depth*slice_stride;
146 __gl_bitmap_size(GLsizei width, GLsizei height) {
147 return __gl_image_size(GL_COLOR_INDEX, GL_BITMAP, width, height, 1, 0);
150 #endif /* _GL_HELPERS_HPP_ */