Compare commits
2 Commits
c1baadc755
...
6edbb3646f
Author | SHA1 | Date |
---|---|---|
mitchellhansen | 6edbb3646f | 2 years ago |
mitchellhansen | 100dcaf79d | 2 years ago |
@ -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
|
Before Width: | Height: | Size: 282 B After Width: | Height: | Size: 282 B |
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 110 B |
Before Width: | Height: | Size: 121 B After Width: | Height: | Size: 121 B |
Before Width: | Height: | Size: 130 B After Width: | Height: | Size: 130 B |
Before Width: | Height: | Size: 126 B After Width: | Height: | Size: 126 B |
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 125 B |
Before Width: | Height: | Size: 133 B After Width: | Height: | Size: 133 B |
Before Width: | Height: | Size: 126 B After Width: | Height: | Size: 126 B |
Before Width: | Height: | Size: 126 B After Width: | Height: | Size: 126 B |
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 131 B |
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 125 B |
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 125 B |
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 99 B |
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 110 B |
Before Width: | Height: | Size: 96 B After Width: | Height: | Size: 96 B |
Before Width: | Height: | Size: 90 B After Width: | Height: | Size: 90 B |
Before Width: | Height: | Size: 112 B After Width: | Height: | Size: 112 B |
Before Width: | Height: | Size: 94 B After Width: | Height: | Size: 94 B |
Before Width: | Height: | Size: 92 B After Width: | Height: | Size: 92 B |
Before Width: | Height: | Size: 94 B After Width: | Height: | Size: 94 B |
Before Width: | Height: | Size: 101 B After Width: | Height: | Size: 101 B |
Before Width: | Height: | Size: 100 B After Width: | Height: | Size: 100 B |
Before Width: | Height: | Size: 278 B After Width: | Height: | Size: 278 B |
Before Width: | Height: | Size: 354 B After Width: | Height: | Size: 354 B |
Before Width: | Height: | Size: 284 B After Width: | Height: | Size: 284 B |
Before Width: | Height: | Size: 337 B After Width: | Height: | Size: 337 B |
Before Width: | Height: | Size: 340 B After Width: | Height: | Size: 340 B |
Before Width: | Height: | Size: 456 B After Width: | Height: | Size: 456 B |
Before Width: | Height: | Size: 421 B After Width: | Height: | Size: 421 B |
Before Width: | Height: | Size: 161 B After Width: | Height: | Size: 161 B |
Before Width: | Height: | Size: 596 B After Width: | Height: | Size: 596 B |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@ -0,0 +1,12 @@
|
|||||||
|
group=texturedquad-data
|
||||||
|
|
||||||
|
[file]
|
||||||
|
filename=shaders/TexturedQuadShader.frag
|
||||||
|
alias=TexturedQuadShader.frag
|
||||||
|
|
||||||
|
[file]
|
||||||
|
filename=shaders/TexturedQuadShader.vert
|
||||||
|
alias=TexturedQuadShader.vert
|
||||||
|
|
||||||
|
[file]
|
||||||
|
filename=stone.tga
|
@ -0,0 +1,11 @@
|
|||||||
|
uniform vec3 color = vec3(1.0, 1.0, 1.0);
|
||||||
|
uniform sampler2D textureData;
|
||||||
|
|
||||||
|
in vec2 interpolatedTextureCoordinates;
|
||||||
|
|
||||||
|
out vec4 fragmentColor;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
fragmentColor.rgb = color*texture(textureData, interpolatedTextureCoordinates).rgb;
|
||||||
|
fragmentColor.a = 1.0;
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
layout(location = 0) in vec4 position;
|
||||||
|
layout(location = 1) in vec2 textureCoordinates;
|
||||||
|
|
||||||
|
out vec2 interpolatedTextureCoordinates;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
interpolatedTextureCoordinates = textureCoordinates;
|
||||||
|
|
||||||
|
gl_Position = position;
|
||||||
|
}
|
After Width: | Height: | Size: 192 KiB |
@ -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;
|
||||||
|
};
|
||||||
|
|