src/video/haiku/SDL_bmodes.cc
changeset 12082 09999a0e8f9a
parent 11811 5d94cb6b24d3
child 12201 8bdc4d340419
equal deleted inserted replaced
12081:277e57c09ff4 12082:09999a0e8f9a
   130 }
   130 }
   131 #endif
   131 #endif
   132 
   132 
   133 
   133 
   134 
   134 
   135 int32 BE_ColorSpaceToBitsPerPixel(uint32 colorspace)
   135 int32 HAIKU_ColorSpaceToBitsPerPixel(uint32 colorspace)
   136 {
   136 {
   137 	int bitsperpixel;
   137 	int bitsperpixel;
   138 
   138 
   139 	bitsperpixel = 0;
   139 	bitsperpixel = 0;
   140 	switch (colorspace) {
   140 	switch (colorspace) {
   161 		break;
   161 		break;
   162 	}
   162 	}
   163 	return(bitsperpixel);
   163 	return(bitsperpixel);
   164 }
   164 }
   165 
   165 
   166 int32 BE_BPPToSDLPxFormat(int32 bpp) {
   166 int32 HAIKU_BPPToSDLPxFormat(int32 bpp) {
   167 	/* Translation taken from SDL_windowsmodes.c */
   167 	/* Translation taken from SDL_windowsmodes.c */
   168 	switch (bpp) {
   168 	switch (bpp) {
   169 	case 32:
   169 	case 32:
   170 		return SDL_PIXELFORMAT_RGB888;
   170 		return SDL_PIXELFORMAT_RGB888;
   171 		break;
   171 		break;
   208 
   208 
   209 	mode->driverdata = bmode;
   209 	mode->driverdata = bmode;
   210 #endif
   210 #endif
   211 
   211 
   212 	/* Set the format */
   212 	/* Set the format */
   213 	int32 bpp = BE_ColorSpaceToBitsPerPixel(bmode->space);
   213 	int32 bpp = HAIKU_ColorSpaceToBitsPerPixel(bmode->space);
   214 	mode->format = BE_BPPToSDLPxFormat(bpp);
   214 	mode->format = HAIKU_BPPToSDLPxFormat(bpp);
   215 }
   215 }
   216 
   216 
   217 /* Later, there may be more than one monitor available */
   217 /* Later, there may be more than one monitor available */
   218 static void _AddDisplay(BScreen *screen) {
   218 static void _AddDisplay(BScreen *screen) {
   219 	SDL_VideoDisplay display;
   219 	SDL_VideoDisplay display;
   233 
   233 
   234 /*
   234 /*
   235  * Functions called by SDL
   235  * Functions called by SDL
   236  */
   236  */
   237 
   237 
   238 int BE_InitModes(_THIS) {
   238 int HAIKU_InitModes(_THIS) {
   239 	BScreen screen;
   239 	BScreen screen;
   240 
   240 
   241 	/* TODO: When Haiku supports multiple display screens, call
   241 	/* TODO: When Haiku supports multiple display screens, call
   242 	   _AddDisplayScreen() for each of them. */
   242 	   _AddDisplayScreen() for each of them. */
   243 	_AddDisplay(&screen);
   243 	_AddDisplay(&screen);
   244 	return 0;
   244 	return 0;
   245 }
   245 }
   246 
   246 
   247 int BE_QuitModes(_THIS) {
   247 int HAIKU_QuitModes(_THIS) {
   248 	/* FIXME: Nothing really needs to be done here at the moment? */
   248 	/* FIXME: Nothing really needs to be done here at the moment? */
   249 	return 0;
   249 	return 0;
   250 }
   250 }
   251 
   251 
   252 
   252 
   253 int BE_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) {
   253 int HAIKU_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) {
   254 	BScreen bscreen;
   254 	BScreen bscreen;
   255 	BRect rc = bscreen.Frame();
   255 	BRect rc = bscreen.Frame();
   256 	rect->x = (int)rc.left;
   256 	rect->x = (int)rc.left;
   257 	rect->y = (int)rc.top;
   257 	rect->y = (int)rc.top;
   258 	rect->w = (int)rc.Width() + 1;
   258 	rect->w = (int)rc.Width() + 1;
   259 	rect->h = (int)rc.Height() + 1;
   259 	rect->h = (int)rc.Height() + 1;
   260 	return 0;
   260 	return 0;
   261 }
   261 }
   262 
   262 
   263 void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display) {
   263 void HAIKU_GetDisplayModes(_THIS, SDL_VideoDisplay *display) {
   264 	/* Get the current screen */
   264 	/* Get the current screen */
   265 	BScreen bscreen;
   265 	BScreen bscreen;
   266 
   266 
   267 	/* Iterate through all of the modes */
   267 	/* Iterate through all of the modes */
   268 	SDL_DisplayMode mode;
   268 	SDL_DisplayMode mode;
   283 	}
   283 	}
   284 	free(bmodes);
   284 	free(bmodes);
   285 }
   285 }
   286 
   286 
   287 
   287 
   288 int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){
   288 int HAIKU_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){
   289 	/* Get the current screen */
   289 	/* Get the current screen */
   290 	BScreen bscreen;
   290 	BScreen bscreen;
   291 	if(!bscreen.IsValid()) {
   291 	if(!bscreen.IsValid()) {
   292 		printf(__FILE__": %d - ERROR: BAD SCREEN\n", __LINE__);
   292 		printf(__FILE__": %d - ERROR: BAD SCREEN\n", __LINE__);
   293 	}
   293 	}
   316 	free(bmode_list);
   316 	free(bmode_list);
   317 	
   317 	
   318 #if SDL_VIDEO_OPENGL
   318 #if SDL_VIDEO_OPENGL
   319 	/* FIXME: Is there some way to reboot the OpenGL context?  This doesn't
   319 	/* FIXME: Is there some way to reboot the OpenGL context?  This doesn't
   320 	   help */
   320 	   help */
   321 //	BE_GL_RebootContexts(_this);
   321 //	HAIKU_GL_RebootContexts(_this);
   322 #endif
   322 #endif
   323 
   323 
   324 	return 0;
   324 	return 0;
   325 }
   325 }
   326 
   326