对不起,如果问题布局很奇怪,或者这是我第一次提出问题。我一周前开始学习c ++,现在我知道如何使用GLFW创建一个窗口我想清理我的代码并使其更好。我试着把#34;创建窗口"名为" window.cpp"的.cpp文件中的内容然后将其导入主文件。但是当我拿出GLFWCreateWindow函数时,它不会识别窗口名称" w_gill"在swapbuffer中,windowshouldclose和destroywindow函数。有人可以帮帮我吗?
这是Main.cpp文件:
#include <iostream>
#include <Windows.h>
#include "window.cpp"
int main(){
do{
createWindow();
glfwSwapBuffers(w_gill);
glfwPollEvents();
} while (!glfwWindowShouldClose(w_gill));
glfwDestroyWindow(w_gill);
glfwTerminate();
return 0;
}
Window.cpp文件:
#include <GL\glew.h>
#include <GLFW\glfw3.h>
int windowWidth = 1920 / 2;
int windowHeight = 1080 / 2;
int createWindow(){
if (!glfwInit())
{
glfwTerminate();
return -1;
}
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_VERSION_MINOR, 4);
glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
GLFWwindow* w_gill;
w_gill = glfwCreateWindow(windowWidth, windowHeight, "Gillow", NULL, NULL);
if (!w_gill)
{
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(w_gill);
glfwSetInputMode(w_gill, GLFW_STICKY_KEYS, GL_TRUE);
}
答案 0 :(得分:1)
没关系,我得到了它,我不得不放
sub(".*(?<=\\()(.+)(?=\\)).*", "\\1", "A B C (123-456-789)", perl=TRUE)
#[1] "123-456-789"
在main.cpp文件中,所以它们是链接的。无论如何,谢谢你的回复。
答案 1 :(得分:0)