DeformDrawer::DeformDrawer(FileReader& props)
  : framebuffer(GL_TEXTURE_RECTANGLE_ARB, 800, 600),
    surface("images/particles/deform2.png")
{
  shader_program.attach(ShaderObject(GL_FRAGMENT_SHADER_ARB, "data/shader/particledeform.frag"));
  shader_program.link();
}
Exemplo n.º 2
0
Shader::Shader(const char * shader_code,ShaderType type):glReference(ShaderObject(-1)){
 
  int reference = glCreateShader(shaderTypes[(int)type]);
  const char * s = shader_code;

  glShaderSource(reference, 1, &s, NULL);
  glCompileShader(reference);

  GLint status;
  glGetShaderiv(reference, GL_COMPILE_STATUS, &status);
  
  if (status == GL_FALSE){
    GLint infoLogLength;
    glGetShaderiv(reference, GL_INFO_LOG_LENGTH, &infoLogLength);
    GLchar *strInfoLog = new GLchar[infoLogLength + 1];
    glGetShaderInfoLog(reference, infoLogLength, NULL, strInfoLog);
    
    const char *strShaderType = NULL;
    switch(type){
    case ShaderType::Vertex: strShaderType = "vertex"; break;
    case ShaderType::Geometry: strShaderType = "geometry"; break;
    case ShaderType::Fragment: strShaderType = "fragment"; break;
    }
    
    std::cout<<"shader code "<<std::string(shader_code)<<"\n";
    
    fprintf(stderr, "Compile failure in %s shader:\n%s\n", strShaderType, strInfoLog);
    delete[] strInfoLog;
  }

  glReference = reference;
  this->type = type;
}
Exemplo n.º 3
0
ShaderObject ShaderObject::load(GraphicContext &gc, ShaderType shader_type, IODevice &file)
{
	int size = file.get_size();
	std::string source(size, 0);
	file.read(&source[0], size);

	return ShaderObject(gc, shader_type, StringHelp::local8_to_text(source));
}
Exemplo n.º 4
0
/*standard OpenGL initialization*/
static bool initialize(const char *filename) {		
  if (!g_input.LoadImageFromFile(filename, false )) return false;
  sProgram = new ProgramGLSL("SelectChannel.glsl");	
  sProgram->AttachShaderObject( 
    ShaderObject( GL_FRAGMENT_SHADER, "SelectChannel.glsl", true ) );
  if (!sProgram->LinkProgram()) return false;
  
  g_img_width = g_input.GetImageWidth();
  g_img_height = g_input.GetDrawHeight();
  ReshapeWindow( g_img_width, g_img_height );	

  g_pyramid = new PyramidGLSL( &g_input, g_sp.GetSigmas(), g_sp.GetLevels() );
  return true;
}