parent
100dcaf79d
commit
6edbb3646f
@ -0,0 +1,13 @@
|
||||
group=floppy-resources
|
||||
|
||||
[file]
|
||||
filename=shaders/pipe_shader.frag
|
||||
alias=pipe_shader.frag
|
||||
|
||||
[file]
|
||||
filename=shaders/pipe_shader.vert
|
||||
alias=pipe_shader.vert
|
||||
|
||||
[file]
|
||||
filename=images/bird.png
|
||||
alias=bird.png
|
@ -0,0 +1,22 @@
|
||||
#include "QuadShader.h"
|
||||
|
||||
QuadShader::QuadShader() {
|
||||
MAGNUM_ASSERT_GL_VERSION_SUPPORTED(GL::Version::GL330);
|
||||
|
||||
const Utility::Resource rs{"texturedquad-data"};
|
||||
|
||||
GL::Shader vert{GL::Version::GL330, GL::Shader::Type::Vertex};
|
||||
GL::Shader frag{GL::Version::GL330, GL::Shader::Type::Fragment};
|
||||
|
||||
vert.addSource(rs.getString("TexturedQuadShader.vert"));
|
||||
frag.addSource(rs.getString("TexturedQuadShader.frag"));
|
||||
|
||||
CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile() && frag.compile());
|
||||
|
||||
attachShaders({vert, frag});
|
||||
|
||||
CORRADE_INTERNAL_ASSERT_OUTPUT(link());
|
||||
|
||||
_colorUniform = uniformLocation("color");
|
||||
setUniform(uniformLocation("textureData"), TextureUnit);
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
#include <Magnum/GL/DefaultFramebuffer.h>
|
||||
#include <Magnum/Platform/Sdl2Application.h>
|
||||
#include <Corrade/Containers/Optional.h>
|
||||
#include <Corrade/Containers/StringView.h>
|
||||
#include <Corrade/PluginManager/Manager.h>
|
||||
#include <Corrade/Utility/Resource.h>
|
||||
#include <Magnum/ImageView.h>
|
||||
#include <Magnum/GL/Buffer.h>
|
||||
#include <Magnum/GL/DefaultFramebuffer.h>
|
||||
#include <Magnum/GL/Mesh.h>
|
||||
#include <Magnum/GL/Texture.h>
|
||||
#include <Magnum/GL/TextureFormat.h>
|
||||
#include <Magnum/Platform/Sdl2Application.h>
|
||||
#include <Magnum/Trade/AbstractImporter.h>
|
||||
#include <Magnum/Trade/ImageData.h>
|
||||
#include <Magnum/GL/Texture.h>
|
||||
#include <Magnum/Math/Color.h>
|
||||
#include <Corrade/Containers/Iterable.h>
|
||||
#include <Corrade/Containers/StringView.h>
|
||||
#include <Corrade/Containers/StringStl.h>
|
||||
#include <Corrade/Utility/Resource.h>
|
||||
#include <Magnum/GL/Context.h>
|
||||
#include <Magnum/GL/Shader.h>
|
||||
#include <Magnum/GL/Version.h>
|
||||
#include <Magnum/GL/AbstractShaderProgram.h>
|
||||
|
||||
using namespace Magnum;
|
||||
|
||||
class QuadShader: public GL::AbstractShaderProgram {
|
||||
public:
|
||||
typedef GL::Attribute<0, Vector2> Position;
|
||||
typedef GL::Attribute<1, Vector2> TextureCoordinates;
|
||||
|
||||
explicit QuadShader();
|
||||
|
||||
QuadShader& setColor(const Color3& color) {
|
||||
setUniform(_colorUniform, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
QuadShader& bindTexture(GL::Texture2D& texture) {
|
||||
texture.bind(TextureUnit);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
enum: Int { TextureUnit = 0 };
|
||||
|
||||
Int _colorUniform;
|
||||
};
|
||||
|
Loading…
Reference in new issue