c++, Identifier is undefined when part of the code is put in another cpp file -
i'm sorry if question layout weird or first time asking question. have started learning c++ week ago , know how create window glfw clean code , make nicer. tried put "create window" stuff inside .cpp file named "window.cpp" , import main file. when take out glfwcreatewindow function doesn't recognize window name "w_gill" in swapbuffer, windowshouldclose , destroywindow functions. can please me?
here main.cpp file:
#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; } and window.cpp file:
#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); }
nevermind got it, had put
glfwwindow* w_gill; int createwindow(); inside of main.cpp file linked. responding anyway.
Comments
Post a Comment