Tag Archives: OpenGL

OpenGL, such as glad library and glfw library, is incompatible

Do you have any friends who have similar problems?
I brought in both Glad and GLFW, and also added the GL library (including gl.h and glu.h) to the project dependencies, as shown below:
D:\GitProject\OpenGLlearn\learnOpenGL\Dependencies\gl
D:\GitProject\OpenGLlearn\learnOpenGL\Dependencies\GLFW\include
D:\GitProject\OpenGLlearn\learnOpenGL\Dependencies\GLAD\include
Here is the error message:

VS2010 compiler can’t open include file: “GL / glaux. H”: no such file or directory


#include <
#include < gl/gl.h>
#include < gl/glu.h>
#include < gl/glaux.h>
#include < gl/glut.h>

=
=
=
=
=
=
C :\ Users \ LJ \ Desktop \ Tracking Locate \ Camera \ Stdafx.h (43): fatal error C1083: Failed to open included file: “gl/glaux. H” : No such file or directory
C:\Program Files\Microsoft SDKS \Windows\ V7.0 A\Include\gl There are only two Files under C:\Program Files\Microsoft SDKS \Windows\v7.0A\Include\gl
So in VS2010, the corresponding header file cannot be found in the default lookup process
C:\Program Files\Microsoft SDKS \Windows\ V7.0 A\Lib
You’d better download these files from the Internet.
So the problem should be solved by copying the glaux-h and glaux-lib files (sometimes using glaux-dll), respectively, to the path referenced by default in VS2010 above.

Solution of VS2008 unable to open GL / glaux. H header file

2011-04-15 wcdj
 
I don’t know why there is no OpenGL header file in SDK after VS2008. Here is a summary for this problem.
 
In Lesson 6 of learning Nehe’s texture mapping, I initially needed to use the header file containing gl/glaux. H, but found that I didn’t have this header file on my system. There are two header paths in the compiler that reference OpenGL:
C:/Program Files/Microsoft SDKs/Windows/v6.0 A/include/gl/gl h (the default)
C:/Program Files/Microsoft Visual Studio 9.0/VC/include/gl/glut. H (the new gl manually folder)

Googled the solution.

thod 1: Find the most used solution, but I do not have VS2003 or VS2005 installed on my system, so I cannot copy it.
I have been porting old openGL program to VS2008. I have solved the problem by copying the “include/gl/glaux.h” and “lib/glaux.lib” from the VS2005 Platform SDK located on “C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK” To the PlatformSDK of VS2008 located on “C:/Program Files/Microsoft SDKS /Windows/ V6.0a “


Based on the reply to https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1065518& SiteID=1, it looks like glaux. Lib is deprecated. Instead link to kernel32.lib, user32.lib, gdi32.lib and advapi32.lib


The easiest way to sort this out is to:
) Install Glut3.6 or newer as directed.
2>pen Visual Studio 2008 and create a new project
3) Cho>C ++ -Empty solution
4) Import Al> the files from your previous OpenGL project
5) delete all headers i.e.
#include < gl/glu.h>
#include < gl/gluax.h>
and any other GL headers
6) then replace with #include < gl/glut.h>
7) recompile.

this worked for all of my 2003 & 2005 Solutions.

thod 4: Download Missing Files.
1: download the source CSDN download
OpenGL installation package download required documents:

http://d.download.csdn.net/down/2560229/ssagnn23 include:
GL. H GLAUX. H GLU. H glut.
H GLAUX. LIB GLU32. LIB glut32. LIB glut. LIB OPENGL32. LIB
GLAUX. DLL GLU32. DLL glut32. DLL glut. DLL OPENGL32. DLL

VS2008 without GL. H, H, glu.h, GLAUX. Lib, glu32.lib, opengl32.lib.

1) Copy GLUX. DLL, GLUT32.DLL, GLU32.DLL and GLU32.DLL to C:/WINDOWS/system32, which should already have OpenGL32.DLL and GLU32.DLL.
. (2) the GL H, GLAUX. J H, glu. H, glut. H a copy to the C:/Program Files/Microsoft Visual Studio 9.0/VC/include/GL
. (3) the GLAUX LIB and Glu32. LIB, glut32. LIB, Opengl32. LIB, C:/Program Files/Microsoft Visual Studio 9.0/VC/lib

br>>
nehe SRC – cn – nehe OpenGL tutorials Chinese version and the code download

http://code.google.com/p/nehe-src-cn/downloads/list nehe OpenGL tutorial Chinese version and the code download

http://www.yakergong.com/nehe/ provides each Lesson # sample code and the file you need.

4 according to the method, after downloading the file and configure, recompile, without the previous mistakes, documents found, but the following mistakes.
error C2664: “auxdibimageLoadw” : Cannot convert parameter 1 from “char *” to “LPCWSTR”
is is because I am building a Unicode character set based project, so I want to use wide characters. It is also possible not to use Unicode character sets in the property page ->; Configure properties ->; You can modify it in general. Select not to use the Unicode character set here; that is, select Unset. And then recompile it. OK!

br>>

reference:
missing glaux. H in v6.0 a SDK?

http://social.msdn.microsoft.com/Forums/en/windowssdk/thread/b66e5f7a-91f6-4dbe-b388-0c131008b08f project under VS2003 under VS2008 compilation, however, Can’t find the gl/glaux. H

http://topic.csdn.net/u/20070930/15/6a900f21-8e41-4325-862f-f6df3a425f36.html VS 2008 OpenGL configuration

http://lujun5918.blog.163.com/blog/static/287227712011013114410553/ Load images generated texture opengl program
http://topic.csdn.net/u/20070823/19/4497cb18-be2a-464f-ad20-b12191a61b26.html
 
 
 
 

Configuring OpenGL development environment in win10 + vs2015 (including the method of installing 32-bit and 64 bit libraries)

In order to learn OpenGL, I wanted to configure both 32-bit and 64-bit development environments in VS, but I didn’t find a solution to this problem on the web. Maybe everyone knows that, so I don’t think it’s a problem… I was suffering from one night and one morning, make a headache, asked the teacher, the method does not work, finally is their own try out, remember this, for other small white point of reference, the following began to systematically introduce the configuration process)
Here’s the file I packed. The Glew library (which has been compiled) can also be downloaded from the official website. I have also given the download address of the official website in the following content.
A, OpenGL library
1. The GLUT libraries

GLUT (OpenGL Utility Toolkit) is a cross-platform tool library that can only be used under Win32, does not provide a 64-bit development environment, and has not been updated since 1998
2. Freeglut library
This library, a modification of the original GLUT library, provides both 32-bit and 64-bit build environments, and is better maintained.
3. The GLEW libraries
Glew (OpenGL Extension Wrangler) is another helper library.
II. Configuration process
1. Configuration of the FreeGLUT library

Download link

Freeglut freeglut 3.0.0 (download you need to download other versions into freeglut version)

OpenGL + VS2015 + Win10 64-bit development environment configuration. OpenGL + VS2015 + Win10 64-bit development environment configuration. OpenGL + VS2015 + Win10

I just want to add two caveats

When using CMAKE to extract a FreeGlut, Configure

32-bit pick 64 choose

store 32-bit generated file folder named freeglut – x86 (can be any name, here only to illustrate behind)
store 32-bit generated file folder named freeglut – x64

SLN generates the solution in the x64 environment in debug mode and release mode respectively.

SLN generates the solution in the x86 environment in debug mode and release mode, respectively
2, 32-bit and 64-bit environment configuration focus!!

32 –

    under the installation path of VS2015 the include file to create a new GL folder will download freeglut – 3.0.0 freeglut 3.0.0 \ freeglut – 3.0.0/include/GL. H header file
    in the C: \ Program Files \ Microsoft Visual Studio (x86) 14.0\VC\ Include \GL (that is, the GL folder created in step 1)
    Put the FreeGlutd. DLL in FreeGlut-x86 \bin\Debug and the FreeGlut-x86 \bin\Release FreeGlut. DLL
    C:\Program Files (x86)\Microsoft Visual Studio
    in 14.0\VC\bin (you may find that the names of the two DLLs are different) Put the.lib file
    FreeGlut-x86\ lib and in RealEase

i>: \Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib

64

    Put the FreeGlutd. DLL from FreeGlut-x64 \bin\Debug and the FreeGlut-x64 \bin\Release FreeGlut. DLL
    C: Program Files (x86)\Microsoft Visual Studio VC 14.0 \ \ bin \ amd64
    will freeglut – x64 \ lib in the Debug and Realease..lib file
    in the C: \ Program Files \ Microsoft Visual Studio (x86) in VC 14.0 \ \ lib \ amd64 note: 32-bit and 64 – bit libraries. H header file is the same as

So now the FreeGLUT library is configured

2. Configuration of GLEW library

2.1 Download and compile source code

Download link

GLEW GLEW – 2.1.0. Zip

Unzip and open glew.sln in glew-2.1.0\glew-2.1.0\build\vc12

The solution is generated in Debug mode in x86 environment, and the 32-bit Debug library is obtained. Generate the solution in Release mode in x86 environment, and get the 32-bit Release library; Build the solution under Debug mode in x64 environment, and get 64-bit Debug library; Generate the solution in Release mode in the x64 environment, resulting in a 64-bit Release library.

2.2 configuration GLEW32 a

    will glew – 2.1.0 \ glew – 2.1.0 \ include \ GL. H header file
    in the C: \ Program Files \ Microsoft Visual Studio (x86) in VC 14.0 \ \ include \ GL

    will
    Glew 2.1.0 \ glew – 2.1.0 \ bin \ Debug \ Win32
    Glew32d. DLL and

    Glew 2.1.0 \ glew – 2.1.0 \ bin \ Release \ Win32
    glew32.dll
    In C: \ Program Files \ Microsoft Visual Studio (x86)
    in the VC 14.0 \ \ bin to glew 2.1.0 \ glew – 2.1.0 \ lib \ Debug \ Win32 2. Under the lib Files and
    glew 2.1.0 \ glew – 2.1.0 \ lib \ Release 2 \ Win32..lib file
    in the C: \ Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib

    64-bit

      will
      Glew 2.1.0 \ glew – 2.1.0 \ bin \ Debug \ x64
      Glew32d. DLL and

      Glew 2.1.0 \ glew – 2.1.0 \ bin \ Release \ x64
      glew32.dll
      In C: \ Program Files \ Microsoft Visual Studio (x86) VC 14.0 \ \ bin \ amd64
      will glew 2.1.0 \ glew – 2.1.0 \ lib \ Debug \ x64 2. Under the lib Files and
      glew 2.1.0 \ glew – 2.1.0 \ lib \ Release \ x64 under 2..lib file
      in the C: \ Program Files (x86)\Microsoft Visual Studio 14.0\VC\ Lib \ AMD64

So far, it is done ~

Put 32-bit DLLs and lib files in the corresponding VS folder, and 64-bit DLLs and lib files in the corresponding VS folder \amd64
if you think these compilation or configuration steps special trouble, you can see my another article, one minute can be configured to start OpenGL programming. (I’ll write another day.)

Drawing function of GLUT

void glutWireSphere(GLdouble radius, GLint slices, GLint stacks); br> v>glutSolidSphere (glDouble radius, GLint Slices, GLint Stacks); Solid sphere
void glutWireCube(GLdouble size);
void GlutSolidCube (GlDouble Size); Solid cube
void glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, GLint nsides, GLint rings);
void GlutSolidTorus (glDouble InnerRadius, glDouble OuterRadius, GLint nsides, GLint rings);
void GlutSolidTorus (glDouble InnerRadius, glDouble OuterRadius, GLint nsides, GLint rings) Solid circle
void glutWireIcosahedron(void);
void glutsolidosahedron (void); Solid 20-hedron
void glutWireOctahedron(void);
void glutsolidOctahedron (void);
void glutsolidOctahedron (void); Solid 8-hedron
void glutWireTetrahedron(void);
void glutsolidTrahedron (void);
void glutsolidTrahedron (void); Solid 4-hedron
void glutWireDodecahedron(GLdouble radius);
void glutSolidDoDecaHedron (glDouble radius); Solid 12-hedron
void glutWireCone(GLdouble radius, GLdouble height, GLint slices, GLint stacks);
void glutSolidCone(glDouble radius, glDouble height, GLint Slices, GLint stacks); A solid cone
void glutWireTeapot(GLdouble size);
void glutSolidTeapot(glDouble Size); Solid teapot

To solve the problem of flashback of calling class function of glutsolidcube() in Win32 program

The problem
Functions such as glutSolidCube() are used in Win32 to flash back without reporting an error.
To solve
GlutSolidCube, GlutSolidSphere and other functions will first check whether GLUT is initialized, and exit the program if GLUT is not initialized.
Therefore, put the following code in WinMain() :

int argc = 0;
char *argv[10] = {};
glutInit(&argc, argv);

Can solve

OpenGL + vs2015 environment configuration problem solving

1. Compile-time prompts
“Error C2381: ‘exit’ : redefine; __declspec(noreturn) different “error

#include <; #include <; GL/glut.h>
# include & lt; stdlib.h>
:
include
:
#include
stdlib.h>
# include & lt; GL/glut.h>
to go through.

enGL and C++ have a bit of an incongruence. Include the standard C++ library header before the GLUT graphics library header.

2. Compile passed, runtime prompt
(1) ERROR LNK2019: Unable to resolve the external symbol __imp____glutInitWithExit@12, which is referenced in the function _glutInit_ATEXIT_HACK@8
(2) ERROR LNK2019: Unable to resolve the external symbol __imp____glutCreateWindowWithExit@8, which is referenced in the function _glutCreateWindow_ATEXIT_HACK@4

Solution:
The # include & lt; GL/glut.h> He added:
# define GLUT_DISABLE_ATEXIT_HACK
(!!!!!! Attention, the front!!)

Problems encountered in running OpenGL

Problems running OpenGL with VS
Problem 1. Linker tool error The link2026XXX module is not secure for the SAFESEH image
Solution:

1. Open the Property Pages dialog box for the project.
2. Click the Linker folder.
3. Click the Command Line property page.
4. Type /SAFESEH:NO into the Additional Options box and click Apply.

Reference: http://www.cnblogs.com/hanxi/archive/2012/06/10/2544230.html

Problem 2. The computer is missing GLUT32.DLL
Solution:
1. Check to see if it is in the Windows/System32 folder
2. If it is a 64-bit system, check to see if it is in the Windows/SYSWOW64 folder

Graphics rendering pipeline diagram of OpenGL

A, an overview of the
The current version of OpenGL is 3.3, which is based on the renderable pipeline to achieve model generation, rendering, image output and other work.
The Render Pipeline is a series of processing of three dimensional vertices into two dimensional discrete pixels. And the user can configure freely in specific shading phases (such as vertex shading and fragment shading phases, which is the biggest difference from fixed pipeline). The brief flow of the renderable pipeline is shown below.

Second, detailed process
The figure above is basically correct, but it’s not very intuitive. How does a three-dimensional vertex transform into a pixel?I’m going to break it down into two big steps, two dimensional vertices, two dimensional vertices discretization.
1. Transformation of three-dimensional coordinates into two-dimensional coordinates
(1) Model vertex construction

Model vertices are built relative to the model’s own coordinates, namely object coordinates. Only the shape of the model can be expressed, and its position and attitude cannot be obtained, so world coordinates must be introduced.

(2) Convert to world coordinates

The world coordinates represent a larger coordinate domain, and each vertex of the model can be represented by the world coordinates. From the object coordinates to the world coordinates, you have to multiply by a world matrix, and you get the model of the relative world coordinates.

(3) World coordinate transformation camera coordinates

The world coordinate transformation of camera coordinates, from object coordinates to world coordinates, is multiplied by an observation matrix, which gives the model relative to the camera coordinates.

(4) Camera coordinate transformation screen coordinate 1

Camera coordinates transform screen coordinates. Any three – dimensional mode is displayed in two – dimensional form (screen). So a three-dimensional model is usually converted to a two-dimensional model. The first step is to build the cone with the camera as the origin.

(5) Camera coordinate transformation screen coordinate 2

Next, the 3D coordinates of the model are transformed to 2D coordinates, which are multiplied by the perspective matrix. Finally, a 2D model is projected onto the near plane of the cone.

2, 2D vertex pixelation

The vertices obtained by perspective projection are linear and cannot be displayed on the screen. They need to be pixelated, as shown in the following figure:

The solution of flicker and no refresh caused by OpenGL + MFC

We know that when you drag a figure in a window, it will flash as you draw it. In GDI, it is more complicated to solve this problem. By generating a memory DC in the memory and letting the brush draw in the memory DC when painting, the flashing problem can be solved by “pasting” the memory DC to the display with BitBLT once after painting. In OpenGL, we solve this problem by double caching. In general, dual caching is common in graphics working software. A double cache is two caches, a foreground cache and a background cache. The drawing is drawn in the background cache, and when it is done, it is swapped to the foreground cache so that there is no flicker.

A: the pixel format defined as support double buffered pixelDesc. DwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_STEREO_DONTCARE;

B: Add such a line of code SwapBuffers(HDC) after the object is drawn. At this point, the OpenGL drawing has no flicker, but the MFC will repeatedly redraw the background to generate flicker

C: Process message loop ON
asebkgnd EraseBkgnd EraseBkgnd

BOOL CoglView::On
EraseBkgnd(CDC* pDC)

{

// TODO: Add message handler code here and/or invoke default values

return TRUE;

//return CView::On
EraseBkgnd(pDC);

}

That solves the flicker problem once and for all!

Reprinted address:
http://blog.csdn.net/lsldd/article/details/7599225

MFC+OpenGL has many ways to remove flicker online. Such as:

http://hi.baidu.com/piaoshi111/blog/item/66dba5ff643caa275c60083b.html

The basic process of using OpenGL in MFC has been explained in considerable detail above. The steps to realize flicker-free are also given.
Now for the first problem: if you select “Split Windows” in the MFC Generation Wizard, you will find that even reloading OnEraseBkgnd will not solve the flicker problem!
The following code is generated by MFC for you:

(CPP)
view plain
The copy

    // In mainfrm. h: Virtual Bool PrecreateWindow (CreateStruct& Cs); // In mainfrm.cpp: BOOL CMainFrame: : OnCreateClient (LPCS LPCREATESTRUCT/* * /, CCreateContext * pContext) {return m_wndSplitter. Create (this, 2, 2,// TODO: adjust the rows and columns CSize (10, 10),// TODO: adjust the minimum size pContext pane); }

    In other words, MFC overloads the onCreateClient function for you to implement split Windows. We know that MainFrm inherits from CFrameWnd. Let’s take a look at what Cframewnd’s OnCreateClient does:

    (CPP)
    view plain
    The copy

      BOOL CFrameWnd: : OnCreateClient (LPCREATESTRUCT, CCreateContext * pContext) {//default create client will create a view if asked for it if (pContext! = NULL & amp; & PContext – & gt; M_pNewViewClass! = NULL) {if (CreateView (pContext AFX_IDW_PANE_FIRST) = = NULL) return FALSE. } return TRUE; }

      This is where we create the view class CXXXView where we initialize OpenGL.

      However, if splitting is used, MFC will automatically add an object m_WNDSplitter of type CSPLitterWnd, and your CXXXView class will simply be a view inside CSPLitterWnd.
      When changing the window size, CSSPLITTERWND first responds to ON_WM_SIZE, and then lets CXXXView handle it further in its response function.
      The window size of CSPLitterWnd is slightly larger than that of its internal CXXXView. Therefore, the refresh of CSPLitterWnd itself will affect the refresh of CXXXView and cause flicker.
      The solution, then, is to either not use the split, which is absolutely fine.
      If you have to split the window, you might need to derive your own CSSPLitterWnd class to modify its behavior.
      Next problem, you might have a window that doesn’t refresh, but only resizes the window.
      This is because your CXXXView only overloads OnDraw. How is OnDraw invoked?
      See *\Microsoft Visual Studio 9.0\VC\atlmfc\ SRC \ MFC \viewcore.cpp

      (CPP)
      view plain
      The copy

      The

        ///the CView drawing support void the CView: : OnPaint () {//standard paint routine CPaintDC dc (this); OnPrepareDC (& amp; dc); Ontouch (& amp; dc); }

        The response to the ON_WM_PAINT message is CView, which calls OnDraw, which you overloaded. Because of the paintdc, dc(this); This caused the window to not refresh continuously.
        Want to know more detailed reasons, please see http://peipengshuai.blog.163.com/blog/static/1901226620123169431072/
        All you need to know is that CPaintDC will remove ON_WM_PAINT from the refresh message queue. After removal, if the window has not changed, it will not refresh automatically.
        So, what you need to do is very simple. Do not use CPaintDC dc(this) in the ON_WM_PAINT response to your CXXXView class; (comment out) can be.
        The next problem: After maximizing the window, some areas of the window (such as the toolbar) will not refresh, leaving blank space.
        The problem has not yet been perfectly solved. Refer to http://topic.csdn.net/t/20020220/16/534304.html, a driver problem. Unable to verify at this time.
        If there is a solution, let us know in the comments.