Console output, with COLOR? and fast
Hello there, I was just wondering what the fastest way to write a buffer of colored text to a console window is. But, not WriteConsoleOutput... I want lowww level, no win32 crud.. I heard a rumor you could do color in cout.. but I think the person was thinking of conio.h, which I don't really want to use either. Anyway, any function names? Assembly links? Where do I start looking if no one knows? Thanks for any help!
Been a while but do a search for:
SetConsoleTextAttribute()
That is what I used but don't remember the exact details.
SetConsoleTextAttribute()
That is what I used but don't remember the exact details.
Ok I lied, I found the old code I used. Not pretty but you should be able to figure it out.
void TitleScreen(){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED| FOREGROUND_GREEN | FOREGROUND_INTENSITY );int i[12] = {185, 186, 187, 188, 200, 201, 202, 203, 204, 205, 206 };cout << "\n\n\n";cout << "\t\t " << (char)i[5] << (char)i[9] << (char)i[9]<<(char)i[9] <<(char)i[9] <<(char)i[9] <<(char)i[9] <<(char)i[9] <<(char)i[9]<< (char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<< (char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<< (char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9] << (char)i[2] << endl;cout << "\t\t " <<(char)i[1] << " " << (char)i[1] << endl;cout << "\t\t " <<(char)i[1] << " CGP PRESENTS " << (char)i[1] << endl;cout << "\t\t " <<(char)i[1] << " " << (char)i[1] << endl;cout << "\t\t " <<(char)i[1] << " MEDIEVAL KNIGHTS V1.0 " << (char)i[1] << endl;cout << "\t\t " <<(char)i[1] << " " << (char)i[1] << endl;cout << "\t\t " <<(char)i[1] << " (C) CGP 2001 " << (char)i[1] << endl;cout << "\t\t " <<(char)i[1] << " " << (char)i[1] << endl;cout << "\t\t " <<(char)i[8] << (char)i[9] << (char)i[9]<<(char)i[9] <<(char)i[9] <<(char)i[9] <<(char)i[9] <<(char)i[9] <<(char)i[9]<< (char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<< (char)i[7]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<< (char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9] << (char)i[0] << endl;cout << "\t\t " <<(char)i[1] << " " << (char)i[1] << " " << (char)i[1] << endl;cout << "\t\t " <<(char)i[1] << " Programmers " << (char)i[1] << " Special Thanks " << (char)i[1] << endl;cout << "\t\t " <<(char)i[1] << " " << (char)i[1] << " " << (char)i[1] << endl;cout << "\t\t " <<(char)i[1] << " Steven Bradley " << (char)i[1] << " Taybrin " << (char)i[1] << endl;cout << "\t\t " <<(char)i[1] << " Frank Verduin " << (char)i[1] << " Pendragon " << (char)i[1] << endl;cout << "\t\t " <<(char)i[1] << " " << (char)i[1] << " " << (char)i[1] << endl;cout << "\t\t " <<(char)i[4] << (char)i[9] << (char)i[9]<<(char)i[9] <<(char)i[9] <<(char)i[9] <<(char)i[9] <<(char)i[9] <<(char)i[9]<< (char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<< (char)i[6]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<< (char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9]<<(char)i[9] << (char)i[3] << endl;cout << endl << endl << endl;system("PAUSE");cout << endl;system("CLS");}
Thanks, but I want to be able to have multiple colors on the screen at the same time.. And anyway, SetConsoleTextAttribute is on the same level as WriteConsoleOutput. Thanks very much for your effort though!
Quote:Original post by n0ob
Thanks, but I want to be able to have multiple colors on the screen at the same time.. And anyway, SetConsoleTextAttribute is on the same level as WriteConsoleOutput. Thanks very much for your effort though!
You can re-call SetConsoleTextAttribute. What are you doing that you need it faster? It should be very fast on that level.
i would think that the "win32 crud" would be the fastest way to do it, because even if you did find a c/c++ "standard" way of doing it (which i don't think exists), those functions would have to call the operating system functions anyway.
Quote:Original post by Anonymous Poster
Write to 0xB8000 newb
Well, I was looking for something like that.. Is there a way to get that to work with VC++6.0? And if those functions did end up calling OS functions, I'd still kinda like to know any :P Thanks all though ^_^
That just writes characters into the screen buffer. Set a pointer to 0xB8000, and then start writing characters, and decrement and increment the pointer as neccesary. Honestly though, that probably isn't the safest thing to do, and may not even work all that well. It's a holdover from the dos days AFAIK. Honestly, I would just use the win32 functions, They aim to be more effective and of course, much safer. Really, they're not going to have a huge performance impact.
Quote:Original post by Anonymous Poster
Write to 0xB8000 newb
This only applies to DOS applications. Win32 console applications cannot use this method, newb.
Use the Win32 Console functions. It's not hard to wrap them up into a streambuf derived class, thus exposing the functionality via C++ streams.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement