- Dev C 2b 2b Directx Example Pdf
- Dev C 2b 2b Directx Example Java
- Dev C 2b 2b Directx Examples
- Dev C 2b 2b Directx Example Key
What is Dev-C++?
Dev-C++, developed by Bloodshed Software, is a fully featured graphical IDE (Integrated Development Environment), which is able to create Windows or console-based C/C++ programs using the MinGW compiler system. MinGW (Minimalist GNU* for Windows) uses GCC (the GNU g++ compiler collection), which is essentially the same compiler system that is in Cygwin (the unix environment program for Windows) and most versions of Linux. There are, however, differences between Cygwin and MinGW; link to Differences between Cygwin and MinGW for more information.
February 22, 2015 - DirectX 11.2 and Windows Phone Now Available. DirectX 11.2 now has it's own set of lessons. It is very similar to the DirectX 11.1 lessons, but features Universal Apps, meaning you can port the code to Windows Phone devices very easily. Next up I plan to add a section for model rendering for DirectX 11, 11.1 and 11.2.
Bloodshed!?
I'll be the first to say that the name Bloodshed won't give you warm and fuzzies, but I think it's best if the creator of Bloodshed explains:
There's also a reason why I keep the Bloodshed name. I don't want people to think Bloodshed is a company, because it isn't. I'm just doing this to help people.
Here is a good remark on the Bloodshed name I received from JohnS:
I assumed that this was a reference to the time and effort it requires of you to make these nice software programs, a la 'Blood, Sweat and Tears'.
Peace and freedom,
Colin Laplace
Getting Dev-C++
The author has released Dev-C++ as free software (under GPL) but also offers a CD for purchase which can contain all Bloodshed software (it's customizable), including Dev-C++ with all updates/patches.
Link to Bloodshed Dev-C++ for a list of Dev-C++ download sites.
You should let the installer put Dev-C++ in the default directory of C:Dev-Cpp, as it will make it easier to later install add-ons or upgrades.
Using Dev-C++
This section is probably why you are here.
All programming done for CSCI-2025 will require separate compilation projects (i.e. class header file(s), class implementation file(s) and a main/application/client/driver file). This process is relatively easy as long as you know what Dev-C++ requires to do this. In this page you will be given instructions using the Project menu choice. In another handout you will be given instructions on how to manually compile, link and execute C++ files at the command prompt of a command window. See here.
Step 1: Configure Dev-C++.
We need to modify one of the default settings to allow you to use the debugger with your programs.
- Go to the 'Tools' menu and select 'Compiler Options'.
- In the 'Settings' tab, click on 'Linker' in the left panel, and change 'Generate debugging information' to 'Yes':
- Click 'OK'.
Step 2: Create a new project.
A 'project' can be considered as a container that is used to store all the elements that are required to compile a program.
- Go to the 'File' menu and select 'New', 'Project...'.
- Choose 'Empty Project' and make sure 'C++ project' is selected.
Here you will also give your project a name. You can give your project any valid filename, but keep in mind that the name of your project will also be the name of your final executable. - Once you have entered a name for your project, click 'OK'.
- Dev-C++ will now ask you where to save your project.
Step 3: Create/add source file(s).
You can add empty source files one of two ways:
- Go to the 'File' menu and select 'New Source File' (or just press CTRL+N) OR
- Go to the 'Project' menu and select 'New File'.
Note that Dev-C++ will not ask for a filename for any new source file until you attempt to:- Compile
- Save the project
- Save the source file
- Exit Dev-C++
- Go to the 'Project' menu and select 'Add to Project' OR
- Right-click on the project name in the left-hand panel and select 'Add to Project'.
EXAMPLE: Multiple source files In this example, more than 3 files are required to compile the program; The 'driver.cpp' file references 'Deque.h' (which requires 'Deque.cpp') and 'Deque.cpp' references 'Queue.h' (which requires 'Queue.cpp'). |
Step 4: Compile.
Once you have entered all of your source code, you are ready to compile.
- Go to the 'Execute' menu and select 'Compile' (or just press CTRL+F9).
It is likely that you will get some kind of compiler or linker error the first time you attempt to compile a project. Syntax errors will be displayed in the 'Compiler' tab at the bottom of the screen. You can double-click on any error to take you to the place in the source code where it occurred. The 'Linker' tab will flash if there are any linker errors. Linker errors are generally the result of syntax errors not allowing one of the files to compile.
Step 5: Execute.
You can now run your program.
- Go to the 'Execute' menu, choose 'Run'.
Disappearing windows
If you execute your program (with or without parameters), you may notice something peculiar; a console window will pop up, flash some text and disappear. The problem is that, if directly executed, console program windows close after the program exits. You can solve this problem one of two ways:
- Method 1 - Adding one library call:
On the line before the main's return enter:system('Pause');
- Method 2 - Scaffolding:
Add the following code before any return statement in main() or any exit() or abort() statement (in any function):/* Scaffolding code for testing purposes */
This will give you a chance to view any output before the program terminates and the window closes.
cin.ignore(256, 'n');
cout << 'Press ENTER to continue...'<< endl;
cin.get();
/* End Scaffolding */ - Method 3 - Command-prompt:
Alternatively, instead of using Dev-C++ to invoke your program, you can just open an MS-DOS Prompt, go to the directory where your program was compiled (i.e. where you saved the project) and enter the program name (along with any parameters). The command-prompt window will not close when the program terminates.
For what it's worth, I use the command-line method.
Step 6: Debug.
When things aren't happening the way you planned, a source-level debugger can be a great tool in determining what really is going on. Dev-C++'s basic debugger functions are controlled via the 'Debug' tab at the bottom of the screen; more advanced functions are available in the 'Debug' menu.
Using the debugger:
The various features of the debugger are pretty obvious. Click the 'Run to cursor' icon to run your program and pause at the current source code cursor location; Click 'Next Step' to step through the code; Click 'Add Watch' to monitor variables.
Setting breakpoints is as easy as clicking in the black space next to the line in the source code.
See the Dev-C++ help topic 'Debugging Your Program' for more information.
Dev-C++ User F.A.Q.
Why do I keep getting errors about 'cout', 'cin', and 'endl' being undeclared?
It has to do with namespaces. You need to add the following line after the includes of your implementation (.cpp) files:
How do I use the C++ string class?
Again, it probably has to do with namespaces. First of all, make sure you '#include ' (not string.h). Next, make sure you add 'using namespace std;' after your includes.
Example:
That's it for now.I am not a Dev-C++ expert by any means (in fact, I do not teach C++ nor use it on a regular basis), but if you have any questions, feel free to email me at jaime@cs.uno.edu
Why do I keep getting errors about 'cout', 'cin', and 'endl' being undeclared?
It has to do with namespaces. You need to add the following line after the includes of your implementation (.cpp) files:
How do I use the C++ string class?
Again, it probably has to do with namespaces. First of all, make sure you '#include ' (not string.h). Next, make sure you add 'using namespace std;' after your includes.
Example:
That's it for now.I am not a Dev-C++ expert by any means (in fact, I do not teach C++ nor use it on a regular basis), but if you have any questions, feel free to email me at jaime@cs.uno.edu
Happy coding!
How to Install Dev-C++ and the GLUT Libraries
for Compiling OpenGL Programs with ANSI C
(version of July 16, 2009)
These notes explain how to compile programs written in ANSI C with OpenGL and GLUT using the Dev-C++ compiler.
Bloodshed Dev-C++ is a free C++ compiler and development environment for Windows operating systems. Like most C++ compilers, it also can be used to compile ANSI C. By installing the GLUT header and library files, it can be used to write programs that use OpenGL. This is needed to run programs for Edward Angel's textbook, Interactive Computer Graphics 5th edition and possibly other computer graphics texts.
These notes do not explain how to compile OpenGL with C++ . The 6th edition of Angel's book uses C++ which will not work with these notes.
These instructions have been tested on a small variety of Windows 2000 and Windows XP systems. These systems come with the files needed for OpenGL, but not the files needed for GLUT.
Dev-C++ does not work well with Microsoft's Vista. The problem, and a possible fix, is discussed here: http://aresio.blogspot.com/2007/06/vista-and-dev-cpp.html but I have not tested this information.
I. Download Dev-C++ from http://www.bloodshed.net/dev/devcpp.html and install it.
Details:
Dev C 2b 2b Directx Example Pdf
Get Dev-C++ 5.0 beta 9.2 (4.9.9.2) (9.0 MB) with Mingw/GCC 3.4.2 Although this is a 'beta' version, it works perfectly fine. Click on SourceForge to go to a list of download sites and pick one. The file will be something like devcpp4.9.9.2_setup.exe. Save this file in a place like C:Temp.
When the download is complete, click on the 'open' button to start the installation process. (Or go to C:Temp andDouble click on devcpp4.9.9.2_setup.exe). You will see a few screens that ask you to pick a language (English) and to agree to the license terms. Choose a 'typical' installation.
Accept the suggested destination for the installation:
Many subdirectories and files are extracted to the destintion:
Answer 'yes' when it asks if you wish to install Dev-cpp for all users. Note: if the installation fails, re-install and try 'no' for this.
A screen says the installation is complete:
Keep the check mark in the box. Click on 'Finish'. A first-time configuration screen appears:
Pick 'English' and 'New Look'. In the next several screens, hit 'Yes' for its suggestions.
Eventually you are done. Click 'OK'.
II. DEV-C++ starts up. Try out the installation with a simple C program.
Details:
The program starts up automatically.
Click File/New/Project. Pick a name for the project (such as 'myProject'). Click 'C Project'. Click on 'Empty Project'. Click 'OK'.
In 'Create New Project', click 'save' (later on you will probably want to create separate subdirectories for your various projects.).
Click 'File/New/Source File' and in 'Add source file to current project' click 'Yes'. You now get a screen where you can edit the source file.
Type in a simple C program, as below. Now click 'File/Save As' and save the file as 'hello.c' (or other name.) Important: be sure that the file extension is .c. With any other extension (such as the suggested .cpp) you will have problems compiling.
Now click 'Execute/Compile and Run'
The program will (hopefully) compile, run, and write its output to a DOS window. If you have the system('pause')
statement in your program, the output will stay in the window until you hit a key. Another way to run the program (after it has been compiled) is to start a DOS window outside of the Dev-Cpp system, then navigate to the subdirectory that holds your project, and type hello.exe.
At this point, the compiler and development environment has been installed. You should find Dev-C++ listed under 'Programs' on the 'Start' menu and will now be able to write, compile, and run C (and C++) programs. You will have include files, libraries, and dll's for OpenGL (and all other standard packages) but not GLUT. GLUT manages the windows and other user interface components needed for OpenGL programming, and needs to be separately installed.
If you do not need GLUT , you can quit now.
III. Download and install GLUT
To run OpenGL with GLUT (which is what the programs in Angel's book use), you need to get three files and place each file in its proper directory. All the files you need (and more) are contained in one zip file.
Details:
Download GLUT files from http://chortle.ccsu.edu/Bloodshed/glutming.zip Download the file glutming.zip
Save the zip file in some convenient location (perhaps C:temp).
Double click on glutming.zip (or otherwise unzip it). You will see the files that are in the zip archive. (Your un-zipping program will probably be diferent than the one shown here, but should work about the same.)
Click on 'Extract' to extract all the subdirectories and files. Pick some convenient directory to extract them to (perhaps C:tempglutming). You only need three files, but extract all of them anyway.
Only three of the files in the various subdirectories are needed. Each of the three files should be put in a subdirectory with other files of its type. Use Explorer to move the files to where they are needed.
Note: If you only see some of these files listed in Explorer, click on 'View/Options/View' and then select the radio button 'Show all Files'.
glut.h -- copy this file to C:Dev-CppincludeGL
Copy from your 'unzipped' subdirectories (wherever they are):
To here:
Dev C 2b 2b Directx Example Java
libglut32.a -- copy this file from your unzipped directories to C:Dev-Cpplib
There may be a newer version of this file there, already. Replace that version with the one you unzipped (if you keep the newer version your programs will not link correctly.)
Copy from your 'unzipped' subdirectories:
To here:
glut32.dll -- move this file to C:WINNTSystem32, or similar location.
The location for this file depends on your operating system. The directory where it goes is the directory that holds the dynamic load libraries (*.dll). An easy way to find where it should go is to look for glu32.dll (use 'Search' from the start menu).
The directory to use should also have the files glu32.dll and opengl32.dll. These should have come with your operating system.
IV. Test Dev-cpp with GLUT
The essential step in compiling and running a C program that contains OpenGL and GLUT functions is to tell the linker where the libraries are. This is done by clicking Project/Project Options/Parameters/Add Library or Options and then navigating to the libraries you need to include: libopengl32.a, libglu32.a, and libglut32.a. The libraries should be added in that order.
Details:
a. Create a subdirectory for a project. Do this first, before you start Dev-Cpp. Create a new subdirectory with 'Explorer' by clicking 'File/New/Folder'.
For example, create a folder C:GLproject.
b. Start Dev-cpp:
c. Start a new project by clicking File/New/Project. In the panel that pops up, name the project something like 'rectangle', click on 'empty project' and 'C': Click OK.
Note: For compiling with OpenGL you must create a project. You need to have a project (not just a single C file) in order to link in the OpenGL libraries.
d. In the next panel, navigate to your folder C:GLproject, and click 'Save'.
e. In Dev-C++, click 'File/New/Source File' and then in the next panel 'Add to Project' click 'yes'. Click 'File/Save As' and then give the file a name. Navigate to your project subdirectory to save the file in it. Name the file something like 'rectangle.c'
Be sure that the file names ends with '.c' anything else will cause big problems.
f. Click and drag your mouse over the following program so that it is highlighted, then click 'Edit/Copy' from the browser's menu bar.
g. Now click in the editing window of Dev-cpp and then click 'Edit/Paste' in its menu bar. The program will appear in the editing window.
Dev C 2b 2b Directx Examples
h. Click 'File/Save'. The file in your project directory should now contain an OpenGL program.
i. Tell Dev-cpp what libraries need to be linked. Click 'Project/Project Options'.
j. Now click 'Parameters'. Click the 'Add Library or Object' button and navigate to the libraries that should be added, found under C:Dev-cpplib
- ../lib/libopengl32.a
- ../lib/libglu32.a
- ../lib/libglut32.a
Add them in that order (only). Notice that the slashes will appear in Unix style '/' rather than DOS-style '.
When you are done adding the three libaries, you should see:
The exact pattern of '../../..' you see depends on how deep in the directory structure your source file lies.
Click 'OK'.
k. Click 'Execute/Compile and Run'. The program should compile, link, and run:
Dev C 2b 2b Directx Example Key
If things don't work (very common) click on the 'Compile Log' tab for some confusing error messages. If you see something like the following, it means that you made a mistake in adding the libraries to the project:
Try to fix the list of libraries, or perhaps start over from scratch.
You now are finished, or have given up.