fix compilation

This commit is contained in:
Kae 2024-08-22 12:52:59 +10:00
parent 4496cc17af
commit 8332536399
2 changed files with 16 additions and 17 deletions

View File

@ -153,8 +153,8 @@ OpenGlRenderer::GlFrameBuffer::GlFrameBuffer(Json const& fbConfig) : config(fbCo
GLenum target = multisample ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D; GLenum target = multisample ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;
glBindTexture(target, texture->glTextureId()); glBindTexture(target, texture->glTextureId());
sizeDiv = config.getUInt("sizeDiv",1); sizeDiv = config.getUInt("sizeDiv", 1);
Vec2U size = jsonToVec2U(config.getArray("size", { 256, 256 }))/sizeDiv; Vec2U size = jsonToVec2U(config.getArray("size", { 256, 256 })) / sizeDiv;
if (multisample) if (multisample)
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, multisample, GL_RGBA8, size[0], size[1], GL_TRUE); glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, multisample, GL_RGBA8, size[0], size[1], GL_TRUE);
@ -280,7 +280,7 @@ void OpenGlRenderer::loadEffectConfig(String const& name, Json const& effectConf
effect.config = effectConfig; effect.config = effectConfig;
effect.includeVBTextures = effectConfig.getBool("includeVBTextures",true); effect.includeVBTextures = effectConfig.getBool("includeVBTextures",true);
m_currentEffect = &effect; m_currentEffect = &effect;
setupGlUniforms(effect,m_screenSize); setupGlUniforms(effect, m_screenSize);
for (auto const& p : effectConfig.getObject("effectParameters", {})) { for (auto const& p : effectConfig.getObject("effectParameters", {})) {
EffectParameter effectParameter; EffectParameter effectParameter;
@ -420,21 +420,21 @@ bool OpenGlRenderer::switchEffectConfig(String const& name) {
if (auto frameBufferId = effect.config.optString("frameBuffer")) { if (auto frameBufferId = effect.config.optString("frameBuffer")) {
auto buf = getGlFrameBuffer(*frameBufferId); auto buf = getGlFrameBuffer(*frameBufferId);
switchGlFrameBuffer(buf); switchGlFrameBuffer(buf);
effectScreenSize = m_screenSize/(buf->sizeDiv); effectScreenSize = m_screenSize / (buf->sizeDiv);
} else { } else {
m_currentFrameBuffer.reset(); m_currentFrameBuffer.reset();
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
} }
glUseProgram(m_program = effect.program); glUseProgram(m_program = effect.program);
setupGlUniforms(effect,effectScreenSize); setupGlUniforms(effect, effectScreenSize);
m_currentEffect = &effect; m_currentEffect = &effect;
setEffectParameter("vertexRounding", m_multiSampling > 0); setEffectParameter("vertexRounding", m_multiSampling > 0);
if (auto fbts = effect.config.optArray("frameBufferTextures")) { if (auto fbts = effect.config.optArray("frameBufferTextures")) {
for (auto const& fbt : *fbts) { for (auto const& fbt : *fbts) {
if (auto frameBufferId = fbt.optString("framebuffer")) { if (auto frameBufferId = fbt.optString("framebuffer")) {
auto textureUniform=fbt.getString("texture"); auto textureUniform = fbt.getString("texture");
auto ptr = m_currentEffect->textures.ptr(textureUniform); auto ptr = m_currentEffect->textures.ptr(textureUniform);
if (ptr) { if (ptr) {
if (!ptr->textureValue || ptr->textureValue->textureId == 0) { if (!ptr->textureValue || ptr->textureValue->textureId == 0) {
@ -547,12 +547,13 @@ void OpenGlRenderer::setScreenSize(Vec2U screenSize) {
glUniform2f(m_screenSizeUniform, m_screenSize[0], m_screenSize[1]); glUniform2f(m_screenSizeUniform, m_screenSize[0], m_screenSize[1]);
for (auto& frameBuffer : m_frameBuffers) { for (auto& frameBuffer : m_frameBuffers) {
unsigned sizeDiv = frameBuffer.second->sizeDiv;
if (unsigned multisample = frameBuffer.second->multisample) { if (unsigned multisample = frameBuffer.second->multisample) {
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, frameBuffer.second->texture->glTextureId()); glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, frameBuffer.second->texture->glTextureId());
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, multisample, GL_RGBA8, m_screenSize[0]/frameBuffer.second->sizeDiv, m_screenSize[1]/frameBuffer.second->sizeDiv, GL_TRUE); glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, multisample, GL_RGBA8, m_screenSize[0] / sizeDiv, m_screenSize[1] / sizeDiv, GL_TRUE);
} else { } else {
glBindTexture(GL_TEXTURE_2D, frameBuffer.second->texture->glTextureId()); glBindTexture(GL_TEXTURE_2D, frameBuffer.second->texture->glTextureId());
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, m_screenSize[0]/frameBuffer.second->sizeDiv, m_screenSize[1]/frameBuffer.second->sizeDiv, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, m_screenSize[0] / sizeDiv, m_screenSize[1] / sizeDiv, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
} }
} }
} }

View File

@ -402,9 +402,9 @@ void ClientApplication::render() {
LogMap::set("client_render_world_total", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - totalStart)); LogMap::set("client_render_world_total", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - totalStart));
auto size = Vec2F(renderer->screenSize()); auto size = Vec2F(renderer->screenSize());
auto quad = renderFlatRect(RectF::withSize(size/-2, size), Vec4B(0.0f,0.0f,0.0f,0.0f), 0.0f); auto quad = renderFlatRect(RectF::withSize(size / -2, size), Vec4B::filled(0), 0.0f);
for (auto& layer : m_postProcessLayers) { for (auto& layer : m_postProcessLayers) {
for(unsigned i = 0; i < layer.passes; i++) { for (unsigned i = 0; i < layer.passes; i++) {
for (auto& effect : layer.effects) { for (auto& effect : layer.effects) {
renderer->switchEffectConfig(effect); renderer->switchEffectConfig(effect);
renderer->render(quad); renderer->render(quad);
@ -466,14 +466,12 @@ void ClientApplication::renderReload() {
m_postProcessLayers.clear(); m_postProcessLayers.clear();
auto postProcessLayers = assets->json("/client.config:postProcessLayers").toArray(); auto postProcessLayers = assets->json("/client.config:postProcessLayers").toArray();
for (auto& layer : postProcessLayers) { for (auto& layer : postProcessLayers) {
List<String> effects; auto effects = jsonToStringList(layer.getArray("effects"));
for (auto& effect : layer.getArray("effects")) { for (auto& effect : effects)
auto effectStr = effect.toString(); loadEffectConfig(effect);
loadEffectConfig(effectStr); m_postProcessLayers.append(PostProcessLayer{ std::move(effects), (unsigned)layer.getUInt("passes", 1) });
effects.append(effectStr);
}
m_postProcessLayers.append(PostProcessLayer{effects,layer.getUInt("passes",1)});
} }
loadEffectConfig("interface"); loadEffectConfig("interface");
} }