Posted  by 

Cannot Open C Dev Opengl Debug Opengl.exe For Writing Opengl

  1. GlfwWindowHint (GLFWOPENGLDEBUGCONTEXT, GLTRUE); Once we initialize GLFW we should have a debug context if we're using OpenGL version 4.3 or higher, or else we have to take our chances and hope the system is still able to request a debug context. Otherwise we have to request debug output using its OpenGL extension(s).
  2. Great thanks this was a great improvement although I don't know why it is not recommended? Now the issue I have with my program that links and runs is that the openGL window opens and works properly but the form will not open.
  3. Combining the mathematical concepts discussed so far (vectors and matrices), we now shift over and introduce the concept of transformations in OpenGL.

A lot of efforts have been made so that these tutorials are as simple to compile & run as possible. Unfortunately, this also means that CMakes hides how to do that on your own project.

So, this tutorial will explain how to build your own C application from scatch. But first, you need a basic knowledge of what the compiler actually does.

Mar 26, 2015  Setting up OpenGL and GLUT Visual Studio - C Forum Searches related to setup opengl setup opengl visual studio 2010 solved how do i setup opengl setup opengl ubuntu opengl setup xp opengl. We need a C/C compiler, either GCC (GNU Compiler Collection) from MinGW or Cygwin (for Windows), or Visual C/C Compiler, or others. Quoting from the opengl.org: 'GLUT is designed for constructing small to medium sized OpenGL programs. While GLUT is well-suited to learning OpenGL and developing. Oct 17, 2011  Hi Im currently using 9800GT on PCIE slot and 9500GT on PCI slot on Windows platform. I have tried to use OpenGL to boost my displaying speed but somehow it is not working properly. Apr 02, 2016  C# Language Bindings for OpenGL 4.5. OpenGL DotNet is a set of libraries and wrappers especially written for C# in order to make 3D OpenGL programming much easier. It is a base consisting of several libraries; on top of these libraries you can build your own 3D game engine and/or make much simpler 3D demos.

Please don’t skip the first two sections. If you’re reading this tutorial, you probably need to know this stuff.

Preprocessing

This is what all those #defines and #includes are about.

C preprocessing is a very simple process : cut’n pasting.

When the preprocessor sees the following MyCode.c :

, it simply opens the file MyHeader.h, and cut’n pastes its contents into MyCode.c :

Similarly, #defines are cut’n pasted, #ifs are analysed and potentially removed, etc.

At the end of this step we have a preprocessed C++ file, without any #define, #if, #ifdef, #include, ready to be compiled.

As an example, here is the main.cpp file of the 6th tutorial, fully preprocessed in Visual : tutorial06_preprocessed. Warning, it’s a huge file ! But it’s worth knowing what a seemingly simple .cpp really looks to the compiler.

Compilation

The compiler translates C++ code into a representation that the CPU can directly understand. For instance, the following code :

will be translated into this : x86 opcodes.

Each .cpp file is compiled separately, and the resulting binary code is written in .o/.obj files.

Note that we don’t have an executable yet : one remaining step is needed.

Linking

The linker takes all the binary code (yours, and the one from external libraries), and generates the final executable. A few notes :

  • A library has the .lib extension.
  • Some libraries are static. This means that the .lib contains all the x86 opcodes needed.
  • Some library are dynamic ( also said shared ). This means that the .lib doesn’t contain any x86 code; it simply says “I swear that functions Foo, Bar and WhatsNot will be available at runtime”.

When the linker has run, you have an executable (.exe on Windows, .nothing_at_all on unix) :

Runtime

When you launch the executable, the OS will open the .exe, and put the x86 opcodes in memory. As said earlier, some code isn’t available at this point : the code from dynamic libraries. But the linker was nice enough to say where to look for it : the .exe clearly says that the glClearColor function is implemented in OpenGL32.dll.

Windows will happily open the .dll and find glClearColor :

Sometimes a .dll can’t be found, probably because you screwed the installation process, and the program just can’t be run.

The instructions on how to build an OpenGL application are separated from the following basic operations. This is on purpose :

  • First, you’ll need to do these thinks all of the time, so you’d better know them well
  • Second, you will know what is OpenGL-specific and what is not.

Visual Studio

Creating a new project

File -> New -> Project -> Empty project. Don’t use any weird wizard. Don’t use any option you may not know about (disable MFC, ATL, precompiled headers, stdafx, main file).

Adding a source file in a project

Right clic on Source Files -> Add new.

Adding include directories

Right clic on project -> Project Properties -> C++ -> General -> Additional include directories. This is actually a dropdown list, you can modify the list conveniently.

Link with a library

Right clic on project -> Project Properties -> Linker -> Input -> Additional dependencies : type the name of the .lib. For instance : opengl32.lib

In Project Properties -> Linker -> General -> Additional library directories, make sure that the path to the above library is present.

Build, Run & Debug

Setting the working directory (where your textures & shaders are) : Project Properties -> Debugging -> Working directory

Running : Shift-F5; but you’ll probably never need to do that. Debug instead : F5

A short list of debugging shortcuts :

  • F9 on a line, or clicking on the left of the line number: setting a breakpoint. A red dot will appear.
  • F10 : execute current line
  • F11 : execute current line, but step into the functions this line is calling (“step into”)
  • Shift-F11 : run until the end of the function (“step out”)

You also have plenty of debugging windows : watched variables, callstack, threads, …

Opengl.exe

QtCreator

QtCreator is available for free at http://qt-project.org/.

Creating a new project

Use a plain C or C++ project; avoid the templates filled with Qt stuff.

Use default options.

Adding a source file in a project

Use the GUI, or add the file in the .pro :

Adding include directories

Debug

In the .pro file :

Link with a library

Right clic on project -> Add library

  • If you’re on Linux and you installed the library with apt-get or similar, chances are that the library registered itself in the system. You can select “System package” and enter the name of the library ( ex : libglfw or glew )
  • If not, use “System Library”. Browse to where you compiled it.

Build, Run & Debug

Building : Ctrl-B, or the hammer on the bottom left corner.

Running : the green arrow. You can set the program’s arguments and working directory in Projects -> Run Settings

Debugging :

  • Setting a breakpoint : Click on the left of the line number. A red dot will appear.
  • F10 : execute current line
  • F11 : execute current line, but step into the functions this line is calling (“step into”)
  • Shift-F11 : run until the end of the function (“step out”)

You also have plenty of debugging windows : watched variables, callstack, threads, …

XCode

Work in progress…

Creating a new project

Adding a source file in a project

Adding include directories

Link with a library

Build, Run & Debug

CMake

CMake will create projects for almost any software building tool : Visual, QtCreator, XCode, make, Code::Blocks, Eclipse, etc, on any OS. This frees you from maintaining many project files.

Creating a new project

Create a CMakeLists.txt file and write the following inside (adapt if needed) :

Launch the CMake GUI, browse to your .txt file, and select your build folder. Click Configure, then Generate. Your solution will be created in the build folder.

Adding a source file in a project

Simply add a line in the add_executable command.

Adding include directories

Link with a library

Build, Run & Debug

CMake doesn’t do that. Use your favourite IDE.

make

Please, just don’t use that.

gcc

It might be worth compiling a small project “by hand” in order to gain a better comprehension of the workflow. Just don’t do this on a real project…

Cooking games download for java. Download and play free Cooking Games. Serve up delicious meals in the best games featuring cooking and kitchens! Big Fish Games. Become a chef and serve up delicious meals to happy diners as you play free Cooking Games. Try before you buy! Download Cooking Games for free. Get project updates, sponsored content from our select partners, and more. Page Information: Download Pizza Manager game for mobiles - one of the best Java games! At PHONEKY Free Java Games Market, you can download mobile games for any phone absolutely free of charge. Nice graphics and addictive gameplay will keep you.

Note that you can also do that on Windows using mingw.

Compile each .cpp file separately :

As said above, you will have a main.o and a tools.o files. Link them :

a a.out file appeared; It’s your executable, run it :

That’s it !

Armed with this knowledge, we can start building our own OpenGL application.

  • Download the dependencies : Here we use GLFW, GLEW and GLM, but depending on your project, you might need something different. Save same preferably in a subdirectory of your project (for instance : external/)
  • They should be pre-compiled for your platform. GLM doesn’t have to be compiled, though.
  • Create a new project with the IDE of your choice
  • Add a new .cpp file in the project
  • Copy and paste, for instance, the following code (this is actually playground.cpp) :
  • Compile the project.

You will have many compiler errors. We will analyse all of them, one by one.

The error messages below are for Visual Studio 2010, but they are more or less similar on GCC.

Visual Studio - fatal error C1083: Cannot open filetype file: ‘GL/glew.h’ : No such file or directory

(or whichever other file)

Some headers are in weird locations. For instance, GLEW include files are located in external/glew-x.y.z/include/. The compiler has no way to magically guess this, so you have to tell him. In the project settings, add the appropriate path in the COMPILER (not linker) options.

Under no circumstance you should copy files in the compiler’s default directory (Program Files/Visual Studio/…). Technically, this will work, but it’s very bad practice.

Also, it’s good practice to use relative paths ( ./external/glew/… instead of C:/Users/username/Downloads/… )

As an example, this is what the tutorial’s CMake use :

Repeat until all files are found.

GCC - fatal error: GL/glew.h: No such file or directory

(or whichever other file)

This means that the library is not installed. If you’re lucky, the library is well-known and you just have to install it. This is the case for GLFW, GLEW and GLM :

If this is not a widespread library, see the answer for Visual Studio above.

Visual Studio - error LNK2019: unresolved external symbol glfwGetWindowParam referenced in function main

(or whichever other symbol in whichever other function)

Congratulations ! You have a linker error. This is excellent news : this means that the compilation succeeded. Just one last step !

glfw functions are in an external library. You have to tell the linker about this library. Add it in the linker options. Don’t forget to add the path to the library.

As an example, this is what the Visual project use. The names are a bit unusual because this is a custom build. What’s more, GLM doesn’t need to be compiled or linked, so it’s not here.

3utools download softonic. If you download these libraries from SourceForge (GLFW, GLEW) and build a library yourself, you have to specify the correct path. For instance :

GCC - main.cpp: undefined reference to `glfwInit’

(or whichever other symbol in whichever other file)

Same answer than for Visual Studio.

Note that on Linux, GLFW and GLEW (and many others) are usually installed with apt-get or similar : sudo apt-get install libglew-dev libglfw-dev (may vary). When you do that, the library is copied in the compiler’s standard directory, so you don’t have to specify the path. Just link to glfw and glew as shown in the 1rst section.

I set everything right, but I still have an “unresolved external symbol” error !

This might me tricky to track down. Here are several options:

I have a linker error with _imp_glewInit or some other symbol that begins with _imp

Cannot Open C Dev Opengl Debug Opengl.exe For Writing Opengl 4

This means that the library (in this case, glew) has been compiled as a static library, but you’re trying to use it as a dynamic library. Simply add the following preprocessor directive in your compiler’s options (for your own project, not glew’s) :

I have some other weird problem with GLFW

Maybe GLFW was built as a dynamic library, but you’re trying to use it as a static one ?

Try adding the following preprocessor directive :

I have another linker problem ! Help me, I’m stuck !

Please send us a detailed report and a fully featured zipped project, and we’ll add instructions.

I’d like to solve this myself. What are the generic rules ?

Let’s say you’re the author of GLFW. You want to provide the function glfwInit().

When building it as a DLL, you have to tell the compiler that glfwInit() is not like any other function in the DLL : it should be seen from others, unlike glfwPrivateImplementationMethodNobodyShouldCareAbout(). This is done by declaring the function “external” (with GCC) or “__declspec(dllexport)” (with Visual).

When you want to use glfw, you need to tell the compiler that this function is not really available : it should link to it dynamically. This is done by declaring the function “external” (with GCC) or “__declspec(dllimport)” (with Visual).

So you use a handy #define : GLFWAPI, and you use it to declare the functions :

GLFWAPI int glfwInit( void );

  • When you’re building as a DLL, you #define GLFW_BUILD_DLL. GLFWAPI then gets #define’d to __declspec(dllexport)
  • When you’re using GLFW as a DLL, you #define GLFW_DLL. GLFWAPI then gets #define’d to __declspec(dllimport)
  • When you’re building as a static lib, GLFWAPI is #define’d to nothing
  • When you’re using GLFW as a static lib, GLFWAPI is #define’d to nothing.

So the rule is : these flags must be consistent. If you build a lib (any lib, not just GLFW) as a DLL, use the right preprocessor definition : GLFW_DLL, GLEW_STATIC

My program crashes !

There are many reasons why a C++ OpenGL application might crash. Here are a few. If you don’t know the exact line where your program crashes, learn how to use a debugger ( see shortcuts above). PLEASE don’t debug with printf().

I don’t even go inside main()

This is most probably because some dll could not be found. Try opening your application with Dependency Walker (Windows) or ldd (Linux; try also this)

My program crashes on glfwOpenWindow(), or any other function that creates an OpenGL context

Several possible reasons :

  • Your GPU doesn’t support the requested OpenGL version. Try to see the supported version with GPU Caps Viewer or similar. Update driver if it seems too low. Integrated Intel cards on netbooks especially suck. Use a lower version of OpenGL (2.1 for instance), and use extensions if you lack features.
  • Your OS doesn’t support the requested OpenGL version : Mac OS… same answer.
  • You’re trying to use GLEW with an OpenGL Core context (i.e. without all the deprecated stuff). This is a GLEW bug. Use glewExperimental=true before glewInit(), or use a compatibility profile ( i.e. use GLFW_OPENGL_COMPAT_PROFILE instead of GLFW_OPENGL_CORE_PROFILE )

My program crashes on the first OpenGL call, or on the first buffer creation

Three possible reasons :

  • You’re not calling glewInit() AFTER glfwOpenWindow()
  • You’re using a core OpenGL profile, and you didn’t create a VAO. Add the following code after glewInit() :
  • You’re using the default build of GLEW, which has a bug. You can’t use a Core OpenGL Profile due to this bug. Either Use glewExperimental=true before glewInit(), or ask GLFW for a Compatibility Profile instead :

My program crashes when I try to load some file

Setup your working directory correctly. See Tutorial 1.

Create a test.txt file and try the following code :

USE THE DEBUGGER !!!! Seriously ! Don’t debug with printf(); use a good IDE. http://www.dotnetperls.com/debugging is for C# but is valid for C++ too. Will vary for XCode and QtCreator, but concepts remain exactly the same.

Something else is wrong

Please contact us by mail

CONTENTS
Background
Obtaining the Software
Installing the Software
Obtaining GLUT Files
Project Settings For anGLUT OpenGL Project
Compiling and RunningYour Project
Background
OpenGL is anopen graphics programming librarydeveloped by Silicon Graphics.Programmers use the applicationprogramming interfaces (APIs) of theselibraries in order to writegraphics programs using a variety of different languages including C++,Java, and Python. The purpose of this documentis to enable you to usean open-source integrated development environment (IDE)for writingOpenGL programs using C++.
Writing a program in any programming language requires a text editor,compiler, and linker in order to generate the executable, or softwareapplication that runs on a particular operating system such as WindowsXP or Mac OS X. Tosimplify the task of writing programs, softwaredevelopers created an IDE that organized all of the tasks of writing aprogram into one application. Popular IDEs include NetBeans (Java),Eclipse (multiple languagebindings), and VisualStudio (allMicrosoft-supported languages). NetBeans and Eclipse are freelyavailable, while Visual Studio is not free. Additionally, many ofthese IDEs have more features than you will probably need to use in anintroductory programming course.
Obtainingthe Software
In order to find the best of both worlds-- a free IDE and a fairlystraightforward IDE for C++, I recommend downloading BloodshedSoftware's Dev-C++for writing OpenGL C++ programs. The link toBloodshed Software is: http://www.bloodshed.net.The link to downloading the most recent version of Dev-C++ can be foundat: http://www.bloodshed.net/dev/devcpp.htmland select the link that says 'Dev-C++ 5.0..with Mingw/GCC'. Please beaware that this software only runs on Windowsoperating systems.

Installingthe Software
To install the software, follow these steps:
  1. From the section labeled 'Dev-C++ 5.0..with Mingw/GCC', selectthe SourceForge link or clickhere.

  2. You will be taken to the SourceForge download server. Here, youcan select the serve from which to download Dev-C++. In most cases, itwill be better to choose a mirror (or download server) somewhere in theUnited States; however, this is not required. In the Download column, click on the linkof the server of your choice.

  3. The page will refresh. If a download window does not appear aftera few seconds, click on the link given near the top of the page. Then,choose a location to save the file. Wait while the file downloads.

  4. Find the location on your computer where you downloaded the fileand double-click on the Dev-C++ installation icon. A dialog box willappear indicating the progress of preparing for the installation.

  5. A dialog box will appear asking what language you want for thisinstallation and then press the Ok button.


  6. Review the license agreement. If you are able to accept the termsof the license agreement, press the IAgree button.


  7. Now it is time to select the type of installation. In order tokeep things simple, choose the option Full for the option of Selectthe Type of Install. Make sure that you have sufficient space toperform the full installation.


  8. Select the location where you want the files installed. Becauseof some difficulties that may occur if you install to a directory namethat contains spaces, choose a directory location or make a newdirectory that does not contain spaces. Although program installationshould typically be in C:ProgramFiles, either make a new directory called C:other-programs or simply acceptthe default location of C:Dev-cpp.


  9. Watch the program install the files.


  10. After the installation program installs all of the necessaryfiles, Dev-C++ should be ready to run. If you want to run Dev-C++ now,make sure to check the item labeled RunDev-C++ 5.. Then, click on the Finish button.


The first time that you run Dev-C++, you will have to complete someadditional configuration steps which are listed below:
  1. Read the notice that appears with the beta software.


  2. Configure the software using the dialog boxes. Speicifically, youwill choose the language that you want to use and decide on the styleof the user interface.


  3. If you would like to have a hierarchy of the classes that you areusing and/or would like to have the ability for code to be completed bythe editor if you type in a series of unique letters, select the Yes.. option; otherwise, select the No.. option.


    • If you selected the Yes..option, you will be presented with the option of using a cache toassist the IDE with code completion. Unless there is a good reason notto do so (such as in the case with the IDE using too much memory andCPU power), create the cache now by selecting the Yes.. option and pressing the Next button.

  4. If everything worked as expected, you should see the followingmessage:


ObtainingGLUT Files
If you are running a Windows computer, the necessary OpenGL filesshould already be available. When in doubt, check the directory C:WINNTsystem32. In thisdirectory, there should be files like opengl32.dlland glu32.dll. If you aremissing any of these files, things will not work correctly when you tryto write OpenGL. Traditionally, the windows that are used for OpenGLprograms were dependent upon the underlying operating system windowmanagement system. This did not allow OpenGL programs to be as portableacross platforms as they should be. To solve this problem, the OpenGLUtility Toolkit, or GLUT, was created. If you have never writtenanyOpenGL programs using GLUT before, the necessary files for running GLUTwill not be avaiable. For this reason, you need to download them. Awebsite which explains how to use Dev-C++ to writeOpenGL GLUT programsalso provides information on where to download the appropriate GLUTfiles in addition to where to put them. The information about how to dothese tasks was taken from: http://www.cs.uofs.edu/~mpc3/cmps370/glutsetup.html.Download the following files from these locations:
  • glut.h fromhttp://www.cs.uofs.edu/~mpc3/cmps370/glut.hand save the file to C:Dev-C++includeGL.
  • glut32.def from http://www.cs.uofs.edu/~mpc3/cmps370/glut32.defand save the file to C:Dev-C++lib.
  • glut32.dll from http://www.cs.uofs.edu/~mpc3/cmps370/glut32.dlland save the file to C:WINNTsystem32.
As stated on the website where thesefiles can be downloaded, make sure to include glut32.dll with anyOpenGL GLUT programs that you distribute since your end-users may nothave this file available for running OpenGL GLUT programs.
ProjectSettings For an GLUT OpenGL Project
In Dev-C++,the IDEorganizes your code files into projects. Forthis reason, you need to specify the project type whenever you beginstart writing a new application. Follow the steps below to setup anOpenGLGLUT project:

Cannot Open C Dev Opengl Debug Opengl.exe For Writing Opengl 2


  1. From the Dev-C++ menu, select File-> New -> Project. A new dialog box will appear.

  2. Press the Basic tab andselect Console Application fromthe types of projects.

  3. Type the name of the project in the field named Name.

  4. Select the C++ Project optionfrom the box with options.

  5. Press the Ok button.

  6. It would be advisable to keep your projects organized in somehierarchy. It may be suitable to make a new directory that contains allof your Dev-C++ projects or place these Dev-C++ projects in some otherappropriate directory. In any case, choose a location and make surethat the project name is indeed what you want the project to be named.The settings for the project will be stored in a file called project-name.dev where project-name is the name you wantedto name the project.

Below is a picture that shows how things should look when you arefinished filling out the information in the dialog box:
You want to choose a console application because the program that youwrite should not contain any Win32 API code (this is code written thataccesses programming libraries specific to the Windows operatingsystem). The console application will enable you to have code that canbe run on an operating system that does not have Windows.
The next series of steps involves configuring the project options sothat files needed to make an OpenGL GLUT program can be easily found bythe Dev-C++ IDE. Instructions similar to the steps listed below appearon the website whose address is: http://www.cs.uofs.edu/~mpc3/cmps370/glutsetup.html.
  1. From the Dev-C++ menu, select Project-> Project Options. A new dialog box will appear

  2. Press the Parameters tabwhich should make the dialog box appear as seen below:


  3. It is necessary to add libraries that will support the operationof OpenGL and GLUT. Repeat the following steps-- press the Add Library or Object button andthen select the appropriate library file. These files begin with theletters 'lib' and ends in '.a'. It will be necessary to add thefollowing files: libglut32.a, libglu32.a, and libopengl32.a. These files will belocated in the libGL directory of your Dev-C++ installation directory.For instance, one path possibility could be: C:Dev-C++lib. When you arefinished, the dialog should look like this:


  4. Then press the Ok button.

Now, it is necessary to find a sample program. Andrew Johnson of theElectronic Visualization Laboratoryat UIC has a simple C program thatmeets this requirement. You can download it from: http://www.evl.uic.edu/aej/488/code/shell1.c.Either copy and paste the code from the website into the Dev-C++ editoror save the file and load the shell.c file into the current project. Achange that you will likely have to make is to change a line with #include<glut.h> to #include<GL/glut.h>. One thing to note, if you are new toprogramming, C++ is an 'improved' version of C that supports datastructures named objects. This loosely means that C program code can becompiled by a C++ compiler.
Compilingand Running Your Project
Compiling and running the code in your project is veryeasy..but..figuring out why your specific program does not compile orrun can become very difficult. This is true of anyone-- those who havespent a lot of time programming and those people who are learning howto program. Since errors are typically unique to each situation forcompiling or debugging, it is up to you to learn how to do this.Assuming that everything written correctly and the project isconfigured to use the proper libraries, do the following:
  • To compile a file, make sure that this file is visible in theeditor by selecting it from the list of files in the project browserand select Execute -> Compile fromthe menu. If you have multiple files in a project, complete this taskfor each file.

  • To run a file, select from the menu Execute -> Run. If your programneeds parameters in order to run properly, first select Execute -> Parameters and fillin the appropriate values in the dialog box. Then, choose this menuoption Execute -> Run.

There are also buttons that can be pressed to compile and run withouthaving to go to the menu each time you want to compile or run a program.