# Simple Graphics Functions¶

Now that we have a simple demonstration program running, let’s review what you are seeing in this code. Actually, there is nothing here but a bunch of fairly simple functions that do the magic graphics work!

You have already seen a few functions in a previous lecture. There are a lot of math functions like sqrt and sin that are provided with the C++ language. But, we want to be able to write our own (we will do that later). For now, we will use a few simple functions I wrote for this class that will let us draw basic shapes on the screen.

## Graphics in C++¶

Graphics programs do not use the command prompt console, so we need to create a different kind of project. Specifically, we will build a Multimedia project. This kind of project will open up a graphics window where we can draw things. This is what Windows does all the time. We will not be building full Windows applications here. Instead, will be writing programs that use graphics to demonstrate programming concepts. The code we will be writing is very much like code being developed by professional programmers in the game industry, and we will be using the same graphics tools many of them are using.

## Graphics is hard!¶

Doing everything ourselves would be really hard and dumb! Instead, we will use functions written by other folks to do most of the work. The main functions are provided by OpenGL. This package is available for every platform, and comes pre-installed in Dev-C++. Before we can use this package, we need to understand how multi-file programs are constructed

## How programs are processed¶

What happens when you compile and run your program? The process is mush more complex than simply clicking on the “flag” in Scratch!

Behind the scenes, there are several tools working. Let’s look at the steps you follow to get a program running

You use the editing capabilities of CLion to create the source code for your program. You could use any editor capable of producing simple text files (Microsoft Notepad is one, but Microsoft Word is definitely not one!). Most programmers get a good programmer’s editor and learn how to use it so they can program outside of an IDE like CLion. My own personal favorite editor is gVim available from http://www.vim.org. This editor is the standard tool on most Linux machines, and the Windows version is pretty nice. If you plan on taking more programming courses, I recommend trying this one out. For our work in this class, we will stick with the editor in CLion.

Once your code is ready to go, we need check it to make sure it islegal C++. We use the C++ compiler to do this. The compiler checks the syntax of your code. If it is correct, it builds an object file as output This is just a file containing part of the final code. If the code is not correct, you get to fix the errors the compiler found.

Once the executable file is available, we can run it. You do this by asking the operating system to run the program for you. Windows has a number of ways you can use to start a program. We can double-click on a executable program file name in Windows Explorer, or type in the name of the executable file in a Command Prompt window.
Or, we can just click on the Run button in CLion.
We build multi-file programs by adding files to our project They will appear on the left side of the window Where main.cpp is found. CLion will compile all files that are part of the project Big programs can have dozens of parts! Ours will only have a few (very few) Go try the lab for this week!
Many beginning programmers do not know how to produce a working program outside of their IDE. That is not a good situation because when you go to work for a company, you might find that they use another IDE, or no IDE at all, and you might be stuck!