I have looked everywhere on the net and nowhere says anything about how I would go about displaying pixels inside a window. Please could someone to post a link to a tutorial or something that would tell me how to do this?
If you want to create pretty windows programs with buttons and menus and listboxes and the like, you will have to find a toolkit that does it (like GTK+, FLTK, wxWidgets, etc.) or learn the Win32 API (on Windows) or KDE or Gnome API (on Linux).
Getting into graphical applications is a very large step, with a steep learning curve. Be prepared to spend a lot of time on it.
Do you want to output colored text?
Then you can use this function:
1 2 3 4 5 6 7 8 9
#include <windows.h>
//win32 api required to change console
void ChangeConsoleColor(int color)
{
HANDLE hCons; //Handle to the console window
hCons = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hCons, color); //Changes text color only
}
The argument "color" is the same as the DOS color command:
0=black, 1=blue, 2=green, etc...
If you want to propogate bad coding practices, you could get away with:
No, i already know about that! I want to be able to create my own images from scratch, inside a window. This is for my custom library so i don't want suggestions of libraries that already provide tools for drawing like the flash drawAPI (I come from an actionscript background), I just want to be able to output pixels to a window!!!
Bubba Ex, you are less likely to get good help if you become belligerent.
Your original request was vague, yet you received friendly and excellent advice, applicable to a great many platforms and development environments.
Your second response was even more vague, expressed complacency with whatever works or just plain wishy-washiness, and twice mentioned text routines out of fifteen words total.
To which you were again cordially advised in a way that both expressed effort to understand what you want and with a comprehensive answer for Win32 if guessed correctly.
Now if you really want to go the hard way, you will have to learn one of: Win32, X11, or Aqua. Of the three Win32 is the easiest and X11 will make you wish you were dead. The choice, however, is dictated by your OS.
If you want to do all that work to put some pixels in a window, go for it. But if all you really want is a window that you can color pixel by pixel, then I suggest you take a look at a nice, cross-platform toolkit like GTK+, FLTK, or wxWidgets, or if you are on *nix you can use the KDE or Gnome window managers' scripting engine to do it.
Playing with graphics is not trivial, and there is no way around it.
I think that if you are wanting to do pixel-by-pixel coloration you are going to have some mad issues doing this in an even remotely feasible time-frame.
Duoas: He doesn't want libraries that do it for him. He wants to go the difficult route.
On Windows, You'd wanna become VERY familiar with the GDI and Win32 API. May even wanna look at direct access to the video card drivers too.
Sorry i sounded so vague. I use Microsoft Visual C++ 2008 and yes, I want to go the difficult route (Win32). Could anyone post a link to a good course on Win32 programming to help me if its so important I become familiar with it?
For Windows API, you could start here:
http://www.winprog.org/tutorial/start.html
then go on to MSDN
http://msdn.microsoft.com/
I would also recommend a couple of books:
“Programming Windows” by Charles Petzold Synopsis
Look it up in Petzold remains the decisive last word in answering questions about Windows development. And in PROGRAMMING WINDOWS, FIFTH EDITION, the esteemed Windows Pioneer Award winner revises his classic text with authoritative coverage of the latest versions of the Windows operating system once again drilling down to the essential API heart of Win32 programming. Topics include: The basics input, output, dialog boxes An introduction to Unicode Graphics drawing, text and fonts, bitmaps and metafiles The kernel and the printer Sound and music Dynamic-link libraries Multitasking and multithreading The Multiple-Document Interface Programming for the Internet and intranets Packed as always with definitive examples, this newest Petzold delivers the ultimate sourcebook and tutorial for Windows programmers at all levels working with Microsoft; Windows 95, Windows 98, or Microsoft Windows NT;. No aspiring or experienced developer can afford to be without it. An electronic version of this book is available on the companion CD.
“Windows Via C/C++” by Jeffrey M. Richter , Christophe Nasarre Synopsis
Get the preeminent guide to programming application for Windows with C++. Programming Applications for Microsoft Windows is a classic book (formerly titled Advanced Windows, Third Edition) and is now fully updated for Windows Vista, including the latest information about Windows XP. In-depth and comprehensive, this essential reference covers the Windows operating system and how to program at the API level. Recognized experts provide an inside view of how Windows works and how to use its features in Visual C++ development tasks. Topics covered include processes, thread pooling, virtual memory, DLLs, file I/O, and message crackers. For systems-level programmers, this is a must-have title. Includes code samples in Visual C++.
When you are happy that you know your way around API programing, there is another book that you may be able to track down, in a library or somthing, that has a lot of useful information (1280 pages):
"Windows Graphics Programming: Win32 GDI and DirectDraw" by Feng Yuan Synopsis(from Amazon)
To deliver high-performance Windows applications, developers need an in-depth understanding of the Win32 GDI and DirectDraw -- but until now, it's been virtually impossible to discover what's going on "behind" Microsoft's API calls. This book rips away the veil, giving experienced Windows programmers the information and techniques they need to maximize performance, efficiency, and reliability -- and to make the best use of Windows graphics APIs and the important new graphics features provided in Windows 2000. Readers will gain a clear, concrete understanding of how GDI and DirectDraw are implemented internally; their limitations, resource requirements, and performance impact; and keys to implementing features and troubleshooting problems. This book is filled with high quality, original, system-level tools, kernal mode drivers, sample programs, and generic C++ classes for Windows programming without MFC. Readers can find out how to build API spys and hooks, detect GDI resource leaks, build image processing software, and more.
Part 1 goes behind the scenes to uncover the Windows system architecture and graphics system internal data structure, and provides techniques for spying on the components of the graphics system. Part 2 provides detailed coverage of the Win32 GDI and Direct Draw API, based on the solid foundation built in Part 1. It covers device context, coordinate space and transformation, pixels, lines, and curves, area fills, various types of bitmaps, image processing, fonts, text, enhanced metafiles, and printing.