comparison libvo/vo_gl.c @ 1290:af0b764f34c5

no segfault if no glx present
author alex
date Sat, 07 Jul 2001 20:53:01 +0000
parents 4c7b219e126c
children 2460ebcb6e69
comparison
equal deleted inserted replaced
1289:3f490fad9bdf 1290:af0b764f34c5
78 78
79 static uint32_t texture_width; 79 static uint32_t texture_width;
80 static uint32_t texture_height; 80 static uint32_t texture_height;
81 81
82 static void resize(int x,int y){ 82 static void resize(int x,int y){
83 printf("Resize: %dx%d\n",x,y); 83 printf("[gl] Resize: %dx%d\n",x,y);
84 glViewport( 0, 0, x, y ); 84 glViewport( 0, 0, x, y );
85 85
86 glMatrixMode(GL_PROJECTION); 86 glMatrixMode(GL_PROJECTION);
87 glLoadIdentity(); 87 glLoadIdentity();
88 glOrtho(0, image_width, image_height, 0, -1,1); 88 glOrtho(0, image_width, image_height, 0, -1,1);
119 119
120 mydisplay = XOpenDisplay(name); 120 mydisplay = XOpenDisplay(name);
121 121
122 if (mydisplay == NULL) 122 if (mydisplay == NULL)
123 { 123 {
124 printf("Can not open display\n"); 124 printf("[gl] Can not open display\n");
125 return -1; 125 return -1;
126 } 126 }
127 127
128 screen = DefaultScreen(mydisplay); 128 screen = DefaultScreen(mydisplay);
129 129
171 // 171 //
172 #endif 172 #endif
173 173
174 // XMatchVisualInfo(mydisplay, screen, depth, TrueColor, &vinfo); 174 // XMatchVisualInfo(mydisplay, screen, depth, TrueColor, &vinfo);
175 vinfo=glXChooseVisual( mydisplay,screen,wsGLXAttrib ); 175 vinfo=glXChooseVisual( mydisplay,screen,wsGLXAttrib );
176 if (vinfo == NULL)
177 {
178 printf("[gl] no GLX support present\n");
179 return -1;
180 }
176 181
177 xswa.background_pixel = 0; 182 xswa.background_pixel = 0;
178 xswa.border_pixel = 1; 183 xswa.border_pixel = 1;
179 // xswa.colormap = XCreateColormap(mydisplay, RootWindow(mydisplay,screen), vinfo.visual, AllocNone); 184 // xswa.colormap = XCreateColormap(mydisplay, RootWindow(mydisplay,screen), vinfo.visual, AllocNone);
180 xswa.colormap = XCreateColormap(mydisplay, RootWindow(mydisplay,screen), vinfo->visual, AllocNone); 185 xswa.colormap = XCreateColormap(mydisplay, RootWindow(mydisplay,screen), vinfo->visual, AllocNone);
237 if (myximage->byte_order != MSBFirst) 242 if (myximage->byte_order != MSBFirst)
238 #else 243 #else
239 if (myximage->byte_order != LSBFirst) 244 if (myximage->byte_order != LSBFirst)
240 #endif 245 #endif
241 { 246 {
242 fprintf( stderr, "No support fon non-native XImage byte order!\n" ); 247 printf("[gl] no support fon non-native XImage byte order!\n");
243 return -1; 248 return -1;
244 } 249 }
245 250
246 printf("DEPTH=%d BPP=%d\n",depth,bpp); 251 printf("DEPTH=%d BPP=%d\n",depth,bpp);
247 #endif 252 #endif
260 while(texture_width<image_height) texture_width*=2; 265 while(texture_width<image_height) texture_width*=2;
261 texture_height=texture_width; 266 texture_height=texture_width;
262 267
263 if(format==IMGFMT_YV12){ 268 if(format==IMGFMT_YV12){
264 yuv2rgb_init(8*BYTES_PP, MODE_BGR); 269 yuv2rgb_init(8*BYTES_PP, MODE_BGR);
265 printf("YUV init OK!\n"); 270 printf("[gl] YUV init OK!\n");
266 image_bpp=8*BYTES_PP; 271 image_bpp=8*BYTES_PP;
267 image_bytes=BYTES_PP; 272 image_bytes=BYTES_PP;
268 } else { 273 } else {
269 image_bpp=format&0xFF; 274 image_bpp=format&0xFF;
270 image_bytes=(image_bpp+7)/8; 275 image_bytes=(image_bpp+7)/8;
278 glDepthMask(GL_FALSE); 283 glDepthMask(GL_FALSE);
279 glDisable(GL_CULL_FACE); 284 glDisable(GL_CULL_FACE);
280 285
281 glEnable(GL_TEXTURE_2D); 286 glEnable(GL_TEXTURE_2D);
282 287
283 printf("Creating %dx%d texture...\n",texture_width,texture_height); 288 printf("[gl] Creating %dx%d texture...\n",texture_width,texture_height);
284 289
285 #if 1 290 #if 1
286 // glBindTexture(GL_TEXTURE_2D, texture_id); 291 // glBindTexture(GL_TEXTURE_2D, texture_id);
287 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); 292 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR);
288 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR); 293 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
490 495
491 static void 496 static void
492 uninit(void) 497 uninit(void)
493 { 498 {
494 } 499 }
495