Hey,
I'm trying to create a program that displays a map and allows the user to put coordinates on the map and enter what the coordinate is. I want the user part to be in a console window, but I want the map to be displayed using SDL.
I can't figure out how to get them to work together. Please help.
SDL uses a nasty trick to hijack main() so that the library initializaes properly on all platforms. (I think it was foolish to do it that way... but that's beside the point.)
IIRC, SDL does not interfere with console I/O, but your console does need to be the active window for it to work (and there isn't any window manager -- at least not that I am aware of -- that permits more than one toplevel window to be active at the same time).
What you will likely want to do is reroute keyboard input (from within SDL -- using the string input functions) to echo to your console window. This is trickier than it looks at first blush.
Having two windows kind of bucks the "fullscreen" kind of capability SDL gives users anyway. Why not just have an I/O sub-window in your game program? It is easier to do than have a separate console window -- and you won't need to play with OS-specific stuff to do it.
I think the idea that you had of the sub-window is the idea I like the best. It sounds the simplest and best. Only problem is.... I have NO idea how to do that. hahaha. So, I'm kinda just stuck. I hate when my projects become stagnant.
The main() that's defined in SDLmain doesn't do anything critical. That's what SDL_Init() is for. If it's bothering you, you can simply #undef main before your own main(). You'll probably have to unlink SDLmain, too.
It's odd, though. Unless this is a native Windows application, using std::cin even with SDLmain should be no problem.
FYI, SDLmain does a few things, but nothing you can't do without. Most notably, parse command line arguments (it will interpret "a spaced argument" as a single argument), which your runtime probably does, anyway, and redirect stdout and stderr to stdout.txt and stderr.txt respectively.
You just have to divvy up your display into two parts -- those parts into which you draw the game and those parts where you draw text. There isn't really any difference between that and drawing a sprite normally. Just take care with your clipping regions.
By "native Windows application" I mean "a Windows application that's not a Windows console application". Check the subsystem on your linker options. It should be "console", not "Windows".
SDL doesn't care about the subsystem, but if you change it to GUI, you definitely will not get a console (well, not one you can just use with std::c*).
You have to draw things to the display the same way as ever. All a clipping region does is prevent attempts to draw stuff from affecting stuff outside the clipping bounds.