Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Help me with graphics in C++

I am just a beginner in programming in C++. Although I know the basics I still have problems regarding graphics.
I am currently trying to develop a program that loads a geographic map and gives the latitude and longitude of the location corresponding to that pointed by the mouse cursor (or through the direction keys).
What I want to know is how do I load the map in BGI.
Your help will be greatly appreciated by me.

Thank you.

Comments

  • SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
    : I am just a beginner in programming in C++. Although I know the basics I still have problems regarding graphics.
    : I am currently trying to develop a program that loads a geographic map and gives the latitude and longitude of the location corresponding to that pointed by the mouse cursor (or through the direction keys).
    : What I want to know is how do I load the map in BGI.
    : Your help will be greatly appreciated by me.
    :
    : Thank you.
    :
    :
    You're trying to do this in DOS?! I suggest taking a day or two to learn Windows32 APIs and you can do this easily. In DOS, you're pretty much responsible for everything from mouse support to manually telling the video card what to do.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • XLoomXLoom Member Posts: 129
    Although I dont agree with [italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic] about windows API being easier, I must say that BGI is a bad way to go. It may be a good and simple thing to use if you want to put a bar or two onto a screen with resolution 640*480*16(not bits, colors... and only 16), but it is all in the past. Getting better resolutions with BGI is as far as I know quite impossible. As your geographical map (you didnt say how it is on disk, is it a .bmp type file or something else) is probably at least 16 bits, it has to be converted into 4 bit image when loaded, it looks really bad. No matter how well you do it.
    ... Come to think of it, if you have not yet learned how to program in DOS, there is no point to do it now. I just wanted to say that DOS isn't more difficult than windows. In windows you often have to do things around corners. I mean, you don't usually have nice, simple control over low level things like drawing pixel or mouse, you have to mess with messages, which are not good enough for everything you might want to do and so on. In DOS you can do most things more directly... except that memory is a problem in 16 bit environment. Writing things using XMS... OK, I just wanted to argue, windows is the way to go. I simply like DOS better because I learned to program in it first.
    One more thing. What does your geographical map look like, I mean the file. Is it bmp or jpg or just some file type you made yourself? I just ask this, because BGI doesnt have much to do with loading files ;), its just graphics. No matter what you decide to use, either windows API or DOS you probably will have to write loading this file yourself, if it isn't bmp. I'd like to know :)

    XLoom
  • SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
    : Although I dont agree with [italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic] about windows API being easier, I must say that BGI is a bad way to go. It may be a good and simple thing to use if you want to put a bar or two onto a screen with resolution 640*480*16(not bits, colors... and only 16), but it is all in the past. Getting better resolutions with BGI is as far as I know quite impossible. As your geographical map (you didnt say how it is on disk, is it a .bmp type file or something else) is probably at least 16 bits, it has to be converted into 4 bit image when loaded, it looks really bad. No matter how well you do it.
    : ... Come to think of it, if you have not yet learned how to program in DOS, there is no point to do it now. I just wanted to say that DOS isn't more difficult than windows. In windows you often have to do things around corners. I mean, you don't usually have nice, simple control over low level things like drawing pixel or mouse, you have to mess with messages, which are not good enough for everything you might want to do and so on. In DOS you can do most things more directly... except that memory is a problem in 16 bit environment. Writing things using XMS... OK, I just wanted to argue, windows is the way to go. I simply like DOS better because I learned to program in it first.
    : One more thing. What does your geographical map look like, I mean the file. Is it bmp or jpg or just some file type you made yourself? I just ask this, because BGI doesnt have much to do with loading files ;), its just graphics. No matter what you decide to use, either windows API or DOS you probably will have to write loading this file yourself, if it isn't bmp. I'd like to know :)
    :
    : XLoom
    :
    Lemme' guess, you're a Visual kiddie? Actually control over pixels is VERY entry-level and quite simple. Also, drawing mouse images is as easy as one or two function calls. No need to bother with messages. You just listen to the messages Windows send your app so you can tell what is going on, and you don't have to do that in some cases, such as a fullscreen game which you wrote most controls and such yourself.

    DOS is slightly harder because you can't get the full range of control without knowing some ASM to send to hardware. You can go up as high as 1024x768 in DOS (look at Duke Nukem 3D or others like Redneck Rampage). Heck, RR went as high as 1600x1200 in DOS! You simply need a VESA driver, which can be found anywhere online for free.

    Another downside to DOS is that nothing is built-in. You want to load a file, you write the code to load each byte yourself. In Windows you can call LoadImage() or something similar. There's no need to code mouse support or to code special functions to listen for mouse messages. Yeah, those fearful "messages" in Windows are the SAME things you get in DOS, only they are defined for EASIER understanding. Rather than telling somebody to listen for 0x120 to tell the mouse is moving, they listen for WM_MOUSEMOVE. Same message to the computer (0x120 for example), but the message that is defined is MUCH easier to understand and debug.

    Finally, there is the biggest problem with DOS. Modern computers do NOT support it. XP has a command-interpreter but it does NOT do DOS. Basic commands and simple functions are all it has. Try running an old DOS game on XP, even without sound. There's a 99.99% chance it will not run or if it does, that it will crash regularly. Coding for DOS is now obsolete. Windows NT, 2K, and XP won't like it, and if you have a CPU faster than a P3 or an AMD faster than 1.2GHz, you need XP or 2K just to take advantage of your processor! That means no DOS.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • XLoomXLoom Member Posts: 129
    No, I am not a Visual kiddie... I mostly use Dev-c. And OpenGL in most of my programs. But, you are right about all these things you wrote. Actually I don't know why I started to promote DOS so much... Guess I was feeling nostalgic because I was having my birthday :). And yes I do know DOS can give higher resolutions, I have done it all. By the way, the reason I didnt mention that higher resolutions are possible in DOS, is that these are a lot slower and harder to use because of bank switching. At least in 16 bit DOS...

    XLoom
  • SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
    : No, I am not a Visual kiddie... I mostly use Dev-c. And OpenGL in most of my programs. But, you are right about all these things you wrote. Actually I don't know why I started to promote DOS so much... Guess I was feeling nostalgic because I was having my birthday :). And yes I do know DOS can give higher resolutions, I have done it all. By the way, the reason I didnt mention that higher resolutions are possible in DOS, is that these are a lot slower and harder to use because of bank switching. At least in 16 bit DOS...
    :
    : XLoom
    :
    Happy belated birthday!

    Yeah, you can achieve high res in DOS, but it is VERY hard to make it work fast unless you have a killer CPU. A few other things to mention are that DOS can't use ANY enhancements (hardware rendering, mmx, 3dnow, EAX, etc etc) without a TON of very advanced coding. Windows can use it by default :D! However when just starting to learn C/C++ I may recomend a console app (includes Windows headers, but uses "main" instead of "WinMain") to run in a DOS box or command interpreter so the user can gain basic knowledge of the essentials (*printf, *scanf, file I/O, etc). Then just switch them up and pick up the basic window-creation stuff and they can do whatever they want!

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

Sign In or Register to comment.