void setup() { setup_models(); setup_cameras(); shader_program_t::build(diffuse_shader, "shader/diffuse.vs", "shader/diffuse.fs"); shader_program_t::build(reflection_shader, "shader/reflection.vs", "shader/reflection.fs"); light_direction = glm::vec3(0.0f, -1.0f, 0.0f); build_image_texutre(image_texture, "wood.png"); build_color_texture(color_texture, viewport.x, viewport.y); build_depth_texture(depth_texture, viewport.x, viewport.y); fbo = new frame_buffer_t(viewport.x, viewport.y); fbo->bind(); fbo->attach_texture(GL_COLOR_ATTACHMENT0_EXT, color_texture); fbo->attach_render_buffer(GL_DEPTH_ATTACHMENT_EXT, GL_DEPTH_COMPONENT); GLenum draw_buffers[] = { GL_COLOR_ATTACHMENT0_EXT }; fbo->select_color_buffers(draw_buffers); if (! fbo->is_valid()) { glfwTerminate(); exit(EXIT_FAILURE); } fbo->release(); glEnable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); }
/******************************************************************************* * PUBLIC FUNCTIONS ******************************************************************************/ void render_init() { GameState* gamestate = get_gamestate(); // Create cameras for both players player1_viewport = Viewport_new( 0, 0, 800, 300 ); player2_viewport = Viewport_new( 0, 300, 800, 300 ); minimap = Viewport_new( 350, 250, 100, 100 ); minimap->ortho = 1; minimap->bottom = gamestate->landscape->southBound; minimap->top = gamestate->landscape->northBound; minimap->left = gamestate->landscape->westBound; minimap->right = gamestate->landscape->eastBound; hud = Viewport_new( 0, 0, 800, 600 ); hud->ortho = 1; hud->bottom = -1; hud->top = 1; hud->left = -1; hud->right = 1; // Set up the scene set_up_GL(); // Set the cameras up setup_cameras(); update_cameras(0); }