RXJava code>, RxAndroid code>, Retrofit code> to support development response type, and refactor the code, refactoring everything but in running an Java lang. NoClassDefFoundError code> this error, and in a few test machine shows the name of the class is different also, For example, on MI4, there is no Handler, and on Huawei, there is no OKHttputils class. This is very confusing. After searching Google, we can't find the problem, but on another Samsung test machine, there is no problem, and finally we find that Multidex is the problem.
Some third party libraries were added during the refactoring, which pushed the number of methods in the entire Android application beyond 65535. The following error should occur when packaging
java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:501)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:282)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:490)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
multiDexEnabled true z multiDexEnabled true defaultConfig
z multiDexEnabled true Automatically when a method is more than 65535 hit two Dex package named classes. Dex code> classes2. Dex code>, some methods were scored the second Dex package, namely the classes2. Dex code>, resulted in 5.0 the following models can't run the error.
Here's the solution:
1. defaultConfigcode> m>dexEnabled true is used>enable MultiDex
2. is added in the dependence on the compile 'com. Android. Support: multidex: 1.0.1' code> support package for 5.0 the following systems
3. If your project already contains the Application class, then let it inherits. Android support. Multidex. MultiDexApplication class, if your Application has inherited the other classes and do not want to do change, so there's another way of using, overwrite attachBaseContext () method:
public class MyApplication extends FooApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Category Archives: How to Fix
Solve the problem of request method ‘get’ not supported
First of all, the error is most likely caused by the incorrect way the request was made. SpringBoot has three common request methods: @requestmapping, @getmapping, and @postmapping.
**
**
- @RequestMapping: This is a general annotation that does not specify a request, so it can accept a series of requests such as POST, GET, PUT, HEAD, etc. @GetMapping: This is the request for GET, the browser default request for this type of request, is short for @RequestMapping(method= requestMethod.get) @PostMapping: This is the request for POST, which is short for @RequestMapping(method= RequestMethod.post)
* *
again turn head to see this error, literally does not support a get request, see your own annotations to project, it was the wrong
I am a visit by enter the URL address bar, the default is the get method, the annotation to @ RequestMapping is ok, the error is solved.
Image file upload error org.springframework.beans .ConversionNotSupportedException
Project Scenario:
prompt:
oject scene: when the administrator adds the product in the e-commerce project, he will upload the picture file for the product.
Problem description:

>
ah <>>
Configuration of OpenGL in VS2010
Configuring OpenGL in Chinese version of VS2010 and problem solving
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\ GL “
2. Let the glut of decompression. Lib and glut32. Lib in “” Programfiles (x86) 10.0 VC \ \ lib \ Microsoft Visual studio” (ditto)
3.
4.
4.
5.
5.
5.
5.
5.
5.
5. Open VS2010, open any project or create a new one, and be careful to add.c to the file name when creating the CPP file (for example, opengl.c). Under the Solution ->; Right-click item ->; Property – & gt; Configure properties ->; Input – & gt; Add a dependency, where you add opengl32.lib; glu32.lib ; glut32 ;
Possible problems:
ERROR LNK1104: Could not open the file ‘opengl32.lib glu32.lib glut32.lib’
1. Note that these files are connected by semicolon, change to opengl32.lib; glu32.lib ; glut32 ;
2. The compiler did not find the path to these files, so you need to manually add: right-click project ->; Property – & gt; VC++ directory, in the include directory and library directory to add the path to store these files.
“Stdafx. h” : No such file or directory
1. Verify that the environment configuration is: Properties →C/C++→ Precompiled Header → “No Precompiled Header”.
#include < #include < stdafx.h> In general, except for MFC projects, precompiled headers are not used.
Glfw configuration
Download the 32-bit version
The file structure after decompression is as follows:

Copy the GLFW folder in include to VC/include in the VS installation directory
If you are using VS2013, copy the lib file from lib-vc2013 to VC/lib in the VS2013 installation directory
Then copy the DLL file from lib-vc2013 to system32 or system64
When writing a program, properties in the project ->; The linker – & gt; Input – & gt; Add glfw3.lib to the attached dependencies
#pragma comment(lib, “glfw3.lib”)
If it fails to start at runtime, then copy the DLL file in lib-vc2013 to the Debug/Release folder
Vs2013 + glfw + glew configure OpenGL development environment
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!!
Configuring glfw library and glad Library in opengl-vs2015
1. To prepare
1.1 Download GLFW library from GLFW official website
1.2 Glad library is generated online
2. The configuration
3. Run tests
4. Function list
glfwInit
glfwCrateWindow
glfwWindowShouldClose
glfwMakeContextCurrent
glfwSwapBuffers
glfwPollEvents
processInput
framebuffer_size_callback
I learn OpenGL, looking for multiple tutorials, clutter. Finally find a relatively complete English course, and find his Chinese translation version. (The author’s English is not very good, no way, alas ~)
Disclaimer: Although this article is original, it is indeed done according to the tutorial, the tutorial gives several methods, I chose the relatively simple, I believe everyone can learn, if you have questions can comment below.
Reference: LearnOpenGL
1. To prepare
1.1 Download GLFW library from GLFW official website
Download address: GLFW official website download page
Select the 32-bit binary version

1.2 Glad library is generated online
Generate address: Glad generates address online

Glad. Zip can be downloaded after generation.
2. The configuration
Unzip Glad. Zip and copy all files (Glad and KHR) to include folder under GLFW-3.2.1.bin. WIN32 after unzip.

Paste the glfw3.dll from lib-vc2015 under GLFW-3.2.1.bin. WIN32 into C:\ WindowsSYSWOW64. (The author’s version is VS2015, Windows is 64-bit, if the reader version is inconsistent, please change. C:\Window\System32: Windows \System32: Windows \System32: Windows \System32: Windows \System32: Windows \System32: Windows \System32

Create a new empty project under vs2015, paste the Glad. C file in the Glad folder into the source file and set up Main. CPP.

Right-click on the project and select Properties. In the VC++ directory, pull down and edit the include directory and library directory. Select the folder “include” and “lib-vc2015” under GLFW-3.2.1.bin. WIN32 respectively.

Linker – Input – Attach Dependencies – Edit Fill in the three filenames under lib-vc2015, note the line breaks.

To prevent readers from typing errors, paste the following:
glfw3.lib
glfw3dll.lib
opengl32.lib
At this point, the configuration is complete!
3. Run tests
Create a new empty project, place the glad.c file under the source file, and set main.cpp.
The code in the main.cpp file is as follows:
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <iostream>
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
void processInput(GLFWwindow *window);
// settings
const unsigned int SCR_WIDTH = 800;
const unsigned int SCR_HEIGHT = 600;
int main()
{
// glfw: initialize and configure
// ------------------------------
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // uncomment this statement to fix compilation on OS X
#endif
// glfw window creation
// --------------------
GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL);
if (window == NULL)
{
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
// glad: load all OpenGL function pointers
// ---------------------------------------
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
std::cout << "Failed to initialize GLAD" << std::endl;
return -1;
}
// render loop
// -----------
while (!glfwWindowShouldClose(window))
{
// input
// -----
processInput(window);
// render
// ------
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
// -------------------------------------------------------------------------------
glfwSwapBuffers(window);
glfwPollEvents();
}
// glfw: terminate, clearing all previously allocated GLFW resources.
// ------------------------------------------------------------------
glfwTerminate();
return 0;
}
// process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly
// ---------------------------------------------------------------------------------------------------------
void processInput(GLFWwindow *window)
{
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
}
// glfw: whenever the window size changed (by OS or user resize) this callback function executes
// ---------------------------------------------------------------------------------------------
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
// make sure the viewport matches the new window dimensions; note that width and
// height will be significantly larger than specified on retina displays.
glViewport(0, 0, width, height);
}
Run the screenshot:

4. Function list
glfwInit
Parameters: no
Function: Initialize the GLFW library
glfwCrateWindow
Parameters: width, height, title, and the remaining two are NULL
Action: Create a form
glfwWindowShouldClose
Parameters: Forms
Action: Whether the form needs to be closed
glfwMakeContextCurrent
Parameters: Forms
Action: Create a form from the context
glfwSwapBuffers
Parameters: Forms
Function: Display the form
glfwPollEvents
Parameters: no
Function: Check the information returned by the operating system
processInput
Parameters: Forms
Function: keyboard key control, for example, press the Esc key to close the form
framebuffer_size_callback
Parameters: Forms
Action: A callback function that changes the form. The form changes accordingly.
More about OpenGL: Introduction to Modern OpenGL
Have a question please comment below, reprint please indicate the source, and attached to the original link, thank you! If there is infringement, please contact in time.
Simple configuration of glfw + glad in vs2015 OpenGL development environment
A tutorial learning OpenGL reference is https://learnopengl-cn.github.io
this tutorial is based on GLFW (window) + glad (cross-platform), the following VS2015 a simple method of environment configuration:
1. New projects
Simply create an empty project and add a blank CPP file.
2. Add the Nupengl Core library
Add method: VS->; Tools – & gt; NUGET Package Manager -> Package management console
and then in the bottom of the Package management console input Install – Package nupengl. Enter the core instruction can
at this point, your this project has been configured glut GLFW glew
3. The configuration is glad
If you don’t need glad, you can skip this step, but glad is used in the tutorial above, so it should also be configured incidentally:
Open the Glad online service, set the Language to C/C++ and, from the API options, select OpenGL version 3.3 and above (we will use version 3.3 for this tutorial, but newer versions will work just fine). Generate
a
ader is selected. Generate
loader is selected. Generate
a
loader is selected. Ignore the Extensions for now (for now). When you have selected everything, click the Generate button to Generate the library files.
: Packages \nupengl. Core.0.1.0.1\build\native\include
: Packages \nupengl. Core.0.1.0.1\build\native\include
After these previous steps, the environment is actually configured
4. Test
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <iostream>
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
void processInput(GLFWwindow *window);
// settings
const unsigned int SCR_WIDTH = 800;
const unsigned int SCR_HEIGHT = 600;
int main()
{
// glfw: initialize and configure
// ------------------------------
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // uncomment this statement to fix compilation on OS X
#endif
// glfw window creation
// --------------------
GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL);
if (window == NULL)
{
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
// glad: load all OpenGL function pointers
// ---------------------------------------
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
std::cout << "Failed to initialize GLAD" << std::endl;
return -1;
}
// render loop
// -----------
while (!glfwWindowShouldClose(window))
{
// input
// -----
processInput(window);
// render
// ------
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
// -------------------------------------------------------------------------------
glfwSwapBuffers(window);
glfwPollEvents();
}
// glfw: terminate, clearing all previously allocated GLFW resources.
// ------------------------------------------------------------------
glfwTerminate();
return 0;
}
// process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly
// ---------------------------------------------------------------------------------------------------------
void processInput(GLFWwindow *window)
{
if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
}
// glfw: whenever the window size changed (by OS or user resize) this callback function executes
// ---------------------------------------------------------------------------------------------
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
// make sure the viewport matches the new window dimensions; note that width and
// height will be significantly larger than specified on retina displays.
glViewport(0, 0, width, height);
}
If the configuration is successful, a window like
Error in header file when calling OpenGL to open obj file in vs2013: unable to open include file: “GL / glut. H”: no such file or directories
The operation is as follows:
1. Download the GLUT Toolkit. https://download.csdn.net/download/lzp1113/10303259
2, after decompression will get 5 file, containing GlU32. Lib glut32. DLL glut32. Lib glut. DLL glut. H glut. Lib
3, let the glut of decompression. H into the C:/Program Files/Microsoft Visual Studio 9.0/VC/include folder.
4. Put the Glut. lib and Glut32.lib Files in the C:/Program Files/Microsoft Visual Studio 9.0/VC/lib folder where the static function libraries are located.
5. Put the extracted Glut. DLL and Glut32.dll in the system32 folder under the operating system directory.
6. Run it again, and if it still fails, change the name of the header file to #include <; gl/glut.h> For the # include & lt; glut.h> . After the fifth step is finished, the error is probably due to the wrong address of the header file include. Generally, it can be finished by following the sixth step.
Vs2015 configuring OpenGL (glfw, glew)
I was in charge of the model part, so I picked up the OpenGL I had learned before. By the way, I have been learning OpenGL in Xubuntu before
. Linux configuration programming environment is really quite convenient. Due to project reasons, have to Windows under the implementation of again. But the configuration environment feels more troublesome, so there is this article, just for the convenience of Xiaobai.
* VS2015
glfw
*>w
VS2015 Community Edition is free, easy to debug, the disadvantage is too big, but it is really the best IDE under Windows.
GLFW GLFW homepage can also use GLUT, just to feel a little bit new.
GLEW GLEW home page updated to version 2.0.

Set up project
Select the Win32 Console project and right-click on the solution ->;
ah select linker ->;
:
:>; Input is added in the additional dependencies OpenGL32. Lib, glfw32. Lib, glew32s. Lib

Here to say a bit, you can use glfw32dll. Lib, glew32. Lib. This requires the corresponding DLL to be placed in the project directory. However, if you select glew32.lib, many functions will not be linked, so it is recommended to choose glfw32s.lib.
Then look for a slightly more complicated program on the Internet
#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;
// Shaders
const GLchar* vertexShaderSource = "#version 330 core\n"
"layout (location = 0) in vec3 position;\n"
"void main()\n"
"{\n"
"gl_Position = vec4(position.x, position.y, position.z, 1.0);\n"
"}\0";
const GLchar* fragmentShader1Source = "#version 330 core\n"
"out vec4 color;\n"
"void main()\n"
"{\n"
"color = vec4(1.0f, 0.5f, 0.2f, 1.0f);\n"
"}\n\0";
const GLchar* fragmentShader2Source = "#version 330 core\n"
"out vec4 color;\n"
"void main()\n"
"{\n"
"color = vec4(1.0f, 1.0f, 0.0f, 1.0f); // The color yellow \n"
"}\n\0";
// The MAIN function, from here we start the application and run the game loop
int main()
{
// 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);
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
glewInit();
// Define the viewport dimensions
int width, height;
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
// Build and compile the shader programs (we ignored compile log checks for readability (if you do encounter issues, add the compile-checks!))
GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
GLuint fragmentShaderOrange = glCreateShader(GL_FRAGMENT_SHADER); // The first fragment shader that outputs the color orange
GLuint fragmentShaderYellow = glCreateShader(GL_FRAGMENT_SHADER); // The second fragment shader that outputs the color yellow
GLuint shaderProgramOrange = glCreateProgram();
GLuint shaderProgramYellow = glCreateProgram(); // The second shader program
glShaderSource(vertexShader, 1, &vertexShaderSource, NULL);
glCompileShader(vertexShader);
glShaderSource(fragmentShaderOrange, 1, &fragmentShader1Source, NULL);
glCompileShader(fragmentShaderOrange);
glShaderSource(fragmentShaderYellow, 1, &fragmentShader2Source, NULL);
glCompileShader(fragmentShaderYellow);
// Link the first program object
glAttachShader(shaderProgramOrange, vertexShader);
glAttachShader(shaderProgramOrange, fragmentShaderOrange);
glLinkProgram(shaderProgramOrange);
// Then link the second program object using a different fragment shader (but same vertex shader) this time.
// This is perfectly allowed since the inputs and outputs of both the vertex and fragment shaders are equally matched.
glAttachShader(shaderProgramYellow, vertexShader);
glAttachShader(shaderProgramYellow, fragmentShaderYellow);
glLinkProgram(shaderProgramYellow);
// Set up vertex data (and buffer(s)) and attribute pointers
// We add a new set of vertices to form a second triangle (a total of 6 vertices); the vertex attribute configuration remains the same (still one 3-float position vector per vertex)
GLfloat firstTriangle[] = {
-0.9f, -0.5f, 0.0f, // Left
-0.0f, -0.5f, 0.0f, // Right
-0.45f, 0.5f, 0.0f, // Top
};
GLfloat secondTriangle[] = {
0.0f, -0.5f, 0.0f, // Left
0.9f, -0.5f, 0.0f, // Right
0.45f, 0.5f, 0.0f // Top
};
GLuint VBOs[2], VAOs[2];
glGenVertexArrays(2, VAOs);
glGenBuffers(2, VBOs);
// ================================
// First Triangle setup
// ===============================
glBindVertexArray(VAOs[0]);
glBindBuffer(GL_ARRAY_BUFFER, VBOs[0]);
glBufferData(GL_ARRAY_BUFFER, sizeof(firstTriangle), firstTriangle, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0); // Vertex attributes stay the same
glEnableVertexAttribArray(0);
glBindVertexArray(0);
// ================================
// Second Triangle setup
// ===============================
glBindVertexArray(VAOs[1]); // Note that we bind to a different VAO now
glBindBuffer(GL_ARRAY_BUFFER, VBOs[1]); // And a different VBO
glBufferData(GL_ARRAY_BUFFER, sizeof(secondTriangle), secondTriangle, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (GLvoid*)0); // Because the vertex data is tightly packed we can also specify 0 as the vertex attribute's stride to let OpenGL figure it out.
glEnableVertexAttribArray(0);
glBindVertexArray(0);
// 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);
// Now when we want to draw the triangle we first use the vertex and orange fragment shader from the first program.
glUseProgram(shaderProgramOrange);
// Draw the first triangle using the data from our first VAO
glBindVertexArray(VAOs[0]);
glDrawArrays(GL_TRIANGLES, 0, 3); // This call should output an orange triangle
// Then we draw the second triangle using the data from the second VAO
// When we draw the second triangle we want to use a different shader program so we switch to the shader program with our yellow fragment shader.
glUseProgram(shaderProgramYellow);
glBindVertexArray(VAOs[1]);
glDrawArrays(GL_TRIANGLES, 0, 3); // This call should output a yellow triangle
glBindVertexArray(0);
// Swap the screen buffers
glfwSwapBuffers(window);
}
// Properly de-allocate all resources once they've outlived their purpose
glDeleteVertexArrays(2, VAOs);
glDeleteBuffers(2, VBOs);
// 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)
{
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GL_TRUE);
}
1 vs20152017 + OpenGL to configure and draw a white rectangle
Steps for installing GLUT in Windows:
1, In C:\Program Files (x86)\ WindowKits \10\Include\10.0.10586.0\um\ GL or C:\Program Files (x86)\ WindowKits \8.1\Include\um\ GL there are GL.H and GLU.H;

The freeglut. J h, freeglut_ext. J h, freeglut_std. J h, glew. J h, glfw3. J h, glfw3native. J h, glut. J h, glxew. J h, wglew. J h, GLU. H and gl. H in C: \ Program Files \ Windows (x86) Kits 10 \ \ Include \ 10.0.10586.0 \ um \ gl or C: \ Program Files (x86) Kits \ Windows \ \ Include \ 8.1 um \ gl.
2, carry freeglut decompressed. Lib, glew32. Lib, glfw3dll. Lib, glu32. Lib, in the folder (C: \ Program Files \ Windows (x86) Kits 10 \ lib \ \ 10.0.10586.0 and, um, x86″
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10586.0\ UM \x64).
There were glu32.lib and opengl32.lib

3, carry freeglut decompressed. DLL, glew32. DLL, glfw3. The DLL into the operating system directory under the system32 folder. (Location: C:\Windows\System32)
If it is a 64-bit operating System, copy it to C:\Windows\System

Two VC engineering configuration:
1) Create a Win32 Console Application.


2) Link to OpenGL libraries. Right click on Project — property,
The Settings are as follows:



I’m going to put FreeGlut.Lib first; glew32.lib; glfw3dll.lib;
Add semicolons between libraries; Or the enter key
3) Modify the code as follows:
#include “stdafx.h”
// opg1.cpp : Defines the entry point for the console application.
//
#include “stdafx.h”
# include “stdafx. H”
# include & lt; GL/glew.h>
# include & lt; GL/glut.h>
# include & lt; math.h>
void display(void)
{
GlClear (GL_COLOR_BUFFER_BIT); /* Clear all pixels */
GlColor3f (1.0, 1.0, 1.0);
GlBegin (GL_POLYGON);// the draw white polygon
GlVertex3f (0.25, 0.25, 0.0);
GlVertex3f (0.75, 0.25, 0.0);
GlVertex3f (0.75, 0.75, 0.0);
GlVertex3f (0.25, 0.75, 0.0);
GlEnd ();
GlFlush (); /* Start processing buffered OpenGL routines */
}
void init (void)
{
GlclearColor (0.0, 0.0, 0.0, 0.0, 0.0); /* select clearing color */
GlMatrixMode (GL_PROJECTION);
GlLoadIdentity ();
GlOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0); /* Initialize viewing values */
}
int main(int argc, char** argv)
{
GlutInit (& amp; argc, argv);
GlutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
GlutInitWindowSize (250, 250); /*Declare initial window size.*/
GlutInitWindowPosition (100, 100); /*Declare initial window position.*/
GlutCreateWindow (” hello “); /*Open window with “hello”in its title bar.*/
The init (); /*Call initialization routines.*/
GlutDisplayFunc (display); /*Register callback function to display graphics.*/
GlutMainLoop (); /*Enter main loop and process events.*/
Return 0; /* ANSI C requires main to return int. */
}
The compile run displays a white rectangle

: Packages \nupengl. Core.0.1.0.1\build\native\include
: Packages \nupengl. Core.0.1.0.1\build\native\include