Пример #1
0
int main(void)
{

//	register_func(fbo_init, fbo_draw);
	register_func(vao_init, vao_draw);
	GLFWwindow* window;
	if (!glfwInit())
		return -1;

	window = glfwCreateWindow(800, 800, "Simple example", NULL, NULL);
	if (!window)
	{
		glfwTerminate();
		return -1;
	}

	glfwMakeContextCurrent(window);

	GLenum glew_err = glewInit();
	if (glew_err != GLEW_OK)
	{
		printf("%s\n", glewGetErrorString(glew_err));
		return -1;
	}

	opengl_init();

	while (!glfwWindowShouldClose(window))
	{
		opengl_draw(1);
		glfwSwapBuffers(window);
		glfwPollEvents();
	}

	glfwDestroyWindow(window);

	glfwTerminate();
	return 1;
}
Пример #2
0
void		opengl_loop(t_opengl *o)
{
	while (glfwGetKey(o->window, GLFW_KEY_ESCAPE) != GLFW_PRESS
		&& !glfwWindowShouldClose(o->window))
	{
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		glUseProgram(o->program);
		glUniformMatrix4fv(o->m_projection_location, 1, GL_FALSE,
			&(o->m_projection.mat[0][0]));
		glUniformMatrix4fv(o->m_view_location, 1, GL_FALSE,
			&(o->m_view.mat[0][0]));
		o->m_model = matrice_multiplication(o->m_model, o->m_rotate);
		glUniformMatrix4fv(o->m_model_location, 1, GL_FALSE,
			&(o->m_model.mat[0][0]));
		glfwSetKeyCallback(o->window, key_callback);
		opengl_draw(o);
		glfwPollEvents();
		glfwSwapBuffers(o->window);
	}
	glDeleteProgram(o->program);
	glfwTerminate();
}