Tag Archives: GLFW

Vs2013 + glfw + glew configure OpenGL development environment

Transfer: http://blog.csdn.net/u011926277/article/details/50912638

Recently found a very good learning OpenGL basics website, click open the link. Since the configuration environment section is not very detailed, after many days of struggle, the development environment was successfully configured, for the record.
1. Download GLFW. The URL is: Click the open link. Because still have over the wall, so use the github download.
2. Download cMake. The URL is: Click the open link. The download is the version used by the author of this site, the Win32 Installer.
3. Download Glew. The URL is: Click the open link. Download the zip package, because the method used here is native compilation.

1> After the tool is prepared, a folder is set up in a directory to place the source code and library. OpenGL folder is set up on the machine, and include and libs folders are set up under it to place the source code and library respectively. The screenshot is shown below.

2> Since glew does not use cMake, glew is compiled first to get the required libraries.
A. Unpack Glew’s zip package, enter the build directory, and open the corresponding project with the corresponding version of VS (select the project under VS12 directory). VS2013 is used for this machine.
B. Open glew.sln with VS2013 or later and compile the project (right-click ->; Generate the solution).
C. Open glew-2.0.0\lib\Debug\Win32 and copy glew32sd.lib to OpenGL/libs.
D. Copy the GL folder from glew-2.0.0\include folder to the OpenGL/include folder.

3> To prepare the GLFW library, use the CMake tool to first generate the project and then compile it. The process is as follows.
A. After installing cMake, open cMake (cmake-gui) and click Browse Source to set the directory to the GLFW directory.
B. Click Browse Build and set the directory to the GLFW/Build folder. (The Build folder here needs to be created by yourself) as follows.

C. Click Configure in the lower left corner and select the target platform. Since this is VS2013, select Visio Studio 12 2013 and click OK.
D. Then click Configure again, and click Generate to build the project. The selection status is as follows.

E. Close cMake. Open the project in vs2013, compile it, and generate glfw3.lib after success.
F. Build \ SRC \Debug directory has just compiled the project generated glfw3.lib library, copy this library to the OpenGL/libs directory.
G. Copy the GLFW folder under GLFW-master /include to the OpenGL/include folder.
H. The files in the finally generated OpenGL folder are as follows:


4> At this point the basic environment is configured, and the next step is to link the libraries to the source code in a newly created, empty project, and import some libraries manually. The specific process is as follows.
A. Create an empty project. (C ++ project)
B. Right-click item ->; Property – & gt; Configure properties ->; Vc + + directories – & gt; Include the directory, add the path to OpenGL/include.
C. Right-click item ->; Property – & gt; Configure properties ->; Vc + + directories – & gt; Add the path to OpenGL/libs. The screenshot is shown below.

D. Right-click item ->; Property – & gt; Configure properties ->; The linker – & gt; Input – & gt; Attach dependencies to which to add
opengl32.Lib
glfw3.lib
glew32sd.lib
, the screenshot is as follows.

E. After saving the configuration in turn, you can enter the code in the Main class and test it. If no error is reported, that is, the environment is configured successfully, the test code can be tested from the beginning of the website or, or copy the code below.

#include <iostream>  

// GLEW  
#define GLEW_STATIC  
#include <GL/glew.h>  

// GLFW  
#include <GLFW/glfw3.h>  


// Function prototypes  
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);

// Window dimensions  
const GLuint WIDTH = 800, HEIGHT = 600;

// The MAIN function, from here we start the application and run the game loop  
int main()
{
	std::cout << "Starting GLFW context, OpenGL 3.3" << std::endl;
	// Init GLFW  
	glfwInit();
	// Set all the required options for GLFW  
	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
	glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

	// Create a GLFWwindow object that we can use for GLFW's functions  
	GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", nullptr, nullptr);
	if (window == nullptr)
	{
		std::cout << "Failed to create GLFW window" << std::endl;
		glfwTerminate();
		return -1;
	}
	glfwMakeContextCurrent(window);
	// Set the required callback functions  
	glfwSetKeyCallback(window, key_callback);

	// Set this to true so GLEW knows to use a modern approach to retrieving function pointers and extensions  
	glewExperimental = GL_TRUE;
	// Initialize GLEW to setup the OpenGL Function pointers  
	if (glewInit() != GLEW_OK)
	{
		std::cout << "Failed to initialize GLEW" << std::endl;
		return -1;
	}

	// Define the viewport dimensions  
	glViewport(0, 0, WIDTH, HEIGHT);

	// Game loop  
	while (!glfwWindowShouldClose(window))
	{
		// Check if any events have been activiated (key pressed, mouse moved etc.) and call corresponding response functions  
		glfwPollEvents();

		// Render  
		// Clear the colorbuffer  
		glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
		glClear(GL_COLOR_BUFFER_BIT);

		// Swap the screen buffers  
		glfwSwapBuffers(window);
	}

	// Terminate GLFW, clearing any resources allocated by GLFW.  
	glfwTerminate();
	return 0;
}

// Is called whenever a key is pressed/released via GLFW  
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode)
{
	std::cout << key << std::endl;
	if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
		glfwSetWindowShouldClose(window, GL_TRUE);
}

cop

F. After compilation and running, the following window appears on behalf of successful environment configuration.

At this point, the environment configuration is complete.

Thanks again for sharing, the environment is finally matched!!

Vs2015 configuring OpenGL (glfw Library)

Recently to use OpenGL, in VS2015 configuration cost a lot of effort, now will be my results directly contribute to everyone, hope to need to configure OpenGL under VS2015 readers save some trouble.
Documents to prepare
Baidu cloud link: https://pan.baidu.com/s/1qZbcLtU password: f58o
PS: The tutorial gives you a 32-bit library. Baidu Cloud Resource is the 64-bit runtime I compiled later. The configuration process is similar to
Download the relevant header files

Download or compile the relevant library files
Here I used the library files compiled by Win32, that is, the Release of x86 platform, including the lib static library and the dynamic DLL library;

File storage
Put all the header and library files in one folder (I put them in the D:/freeglutlib folder);

Part program
1. Open VS2015, create a new Win32 console program, set the compilation environment as x86 or Win32, Release version;

2. Find the property manager and create a new property sheet under the corresponding compilation environment;

3. Select the VC++ directory ->; Include directory, library directory, just saved the header file and library file corresponding folder to add in


4, Compiler ->; Input – & gt; Attach a dependency, and type the DLL names of all the external libraries used

5. Add code in main file to test

Summary of problems encountered in using OpenGL in QT

Configure environment VS2015 + QT5.9

: Error LNK2019: Unable to parse the external symbol – **.
: Error LNK2019: Unable to parse the external symbol – **.
solution
en cmake, put BUILD_SHARED_LIBS on the box, recompile to generate glfw3.lib and glfw3dll. DLL, add them to Qt’s pro, compile to pass.
Problem – Glad include
in Pro after configuration Glad path, add

#include <glad/glad.h>

If the position is not appropriate, an alarm will appear:

error: C1189: #error:  OpenGL header already included, remove this include, glad already provides it

containing glad must precede all penGL *** h>rs.
GlDrawElements ()
call function drawelements () e> :

Error - 
RtlWerpReportException failed with status code :-1073741823. Will try to launch the process directly

1. ***Pointer s>uffer error, vertex index out of bounds reference vertex array;
br bb3 GlbindVertexArray (0)

GlbindV>xArray (0)

GlbindVertexArray (0)

GlbindVerTexArray (0)

GlbindVerTexArray (0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0);
br> <>>



3. Call makeCurrent()fore binding VAO.
(To be continued)

(64 bit) OpenGL configuration + vs2017 + glew + glfw

Note: **** native OpenGL version must be higher than Glew library version
native OpenGL version

enGL version string: 4.5.0 – Build 25.20.100.6323
<>>

OpenGL version string: 4.5.0 – Build 25.20.100.6323

OpenGL version string: 4.5.0 – Build 25.20.100.6323
Download:
1. glew:http://glew.sourceforge.net/ find corresponding native OpenGL version of glew
2. GLFW: glfw.org click on the top right corner of the download
3. VS2017:https://visualstudio.microsoft.com/zh-hans/vs/
Glew:
: glew
: glew
: glew
: glew
: glew
: glew
: glew
: glew
: glew
: glew
: glew
: glew
: glew
Select VC10 (or V12 or later) in the Build folder to open the glew.sln solution.
2. You will be prompted to upgrade Glew projects created by a lower version of VS. Click “OK” to upgrade the VC++ compiler and libraries to support compilation of VS 2017.


br>

include\GL

5, Return to glew-1.10.0 root and copy glew32.lib from “lib\Release\Win32” to “lib\x86”, such as E:\vs2017\VC\Tools\MSVC\14.16.27023\lib\x86
6, Return to glew-1.10.0 root directory, copy glew32.lib from lib\Release\x64 to lib\x64 of VS installation directory, such as E:\vs2017\VC\Tools\MSVC\14.16.27023\lib\x64
(This is not very safe, because it is difficult to manage and easy to lose, the preferred way is to create a new directory containing all the third party libraries and header files. And specify these folders in your IDE or compiler.
7, Copy glew32.dll from bin\Release\Win32 to C:\Windows\System32, then return to glew-1.10.0 root
8, Go back to glew-1.10.0 root and copy glew32.dll from bin\Release\x64 to C:\ WindowsSYSWOW64
At this point, the configuration of the Glew library is complete!


mpile Source code
<>>

Compile Source code


Compile Source code


Compile Source code