C++ error when using GLFW calls -
i've been learning program in c++ recently, i've run problem when using glew , glfw.
source (.cpp):
#include<iostream> #define glew_static #include "glew/glew.h" #include <glfw/glfw3.h> int main(){ std::cout<<"test"; glfwwindow* window; window = glfwcreatewindow(800,600,"test", glfwgetprimarymonitor(),null); return 0; } this program compiles no errors, when run, no output generated despite std::cout. however, glfwcreatewindow call commented out, program shows output should.
i'm extremely confused , know if there's can fix it.
edit: doubt it's problem std::cout, because when try showing window so, still no response program.
glfwshowwindow(window); while(!glfwwindowshouldclose(window))glfwpollevents(); glfwdestroywindow(window); edit 2: here code of now:
#define glew_static #include "glew/glew.h" #include <glfw/glfw3.h> #include <iostream> int main(){ std::cout<<"test" << std::endl; glfwinit(); glfwwindow* window; window = glfwcreatewindow(800,600,"test", null, null); glfwshowwindow(window); while(!glfwwindowshouldclose(window))glfwpollevents(); glfwdestroywindow(window); glfwterminate(); std::cin.get(); } edit 3: title
edit 4: after experimentation, i've found mention of glfw call in source file seems prevent program running. following generates no output:
int main(){ std::cout<<"test" << std::endl; std::cout.flush(); std::cin.get(); } void test(){ glfwinit(); glfwwindow* window; window = glfwcreatewindow(800,600,"test", null, null); glfwshowwindow(window); while(!glfwwindowshouldclose(window))glfwpollevents(); glfwdestroywindow(window); glfwterminate(); }
some reasons no output on stdout:
- if running on windows, program may have been compiled within windows subsystem. then, print
stdoutgo bitbucket. if using mingw toolchain, controlled-mwindowslinker flag - if program crashes, buffered output may not written. therefore, try flush output stream before doing else. note programs may crash silently.
some things can ask find out more:
- what happens when step through code debugger shipped compiler?
- since
glfwcreatewindowhid output, maybe crashes inside function. did pass correct arguments? - does
glfwcreatewindowreturn valid pointer?
Comments
Post a Comment