Looking For Help with SDL Console

Started by
9 comments, last by willthiswork89 18 years, 2 months ago
I wanted to know if there was a way to change the background color and or the font color other then changing it using addbackground picture... i wanted to change the actual color from like black to grey.. Thanks for the Help Guys
Advertisement
Well, you could create a surface:
SDL_Surface *pColor = NULL;pColor = SDL_CreateRGBSurface(Flags, // SDL_SWSURFACE                              Width, Height, Bpp,                              RMASK, GMASK, BMASK, AMASK);Uint32 Color = 0xRRGGBB; // The colors in this order!SDL_FillRect(pColor, NULL, Color);// Set your background to this surface, and remember to delete it!

There could be a better way, but I don't use that.
Thank you for the response although you mis interpreted my question. SDL Console is a Quake-Like Console Screen for input... the color of it is black and my actual window is a picture of black.. so the text is hard to see.
Quote:Original post by willthiswork89
Thank you for the response although you mis interpreted my question. SDL Console is a Quake-Like Console Screen for input... the color of it is black and my actual window is a picture of black.. so the text is hard to see.


Well, exactly. If there is no function like that, create a surface of color like 0x00ffff and make that the background with the setbackground function you said that existed.

Note: That's 0 r, 255 g, 255 b, but in 0xRRGGBB form in hex (hint: ff = 255, 00 = 0).

EDIT: Oh, I see that you're saying that you don't want to do it this way... Well, sorry. I don't know of any functions for SDL_Console to modify it's background.
well the add background actually takes a filename to load... the only thing i can possibly think of is to make an image and add the image to the thing.
Quote:Original post by willthiswork89
well the add background actually takes a filename to load... the only thing i can possibly think of is to make an image and add the image to the thing.


Ohh.... Well, I guess that's the only solution, then.
Loading a file to just display a big square of a color sounds like a very bad solution to me. You could draw primitives with SDL_gfx found here. Try it if you havent.

What console class are you using? Is it open source? If it is, then its probably not that hard to add this stuff yourself if the only option to change the background is to load a file.

If its not open source, writing a (basic) console class yourself isnt all that hard. Take input -> send to game engine -> print whatever result game engine returned.

Good luck. [smile]
well i was mainly looking for somthing to do Username and Password and since sdl has no gui... its kinda hard... i never thouhg tabout just doing a simple thing but getting a blinker and stuff... it would be kinda hard.. but ide love to start working on a project like this...
Please anyone? im looking to try and start on this login please and thank you :)
Quote:Original post by willthiswork89
Please anyone? im looking to try and start on this login please and thank you :)


Here:
int CON_Background(ConsoleInformation *console, Uint32 Color, int x, int y) {	SDL_Surface *temp;		temp = SDL_CreateRGBSurface(SDL_SWSURFACE,        console->BackgroundImage->w,        console->InputBackground->h,        32,        #ifdef SDL_LIL_ENDIAN        0x000000ff,        0x0000ff,        0x00ff,        0xff        #else        0xff,        0x00ff,        0x0000ff,        0x000000ff        #endif // I FORGOT THIS!        );            SDL_FillRect(temp, NULL, Color);		SDL_Rect backgroundsrc, backgrounddest;	if(!console)		return 1;	if(!temp) {		CON_Out(console, "Cannot load background %s.", image);		return 1;	}	console->BackgroundImage = SDL_DisplayFormat(temp);	SDL_FreeSurface(temp);	console->BackX = x;	console->BackY = y;	backgroundsrc.x = 0;	backgroundsrc.y = console->ConsoleSurface->h - console->FontHeight - console->BackY;	backgroundsrc.w = console->BackgroundImage->w;	backgroundsrc.h = console->InputBackground->h;	backgrounddest.x = console->BackX;	backgrounddest.y = 0;	backgrounddest.w = console->BackgroundImage->w;	backgrounddest.h = console->FontHeight;	SDL_FillRect(console->InputBackground, NULL, SDL_MapRGBA(console->ConsoleSurface->format, 0, 0, 0, SDL_ALPHA_OPAQUE));	SDL_BlitSurface(console->BackgroundImage, &backgroundsrc, console->InputBackground, &backgrounddest);	CON_UpdateConsole(console);	return 0;}

I went to the website, downloaded it, and inspected it.

After reading a couple of functions, I made that up.

Just add it to your project, and see if it works. The Color is a Uint32 that can be achieved with SDL_MapRGB(what->format, r, g, b), or 0xRRGGBB, in hex.

I have no idea if it will work, but it should. You should know what to do with the other stuff.

Good luck!

EDIT: Added an #endif, it was needed. Sorry, but I wrote that off the top of my head and forgot the #endif.

[Edited by - agi_shi on January 28, 2006 6:06:54 AM]

This topic is closed to new replies.

Advertisement