[nostalgia/core/userland] Cleanup some extraneous GL calls
This commit is contained in:
parent
c4b9858738
commit
e56fa3a531
@ -7,6 +7,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#ifdef NOST_FPS_PRINT
|
||||||
|
#include <iostream>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <ox/std/bit.hpp>
|
#include <ox/std/bit.hpp>
|
||||||
#include <ox/std/defines.hpp>
|
#include <ox/std/defines.hpp>
|
||||||
@ -18,7 +21,6 @@
|
|||||||
|
|
||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
|
|
||||||
using TileMap = std::array<std::array<int, 128>, 128>;
|
|
||||||
|
|
||||||
namespace renderer {
|
namespace renderer {
|
||||||
|
|
||||||
@ -38,7 +40,6 @@ struct Background: public Bufferset {
|
|||||||
|
|
||||||
struct GlImplData {
|
struct GlImplData {
|
||||||
GLuint bgShader = 0;
|
GLuint bgShader = 0;
|
||||||
std::array<TileMap, 4> bgTileMaps; // old, replaced by backgrounds
|
|
||||||
int64_t prevFpsCheckTime = 0;
|
int64_t prevFpsCheckTime = 0;
|
||||||
uint64_t draws = 0;
|
uint64_t draws = 0;
|
||||||
std::array<Background, 1> backgrounds;
|
std::array<Background, 1> backgrounds;
|
||||||
@ -114,18 +115,18 @@ static void initBackgroundBufferObjects(Context *ctx, Background *bg) noexcept {
|
|||||||
setTileBufferObject(ctx, i * BgVertexVboRows, x, y, 0, vbo, ebo);
|
setTileBufferObject(ctx, i * BgVertexVboRows, x, y, 0, vbo, ebo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendVbo(*bg);
|
|
||||||
sendEbo(*bg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initBackgroundBufferset(Context *ctx, GLuint shader, Background *bufferset) {
|
static void initBackgroundBufferset(Context *ctx, GLuint shader, Background *bg) {
|
||||||
// vao
|
// vao
|
||||||
glGenVertexArrays(1, &bufferset->vao);
|
glGenVertexArrays(1, &bg->vao);
|
||||||
glBindVertexArray(bufferset->vao);
|
glBindVertexArray(bg->vao);
|
||||||
// vbo & ebo
|
// vbo & ebo
|
||||||
glGenBuffers(1, &bufferset->vbo);
|
glGenBuffers(1, &bg->vbo);
|
||||||
glGenBuffers(1, &bufferset->ebo);
|
glGenBuffers(1, &bg->ebo);
|
||||||
initBackgroundBufferObjects(ctx, bufferset);
|
initBackgroundBufferObjects(ctx, bg);
|
||||||
|
sendVbo(*bg);
|
||||||
|
sendEbo(*bg);
|
||||||
// vbo layout
|
// vbo layout
|
||||||
auto posAttr = static_cast<GLuint>(glGetAttribLocation(shader, "position"));
|
auto posAttr = static_cast<GLuint>(glGetAttribLocation(shader, "position"));
|
||||||
glEnableVertexAttribArray(posAttr);
|
glEnableVertexAttribArray(posAttr);
|
||||||
@ -186,7 +187,7 @@ ox::Error loadBgTexture(Context *ctx, int section, void *pixels, int w, int h) {
|
|||||||
void draw(Context *ctx) {
|
void draw(Context *ctx) {
|
||||||
const auto id = ctx->rendererData<renderer::GlImplData>();
|
const auto id = ctx->rendererData<renderer::GlImplData>();
|
||||||
++id->draws;
|
++id->draws;
|
||||||
if (id->draws >= 5000) {
|
if (id->draws >= 500) {
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
const auto now = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
|
const auto now = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
|
||||||
const auto duration = static_cast<double>(now - id->prevFpsCheckTime) / 1000.0;
|
const auto duration = static_cast<double>(now - id->prevFpsCheckTime) / 1000.0;
|
||||||
@ -220,6 +221,7 @@ void clearTileLayer(Context *ctx, int layer) {
|
|||||||
const auto id = ctx->rendererData<renderer::GlImplData>();
|
const auto id = ctx->rendererData<renderer::GlImplData>();
|
||||||
auto bg = id->backgrounds[static_cast<std::size_t>(layer)];
|
auto bg = id->backgrounds[static_cast<std::size_t>(layer)];
|
||||||
initBackgroundBufferObjects(ctx, &bg);
|
initBackgroundBufferObjects(ctx, &bg);
|
||||||
|
bg.updated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hideSprite(Context*, unsigned) {
|
void hideSprite(Context*, unsigned) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user