Tag Archives: OpenGL

The first time I write OpenGL program, what should I do when I encounter “can’t open include file:” GL / glaux. H “: no such file or directory”?

Recently, while learning the tutorial of Nehe, I use VS2010 as the learning and development platform.

I just copied the nehe code into the empty project I built. I was about to compile and run, but I did not expect to meet the “cannot open the included file:” glaux-h “: No such file or directory”! How to do?

So, I baidu.com, there is no relevant glaux file in the system.

Therefore, the solution is as follows:
1) Search and download GLAUX related files online
2) Copy glaux. DLL to C:\Windows\System32
3) Copy glaux.lib to C:\Program Files (x86)\Microsoft SDKS \Windows\v7.0A\ lib
4) Copy glaux. H to C:\Program Files (x86)\Microsoft SDKS \Windows\ V7.0 A\Include\ GL

Click Compile Run again, “Cannot resolve the external symbol __imp__glLoadIdentity@0, the symbol in the function” appears.

Once again baidu, originally, is not to join the related lib caused, so also in the code to add:
#pragma comment(lib,”opengl32.lib”)
#pragma comment(lib,”glu32.lib”)
#pragma comment(lib,”glut32.lib”)

Actually, I didn’t find glut32.lib on my computer, so I commented the “#pragma comment(lib,”glut32.lib”)”.

Click compile and run again, and the program finally runs. It’s a relief.

Solution to the problem that OpenGL can’t find glew32.dll in vs2019

#define GLEW_STATIC
#define GLEW_STATIC
#define GLEW_STATIC
#define GLEW_STATIC
#define GLEW_STATIC
#include < GL/glew.h>
#include < GLFW/glfw3.h>
#include
# pragma comment (lib, “glew32. Lib”)
int main() {

glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);


// Open GLFW Window
GLFWwindow* window = glfwCreateWindow(800, 600, "My OpenGL Game", NULL, NULL);

if (window == NULL)
{
	printf("open window failed");
	glfwTerminate();
	return -1;
}

glfwMakeContextCurrent(window);

// Init GLEW
GLboolean glewExperimental = true;
if (glewInit() != GLEW_OK)
{
	printf("init GLEW failed");
	glfwTerminate();
	return -1;
}

glViewport(0, 0, 800, 600);

while (!glfwWindowShouldClose(window))
{
	glfwSwapBuffers(window);
	glfwPollEvents();
}

glfwTerminate();
return 0;

}
Glew32.dll

1

1

1

1

1

1

br>
> You need to enter the C disk with admin privileges, then put a copy of glew32.dll into C:\Windows\SysWOW64, the problem is fixed, the window appears

Create an OpenGL project in codeblock

This semester’s graphics need to use OpenGL, but the teacher configured OpenGL in class is VS2010, I don’t know what is wrong with my computer. Several installs of VS2010 are useless. So I went online to find out how to configure OpenGL in Codeblock. But many of them are useless. Very not easy to find the method is feasible in this blog (assault delete) : http://blog.csdn.net/yang_7_46/article/details/24674849
The resources I also uploaded to: http://download.csdn.net/detail/qq_33276623/9468487
Specific configuration method (yes I was the screenshot. Face covering) : Ahah

How do you create the project once you’ve configured it?
1. The file – & gt; New – & gt; For the project, select GLUT Project

The following steps are done by themselves. This is it

You need to select MinGW, and the next step is to create it successfully.
If you want to add files to the Codeblock project, select the project -> from the top function bar; Just add it.

Configuring OpenGL with win 10 + CodeBlocks

Download Windows environment GLUT, website is: http://pan.baidu.com/s/1qXEUHR2 password: tr2h

Unpack the downloaded package, and you will get three files (Glut.h, Glut32.dll, LibGlut32.a).

C: IDE\ Codeblocks \MinGW\include\GL; C: IDE\ Codeblocks \MinGW\include\GL
(2) Put the unpacked libGlut32.a in the folder where the static library is located C:\IDE\CodeBlocks\MinGW\lib.
(3) Put the unpacked glut32.dll into the system32 folder under the operating system directory. (The typical location is: C:\ WindowsSystem32, this is for 32-bit operating systems. If you are installing a 64-bit operating system, you should place GLUT32.dll in the C:\ WindowsSyswow64 folder under the operating system directory.)

Example:
(1) Create a GLUT project



(2) Select the project path



(3) Select the path of GLUT, that is, under the MinGW directory of CodeblCoks

(4) Finish directly



(5) The operating results are as follows


Using the third party OpenGL in codeblock

Configuring OpenGL with VS is of course quick and smooth, but I prefer to write small programs with lightweight Codeblock, and as a novice to Codeblock, it took me a long time to figure it out

Codeblock already has some OpenGL header files and.a library files, but they are not comprehensive and GLUT is missing. So I downloaded the “full version” that someone else had cobbled together to use. The configuration steps are as follows:

(1) Unpack OpenGL into a folder, which usually contains an include folder containing header files and a lib folder containing lib files, or simply mix the header files and lib files into a folder.

(2) Open Codeblock and click Settings->; Open a dialog box, click New on the second line, enter the name of the variable you like, mine is OpenGL, press OK, then in the left side of the base column to fill in the directory where OpenGL is located, mine is D:\MyWorkSpace\ openGL_sdk, in the include column and lib column to fill in as follows. In short, provide the directory where the header and lib files are located. If all the files are mixed together, the three paths can be the same. Finally, click Close.

(3) If you want only one Project to be able to detect OpenGL’s directory, then click Project-> on the existing Project; Build Option; If you want all projects to be able to detect the OpenGL directory, click Settings->; Complier. Then go to the Search Directories TAB and Add a $(#OpenGL)\include column in the Comier TAB below, and a $(#OpenGL)\lib column in the Linker TAB next to it. Go to the Linker Settings TAB above, press Add below to Add all the lib files in the OpenGL directory (the number of files may not be the same as mine, NO matter), and then press “OK” or “No” in the dialog box that pops up. Finally press OK.

(4) Compiling and linking. At this point, if there are no problems, congratulations, the configuration is complete. However, maybe some people like me are suffering from a problem, compiler error, something like:

        
Filename reference to ‘__ ‘

Error messages in this format are usually caused by a failure to link the LIB file, so at first I thought the MINGW compiler could not use LIB, but only A files, so I went back to the MINGW utility and tried to convert LIB to A files, but it didn’t work and generated a DLL. And even weirder on my roommate’s machine, it generates obj. It didn’t seem to happen to anyone else on the Internet, so I didn’t find a solution for it for a long time, so I decided to ditch it. After a long search, I finally found two articles that said,
Undefined reference”
The question:

http://www.mingw.org/wiki/HOWTO_Use_Mark_J_Kilgards_OpenGL_Utility_Toolkit_GLUT_with_MinGW

http://blog.csdn.net/huys03/article/details/2260949

       
My in containing the include OpenGL precompiled instruction before increase # define _STDCALL_SUPPORTED success, maybe others’ not yet, in order to insurance, you can write:

#define _STDCALL_SUPPORTED
#define _M_IX86
#define GLUT_DISABLE_ATEXIT_HACK

Remember to put it in front of the header file code that contains OpenGL. You can remove the warning by adding the following code in the previous position:

#define GLUT_NO_WARNING_DISABLE

I hope you found this article useful.

OpenGL configuration under CodeBlocks in Ubuntu


OpenGL configuration in Codeblocks requires only one step:

Project -> “Proproties” are added to the picture below

-lGL -lGLU -lglut

Compile and run successfully.

Please leave me a message if you have any questions.


Reference: http://lazyfoo.net/tutorials/OpenGL/01_hello_opengl/linux/codeblocks/index.php

Configuration of OpenGL under CodeBlocks and solutions to problems encountered

The configuration process: https://blog.csdn.net/sophiale07/article/details/44965875
Undefined reference to ‘_XX OpenGL function name ‘.
Solution:
Add before include precompile directives that include OpenGL

 #define _STDCALL_SUPPORTED

 
If it still doesn’t work, add

#define _M_IX86  
#define GLUT_DISABLE_ATEXIT_HACK  

There may also be warnings, which can be removed by the following code:

#define GLUT_NO_WARNING_DISABLE

Modify the compilation and Makefile methods for undefined reference errors.
https://blog.csdn.net/huys03/article/details/2260949

Configure OpenGL in CodeBlocks

There are many online tutorials, but some are easy to use and some are not.
There are two broad categories. One is that you don’t have to manually add libraries after you’ve configured them, but a New GLUT Project is needed to create a New Project instead of the usual Console Application. This category can refer to this document: https://wenku.baidu.com/view/7396dc8783d049649b66588c.html
Another type of configuration method, when configured, will be a New normal Console Application, but you will need to manually add the OpenGL library.
I chose the second category because I found that the console could not be tuned out of the configuration method of the first category, so I could not see the output of the console. Debug is very inconvenient, so I haven’t found a solution yet.
General reference is http://www.yalewoo.com/opengl_notes_2_use_opengl_in_codeblocks.html, but is not identical also, built after the project need to add one more libraries.

Steps:
Glut. h goes into the MinGW\include\GL directory of the compiler. .
glut32 lib in MinGW \ lib directory
glut32. The DLL into the C: \ Windows \ System in

Open the codeblocks create the console program, and then in the project to build the options – would add three static link library glut32 Settings. The lib, libopengl32. A, as well as libglu32. A, their paths in the lib folder of the compiler.

Summary of problems encountered by CodeBlocks + OpenGL

1. Explore the installation software, configure OpenGL, the key is where the several files of GLU are placed, and how to set up the link library for the new project.
2. Try to run the code for the class
#include< #include< iostream> and # include< stdio.h> #include < #include < GL/gl.h> And # include & lt; GL/glut.h> needs to replace include < GL/ogl.h> . Not familiar with OpenGL header files.
3. Summary of Mistakes:
1.error:assignment of read-only variable 'S_width'
2.error:initializer element is not constant
The initializer element is not constant error occurred during compilation. Problem: The value of a global variable cannot be determined at compile time, but must be determined at execution time (compile principle). That is, the global variable should be declared outside the function, and the assignment should be done inside the function. Solution: Declare the variable name externally and assign the value inside the function.
3. The codeblocks warning: ignoring # pragma comment {- Wunknown - pragmas}
Problem: see online is the way mingw use MSVC will issued a warning: ignoring # pragma comment - Wunknown - pragmas reason is that, under the GCC with # pragma comment (lib, "ws2_32") equivalent prepared statements. Solution: Toolbar -->; The Project - & gt; Build Options, select Linker Settings, and Add the statically linked library files you need
opengl32.lib/ code>
ned reference to OpenGL
> Look at the net summary reasons have a lot of, I did not put the library link.
5. Use Codeblocks to create header files. You can refer to this article
https://blog.csdn.net/qq_40741513/article/details/80858910 click File> > New> > Build target> > Files> > C/C++header > > go
Go to codeblocks, file->; So addfile, add the.h file that you created.
uses "" when including header files, for example: "header.h". Because & lt; > "" is used to include the compiler's own header files, "" is used to include your own header files.
#ifndef header.h
define header.h...
#define header.h...
#endif prevents duplication of definitions, or if you do not use the header multiple times. "Header. H" is generally the upper case name of the HEADER file
6. There is exit was not declared in this scope , undefined reference to WinMain @ 16 'collect2. Exe: error: ld returned 1 exit these problems
Try to experiment the code on the net, after debugging in the computer run, feel very happy.
learning
Codeblocks DLL is what folder (https://blog.csdn.net/kld1412/article/details/51628424) codeblocks CPB is what files. .cbp(Codeblocks Project) Codeblocks Project OpenGL Profile Resources Download This is all but integral enough (https://download.csdn.net/download/blink31/4376444) in AutoCAD and interactive environment modelling and so on3dmax, users can use the mouse drag form on a computer screen to do 3 d any degrees of freedom of rotation, the user can observe the form the geometry characteristics of the different sides. This user-friendly technology is ---- Trackball technology.
Example problem record:
1. Drawing the classroom globes:

F:\test\earth\src\earth.cpp|84|error: no matching function for call to 'std::basic_ifstream<wchar_t>::basic_ifstream(const wchar_t*&)'|

To be solved
2 Code::Blocks : undefined reference to xxxxxx@4'
Reason: lack of lib library. Solution: Add a lib library.
3. about console file stdafx.h. refer to this blog post
The solution is to copy this stack of code into your new "stdafx.h", and then
Just put it in the same directory as your source files.
initializer element is not constant itializer element is not constant. Change to #define using the method described here, but error 2 appears above. No solution has been found to the problem.
5. The use of glaux
Learning Resources:
1.OpenGL simulation of solar system running
2.OpenGL drawing rotating teapot
. Use OpenGL to do a clock animation
4. Use OpenGL to achieve a bouncing ball
Learning website
https://learnopengl-cn.github.io/

Configuring OpenGL in Code:: blocks

Configuring OpenGL in Codeblocks is slightly different than configuring OpenGL in VC, VS, and requires slightly different library files. This article takes CB13 as an example. (Old and new versions are common, but it is best to use mingw tools, GCC/GDB, etc., other compiled kernels are not tested)
First, download the library files (downloaded at the bottom of the article, uploaded to the 100 cloud, if the link fails, you can reply or email me to continue the upload), including Glut. h, Glut32.dll, LibGlut32.a.

    Put the glut32. h file under the MinGw\include\GL directory and the glut32. DLL file under the C:\Windows\ system32 directory (for 64-bit operating systems, put the file under the C:\Windows\SysWOW64 directory) and the libglut32.a file under the MinGw\lib\ directory
(From the blog of CSDN WWWISKEY)
And then you set up the project, and notice that you set up the project for GLUT

The next step, when I get here,

Path selection:

Different installation paths and different systems may vary, but choose the MinGW folder under the CodeBlocks installation path.
Then proceed, when it is time to select the Project name and save the path, the path must not be in Chinese, and it is better not to be on the desktop (sometimes can not compile, CB common fault). Once established, you can open the Main.cpp sample program in the Projects TAB of the Management sidebar on the left.
Not yet, select the top column Project->; Build Options, click the Debug TAB on the left, the Linker Setting TAB on the right, and click Add below.

File select this:

* Note: Do not mix libglu32.a with libglut32.a.
Open, “Keep Relative Path”, “No”, OK all the way, then F9 can run the program.
Also, if you don’t need ifdef in the sample program, you can simply do this:

If you want to use this library in the future, just include GL/ Glut.h.
The result should be this:

The main difference with VC and VS is that the library file is libglut32.a instead of other.lib files, so all we need to do is convert glut32.lib to libglut32.a. There is a program on SourceForge that can do this, but I can’t find it now, so just download it.
Relevant documents please go to my personal page: http://alanzjl.sinaapp.com/2015/02/opengl_in_codeblocks/
Or: http://download.csdn.net/detail/alanzjl/8463847 to download

Installation and use of OpenGL based on CodeBlocks

1. The main process, in my collection. You can find the original blog directly.
2. Attention:
A libbgi.a file is also downloaded. It is installed under C: Program Files (x86)\CodeBlocks\MinGW\lib. Download Address:
http://www.3673.com/file/280472.html
Second:
Put the glut32.h file under the MinGw\include\GL directory
Put the glut32.dll file under the C:\Windows\ system32 directory (for a 64-bit operating system, put the file under the C:\Windows\SysWOW64 directory)
t the libglut32.a under the MinGw\lib\ directory
T> are the three full lines of the author. I just installed the second file in the wrong path and caused a lot of errors.
In addition: want to test your results immediately, here are some examples of application: https://blog.csdn.net/Halsey_/article/details/79684493