[nostalgia] Start on new TileSheetEditor
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2016 - 2021 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
#include <nostalgia/common/point.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/glutils/glutils.hpp>
|
||||
#include <nostalgia/studio/studio.hpp>
|
||||
|
||||
namespace nostalgia::core {
|
||||
|
||||
class TileSheetGrid {
|
||||
|
||||
private:
|
||||
static constexpr auto VertexVboRows = 1;
|
||||
static constexpr auto VertexVboRowLength = 4;
|
||||
static constexpr auto VertexVboLength = VertexVboRows * VertexVboRowLength;
|
||||
static constexpr auto VertexEboLength = 1;
|
||||
|
||||
static constexpr auto VShad = R"(
|
||||
{}
|
||||
in vec2 vPt1;
|
||||
in vec2 vPt2;
|
||||
out VS_OUT {
|
||||
vec2 pt1;
|
||||
vec2 pt2;
|
||||
} vs_out;
|
||||
void main() {
|
||||
vs_out.pt1 = vPt1;
|
||||
vs_out.pt2 = vPt2;
|
||||
gl_Position = vec4(vPt1, 0.0, 1.0);
|
||||
})";
|
||||
|
||||
static constexpr auto FShad = R"(
|
||||
{}
|
||||
in vec3 fColor;
|
||||
out vec4 outColor;
|
||||
void main() {
|
||||
outColor = vec4(0.4431, 0.4901, 0.4941, 1.0);
|
||||
})";
|
||||
|
||||
static constexpr auto GShad = R"glsl(
|
||||
{}
|
||||
in VS_OUT {
|
||||
vec2 pt1;
|
||||
vec2 pt2;
|
||||
} gs_in[];
|
||||
layout(line_strip, max_vertices = 2) out;
|
||||
void main() {
|
||||
//gl_Position = vec4(gs_in[0].pt1, 0, 0);
|
||||
//EmitVertex();
|
||||
//gl_Position = vec4(gs_in[0].pt2, 0, 0);
|
||||
//EmitVertex();
|
||||
//EndPrimitive();
|
||||
})glsl";
|
||||
|
||||
glutils::GLProgram m_shader;
|
||||
glutils::BufferSet m_bufferSet;
|
||||
|
||||
public:
|
||||
ox::Error buildShader() noexcept;
|
||||
|
||||
void draw(bool update) noexcept;
|
||||
|
||||
void initBufferSet(const NostalgiaGraphic &img) noexcept;
|
||||
|
||||
private:
|
||||
static void setBufferObject(unsigned vertexRow, common::Point pt1, common::Point pt2, float *vbo, GLuint *ebo) noexcept;
|
||||
|
||||
void setBufferObjects(const NostalgiaGraphic &img, glutils::BufferSet *bg) noexcept;
|
||||
|
||||
static class ImVec2 pixelSize() noexcept;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user