Hi, I took some advice given to me on my previous topic and began learning GLFW (seems nice enough so far), but I have hit a snag. glfwSetWindowTitle isn’t working for me at all. The window I’ve created keeps the default name, regardless, though behaving properly otherwise.
Tutorial program that works: GLFW:Tutorials:Basics (An Example)
My test source, so far:
#include<GL/glfw.h>
#include<stdlib.h>
#include<stdio.h>
void init(int width,int height,const char* title){
glfwInit();
glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE,GL_TRUE);
if (glfwOpenWindow(width,height, 5, 6, 5, 0, 0, 0, GLFW_WINDOW) != GL_TRUE)
glfwTerminate();
glfwSetWindowTitle(title);
}
int main(){
while(0==0){
init(640,480,"title");
getchar();
glfwTerminate();
}
}
Obviously, I haven’t gotten around to glfw’s keyboard input stuff yet, but this is just a window test anyway. Hopefully, someone can point out what is probably obviously-wrong with my work so far. @_@;
What’s wrong is that you keep initializing GLFW in your loop. Your init
call should be outside of the loop.
Also, the traditional method for creating an infinite loop is while(true)
.
Thank you for the while-loop advice, and also for pointing out my little goof-up, I could have sworn it was outside of it… @_@
Well, we all make silly little mistakes sometimes, right? Thanks a ton!
ReEDIT: Thanks, while(1) saves a bit of time typing, lol… Anyway, the following code is just as ineffective:
#include<GL/glfw.h>
#include<stdlib.h>
#include<stdio.h>
void init(int width,int height,const char* title){
glfwInit();
glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE,GL_TRUE);
if (glfwOpenWindow(width,height, 5, 6, 5, 0, 0, 0, GLFW_WINDOW) != GL_TRUE)
glfwTerminate();
glfwSetWindowTitle(title);
}
int main(){
init(640,480,"title");
while(1){
getchar();
glfwTerminate();
}
}
I have no idea what’s up, but it just isn’t renaming the window. @_@;
EDIT: SUCCESS! I added glfwPollEvents so I could test key input while waiting, and that fixed everything, somehow