Mercurial > mplayer.hg
comparison libvo/vo_gl2.c @ 14090:e84643be7bd0
Move selection of internal texture format to appropriate place, should
be at texture initialization as visual might change.
author | reimar |
---|---|
date | Fri, 03 Dec 2004 00:11:28 +0000 |
parents | c4033dcb986f |
children | f0c1ee83b216 |
comparison
equal
deleted
inserted
replaced
14089:00283cb37fd0 | 14090:e84643be7bd0 |
---|---|
122 if(*px>1.0) *px=1.0; | 122 if(*px>1.0) *px=1.0; |
123 *py=(float)y*texpercy; | 123 *py=(float)y*texpercy; |
124 if(*py>1.0) *py=1.0; | 124 if(*py>1.0) *py=1.0; |
125 } | 125 } |
126 | 126 |
127 static GLint getInternalFormat() | |
128 { | |
129 #ifdef GL_WIN32 | |
130 PIXELFORMATDESCRIPTOR pfd; | |
131 int pf = GetPixelFormat(vo_hdc); | |
132 if (!DescribePixelFormat(vo_hdc, pf, sizeof pfd, &pfd)) { | |
133 r_sz = g_sz = b_sz = a_sz = 0; | |
134 } else { | |
135 r_sz = pfd.cRedBits; | |
136 g_sz = pfd.cGreenBits; | |
137 b_sz = pfd.cBlueBits; | |
138 a_sz = pfd.cAlphaBits; | |
139 } | |
140 #else | |
141 if (glXGetConfig(mDisplay, gl_vinfo, GLX_RED_SIZE, &r_sz) != 0) r_sz = 0; | |
142 if (glXGetConfig(mDisplay, gl_vinfo, GLX_GREEN_SIZE, &g_sz) != 0) g_sz = 0; | |
143 if (glXGetConfig(mDisplay, gl_vinfo, GLX_BLUE_SIZE, &b_sz) != 0) b_sz = 0; | |
144 if (glXGetConfig(mDisplay, gl_vinfo, GLX_ALPHA_SIZE, &a_sz) != 0) a_sz = 0; | |
145 #endif | |
146 | |
147 rgb_sz=r_sz+g_sz+b_sz; | |
148 if(rgb_sz<=0) rgb_sz=24; | |
149 | |
150 #ifdef TEXTUREFORMAT_ALWAYS | |
151 return TEXTUREFORMAT_ALWAYS; | |
152 #else | |
153 if(r_sz==3 && g_sz==3 && b_sz==2 && a_sz==0) | |
154 return GL_R3_G3_B2; | |
155 if(r_sz==4 && g_sz==4 && b_sz==4 && a_sz==0) | |
156 return GL_RGB4; | |
157 if(r_sz==5 && g_sz==5 && b_sz==5 && a_sz==0) | |
158 return GL_RGB5; | |
159 if(r_sz==8 && g_sz==8 && b_sz==8 && a_sz==0) | |
160 return GL_RGB8; | |
161 if(r_sz==10 && g_sz==10 && b_sz==10 && a_sz==0) | |
162 return GL_RGB10; | |
163 if(r_sz==2 && g_sz==2 && b_sz==2 && a_sz==2) | |
164 return GL_RGBA2; | |
165 if(r_sz==4 && g_sz==4 && b_sz==4 && a_sz==4) | |
166 return GL_RGBA4; | |
167 if(r_sz==5 && g_sz==5 && b_sz==5 && a_sz==1) | |
168 return GL_RGB5_A1; | |
169 if(r_sz==8 && g_sz==8 && b_sz==8 && a_sz==8) | |
170 return GL_RGBA8; | |
171 if(r_sz==10 && g_sz==10 && b_sz==10 && a_sz==2) | |
172 return GL_RGB10_A2; | |
173 #endif | |
174 return GL_RGB; | |
175 } | |
176 | |
127 static int initTextures() | 177 static int initTextures() |
128 { | 178 { |
129 struct TexSquare *tsq=0; | 179 struct TexSquare *tsq=0; |
130 int e_x, e_y, s, i=0; | 180 int e_x, e_y, s, i=0; |
131 int x=0, y=0; | 181 int x=0, y=0; |
141 e_y=0; s=1; | 191 e_y=0; s=1; |
142 while (s<texture_height) | 192 while (s<texture_height) |
143 { s*=2; e_y++; } | 193 { s*=2; e_y++; } |
144 texture_height=s; | 194 texture_height=s; |
145 | 195 |
196 gl_internal_format = getInternalFormat(); | |
146 | 197 |
147 /* Test the max texture size */ | 198 /* Test the max texture size */ |
148 do | 199 do |
149 { | 200 { |
150 glTexImage2D (GL_PROXY_TEXTURE_2D, 0, | 201 glTexImage2D (GL_PROXY_TEXTURE_2D, 0, |
573 } | 624 } |
574 | 625 |
575 #ifdef GL_WIN32 | 626 #ifdef GL_WIN32 |
576 | 627 |
577 static int config_w32(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { | 628 static int config_w32(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { |
578 PIXELFORMATDESCRIPTOR pfd; | |
579 int pf; | |
580 | |
581 o_dwidth = d_width; | 629 o_dwidth = d_width; |
582 o_dheight = d_height; | 630 o_dheight = d_height; |
583 vo_fs = flags & VOFLAG_FULLSCREEN; | 631 vo_fs = flags & VOFLAG_FULLSCREEN; |
584 vo_vm = flags & VOFLAG_MODESWITCHING; | 632 vo_vm = flags & VOFLAG_MODESWITCHING; |
585 | 633 |
590 if (!createRenderingContext()) | 638 if (!createRenderingContext()) |
591 return -1; | 639 return -1; |
592 | 640 |
593 if (vo_fs) | 641 if (vo_fs) |
594 aspect(&d_width, &d_height, A_ZOOM); | 642 aspect(&d_width, &d_height, A_ZOOM); |
595 | |
596 pf = GetPixelFormat(vo_hdc); | |
597 if (!DescribePixelFormat(vo_hdc, pf, sizeof pfd, &pfd)) { | |
598 r_sz = g_sz = b_sz = a_sz = 0; | |
599 } else { | |
600 r_sz = pfd.cRedBits; | |
601 g_sz = pfd.cGreenBits; | |
602 b_sz = pfd.cBlueBits; | |
603 a_sz = pfd.cAlphaBits; | |
604 } | |
605 | 643 |
606 return 0; | 644 return 0; |
607 } | 645 } |
608 | 646 |
609 #else | 647 #else |
727 vo_x11_nofs_sizepos(0, 0, d_width, d_height); | 765 vo_x11_nofs_sizepos(0, 0, d_width, d_height); |
728 if (vo_fs ^ (flags & VOFLAG_FULLSCREEN)) | 766 if (vo_fs ^ (flags & VOFLAG_FULLSCREEN)) |
729 vo_x11_fullscreen(); | 767 vo_x11_fullscreen(); |
730 | 768 |
731 setGlWindow(&gl_vinfo, &gl_context, vo_window); | 769 setGlWindow(&gl_vinfo, &gl_context, vo_window); |
732 | |
733 if(glXGetConfig(mDisplay,gl_vinfo,GLX_RED_SIZE, &r_sz)!=0) | |
734 r_sz=0; | |
735 if(glXGetConfig(mDisplay,gl_vinfo,GLX_GREEN_SIZE, &g_sz)!=0) | |
736 g_sz=0; | |
737 if(glXGetConfig(mDisplay,gl_vinfo,GLX_BLUE_SIZE, &b_sz)!=0) | |
738 b_sz=0; | |
739 if(glXGetConfig(mDisplay,gl_vinfo,GLX_ALPHA_SIZE, &a_sz)!=0) | |
740 a_sz=0; | |
741 | |
742 return 0; | 770 return 0; |
743 } | 771 } |
744 | 772 |
745 #ifdef HAVE_NEW_GUI | 773 #ifdef HAVE_NEW_GUI |
746 static int config_glx_gui(uint32_t d_width, uint32_t d_height) { | 774 static int config_glx_gui(uint32_t d_width, uint32_t d_height) { |
747 vo_dwidth = d_width; | 775 vo_dwidth = d_width; |
748 vo_dheight = d_height; | 776 vo_dheight = d_height; |
749 guiGetEvent( guiSetShVideo,0 ); // the GUI will set up / resize the window | 777 guiGetEvent( guiSetShVideo,0 ); // the GUI will set up / resize the window |
750 setGlWindow(&gl_vinfo, &gl_context, vo_window); | 778 setGlWindow(&gl_vinfo, &gl_context, vo_window); |
751 | |
752 if (glXGetConfig(mDisplay,gl_vinfo,GLX_RED_SIZE, &r_sz) != 0) r_sz = 0; | |
753 if (glXGetConfig(mDisplay,gl_vinfo,GLX_GREEN_SIZE, &g_sz) != 0) g_sz = 0; | |
754 if (glXGetConfig(mDisplay,gl_vinfo,GLX_BLUE_SIZE, &b_sz) != 0) b_sz = 0; | |
755 if (glXGetConfig(mDisplay,gl_vinfo,GLX_ALPHA_SIZE, &a_sz) != 0) a_sz = 0; | |
756 return 0; | 779 return 0; |
757 } | 780 } |
758 #endif | 781 #endif |
759 | 782 |
760 #endif | 783 #endif |
857 { | 880 { |
858 mp_msg(MSGT_VO, MSGL_INFO, "[gl2] You have OpenGL >= 1.2 capable drivers, GOOD (16bpp and BGR is ok!)\n"); | 881 mp_msg(MSGT_VO, MSGL_INFO, "[gl2] You have OpenGL >= 1.2 capable drivers, GOOD (16bpp and BGR is ok!)\n"); |
859 } else { | 882 } else { |
860 mp_msg(MSGT_VO, MSGL_INFO, "[gl2] You have OpenGL < 1.2 drivers, BAD (16bpp and BGR may be damaged!)\n"); | 883 mp_msg(MSGT_VO, MSGL_INFO, "[gl2] You have OpenGL < 1.2 drivers, BAD (16bpp and BGR may be damaged!)\n"); |
861 } | 884 } |
862 | |
863 rgb_sz=r_sz+g_sz+b_sz; | |
864 if(rgb_sz<=0) rgb_sz=24; | |
865 | |
866 if(r_sz==3 && g_sz==3 && b_sz==2 && a_sz==0) { | |
867 gl_internal_format=GL_R3_G3_B2; | |
868 } else if(r_sz==4 && g_sz==4 && b_sz==4 && a_sz==0) { | |
869 gl_internal_format=GL_RGB4; | |
870 } else if(r_sz==5 && g_sz==5 && b_sz==5 && a_sz==0) { | |
871 gl_internal_format=GL_RGB5; | |
872 } else if(r_sz==8 && g_sz==8 && b_sz==8 && a_sz==0) { | |
873 gl_internal_format=GL_RGB8; | |
874 } else if(r_sz==10 && g_sz==10 && b_sz==10 && a_sz==0) { | |
875 gl_internal_format=GL_RGB10; | |
876 } else if(r_sz==2 && g_sz==2 && b_sz==2 && a_sz==2) { | |
877 gl_internal_format=GL_RGBA2; | |
878 } else if(r_sz==4 && g_sz==4 && b_sz==4 && a_sz==4) { | |
879 gl_internal_format=GL_RGBA4; | |
880 } else if(r_sz==5 && g_sz==5 && b_sz==5 && a_sz==1) { | |
881 gl_internal_format=GL_RGB5_A1; | |
882 } else if(r_sz==8 && g_sz==8 && b_sz==8 && a_sz==8) { | |
883 gl_internal_format=GL_RGBA8; | |
884 } else if(r_sz==10 && g_sz==10 && b_sz==10 && a_sz==2) { | |
885 gl_internal_format=GL_RGB10_A2; | |
886 } else { | |
887 gl_internal_format=GL_RGB; | |
888 } | |
889 | |
890 #ifdef TEXTUREFORMAT_ALWAYS | |
891 gl_internal_format=TEXTUREFORMAT_ALWAYS; | |
892 #endif | |
893 | 885 |
894 glFindFormat(format, &image_bpp, NULL, &gl_bitmap_format, &gl_bitmap_type); | 886 glFindFormat(format, &image_bpp, NULL, &gl_bitmap_format, &gl_bitmap_type); |
895 | 887 |
896 image_bytes=(image_bpp+7)/8; | 888 image_bytes=(image_bpp+7)/8; |
897 | 889 |