Jump to content
  • Advertisement
Sign in to follow this  
Clotty

How does programming work?

This topic is 4748 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

I've read some articles and covered a few things, but I have one unanswered question ... I've heard of using a main program like C++, and then being able to combine it with something DierectX to enhance graphics or something ... I just wondered if I could have a brief overview of how this all works and if I'm missing anything? Feedback appreaciated.

Share this post


Link to post
Share on other sites
Advertisement
C++ is just one of many programming languages that can be used to develop programs for computers running on Operating Systems like Windows (2000, ME, XP, etc), Linux (in all of its wonderful and not-so-wonderful flavors) or Mac

DirectX is a windows-only library (correct me if Im wrong anyone that knows more about this than I do =) ) that you can call up in C++ to actually do the graphic rendering and whatnot.

The imo-better-graphics library OpenGL can run on both Linux and Windows and is (again imo) easier to work with.

So to make a program you would write code that did something like this:

//code
Include needed Direct X or OpenGL files
Include other files that this file needs to run

Function{
DirectX or OpenGL stuff to create some graphics (initialize and set up opengl or directx)
}
Function{
Render graphics to window
}
Main
gameloop

//end of code

Now this is a no-brainer but this code won't work if you just copy and paste into a compiler. Id bet money that there is someone that would actually think this would work as is lol =)

I hope I helped a little or a whole lot =)

~Brandon Haston~

Share this post


Link to post
Share on other sites
Quote:
Original post by Clotty
I've read some articles and covered a few things, but I have one unanswered question ...

I've heard of using a main program like C++, and then being able to combine it with something DierectX to enhance graphics or something ... I just wondered if I could have a brief overview of how this all works and if I'm missing anything?

Feedback appreaciated.



As stated above, C++ is indeed a programming language, and you can indeed use the DirectX SDK ( DirectX ) to build 3 Dimensional games, and DirectX isn't your only choice ( See signature for details. )

[Edited by - Lenox on May 23, 2005 10:00:56 PM]

Share this post


Link to post
Share on other sites
hmmm... probably you need a more low level answer...

Programming is dividing complex operations such as "make a shoot'em'up" into elementary operations that the compiler understands. A compiler is a program that changes what you write in some "programming language" (such as C++)) to a form the processor understands (binary). Programming everything using only the elementary commands is hard, so smart people made libraries (pieces of code, such as directX), that you can use to achieve "less elementary" operations easier.

Share this post


Link to post
Share on other sites
Thanks guys, I have a better understanding now. Basically, A programming language like C++ does need Open or DirectX, but to enhance graphics and make some nice 3D designs, you'd need to add them in. How hard is it incoorporating Open or DirectX into C++ script?

Share this post


Link to post
Share on other sites
It takes some skill and practice, but with the propper knowledge it isn't too hard. Like anything, it becomes easier with practice. I'd suggest going 2D first. One step at a time ;);

-IV

Share this post


Link to post
Share on other sites
Quote:
Original post by Clotty
Thanks guys, I have a better understanding now. Basically, A programming language like C++ does need Open or DirectX, but to enhance graphics and make some nice 3D designs, you'd need to add them in. How hard is it incoorporating Open or DirectX into C++ script?
You need them to have 3D graphics, not just to enhance them. Also, you probably mean "OpenGL" and C++ programs aren't (usually) considered scripts. Tutorials should help explain how to use OpenGL and DirectX, but make sure you know C++ pretty well before learning them.

Share this post


Link to post
Share on other sites
C++ in the most technical sense is just a detailing of a unique language specification. A language (programming) then is a set of rules describing how text specifying instructions for the CPU to perform should be formatted.

Therefore, C++ is not a program -- it is in effect a language which describes instructions for the CPU to carry out. However, the processor itself can not read text, nor can in comprehend many of the logical constructs present in modern programming languages (such as C++).

To remedy this, programs called compilers were built whose purpose is to take in a text file whose contents conform to some language specification, and according to said language, convert the text (commonly called "source code", "code" or "source") into a different format which the CPU does understand. Typically, this second, converted-to format is termed "machine language", derived from the fact that it is a "language which the machine understands".

The name "compiler" comes from an interpretation of what such a program does. A compiler would seem to "compile", or mash together, all of your code (which is very often distributed across several text files) into a single executable file. The exe file is essentially a string of binary digits specifying the low-level instruction the CPU should execute (instructions such as "move this piece of memory over there").

Machine language is often just a binary equilavent of assembly, which represents commands with triples of characters rather than binary digits. For example, the "move this piece of memory over there" would be represented in assembly as "mov". The operation of adding two numbers would be "add", whereas subtraction would be "sub".

Assembly language is said to be "low-level", whereas C++ is said to be "high-level". These terms are based on how accurately the language conveys the actual processes which will be performed by the CPU. The more abstracted the language is (meaning the more that can be done with a single command), the less low-level it is and the more high-level. Also, the more responsibility placed upon the programming (such as memory-management) also contributes to a language's "lowliness".

DirectX and OpenGL (not "Open", but "OpenGL"; it is an acronym for Open Graphics Library) are APIs (acronym for Application Programming Interface) which provide a layer of abstraction between the user's code (most likely C++) and the graphics hardware.

The need for such APIs arises from the fact that most graphics cards operate in with a different format of instructions. These instructions are similar to those of assembly, however they differ between cards as previously stated. The job of a graphics API (e.g. Direct3D and OpenGL) is to automatically take high-level graphics commands and convert them into the low-level representations readable by the computer running the program.

Incorporating such APIs into a program is unfortunately not often a trivial task. You first must be proficient with the programming language of choice. You must also be proficient with 3D math if the API is to be used efficiently and effectly. Lastly, you must take the time to famiarlize yourself with the interfaces of the API.

If you are already proficient with your language of choice and with 3D math, then learning an API is typically easy, and can take only a few days to a week. The transition would still not be "trivial" in my opinion, though, as it is a transition which will likely effect the entirety of your program.

I hope my explanations were helpful,
nilkn

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!