comparison libvo/vo_gl.c @ 14078:c4033dcb986f

More similar code from gl and gl2 moved to gl_common
author reimar
date Wed, 01 Dec 2004 17:05:58 +0000
parents 9e331a5299b2
children 718ec28220d6
comparison
equal deleted inserted replaced
14077:3d3f3cc8494a 14078:c4033dcb986f
1 #define TEXTUREFORMAT_ALWAYS GL_RGB8
2
3 #include <stdio.h> 1 #include <stdio.h>
4 #include <stdlib.h> 2 #include <stdlib.h>
5 #include <string.h> 3 #include <string.h>
6 #include <math.h> 4 #include <math.h>
7 #include <errno.h> 5 #include <errno.h>
102 #endif 100 #endif
103 vo_osd_changed(OSDTYPE_OSD); 101 vo_osd_changed(OSDTYPE_OSD);
104 } 102 }
105 } 103 }
106 104
107 static int find_gl_format (uint32_t format)
108 {
109 image_bytes = (IMGFMT_RGB_DEPTH(format)+7)/8;
110 gl_texfmt = 3;
111 switch (format) {
112 case IMGFMT_RGB24:
113 gl_format = GL_RGB;
114 gl_type = GL_UNSIGNED_BYTE;
115 break;
116 case IMGFMT_RGBA:
117 gl_texfmt = 4;
118 gl_format = GL_RGBA;
119 gl_type = GL_UNSIGNED_BYTE;
120 break;
121 case IMGFMT_Y800:
122 case IMGFMT_Y8:
123 gl_texfmt = 1;
124 image_bytes = 1;
125 gl_format = GL_LUMINANCE;
126 gl_type = GL_UNSIGNED_BYTE;
127 break;
128 #ifdef GL_VERSION_1_2
129 #if 0
130 // we do not support palettized formats, although the format the
131 // swscale produces works
132 case IMGFMT_RGB8:
133 gl_format = GL_RGB;
134 gl_type = GL_UNSIGNED_BYTE_2_3_3_REV;
135 break;
136 #endif
137 case IMGFMT_RGB15:
138 gl_format = GL_RGBA;
139 gl_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
140 break;
141 case IMGFMT_RGB16:
142 gl_format = GL_RGB;
143 gl_type = GL_UNSIGNED_SHORT_5_6_5_REV;
144 break;
145 #if 0
146 case IMGFMT_BGR8:
147 // special case as red and blue have a differen number of bits.
148 // GL_BGR and GL_UNSIGNED_BYTE_3_3_2 isn't supported at least
149 // by nVidia drivers, and in addition would give more bits to
150 // blue than to red, which isn't wanted
151 gl_format = GL_RGB;
152 gl_type = GL_UNSIGNED_BYTE_3_3_2;
153 break;
154 #endif
155 case IMGFMT_BGR15:
156 gl_format = GL_BGRA;
157 gl_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
158 break;
159 case IMGFMT_BGR16:
160 gl_format = GL_RGB;
161 gl_type = GL_UNSIGNED_SHORT_5_6_5;
162 break;
163 case IMGFMT_BGR24:
164 gl_format = GL_BGR;
165 gl_type = GL_UNSIGNED_BYTE;
166 break;
167 case IMGFMT_BGRA:
168 gl_texfmt = 4;
169 gl_format = GL_BGRA;
170 gl_type = GL_UNSIGNED_BYTE;
171 break;
172 #endif
173 default:
174 gl_texfmt = 4;
175 gl_format = GL_RGBA;
176 gl_type = GL_UNSIGNED_BYTE;
177 return 0;
178 }
179 #ifdef TEXTUREFORMAT_ALWAYS
180 gl_texfmt = TEXTUREFORMAT_ALWAYS;
181 #endif
182 return 1;
183 }
184
185 /** 105 /**
186 * \brief Initialize a (new or reused) OpenGL context. 106 * \brief Initialize a (new or reused) OpenGL context.
187 */ 107 */
188 static int initGl(uint32_t d_width, uint32_t d_height) { 108 static int initGl(uint32_t d_width, uint32_t d_height) {
189 unsigned char *ImageData = NULL; 109 unsigned char *ImageData = NULL;
228 static uint32_t 148 static uint32_t
229 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) 149 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
230 { 150 {
231 image_height = height; 151 image_height = height;
232 image_width = width; 152 image_width = width;
233 find_gl_format (format); 153 glFindFormat(format, &image_bytes, &gl_texfmt, &gl_format, &gl_type);
154 image_bytes = (image_bytes + 7) / 8;
234 155
235 sub_bg_alpha = 255; // We need alpha = 255 for invisible part of the OSD 156 sub_bg_alpha = 255; // We need alpha = 255 for invisible part of the OSD
236 int_pause = 0; 157 int_pause = 0;
237 158
238 panscan_init(); 159 panscan_init();
527 int caps = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; 448 int caps = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
528 if (use_osd) 449 if (use_osd)
529 caps |= VFCAP_OSD; 450 caps |= VFCAP_OSD;
530 if ((format == IMGFMT_RGB24) || (format == IMGFMT_RGBA)) 451 if ((format == IMGFMT_RGB24) || (format == IMGFMT_RGBA))
531 return caps; 452 return caps;
532 if (many_fmts && find_gl_format(format)) 453 if (many_fmts &&
454 glFindFormat(format, NULL, NULL, NULL, NULL))
533 return caps; 455 return caps;
534 return 0; 456 return 0;
535 } 457 }
536 458
537 459