void GLSLProgram::GLRestore() { ILOG("Restoring GLSL program %s/%s", strlen(this->vshader_filename) > 0 ? this->vshader_filename : "(mem)", strlen(this->fshader_filename) > 0 ? this->fshader_filename : "(mem)"); glsl_recompile(this); // Note that any shader uniforms are still lost, hopefully the client sets them every frame at a minimum... }
void glsl_refresh() { ILOG("glsl_refresh()"); for (std::set<GLSLProgram *>::const_iterator iter = active_programs.begin(); iter != active_programs.end(); ++iter) { if (!glsl_up_to_date(*iter)) { glsl_recompile(*iter); } } }
GLSLProgram *glsl_create_source(const char *vshader_src, const char *fshader_src) { GLSLProgram *program = new GLSLProgram(); program->program_ = 0; program->vsh_ = 0; program->fsh_ = 0; program->vshader_source = vshader_src; program->fshader_source = fshader_src; strcpy(program->name, "[srcshader]"); strcpy(program->vshader_filename, ""); strcpy(program->fshader_filename, ""); if (glsl_recompile(program)) { active_programs.insert(program); } register_gl_resource_holder(program); return program; }
void GLSLProgram::GLRestore() { // Quoth http://developer.android.com/reference/android/opengl/GLSurfaceView.Renderer.html; // "Note that when the EGL context is lost, all OpenGL resources associated with that context will be automatically deleted. // You do not need to call the corresponding "glDelete" methods such as glDeleteTextures to manually delete these lost resources." // Hence, we comment out: // glDeleteShader(this->vsh_); // glDeleteShader(this->fsh_); // glDeleteProgram(this->program_); this->program_ = 0; this->vsh_ = 0; this->fsh_ = 0; ILOG("Restoring GLSL program %s/%s", strlen(this->vshader_filename) > 0 ? this->vshader_filename : "(mem)", strlen(this->fshader_filename) > 0 ? this->fshader_filename : "(mem)"); glsl_recompile(this); // Note that any shader uniforms are still lost, hopefully the client sets them every frame at a minimum... }
GLSLProgram *glsl_create_source(const char *vshader_src, const char *fshader_src, std::string *error_message) { GLSLProgram *program = new GLSLProgram(); program->program_ = 0; program->vsh_ = 0; program->fsh_ = 0; program->vshader_source = vshader_src; program->fshader_source = fshader_src; strcpy(program->name, "[srcshader]"); strcpy(program->vshader_filename, ""); strcpy(program->fshader_filename, ""); if (glsl_recompile(program, error_message)) { active_programs.insert(program); } else { ELOG("Failed compiling GLSL program from source strings"); delete program; return 0; } register_gl_resource_holder(program); return program; }
GLSLProgram *glsl_create(const char *vshader, const char *fshader, std::string *error_message) { GLSLProgram *program = new GLSLProgram(); program->program_ = 0; program->vsh_ = 0; program->fsh_ = 0; program->vshader_source = 0; program->fshader_source = 0; strcpy(program->name, vshader + strlen(vshader) - 15); strcpy(program->vshader_filename, vshader); strcpy(program->fshader_filename, fshader); if (glsl_recompile(program, error_message)) { active_programs.insert(program); } else { ELOG("Failed compiling GLSL program: %s %s", vshader, fshader); delete program; return 0; } register_gl_resource_holder(program); return program; }
GLSLProgram *glsl_create(const char *vshader, const char *fshader) { GLSLProgram *program = new GLSLProgram(); program->program_ = 0; program->vsh_ = 0; program->fsh_ = 0; program->vshader_source = 0; program->fshader_source = 0; strcpy(program->name, vshader + strlen(vshader) - 15); strcpy(program->vshader_filename, vshader); strcpy(program->fshader_filename, fshader); if (glsl_recompile(program)) { active_programs.insert(program); } else { FLOG("Failed building GLSL program: %s %s", vshader, fshader); } register_gl_resource_holder(program); return program; }