-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
component: added shader and shader_program class
- Loading branch information
Showing
29 changed files
with
402 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#version 330 core | ||
out vec4 FragColor; | ||
void main() | ||
{ | ||
FragColor = vec4(0.2, 0.5, 0.8, 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#version 330 core | ||
layout (location = 0) in vec3 aPos; | ||
void main() | ||
{ | ||
gl_Position = vec4(aPos, 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* @file shader_program.hpp | ||
* @date 11/2/24 | ||
* @brief | ||
* | ||
* @copyright Copyright (c) 2024 Ruixiang Du (rdu) | ||
*/ | ||
|
||
#ifndef QUICKVIZ_SHADER_PROGRAM_HPP | ||
#define QUICKVIZ_SHADER_PROGRAM_HPP | ||
|
||
#include <glm/glm.hpp> | ||
|
||
#include <cstdint> | ||
#include <unordered_map> | ||
|
||
#include "imview/component/shader.hpp" | ||
|
||
namespace quickviz { | ||
class ShaderProgram { | ||
public: | ||
ShaderProgram(); | ||
~ShaderProgram(); | ||
|
||
// public methods | ||
void AttachShader(const Shader& shader); | ||
bool LinkProgram(); | ||
void Use() const; | ||
|
||
// Uniform setting functions | ||
void SetUniform(const std::string& name, bool value); | ||
void SetUniform(const std::string& name, int value); | ||
void SetUniform(const std::string& name, float value); | ||
void SetUniform(const std::string& name, const glm::vec3& vector); | ||
void SetUniform(const std::string& name, const glm::mat4& matrix); | ||
|
||
private: | ||
uint32_t GetUniformLocation(const std::string& name); | ||
|
||
uint32_t program_id_; | ||
std::unordered_map<std::string, uint32_t> uniform_location_cache_; | ||
}; | ||
} // namespace quickviz | ||
|
||
#endif // QUICKVIZ_SHADER_PROGRAM_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* @file gl_widget.hpp | ||
* @date 10/29/24 | ||
* @brief | ||
* | ||
* @copyright Copyright (c) 2024 Ruixiang Du (rdu) | ||
*/ | ||
|
||
#ifndef XMOTION_GL_WIDGET_HPP | ||
#define XMOTION_GL_WIDGET_HPP | ||
|
||
#include <memory> | ||
#include <functional> | ||
|
||
#include "imview/panel.hpp" | ||
#include "imview/component/frame_buffer.hpp" | ||
|
||
namespace quickviz { | ||
class GlWidget : public Panel { | ||
public: | ||
GlWidget(const std::string& widget_name); | ||
~GlWidget() = default; | ||
|
||
// public methods | ||
using GlRenderFunction = std::function<void(const FrameBuffer&)>; | ||
void SetGlRenderFunction(GlRenderFunction func); | ||
void Draw() override; | ||
|
||
private: | ||
GlRenderFunction render_function_; | ||
std::unique_ptr<FrameBuffer> frame_buffer_; | ||
}; | ||
} // namespace quickviz | ||
|
||
#endif // XMOTION_GL_WIDGET_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.