visual studio 中的 OpenGL 无法使用清晰的颜色
OpenGL in visual studio can't use clear color
所以,在 main.cpp 我有:
#include <iostream>
#include "SRC\Graphics\Headers\MakeWindow.h"
int main()
{
if (!glfwInit())
{
std::cout << "Failed to open GLFW" << std::endl;
std::cin.get();
return -1;
}
std::cin.get();
char name_LOL[10] = "Hi There";
ENGINEG::Make_Window MyWindow(250, 500, name_LOL);
if (MyWindow.Is_Closed())
{
std::cout << "Failed to open window" << std::endl;
std::cin.get();
return -1;
}
glClearColor(0.2f, 0.3f, 0.8f, 1.0f);
MyWindow.Set_Window();
while (true)
{
glClear(GL_COLOR_BUFFER_BIT);
glfwPollEvents();
MyWindow.Update();
}
std::cin.get();
MyWindow.Colose_Window();
if (!MyWindow.Is_Closed())
{
std::cout << "Failed to close window" << std::endl;
std::cin.get();
return -1;
}
std::cin.get();
glfwTerminate();
std::cout << "Done!" << std::endl;
std::cin.get();
return 0;
}
在 Makewindow.h 导入 GLFW,因此 opengl 应该导入,但我在使用 opengl 函数时仍然遇到此错误。
错误 LNK2019 未解析的外部符号 __imp__glClearColor@16 在函数 _main 中引用 Game_Engine
glfw 函数是否还有其他未解析的外部符号?您很可能没有在链接器设置中包含 glfw3.lib。转到 project->properties->linker->input->additional dependencies,并确保您拥有所需的一切(glfw3.lib、opengl32.lib)。
所以,在 main.cpp 我有:
#include <iostream>
#include "SRC\Graphics\Headers\MakeWindow.h"
int main()
{
if (!glfwInit())
{
std::cout << "Failed to open GLFW" << std::endl;
std::cin.get();
return -1;
}
std::cin.get();
char name_LOL[10] = "Hi There";
ENGINEG::Make_Window MyWindow(250, 500, name_LOL);
if (MyWindow.Is_Closed())
{
std::cout << "Failed to open window" << std::endl;
std::cin.get();
return -1;
}
glClearColor(0.2f, 0.3f, 0.8f, 1.0f);
MyWindow.Set_Window();
while (true)
{
glClear(GL_COLOR_BUFFER_BIT);
glfwPollEvents();
MyWindow.Update();
}
std::cin.get();
MyWindow.Colose_Window();
if (!MyWindow.Is_Closed())
{
std::cout << "Failed to close window" << std::endl;
std::cin.get();
return -1;
}
std::cin.get();
glfwTerminate();
std::cout << "Done!" << std::endl;
std::cin.get();
return 0;
}
在 Makewindow.h 导入 GLFW,因此 opengl 应该导入,但我在使用 opengl 函数时仍然遇到此错误。
错误 LNK2019 未解析的外部符号 __imp__glClearColor@16 在函数 _main 中引用 Game_Engine
glfw 函数是否还有其他未解析的外部符号?您很可能没有在链接器设置中包含 glfw3.lib。转到 project->properties->linker->input->additional dependencies,并确保您拥有所需的一切(glfw3.lib、opengl32.lib)。