Sign in to follow this  

C++ Core Graphics commands??

This topic is 4337 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I have recently went from learning to programm in java and just made the switch to C++ a few months ago. Well, I am learning from Bruce Eckels online "thinking in c++". And I am catching on very quickly as my java expeaience is really helping alot! One thing I noticed about all beggener tutorials that deal with the "core" standard C++, and the command line. There is no graphical keywords, functions or commands that I have found so far. I know GDi(+), and Direct X and Opengl etc.. but thats not what I am talking about... Those libraries had to be made somehow so there has to be some basic 2d graphics in core C++. What did programmer's use in the DOS era?? (I was using lame Q-Basic back then, whuch was my first language) IS ther commands to change the background color or text color? How about drawing a basic line, or plotting points on the screen? There has got to be something along those lines, every other language has that stuff built in (that I've dealt with) Is there a simple 2d graphics api? or core C/C++ commands, I would love to mess around with that sort of thing before I get into DirectX/Windows GDi/or Opengl stuff(which is down the road for me.) Also can someone explain namespaces for me? Is there a danger in using : ///code: using namespace std; 'in programs instead of': " std::cout << "blah" <<endl; Etc.. ? One last thing for now what are unsigned and signed keywords for variables : most definitions are very vague. Thanks for any help!

Share this post


Link to post
Share on other sites
There are no core graphics APIs. There can be none, as c is not a system specific language.

Simple 2d libraries:

Allegro
SDL

signed and unsigned means weather or not a variable has a sign bit. If it does you can have a +/- range. If it is unsigned, your numbers can only be positive.

Share this post


Link to post
Share on other sites
Whether dropping the namespace prefix of a qualified name could be dropped at a specific scope depends on the visibility of all symbols known there.
using namespace x;
in C++ is has the same effect as
import x.*;
in Java w.r.t. the visibility of symbols: All symbols declared in the scope of x could be used w/o writing them qualified with x. or x::, resp.

So, whether
using namespace std;
could be done w/o danger in a particular case will be told you by your compiler :) Most often it will be okay.


Btw: If of interest:
All enums, variables, classes, functions, member fields, member routines, and similar stuff I may have forgotten here is represented by a name ("symbol"). Obviously, if a big app is made (e.g. a game :) there are really many such symbols needed. Moreover, there are symbols one has no infuence on, namely as soon as third party libraries are used (what is in fact not avoidable). So there was a need to either make symbols long enough (and hence inconvenient) to be unique (often done by prefixing, e.g. OpenGL uses the gl/GL prefix, while Direct3D uses D3D, and so on), or to think about a qualified naming scheme (Java does a similar thing with its packages). Qualifying the names has the advantages to use also the "normal" short names if they are unique in a given scope, and that the names of the already existing libs could be integrated w/o change.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
As the previous poster said, there is no 'core' graphics library for c++. Indeed many other languages have some sort of graphics library build in to them. That library is some sort of wrapper arround the GDI though. (at least when running in a windows environment)

Share this post


Link to post
Share on other sites
To get graphics to display in a DOS program, programmers would work directly with the video memory, changing color bytes to effect what was displayed on the screen. I do not believe it is as easy to do in protected mode (Windows XP for instance) so I'd go with OpenGL, DirectX, or some other graphics API.

The only real problem I see with "using namespace std;" is a possible name conflict, but you shouldn't be declaring a "cout" function anyways so that's not a real problem :).

I know the previous poster explained this already, but I'll take a stab at it as well. If you use "unsigned" in front of the variable type (for example, "unsigned int iVar;") it means that that variable can't have a negative value, such as -50, -392, -2333. The good thing about this though is you can put larger numbers into that variable. If you use "signed" in front of the variable type (for example, "signed int iVar;") then you can put negative numbers into that variable. Using a "signed variable" will decrease how big of a number you can put in there but as stated before, you can use negatives. If a variable type does not have "signed" or "unsigned" infront of it, it's set to signed by default.

I hope this helped :).

Edit: Wow, allot of people replied while I was typing this. "previous poster" refers to the first reply.

VBStrider

Share this post


Link to post
Share on other sites
Thanks for the help everyone! This community is great! One thing still bothering me.. I thought that Dirext X and Open GL, and Windows GdI were all programmed with C/C++. If C doesn't have it own graphical stuff, what are those libraries built from? The one guy said DOS graphics were programmed by directly accessing the video memory, I assume the "windows" in MS windows is done originally the same way, by Assembly language?? As well as the 3d libraries? If not assambly what was used to construct those libraries? Just curious, It's been buggin me thanks again everyone.

Share this post


Link to post
Share on other sites
When you get down INTO these core APIs, you reach voodoo land ... where things programers know and love just don't mean anything. Such as when writing a device driver, you often find you use MAGIC ADDRESSES and send buffers of bytes over MAGIC PORTS ...

The C / C++ code that does this stuff looks just like any normal C / C++ code, it simply moves and computes values in various addresses ... but what is going on under the hood is ... bytes written to certain virtual addresses are actually going to certain devices. bytes written to certain ports or raising interupts so that certain devices can read them ... stuff like that.

So even though the API is WRITTEN in C/C++ ... it only works due to the voodoo that is in your BIOS / Chipset / Operating System / and Platform-Specific libraries.

Share this post


Link to post
Share on other sites
Quote:
Original post by Xai
When you get down INTO these core APIs, you reach voodoo land ... where things programers know and love just don't mean anything. Such as when writing a device driver, you often find you use MAGIC ADDRESSES and send buffers of bytes over MAGIC PORTS ...

The C / C++ code that does this stuff looks just like any normal C / C++ code, it simply moves and computes values in various addresses ... but what is going on under the hood is ... bytes written to certain virtual addresses are actually going to certain devices. bytes written to certain ports or raising interupts so that certain devices can read them ... stuff like that.

So even though the API is WRITTEN in C/C++ ... it only works due to the voodoo that is in your BIOS / Chipset / Operating System / and Platform-Specific libraries.


Spooky.

Share this post


Link to post
Share on other sites
Quote:
Original post by silverphyre673
Quote:
Original post by Xai
So even though the API is WRITTEN in C/C++ ... it only works due to the voodoo that is in your BIOS / Chipset / Operating System / and Platform-Specific libraries.


Spooky.


I allways knew my graphics drivers were haunted...

Share this post


Link to post
Share on other sites

This topic is 4337 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this