Mercurial > mplayer.hg
annotate libvo/gl_common.c @ 16109:519a307e3ccf
OpenGL fixes for windows and vo_gl.c ported to windows.
author | reimar |
---|---|
date | Tue, 26 Jul 2005 13:47:18 +0000 |
parents | 629c54dc7e0d |
children | 5683110fce0a |
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 |
16099 | 3 void (APIENTRY *BindBuffer)(GLenum, GLuint); |
4 GLvoid* (APIENTRY *MapBuffer)(GLenum, GLenum); | |
5 GLboolean (APIENTRY *UnmapBuffer)(GLenum); | |
16109
519a307e3ccf
OpenGL fixes for windows and vo_gl.c ported to windows.
reimar
parents:
16099
diff
changeset
|
6 void (APIENTRY *BufferData)(GLenum, intptr_t, const GLvoid *, GLenum); |
16099 | 7 void (APIENTRY *CombinerParameterfv)(GLenum, const GLfloat *); |
8 void (APIENTRY *CombinerParameteri)(GLenum, GLint); | |
9 void (APIENTRY *CombinerInput)(GLenum, GLenum, GLenum, GLenum, GLenum, | |
10 GLenum); | |
11 void (APIENTRY *CombinerOutput)(GLenum, GLenum, GLenum, GLenum, GLenum, | |
12 GLenum, GLenum, GLboolean, GLboolean, | |
13 GLboolean); | |
14 void (APIENTRY *ActiveTexture)(GLenum); | |
15 void (APIENTRY *BindTexture)(GLenum, GLuint); | |
16 void (APIENTRY *MultiTexCoord2f)(GLenum, GLfloat, GLfloat); | |
17 void (APIENTRY *BindProgram)(GLenum, GLuint); | |
18 void (APIENTRY *ProgramString)(GLenum, GLenum, GLsizei, const GLvoid *); | |
19 void (APIENTRY *ProgramEnvParameter4f)(GLenum, GLuint, GLfloat, GLfloat, | |
20 GLfloat, GLfloat); | |
21 | |
13653
799f81d3cb19
added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff
changeset
|
22 /** |
799f81d3cb19
added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff
changeset
|
23 * \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
|
24 * \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
|
25 */ |
799f81d3cb19
added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff
changeset
|
26 void glAdjustAlignment(int stride) { |
799f81d3cb19
added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff
changeset
|
27 GLint gl_alignment; |
799f81d3cb19
added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff
changeset
|
28 if (stride % 8 == 0) |
799f81d3cb19
added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff
changeset
|
29 gl_alignment=8; |
799f81d3cb19
added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff
changeset
|
30 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
|
31 gl_alignment=4; |
799f81d3cb19
added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff
changeset
|
32 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
|
33 gl_alignment=2; |
799f81d3cb19
added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff
changeset
|
34 else |
799f81d3cb19
added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff
changeset
|
35 gl_alignment=1; |
799f81d3cb19
added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff
changeset
|
36 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
|
37 } |
799f81d3cb19
added gl_common for code used by both vo_gl.c and vo_gl2.c.
reimar
parents:
diff
changeset
|
38 |
14078
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
39 #include "img_format.h" |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
40 |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
41 struct gl_name_map_struct { |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
42 GLint value; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
43 char *name; |
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 |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
46 #undef MAP |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
47 #define MAP(a) {a, #a} |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
48 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
|
49 // internal format |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
50 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
|
51 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
|
52 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
|
53 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
|
54 |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
55 // format |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
56 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
|
57 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
|
58 MAP(GL_COLOR_INDEX), |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
59 // rest 1.2 only |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
60 #ifdef GL_VERSION_1_2 |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
61 MAP(GL_BGR), MAP(GL_BGRA), |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
62 #endif |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
63 |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
64 //type |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
65 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
|
66 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
|
67 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
|
68 // rest 1.2 only |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
69 #ifdef GL_VERSION_1_2 |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 #endif |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
77 {0, 0} |
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 MAP |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
80 |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
81 /** |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
82 * \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
|
83 * \param value the constant |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
84 * \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
|
85 */ |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
86 const char *glValName(GLint value) |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
87 { |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
88 int i = 0; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
89 |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
90 while (gl_name_map[i].name) { |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
91 if (gl_name_map[i].value == value) |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
92 return gl_name_map[i].name; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
93 i++; |
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 return "Unknown format!"; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
96 } |
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 #undef TEXTUREFORMAT_ALWAYS |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
99 //! 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
|
100 #define TEXTUREFORMAT_ALWAYS GL_RGB8 |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
101 |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
102 /** |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
103 * \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
|
104 * |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
105 * All parameters may be NULL. |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
106 * \param fmt MPlayer format to analyze. |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
107 * \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
|
108 * \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
|
109 * 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
|
110 * \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
|
111 * \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
|
112 * \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
|
113 */ |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
114 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
|
115 GLenum *gl_format, GLenum *gl_type) |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
116 { |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
117 int dummy1; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
118 GLenum dummy2; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
119 if (bpp == NULL) bpp = &dummy1; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
120 if (gl_texfmt == NULL) gl_texfmt = &dummy2; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
121 if (gl_format == NULL) gl_format = &dummy2; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
122 if (gl_type == NULL) gl_type = &dummy2; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
123 |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
124 *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
|
125 *gl_texfmt = 3; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
126 switch (fmt) { |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
127 case IMGFMT_RGB24: |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
128 *gl_format = GL_RGB; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
129 *gl_type = GL_UNSIGNED_BYTE; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
130 break; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
131 case IMGFMT_RGBA: |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
132 *gl_texfmt = 4; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
133 *gl_format = GL_RGBA; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
134 *gl_type = GL_UNSIGNED_BYTE; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
135 break; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
136 case IMGFMT_Y800: |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
137 case IMGFMT_Y8: |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
138 *gl_texfmt = 1; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
139 *bpp = 8; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
140 *gl_format = GL_LUMINANCE; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
141 *gl_type = GL_UNSIGNED_BYTE; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
142 break; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
143 #ifdef GL_VERSION_1_2 |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
144 #if 0 |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
145 // 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
|
146 // swscale produces works |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
147 case IMGFMT_RGB8: |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
148 gl_format = GL_RGB; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
149 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
|
150 break; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
151 #endif |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
152 case IMGFMT_RGB15: |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
153 *gl_format = GL_RGBA; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
154 *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
|
155 break; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
156 case IMGFMT_RGB16: |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
157 *gl_format = GL_RGB; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
158 *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
|
159 break; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
160 #if 0 |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
161 case IMGFMT_BGR8: |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
162 // 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
|
163 // 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
|
164 // 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
|
165 // 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
|
166 gl_format = GL_RGB; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
167 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
|
168 break; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
169 #endif |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
170 case IMGFMT_BGR15: |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
171 *gl_format = GL_BGRA; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
172 *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
|
173 break; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
174 case IMGFMT_BGR16: |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
175 *gl_format = GL_RGB; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
176 *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
|
177 break; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
178 case IMGFMT_BGR24: |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
179 *gl_format = GL_BGR; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
180 *gl_type = GL_UNSIGNED_BYTE; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
181 break; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
182 case IMGFMT_BGRA: |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
183 *gl_texfmt = 4; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
184 *gl_format = GL_BGRA; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
185 *gl_type = GL_UNSIGNED_BYTE; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
186 break; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
187 #endif |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
188 default: |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
189 *gl_texfmt = 4; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
190 *gl_format = GL_RGBA; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
191 *gl_type = GL_UNSIGNED_BYTE; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
192 return 0; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
193 } |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
194 #ifdef TEXTUREFORMAT_ALWAYS |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
195 *gl_texfmt = TEXTUREFORMAT_ALWAYS; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
196 #endif |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
197 return 1; |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
198 } |
c4033dcb986f
More similar code from gl and gl2 moved to gl_common
reimar
parents:
13843
diff
changeset
|
199 |
16099 | 200 static void *setNull(const GLubyte *s) { |
201 return NULL; | |
202 } | |
203 | |
204 static void *(*getProcAddress)(const GLubyte *procName); | |
205 | |
206 static void getFunctions() { | |
207 if (!getProcAddress) | |
208 getProcAddress = setNull; | |
209 BindBuffer = getProcAddress("glBindBuffer"); | |
210 if (!BindBuffer) | |
211 BindBuffer = getProcAddress("glBindBufferARB"); | |
212 MapBuffer = getProcAddress("glMapBuffer"); | |
213 if (!MapBuffer) | |
214 MapBuffer = getProcAddress("glMapBufferARB"); | |
215 UnmapBuffer = getProcAddress("glUnmapBuffer"); | |
216 if (!UnmapBuffer) | |
217 UnmapBuffer = getProcAddress("glUnmapBufferARB"); | |
218 BufferData = getProcAddress("glBufferData"); | |
219 if (!BufferData) | |
220 BufferData = getProcAddress("glBufferDataARB"); | |
221 CombinerParameterfv = getProcAddress("glCombinerParameterfv"); | |
222 if (!CombinerParameterfv) | |
223 CombinerParameterfv = getProcAddress("glCombinerParameterfvNV"); | |
224 CombinerParameteri = getProcAddress("glCombinerParameteri"); | |
225 if (!CombinerParameteri) | |
226 CombinerParameteri = getProcAddress("glCombinerParameteriNV"); | |
227 CombinerInput = getProcAddress("glCombinerInput"); | |
228 if (!CombinerInput) | |
229 CombinerInput = getProcAddress("glCombinerInputNV"); | |
230 CombinerOutput = getProcAddress("glCombinerOutput"); | |
231 if (!CombinerOutput) | |
232 CombinerOutput = getProcAddress("glCombinerOutputNV"); | |
233 ActiveTexture = getProcAddress("glActiveTexture"); | |
234 if (!ActiveTexture) | |
235 ActiveTexture = getProcAddress("glActiveTextureARB"); | |
236 BindTexture = getProcAddress("glBindTexture"); | |
237 if (!BindTexture) | |
238 BindTexture = getProcAddress("glBindTextureARB"); | |
239 MultiTexCoord2f = getProcAddress("glMultiTexCoord2f"); | |
240 if (!MultiTexCoord2f) | |
241 MultiTexCoord2f = getProcAddress("glMultiTexCoord2fARB"); | |
242 BindProgram = getProcAddress("glBindProgram"); | |
243 if (!BindProgram) | |
244 BindProgram = getProcAddress("glBindProgramARB"); | |
245 if (!BindProgram) | |
246 BindProgram = getProcAddress("glBindProgramNV"); | |
247 ProgramString = getProcAddress("glProgramString"); | |
248 if (!ProgramString) | |
249 ProgramString = getProcAddress("glProgramStringARB"); | |
250 if (!ProgramString) | |
251 ProgramString = getProcAddress("glProgramStringNV"); | |
252 ProgramEnvParameter4f = getProcAddress("glProgramEnvParameter4f"); | |
253 if (!ProgramEnvParameter4f) | |
254 ProgramEnvParameter4f = getProcAddress("glProgramEnvParameter4fARB"); | |
255 if (!ProgramEnvParameter4f) | |
256 ProgramEnvParameter4f = getProcAddress("glProgramEnvParameter4fNV"); | |
257 } | |
258 | |
14142
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
259 #ifdef GL_WIN32 |
16109
519a307e3ccf
OpenGL fixes for windows and vo_gl.c ported to windows.
reimar
parents:
16099
diff
changeset
|
260 static void *w32gpa(const GLubyte *procName) { |
519a307e3ccf
OpenGL fixes for windows and vo_gl.c ported to windows.
reimar
parents:
16099
diff
changeset
|
261 return wglGetProcAddress(procName); |
519a307e3ccf
OpenGL fixes for windows and vo_gl.c ported to windows.
reimar
parents:
16099
diff
changeset
|
262 } |
519a307e3ccf
OpenGL fixes for windows and vo_gl.c ported to windows.
reimar
parents:
16099
diff
changeset
|
263 |
14142
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
264 int setGlWindow(int *vinfo, HGLRC *context, HWND win) |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
265 { |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
266 int new_vinfo; |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
267 HDC windc = GetDC(win); |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
268 HGLRC new_context = 0; |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
269 int keep_context = 0; |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
270 |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
271 // 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
|
272 // 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
|
273 glFinish(); |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
274 new_vinfo = GetPixelFormat(windc); |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
275 if (*context && *vinfo && new_vinfo && *vinfo == new_vinfo) { |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
276 // we can keep the wglContext |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
277 new_context = *context; |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
278 keep_context = 1; |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
279 } else { |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
280 // create a context |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
281 new_context = wglCreateContext(windc); |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
282 if (!new_context) { |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
283 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
|
284 return SET_WINDOW_FAILED; |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
285 } |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
286 } |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
287 |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
288 // set context |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
289 if (!wglMakeCurrent(windc, new_context)) { |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
290 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
|
291 if (!keep_context) { |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
292 wglDeleteContext(new_context); |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
293 } |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
294 return SET_WINDOW_FAILED; |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
295 } |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
296 |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
297 // set new values |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
298 vo_window = win; |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
299 vo_hdc = windc; |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
300 { |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
301 RECT rect; |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
302 GetClientRect(win, &rect); |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
303 vo_dwidth = rect.right; |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
304 vo_dheight = rect.bottom; |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
305 } |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
306 if (!keep_context) { |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
307 if (*context) |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
308 wglDeleteContext(*context); |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
309 *context = new_context; |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
310 *vinfo = new_vinfo; |
16109
519a307e3ccf
OpenGL fixes for windows and vo_gl.c ported to windows.
reimar
parents:
16099
diff
changeset
|
311 getProcAddress = w32gpa; |
16099 | 312 getFunctions(); |
14142
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
313 |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
314 // and inform that reinit is neccessary |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
315 return SET_WINDOW_REINIT; |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
316 } |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
317 return SET_WINDOW_OK; |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
318 } |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
319 |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
320 void releaseGlContext(int *vinfo, HGLRC *context) { |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
321 *vinfo = 0; |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
322 if (*context) { |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
323 wglMakeCurrent(0, 0); |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
324 wglDeleteContext(*context); |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
325 } |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
326 *context = 0; |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
327 } |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
14089
diff
changeset
|
328 #else |
13843 | 329 /** |
14269 | 330 * \brief Returns the XVisualInfo associated with Window win. |
13843 | 331 * \param win Window whose XVisualInfo is returne. |
332 * \return XVisualInfo of the window. Caller must use XFree to free it. | |
333 */ | |
334 static XVisualInfo *getWindowVisualInfo(Window win) { | |
335 XWindowAttributes xw_attr; | |
336 XVisualInfo vinfo_template; | |
337 int tmp; | |
338 XGetWindowAttributes(mDisplay, win, &xw_attr); | |
339 vinfo_template.visualid = XVisualIDFromVisual(xw_attr.visual); | |
340 return XGetVisualInfo(mDisplay, VisualIDMask, &vinfo_template, &tmp); | |
341 } | |
342 | |
343 /** | |
344 * \brief Changes the window in which video is displayed. | |
345 * If possible only transfers the context to the new window, otherwise | |
346 * creates a new one, which must be initialized by the caller. | |
347 * \param vinfo Currently used visual. | |
348 * \param context Currently used context. | |
349 * \param win window that should be used for drawing. | |
350 * \return one of SET_WINDOW_FAILED, SET_WINDOW_OK or SET_WINDOW_REINIT. | |
351 * In case of SET_WINDOW_REINIT the context could not be transfered | |
352 * and the caller must initialize it correctly. | |
353 */ | |
354 int setGlWindow(XVisualInfo **vinfo, GLXContext *context, Window win) | |
355 { | |
356 XVisualInfo *new_vinfo; | |
357 GLXContext new_context = NULL; | |
358 int keep_context = 0; | |
359 | |
360 // should only be needed when keeping context, but not doing glFinish | |
361 // can cause flickering even when we do not keep it. | |
362 glFinish(); | |
363 new_vinfo = getWindowVisualInfo(win); | |
364 if (*context && *vinfo && new_vinfo && | |
365 (*vinfo)->visualid == new_vinfo->visualid) { | |
366 // we can keep the GLXContext | |
367 new_context = *context; | |
368 XFree(new_vinfo); | |
369 new_vinfo = *vinfo; | |
370 keep_context = 1; | |
371 } else { | |
372 // create a context | |
373 new_context = glXCreateContext(mDisplay, new_vinfo, NULL, True); | |
374 if (!new_context) { | |
375 mp_msg(MSGT_VO, MSGL_FATAL, "[gl] Could not create GLX context!\n"); | |
376 XFree(new_vinfo); | |
377 return SET_WINDOW_FAILED; | |
378 } | |
379 } | |
380 | |
381 // set context | |
382 if (!glXMakeCurrent(mDisplay, vo_window, new_context)) { | |
383 mp_msg (MSGT_VO, MSGL_FATAL, "[gl] Could not set GLX context!\n"); | |
384 if (!keep_context) { | |
385 glXDestroyContext (mDisplay, new_context); | |
386 XFree(new_vinfo); | |
387 } | |
388 return SET_WINDOW_FAILED; | |
389 } | |
390 | |
391 // set new values | |
392 vo_window = win; | |
393 { | |
394 Window root; | |
395 int tmp; | |
396 XGetGeometry(mDisplay, vo_window, &root, &tmp, &tmp, | |
397 &vo_dwidth, &vo_dheight, &tmp, &tmp); | |
398 } | |
399 if (!keep_context) { | |
400 if (*context) | |
401 glXDestroyContext(mDisplay, *context); | |
402 *context = new_context; | |
403 if (*vinfo) | |
404 XFree(*vinfo); | |
405 *vinfo = new_vinfo; | |
16099 | 406 #ifdef GLX_ARB_get_proc_address |
407 getProcAddress = (void *)glXGetProcAddressARB; | |
408 #else | |
409 getProcAddress = NULL; | |
410 #endif | |
411 getFunctions(); | |
13843 | 412 |
413 // and inform that reinit is neccessary | |
414 return SET_WINDOW_REINIT; | |
415 } | |
416 return SET_WINDOW_OK; | |
417 } | |
418 | |
419 /** | |
420 * \brief free the VisualInfo and GLXContext of an OpenGL context. | |
421 */ | |
422 void releaseGlContext(XVisualInfo **vinfo, GLXContext *context) { | |
423 if (*vinfo) | |
424 XFree(*vinfo); | |
425 *vinfo = NULL; | |
426 if (*context) | |
14089
00283cb37fd0
Make the context not current before destroying it.
reimar
parents:
14078
diff
changeset
|
427 { |
00283cb37fd0
Make the context not current before destroying it.
reimar
parents:
14078
diff
changeset
|
428 glFinish(); |
00283cb37fd0
Make the context not current before destroying it.
reimar
parents:
14078
diff
changeset
|
429 glXMakeCurrent(mDisplay, None, NULL); |
13843 | 430 glXDestroyContext(mDisplay, *context); |
14089
00283cb37fd0
Make the context not current before destroying it.
reimar
parents:
14078
diff
changeset
|
431 } |
13843 | 432 *context = 0; |
433 } | |
434 #endif | |
435 |