src/video/bwindow/SDL_bmodes.cc
changeset 5926 d9d57de9fb4e
parent 5925 262ce29aabf6
child 5927 463b84c19645
equal deleted inserted replaced
5925:262ce29aabf6 5926:d9d57de9fb4e
    30 
    30 
    31 #ifdef __cplusplus
    31 #ifdef __cplusplus
    32 extern "C" {
    32 extern "C" {
    33 #endif
    33 #endif
    34 
    34 
       
    35 /* This wrapper is here so that the driverdata can be freed */
       
    36 typedef struct SDL_DisplayModeData {
       
    37 	display_mode *bmode;
       
    38 };
       
    39 
       
    40 
       
    41 
    35 static inline SDL_BWin *_ToBeWin(SDL_Window *window) {
    42 static inline SDL_BWin *_ToBeWin(SDL_Window *window) {
    36 	return ((SDL_BWin*)(window->driverdata));
    43 	return ((SDL_BWin*)(window->driverdata));
    37 }
    44 }
    38 
    45 
    39 static inline SDL_BApp *_GetBeApp() {
    46 static inline SDL_BApp *_GetBeApp() {
   105 static inline void BE_BDisplayModeToSdlDisplayMode(display_mode *bmode,
   112 static inline void BE_BDisplayModeToSdlDisplayMode(display_mode *bmode,
   106 		SDL_DisplayMode *mode) {
   113 		SDL_DisplayMode *mode) {
   107 	mode->w = bmode->virtual_width;
   114 	mode->w = bmode->virtual_width;
   108 	mode->h = bmode->virtual_height;
   115 	mode->h = bmode->virtual_height;
   109 	mode->refresh_rate = (int)get_refresh_rate(*bmode);
   116 	mode->refresh_rate = (int)get_refresh_rate(*bmode);
   110 	mode->driverdata = bmode;	/* This makes setting display
   117 	SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1, sizeof(SDL_DisplayModeData));
   111 									   modes easier */
   118 	data->bmode = bmode;
       
   119 	mode->driverdata = data;
   112 
   120 
   113 	/* Set the format */
   121 	/* Set the format */
   114 	int32 bpp = ColorSpaceToBitsPerPixel(bmode->space);
   122 	int32 bpp = ColorSpaceToBitsPerPixel(bmode->space);
   115 	mode->format = BPPToSDLPxFormat(bpp);
   123 	mode->format = BPPToSDLPxFormat(bpp);
   116 }
   124 }
   189 int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){
   197 int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){
   190 	/* Get the current screen */
   198 	/* Get the current screen */
   191 	BScreen bscreen;
   199 	BScreen bscreen;
   192 	
   200 	
   193 	/* Set the mode using the driver data */
   201 	/* Set the mode using the driver data */
   194 	display_mode *bmode = (display_mode*)mode->driverdata;
   202 	display_mode *bmode = ((SDL_DisplayModeData*)mode->driverdata)->bmode;
   195 	if(bscreen.SetMode(bmode) == B_OK) {
   203 	if(bscreen.SetMode(bmode) == B_OK) {
   196 		return 0;	/* No error */
   204 		return 0;	/* No error */
   197 	}
   205 	}
   198 	
   206 	
   199 	return -1;
   207 	return -1;