aboutsummaryrefslogtreecommitdiff
path: root/src/RenderBackend/OpenGL/ShaderProgram.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/RenderBackend/OpenGL/ShaderProgram.cpp')
-rw-r--r--src/RenderBackend/OpenGL/ShaderProgram.cpp57
1 files changed, 2 insertions, 55 deletions
diff --git a/src/RenderBackend/OpenGL/ShaderProgram.cpp b/src/RenderBackend/OpenGL/ShaderProgram.cpp
index 7990a82..ba0e6dd 100644
--- a/src/RenderBackend/OpenGL/ShaderProgram.cpp
+++ b/src/RenderBackend/OpenGL/ShaderProgram.cpp
@@ -28,26 +28,6 @@ namespace amalgine {
delete []attachedShaders;
}
- #if 0
- bool ShaderProgram::setPixelShader(CompiledPixelShader *pixelShader)
- {
- if(!pixelShader) return false;
-
- // TODO: Do not allow adding shader if the program has already been built
- glAttachShader(shaderProgramId, pixelShader->getShaderId());
-
- const auto &pixelAttributes = pixelShader->getPixelAttributes();
- for(const auto &pixelAttribute : pixelAttributes)
- {
- const string &attributeName = pixelAttribute.first;
- i32 attributeLocation = pixelAttribute.second;
- glBindFragDataLocation(shaderProgramId, attributeLocation, attributeName.c_str());
- }
-
- return true;
- }
- #endif
-
// static
Result<std::unique_ptr<ShaderProgram>> ShaderProgram::build(const std::vector<Shader*> &shaders) {
u32 shader_program_id = glCreateProgram();
@@ -64,40 +44,7 @@ namespace amalgine {
return Result<std::unique_ptr<ShaderProgram>>::Ok(std::move(shader_program));
}
- Result<Uniform> ShaderProgram::get_uniform_by_name(const char *name) {
- GLint uniform_id = glGetUniformLocation(program_id, name);
- if(uniform_id == -1)
- return Result<Uniform>::Err(std::string("Uniform with name ") + name + " was not found");
-
- Uniform uniform(uniform_id, program_id);
- return Result<Uniform>::Ok(std::move(uniform));
- }
-
- int ShaderProgram::set_input_data(const char *name, const DeviceMemory &data) {
- GLint attrib_location = glGetAttribLocation(program_id, name);
- if(attrib_location == -1) {
- fprintf(stderr, "No such attribute in shader: %s\n", name);
- return -1;
- }
-
- data.use();
- glEnableVertexAttribArray(attrib_location);
- switch(data.get_type()) {
- case DeviceMemoryType::NONE:
- return -1;
- case DeviceMemoryType::VEC2: {
- glVertexAttribPointer(attrib_location, 2, GL_FLOAT, GL_FALSE, 0, 0);
- break;
- }
- case DeviceMemoryType::VEC3: {
- glVertexAttribPointer(attrib_location, 3, GL_FLOAT, GL_FALSE, 0, 0);
- break;
- }
- }
- return 0;
- }
-
- void ShaderProgram::use() {
- glUseProgram(program_id);
+ ShaderFrame ShaderProgram::create_frame() {
+ return { program_id };
}
}