void camera_render_stereo(Camera* c) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //left camera_look(c); glColorMask(1, 0, 0, 0);// bloque Green et Blue et Transparence glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt( 0,0,0,//pos 1,0,0,//pt visé 0,0,1);//up glRotated(c->rho,1,0,0); glRotated(c->theta, 0.0, 1.0, 0.0); glRotated(c->phi, 0.0, 0.0, 1.0); glTranslated(c->x, c->y, c->z); camera_ApplyLeftFrustum(c); game_render(c->game); //clear buffer glClear(GL_DEPTH_BUFFER_BIT) ; //right camera_look(c); glColorMask(0, 1, 1, 0);//bloque Red et Transparence glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt( 0,0,0,//pos 1,0,0,//pt visé 0,0,1);//up glRotated(c->rho,1,0,0); glRotated(c->theta, 0.0, 1.0, 0.0); glRotated(c->phi, 0.0, 0.0, 1.0); glTranslated(c->x, c->y, c->z); camera_ApplyRightFrustum(c); game_render(c->game); // glColorMask(1, 1, 1, 1); glClear(GL_DEPTH_BUFFER_BIT); camera_HUD(c); //update screen // glFlush(); // SDL_GL_SwapBuffers(); }
void camera_render(Camera* c) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // // glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_COMPONENT, GL_TEXTURE_2D, game->depth_tex_id, 0); // glUseProgram(game->shader_id_dummy); // glFramebufferTexture2D(game->frame_buffer_id,GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D,game->color_tex_id,0); // // glFramebufferTexture2D(game->frame_buffer_id,GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D,game->depth_tex_id,0); // glBindFramebuffer(GL_FRAMEBUFFER,game->frame_buffer_id); // camera_HUD(c); double time_=SDL_GetTicks()*0.001; camera_look(c); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt( 0,0,0,//pos 1,0,0,//pt visé 0,0,1);//up glRotated(c->rho,1,0,0); glRotated(c->theta, 0.0, 1.0, 0.0); glRotated(c->phi, 0.0, 0.0, 1.0); // glTranslated(c->x, c->y + 10*cos(time_), c->z + 0.5 * 10*sin(time_)); glTranslated(c->x, c->y + c->fake_y, c->z + c->fake_z); game_render(c->game); // c->game->render(c->game); glClear(GL_DEPTH_BUFFER_BIT); camera_HUD(c); // glFlush(); // SDL_GL_SwapBuffers(); // // SDL_Surface * image = IMG_Load("screenshot/01.png"); // // glTexImage2D (GL_TEXTURE_2D, 0, 3, // // image->w, image->h, 0, // // GL_RGB, GL_UNSIGNED_BYTE, image->pixels); // glBindFramebuffer(GL_FRAMEBUFFER,0); // glUseProgram(game->shader_id_dof); // glActiveTexture (GL_TEXTURE0); // glBindTexture (GL_TEXTURE_2D, game->color_tex_id); // // glBindTexture (GL_TEXTURE_2D, game->depth_tex_id); // glUniform1i(game->shader_dof_color_id,GL_TEXTURE0); // glBegin( GL_QUADS ); // glVertex2d(-1,-1); // glVertex2d(-1, 1); // glVertex2d( 1, 1); // glVertex2d( 1,-1); // glEnd(); }
int prepare_render_shadow(camera3d_t light,GLuint* shadowFBO) { glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, shadowFBO[0]); glPushAttrib(GL_VIEWPORT_BIT | GL_COLOR_BUFFER_BIT); glClear( GL_DEPTH_BUFFER_BIT); glViewport(0,0,shadowFBO[2],shadowFBO[3]); glCullFace(GL_FRONT); // only draw back faces glUseProgramObjectARB(0); camera_look(light); return 0; }
int prepare_render_normal(camera3d_t camera) { glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); camera_look(camera); return 0; }