Ejemplo n.º 1
0
void blurfilter(Framebuffer *src, Framebuffer *work, float pixel, int rad, float minus) {
  int x;

  glMatrixMode(GL_PROJECTION);
  glPushMatrix();
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();

  glueBeginrender(work);
  gluePrepareflags(0);
  glClear(GL_COLOR_BUFFER_BIT);
  glueSet2d(GLUE_NO_DEPTH);
  glueDisabletexture();

  glUseProgramObjectARB(shader_blur);
  glueGlsl_bindtex(shader_blur, "t_color", src->texnum, 0, GL_TEXTURE_2D, GLUE_CLAMP|GLUE_NO_MIPMAP);
	glUniform2fARB(glGetUniformLocationARB(shader_blur, "direction"), pixel/src->xres, 0.0);
	glUniform1iARB(glGetUniformLocationARB(shader_blur, "radius"), rad);
	glUniform1fARB(glGetUniformLocationARB(shader_blur, "minus"), minus);
  glue2dquad();
  glUseProgramObjectARB(0);
  glueEndrender();

  glClear(GL_COLOR_BUFFER_BIT);
  glueSet2d(GLUE_NO_DEPTH);

  glUseProgramObjectARB(shader_blur);
  glueGlsl_bindtex(shader_blur, "t_color", work->texnum, 0, GL_TEXTURE_2D, GLUE_CLAMP|GLUE_NO_MIPMAP);
	glUniform2fARB(glGetUniformLocationARB(shader_blur, "direction"), 0, pixel/work->yres);
  float radmultiplier=(float)work->yres/(float)src->yres;
//  glueNoticef("blur multiplier shit %5.2f", radmultiplier);
	glUniform1iARB(glGetUniformLocationARB(shader_blur, "radius"), rad*radmultiplier);
  glue2dquad();
  glUseProgramObjectARB(0);

  glMatrixMode(GL_PROJECTION);
  glPopMatrix();
  glMatrixMode(GL_MODELVIEW);
  glPopMatrix();
}
Ejemplo n.º 2
0
glue_static void glueRendercubemap(Framebuffer *fbo, skene *s, float t, Vertex pos, Vertex tgt, float zmin, float zmax, int maxface) {
  int x;
  Vertex lookat;
  	
	const float lookz[6][6] = {
		{  0.0,  0.0,  1.0,  0.0, -1.0,  0.0 },
		{  1.0,  0.0,  0.0,  0.0, -1.0,  0.0 },
		{ -1.0,  0.0,  0.0,  0.0, -1.0,  0.0 },
		{  0.0,  1.0,  0.0,  0.0,  0.0,  1.0 },
		{  0.0, -1.0,  0.0,  0.0,  0.0, -1.0 },
		{  0.0,  0.0, -1.0,  0.0, -1.0,  0.0 }
	};	

  lookat.x=tgt.x-pos.x;
  lookat.y=tgt.y-pos.y;
  lookat.z=tgt.z-pos.z;
  normalize(&lookat);

  for (x=0; x<maxface; x++) {

    glueBeginrender(fbo);
    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, cubesides[x], fbo->texnum, 0);
    //gluePrepareflags2(black);
  	glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(90, 1, zmin, zmax);
  	glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
		gluLookAt(0, 0, 0, lookz[x][0], lookz[x][1], lookz[x][2], lookz[x][3], lookz[x][4], lookz[x][5]);
    glScalef(1, 1, -1);
    gluLookAt(pos.x, pos.y, pos.z, tgt.x, tgt.y, tgt.z, 0, 1, 0);
    s(t, t, 0, &x, 2|4);
    //checkfbostatus();
    glueEndrender();
  }

  
}