[nostalgia/core/studio] Add scrolling support to TileSheetEditor
This commit is contained in:
@@ -18,13 +18,15 @@ ox::Error TileSheetGrid::buildShader() noexcept {
|
||||
return glutils::buildShaderProgram(pixelLineVshad, pixelLineFshad, pixelLineGshad).moveTo(&m_shader);
|
||||
}
|
||||
|
||||
void TileSheetGrid::draw(bool update) noexcept {
|
||||
glLineWidth(3);
|
||||
void TileSheetGrid::draw(bool update, const ImVec2 &scroll) noexcept {
|
||||
glLineWidth(3 * m_pixelSizeMod * 0.5f);
|
||||
glUseProgram(m_shader);
|
||||
glBindVertexArray(m_bufferSet.vao);
|
||||
if (update) {
|
||||
glutils::sendVbo(m_bufferSet);
|
||||
}
|
||||
const auto uniformScroll = static_cast<GLint>(glGetUniformLocation(m_shader, "gScroll"));
|
||||
glUniform2f(uniformScroll, scroll.x, scroll.y);
|
||||
glDrawArrays(GL_POINTS, 0, m_bufferSet.vertices.size() / VertexVboRowLength);
|
||||
}
|
||||
|
||||
@@ -96,8 +98,8 @@ void TileSheetGrid::setBufferObjects(const NostalgiaGraphic &img, glutils::Buffe
|
||||
}
|
||||
}
|
||||
|
||||
ImVec2 TileSheetGrid::pixelSize() const noexcept {
|
||||
const auto [sw, sh] = ImGui::GetContentRegionAvail();
|
||||
ImVec2 TileSheetGrid::pixelSize(const ImVec2 &paneSize) const noexcept {
|
||||
const auto [sw, sh] = paneSize;
|
||||
constexpr float ymod = 0.35f / 10.0f;
|
||||
const auto xmod = ymod * sh / sw;
|
||||
return {xmod * m_pixelSizeMod, ymod * m_pixelSizeMod};
|
||||
|
||||
Reference in New Issue
Block a user