Beispiel #1
0
int main(int argc, char** argv)
{
	int width, height;
	GLFWwindow* window;

	if (!glfwInit())
	{
		fprintf(stderr, "Failed to initialize GLFW\n");
		exit(EXIT_FAILURE);
	}

	width = 640;
	height = 480;

	viewport_width = width;
	viewport_height = height;	

	window = glfwCreateWindow(width, height, "Particle Engine", NULL, NULL);
	if (!window)
	{
		fprintf(stderr, "Failed to create GLFW window\n");
		glfwTerminate();
		exit(EXIT_FAILURE);
	}

	glfwMakeContextCurrent(window);

	glfwSwapInterval(1);

	glfwSetFramebufferSizeCallback(window, resize_callback);
	glfwSetKeyCallback(window, key_callback);
	glfwSetCursorPosCallback(window, cursor_position_callback);
	glfwSetMouseButtonCallback(window, mouse_button_callback);
	glfwSetScrollCallback(window, scroll_callback);

	// Set initial aspect ratio
	glfwGetFramebufferSize(window, &width, &height);
	resize_callback(window, width, height);

	render = new TBaluRender(TVec2i(width, height));

	Init();

	balu_time.Start();

	glfwSetTime(0.0);

	while (!glfwWindowShouldClose(window))
	{
		draw_scene(window, glfwGetTime());

		glfwSwapBuffers(window);
		glfwPollEvents();
	}

	delete render;

	glfwDestroyWindow(window);
	glfwTerminate();

	exit(EXIT_SUCCESS);
}