annotate libvo/gl_common.c @ 14348:c3d49ffa01fd

Extend copyright to 2005, typos.
author diego
date Tue, 04 Jan 2005 01:06:00 +0000
parents 718ec28220d6
children 629c54dc7e0d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13653
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
1 #include "gl_common.h"
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
2
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
3 /**
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
4 * \brief adjusts the GL_UNPACK_ALGNMENT to fit the stride.
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
5 * \param stride number of bytes per line for which alignment should fit.
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
6 */
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
7 void glAdjustAlignment(int stride) {
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
8 GLint gl_alignment;
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
9 if (stride % 8 == 0)
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
10 gl_alignment=8;
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
11 else if (stride % 4 == 0)
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
12 gl_alignment=4;
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
13 else if (stride % 2 == 0)
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
14 gl_alignment=2;
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
15 else
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
16 gl_alignment=1;
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
17 glPixelStorei (GL_UNPACK_ALIGNMENT, gl_alignment);
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
18 }
799f81d3cb19 added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff changeset
19
14078
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
20 #include "img_format.h"
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
21
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
22 struct gl_name_map_struct {
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
23 GLint value;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
24 char *name;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
25 };
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
26
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
27 #undef MAP
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
28 #define MAP(a) {a, #a}
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
29 static const struct gl_name_map_struct gl_name_map[] = {
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
30 // internal format
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
31 MAP(GL_R3_G3_B2), MAP(GL_RGB4), MAP(GL_RGB5), MAP(GL_RGB8),
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
32 MAP(GL_RGB10), MAP(GL_RGB12), MAP(GL_RGB16), MAP(GL_RGBA2),
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
33 MAP(GL_RGBA4), MAP(GL_RGB5_A1), MAP(GL_RGBA8), MAP(GL_RGB10_A2),
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
34 MAP(GL_RGBA12), MAP(GL_RGBA16), MAP(GL_LUMINANCE8),
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
35
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
36 // format
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
37 MAP(GL_RGB), MAP(GL_RGBA), MAP(GL_RED), MAP(GL_GREEN), MAP(GL_BLUE),
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
38 MAP(GL_ALPHA), MAP(GL_LUMINANCE), MAP(GL_LUMINANCE_ALPHA),
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
39 MAP(GL_COLOR_INDEX),
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
40 // rest 1.2 only
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
41 #ifdef GL_VERSION_1_2
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
42 MAP(GL_BGR), MAP(GL_BGRA),
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
43 #endif
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
44
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
45 //type
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
46 MAP(GL_BYTE), MAP(GL_UNSIGNED_BYTE), MAP(GL_SHORT), MAP(GL_UNSIGNED_SHORT),
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
47 MAP(GL_INT), MAP(GL_UNSIGNED_INT), MAP(GL_FLOAT), MAP(GL_DOUBLE),
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
48 MAP(GL_2_BYTES), MAP(GL_3_BYTES), MAP(GL_4_BYTES),
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
49 // rest 1.2 only
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
50 #ifdef GL_VERSION_1_2
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
51 MAP(GL_UNSIGNED_BYTE_3_3_2), MAP(GL_UNSIGNED_BYTE_2_3_3_REV),
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
52 MAP(GL_UNSIGNED_SHORT_5_6_5), MAP(GL_UNSIGNED_SHORT_5_6_5_REV),
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
53 MAP(GL_UNSIGNED_SHORT_4_4_4_4), MAP(GL_UNSIGNED_SHORT_4_4_4_4_REV),
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
54 MAP(GL_UNSIGNED_SHORT_5_5_5_1), MAP(GL_UNSIGNED_SHORT_1_5_5_5_REV),
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
55 MAP(GL_UNSIGNED_INT_8_8_8_8), MAP(GL_UNSIGNED_INT_8_8_8_8_REV),
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
56 MAP(GL_UNSIGNED_INT_10_10_10_2), MAP(GL_UNSIGNED_INT_2_10_10_10_REV),
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
57 #endif
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
58 {0, 0}
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
59 };
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
60 #undef MAP
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
61
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
62 /**
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
63 * \brief return the name of an OpenGL constant
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
64 * \param value the constant
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
65 * \return name of the constant or "Unknown format!"
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
66 */
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
67 const char *glValName(GLint value)
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
68 {
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
69 int i = 0;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
70
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
71 while (gl_name_map[i].name) {
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
72 if (gl_name_map[i].value == value)
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
73 return gl_name_map[i].name;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
74 i++;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
75 }
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
76 return "Unknown format!";
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
77 }
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
78
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
79 #undef TEXTUREFORMAT_ALWAYS
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
80 //! always return this format as internal texture format in glFindFormat
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
81 #define TEXTUREFORMAT_ALWAYS GL_RGB8
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
82
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
83 /**
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
84 * \brief find the OpenGL settings coresponding to format.
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
85 *
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
86 * All parameters may be NULL.
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
87 * \param fmt MPlayer format to analyze.
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
88 * \param bpp [OUT] bits per pixel of that format.
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
89 * \param gl_texfmt [OUT] internal texture format that fits the
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
90 * image format, not necessarily the best for performance.
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
91 * \param gl_format [OUT] OpenGL format for this image format.
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
92 * \param gl_type [OUT] OpenGL type for this image format.
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
93 * \return 1 if format is supported by OpenGL, 0 if not.
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
94 */
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
95 int glFindFormat(uint32_t fmt, uint32_t *bpp, GLenum *gl_texfmt,
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
96 GLenum *gl_format, GLenum *gl_type)
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
97 {
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
98 int dummy1;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
99 GLenum dummy2;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
100 if (bpp == NULL) bpp = &dummy1;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
101 if (gl_texfmt == NULL) gl_texfmt = &dummy2;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
102 if (gl_format == NULL) gl_format = &dummy2;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
103 if (gl_type == NULL) gl_type = &dummy2;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
104
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
105 *bpp = IMGFMT_IS_BGR(fmt)?IMGFMT_BGR_DEPTH(fmt):IMGFMT_RGB_DEPTH(fmt);
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
106 *gl_texfmt = 3;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
107 switch (fmt) {
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
108 case IMGFMT_RGB24:
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
109 *gl_format = GL_RGB;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
110 *gl_type = GL_UNSIGNED_BYTE;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
111 break;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
112 case IMGFMT_RGBA:
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
113 *gl_texfmt = 4;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
114 *gl_format = GL_RGBA;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
115 *gl_type = GL_UNSIGNED_BYTE;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
116 break;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
117 case IMGFMT_Y800:
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
118 case IMGFMT_Y8:
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
119 *gl_texfmt = 1;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
120 *bpp = 8;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
121 *gl_format = GL_LUMINANCE;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
122 *gl_type = GL_UNSIGNED_BYTE;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
123 break;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
124 #ifdef GL_VERSION_1_2
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
125 #if 0
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
126 // we do not support palettized formats, although the format the
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
127 // swscale produces works
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
128 case IMGFMT_RGB8:
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
129 gl_format = GL_RGB;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
130 gl_type = GL_UNSIGNED_BYTE_2_3_3_REV;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
131 break;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
132 #endif
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
133 case IMGFMT_RGB15:
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
134 *gl_format = GL_RGBA;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
135 *gl_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
136 break;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
137 case IMGFMT_RGB16:
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
138 *gl_format = GL_RGB;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
139 *gl_type = GL_UNSIGNED_SHORT_5_6_5_REV;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
140 break;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
141 #if 0
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
142 case IMGFMT_BGR8:
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
143 // special case as red and blue have a differen number of bits.
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
144 // GL_BGR and GL_UNSIGNED_BYTE_3_3_2 isn't supported at least
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
145 // by nVidia drivers, and in addition would give more bits to
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
146 // blue than to red, which isn't wanted
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
147 gl_format = GL_RGB;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
148 gl_type = GL_UNSIGNED_BYTE_3_3_2;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
149 break;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
150 #endif
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
151 case IMGFMT_BGR15:
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
152 *gl_format = GL_BGRA;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
153 *gl_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
154 break;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
155 case IMGFMT_BGR16:
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
156 *gl_format = GL_RGB;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
157 *gl_type = GL_UNSIGNED_SHORT_5_6_5;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
158 break;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
159 case IMGFMT_BGR24:
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
160 *gl_format = GL_BGR;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
161 *gl_type = GL_UNSIGNED_BYTE;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
162 break;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
163 case IMGFMT_BGRA:
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
164 *gl_texfmt = 4;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
165 *gl_format = GL_BGRA;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
166 *gl_type = GL_UNSIGNED_BYTE;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
167 break;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
168 #endif
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
169 default:
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
170 *gl_texfmt = 4;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
171 *gl_format = GL_RGBA;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
172 *gl_type = GL_UNSIGNED_BYTE;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
173 return 0;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
174 }
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
175 #ifdef TEXTUREFORMAT_ALWAYS
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
176 *gl_texfmt = TEXTUREFORMAT_ALWAYS;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
177 #endif
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
178 return 1;
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
179 }
c4033dcb986f More similar code from gl and gl2 moved to gl_common
reimar
parents: 13843
diff changeset
180
14142
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
181 #ifdef GL_WIN32
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
182 int setGlWindow(int *vinfo, HGLRC *context, HWND win)
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
183 {
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
184 int new_vinfo;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
185 HDC windc = GetDC(win);
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
186 HGLRC new_context = 0;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
187 int keep_context = 0;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
188
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
189 // should only be needed when keeping context, but not doing glFinish
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
190 // can cause flickering even when we do not keep it.
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
191 glFinish();
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
192 new_vinfo = GetPixelFormat(windc);
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
193 if (*context && *vinfo && new_vinfo && *vinfo == new_vinfo) {
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
194 // we can keep the wglContext
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
195 new_context = *context;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
196 keep_context = 1;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
197 } else {
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
198 // create a context
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
199 new_context = wglCreateContext(windc);
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
200 if (!new_context) {
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
201 mp_msg(MSGT_VO, MSGL_FATAL, "[gl] Could not create GL context!\n");
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
202 return SET_WINDOW_FAILED;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
203 }
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
204 }
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
205
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
206 // set context
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
207 if (!wglMakeCurrent(windc, new_context)) {
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
208 mp_msg (MSGT_VO, MSGL_FATAL, "[gl] Could not set GL context!\n");
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
209 if (!keep_context) {
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
210 wglDeleteContext(new_context);
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
211 }
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
212 return SET_WINDOW_FAILED;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
213 }
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
214
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
215 // set new values
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
216 vo_window = win;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
217 vo_hdc = windc;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
218 {
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
219 RECT rect;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
220 GetClientRect(win, &rect);
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
221 vo_dwidth = rect.right;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
222 vo_dheight = rect.bottom;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
223 }
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
224 if (!keep_context) {
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
225 if (*context)
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
226 wglDeleteContext(*context);
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
227 *context = new_context;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
228 *vinfo = new_vinfo;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
229
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
230 // and inform that reinit is neccessary
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
231 return SET_WINDOW_REINIT;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
232 }
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
233 return SET_WINDOW_OK;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
234 }
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
235
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
236 void releaseGlContext(int *vinfo, HGLRC *context) {
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
237 *vinfo = 0;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
238 if (*context) {
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
239 wglMakeCurrent(0, 0);
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
240 wglDeleteContext(*context);
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
241 }
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
242 *context = 0;
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
243 }
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 14089
diff changeset
244 #else
13843
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
245 /**
14269
718ec28220d6 Doxygen comments improved
reimar
parents: 14142
diff changeset
246 * \brief Returns the XVisualInfo associated with Window win.
13843
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
247 * \param win Window whose XVisualInfo is returne.
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
248 * \return XVisualInfo of the window. Caller must use XFree to free it.
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
249 */
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
250 static XVisualInfo *getWindowVisualInfo(Window win) {
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
251 XWindowAttributes xw_attr;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
252 XVisualInfo vinfo_template;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
253 int tmp;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
254 XGetWindowAttributes(mDisplay, win, &xw_attr);
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
255 vinfo_template.visualid = XVisualIDFromVisual(xw_attr.visual);
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
256 return XGetVisualInfo(mDisplay, VisualIDMask, &vinfo_template, &tmp);
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
257 }
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
258
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
259 /**
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
260 * \brief Changes the window in which video is displayed.
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
261 * If possible only transfers the context to the new window, otherwise
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
262 * creates a new one, which must be initialized by the caller.
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
263 * \param vinfo Currently used visual.
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
264 * \param context Currently used context.
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
265 * \param win window that should be used for drawing.
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
266 * \return one of SET_WINDOW_FAILED, SET_WINDOW_OK or SET_WINDOW_REINIT.
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
267 * In case of SET_WINDOW_REINIT the context could not be transfered
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
268 * and the caller must initialize it correctly.
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
269 */
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
270 int setGlWindow(XVisualInfo **vinfo, GLXContext *context, Window win)
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
271 {
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
272 XVisualInfo *new_vinfo;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
273 GLXContext new_context = NULL;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
274 int keep_context = 0;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
275
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
276 // should only be needed when keeping context, but not doing glFinish
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
277 // can cause flickering even when we do not keep it.
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
278 glFinish();
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
279 new_vinfo = getWindowVisualInfo(win);
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
280 if (*context && *vinfo && new_vinfo &&
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
281 (*vinfo)->visualid == new_vinfo->visualid) {
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
282 // we can keep the GLXContext
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
283 new_context = *context;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
284 XFree(new_vinfo);
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
285 new_vinfo = *vinfo;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
286 keep_context = 1;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
287 } else {
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
288 // create a context
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
289 new_context = glXCreateContext(mDisplay, new_vinfo, NULL, True);
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
290 if (!new_context) {
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
291 mp_msg(MSGT_VO, MSGL_FATAL, "[gl] Could not create GLX context!\n");
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
292 XFree(new_vinfo);
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
293 return SET_WINDOW_FAILED;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
294 }
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
295 }
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
296
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
297 // set context
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
298 if (!glXMakeCurrent(mDisplay, vo_window, new_context)) {
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
299 mp_msg (MSGT_VO, MSGL_FATAL, "[gl] Could not set GLX context!\n");
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
300 if (!keep_context) {
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
301 glXDestroyContext (mDisplay, new_context);
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
302 XFree(new_vinfo);
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
303 }
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
304 return SET_WINDOW_FAILED;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
305 }
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
306
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
307 // set new values
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
308 vo_window = win;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
309 {
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
310 Window root;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
311 int tmp;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
312 XGetGeometry(mDisplay, vo_window, &root, &tmp, &tmp,
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
313 &vo_dwidth, &vo_dheight, &tmp, &tmp);
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
314 }
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
315 if (!keep_context) {
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
316 if (*context)
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
317 glXDestroyContext(mDisplay, *context);
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
318 *context = new_context;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
319 if (*vinfo)
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
320 XFree(*vinfo);
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
321 *vinfo = new_vinfo;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
322
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
323 // and inform that reinit is neccessary
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
324 return SET_WINDOW_REINIT;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
325 }
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
326 return SET_WINDOW_OK;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
327 }
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
328
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
329 /**
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
330 * \brief free the VisualInfo and GLXContext of an OpenGL context.
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
331 */
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
332 void releaseGlContext(XVisualInfo **vinfo, GLXContext *context) {
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
333 if (*vinfo)
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
334 XFree(*vinfo);
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
335 *vinfo = NULL;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
336 if (*context)
14089
00283cb37fd0 Make the context not current before destroying it.
reimar
parents: 14078
diff changeset
337 {
00283cb37fd0 Make the context not current before destroying it.
reimar
parents: 14078
diff changeset
338 glFinish();
00283cb37fd0 Make the context not current before destroying it.
reimar
parents: 14078
diff changeset
339 glXMakeCurrent(mDisplay, None, NULL);
13843
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
340 glXDestroyContext(mDisplay, *context);
14089
00283cb37fd0 Make the context not current before destroying it.
reimar
parents: 14078
diff changeset
341 }
13843
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
342 *context = 0;
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
343 }
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
344 #endif
3f28d2a56758 fullscreen fixes and GUI support for vo_gl
reimar
parents: 13653
diff changeset
345