Advertisement
WeltEnSTurm

Untitled

Oct 20th, 2014
600
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 1.24 KB | None | 0 0
  1.     void initDeferred(){
  2.  
  3.         batch = new Batch;
  4.         batch.begin(4, GL_TRIANGLE_FAN);
  5.         batch.add([-1, 1, 0]);
  6.         batch.add([-1, -1, 0]);
  7.         batch.add([1, -1, 0]);
  8.         batch.add([1, 1, 0]);
  9.         batch.finish();
  10.  
  11.         width = 512;
  12.         height = 512;
  13.         gbuffer = new GBuffer(width, height);
  14.         string vertex = "
  15.             #version 330
  16.             in vec4 vertex;
  17.             void main(){
  18.                 gl_Position = vertex;
  19.             }
  20.         ";
  21.         string fragment = "
  22.             #version 330
  23.             out vec3 outDiffuse;
  24.             void main(){
  25.                 outDiffuse = vec3(1,1,1);
  26.             }
  27.         ";
  28.         geomPassShader = Shader.prepare("gbuffer_forwarder");
  29.         geomPassShader.start("gbuffer_forwarder", vertex, fragment);
  30.         geomPassShader.addAttribute(gl.attributeVertex, "vertex");
  31.         geomPassShader.bindFragOut(GBuffer.DIFFUSE, "outDiffuse");
  32.         geomPassShader.finish;
  33.     }
  34.  
  35.     void geomPass(){
  36.         gbuffer.bindWrite;
  37.         glViewport(0,0,width,height);
  38.         float[3] green = [0, 1, 0];
  39.         float one = 1;
  40.         glClearBufferfv(GL_COLOR, 0, green.ptr);
  41.         glClearBufferfv(GL_DEPTH, 0, &one);
  42.         geomPassShader.use;
  43.         batch.draw;
  44.     }
  45.  
  46.     void lightPass(){
  47.         glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
  48.         gbuffer.bindRead();
  49.         gbuffer.setRead(GBuffer.DIFFUSE);
  50.         glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
  51.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement