///////////////////////////////////////////////////////////////////////
//
//triangles. CPP
//
///////////////////////////////////////////////////////////////////////
#include
using namespace std;
# include "VGL. H"
# include "LoadShaders. H"
Enum VAO_IDs {Triangles, NumVAOs};
Enum Buffer_IDs {ArrayBuffer NumBuffers};
Enum Attrib_IDs {vPosition=0};
GLuint VAOs [NumVAOs];
GLuint Buffers [NumBuffers];
Const GLuint NumVertices=6;
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//
//init
//
Void init (void)
{
GlGenVertexArrays (NumVAOs VAOs);
GlBindVertexArray (VAOs (Triangles));
GLfloat are [NumVertices] [2]={
{0.90, 0.90},//Triangle 1
{0.85, 0.90},
{0.90, 0.85},
{0.90, 0.85},//Triangle 2
{0.90, 0.90},
{0.85, 0.90}
};
GlGenBuffers (NumBuffers, Buffers);
GlBindBuffer (GL_ARRAY_BUFFER, Buffers [ArrayBuffer]);
GlBufferData (GL_ARRAY_BUFFER, sizeof (are),
Are drawn, GL_STATIC_DRAW);
ShaderInfo shaders []={
{GL_VERTEX_SHADER, "triangles. Vert"},
{GL_FRAGMENT_SHADER, "triangles. Frag"},
{GL_NONE, NULL}
};
GLuint program=LoadShaders (shaders);
GlUseProgram (program);
GlVertexAttribPointer (vPosition, 2, GL_FLOAT,
GL_FALSE, 0, BUFFER_OFFSET (0));
GlEnableVertexAttribArray (vPosition);
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//
//display
//
Void the display (void)
{
GlClear (GL_COLOR_BUFFER_BIT);
GlBindVertexArray (VAOs (Triangles));
GlDrawArrays (GL_TRIANGLES, 0, NumVertices);
GlFlush ();
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//
//the main
//
Int main (int arg c, char * * argv)
{
GlutInit (& amp; Arg c, argv);
GlutInitDisplayMode (GLUT_RGBA);
GlutInitWindowSize (512, 512);
GlutInitContextVersion (4, 3);
GlutInitContextProfile (GLUT_CORE_PROFILE);
glutCreateWindow(argv[0]);
If (glewInit ()) {
Cerr & lt; <"Unable to initialize GLEW... Exiting "& lt;The exit (EXIT_FAILURE);
}
The init ();
glutDisplayFunc(display);
glutMainLoop();
}
But still encounter LNK2001, LNK2019 error:
VS2015 information:
1> LoadShaders. CPP
1> Being generated code...
1> LIBCMTD. Lib (initializers. Obj) : warning LNK4098: the default library "MSVCRTD. Lib" conflict with the use of other libraries; Please use the/NODEFAULTLIB: library
1> Freeglut_static_vs2010_d. Lib (freeglut_init. Obj) : error LNK2019: cannot resolve _sscanf external symbols, the symbol referenced in the function _glutInit
1> Freeglut_static_vs2010_d. Lib (freeglut_main. Obj) : error LNK2019: cannot resolve _vfprintf external symbols, the symbol referenced in the function _fgError
1> Freeglut_static_vs2010_d. Lib (freeglut_main. Obj) : error LNK2019: cannot resolve ___iob_func external symbols, the symbol referenced in the function _fgError
1> Freeglut_static_vs2010_d. Lib (freeglut_display. Obj) : error LNK2001: cannot resolve the external symbol of ___iob_func
1> Freeglut_static_vs2010_d. Lib (freeglut_joystick. Obj) : error LNK2019: cannot resolve __snprintf external symbols, the symbol referenced in the function _fghJoystickGetOEMProductName
1> MSVCRTD. Lib (_chandler4gs_. Obj) : error LNK2019: cannot resolve __except_handler4_common external symbols, the symbol referenced in the function __except_handler4
1> Charles File E: \ \ \ c + + Source File \ $OpenGL \ testing3 VS2015 \ \ Debug \ testing3. Exe: fatal error LNK1120: five cannot resolve the external command
==========all regenerated: zero success, failure, skip 0==========
Whether oglpg - 8 th - edition freeglut_static_2010. Lib and libcmtd lib have conflict? I use VS2010 libcmtd lib 2015, replacing the mistake turned out to be a 52. How to do?
CodePudding user response:
If trouble you look at the great god, solves the problem, I will appreciate it very much! And I will put the specific configuration method writes his own blog, to those who use VS2015 for your reference,CodePudding user response:
Try the libcmtd. Lib this library ignoredCodePudding user response:
http://www.cnblogs.com/gagugagu/p/5211452.htmlCodePudding user response:
Vs must use Windows console project, specify the library file directory, because of the glut, glew are many tags, the window header file can't disorderly, such as two glut. J h, death,CodePudding user response:
You can see, my configuration method, engineering source: https://blog.csdn.net/guyuealian/article/details/85262650