mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-09-10 12:02:53 +02:00
Integrate fallback glBindFramebuffer
implementation into libretro builds
This commit is contained in:
parent
7e4484a640
commit
540d5f1a1a
4 changed files with 24 additions and 20 deletions
|
@ -35,6 +35,7 @@
|
|||
#include "core.h"
|
||||
#include "filesystem.h"
|
||||
#include "gl-fun.h"
|
||||
#include "gl-meta.h"
|
||||
|
||||
using namespace mkxp_retro;
|
||||
using namespace mkxp_sandbox;
|
||||
|
@ -381,7 +382,7 @@ extern "C" RETRO_API void retro_run() {
|
|||
}
|
||||
|
||||
if (hw_render.context_type != RETRO_HW_CONTEXT_NONE) {
|
||||
gl.BindFramebuffer(GL_DRAW_FRAMEBUFFER, hw_render.get_current_framebuffer());
|
||||
GLMeta::blitBeginScreen({640, 480});
|
||||
}
|
||||
|
||||
if (mkxp_retro::sandbox.has_value()) {
|
||||
|
@ -414,6 +415,10 @@ extern "C" RETRO_API void retro_run() {
|
|||
}
|
||||
video_refresh(fb, 640, 480, 640 * 4);
|
||||
|
||||
if (hw_render.context_type != RETRO_HW_CONTEXT_NONE) {
|
||||
GLMeta::blitEnd();
|
||||
}
|
||||
|
||||
if (mkxp_retro::sandbox.has_value()) {
|
||||
audio->render();
|
||||
alcRenderSamplesSOFT(al_device, sound_buf, 735);
|
||||
|
|
|
@ -216,8 +216,4 @@ void initGLFunctions()
|
|||
|
||||
if (!gles || glMajor >= 3 || HAVE_EXT(OES_texture_npot))
|
||||
gl.npot_repeat = true;
|
||||
|
||||
#ifdef MKXPZ_RETRO // TODO: implement fallback for `glBlitFramebuffer`
|
||||
assert(gl.BlitFramebuffer != NULL);
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
#include "quad.h"
|
||||
#include "config.h"
|
||||
#include "etc.h"
|
||||
#ifdef MKXPZ_RETRO
|
||||
# include "core.h"
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
namespace FBO
|
||||
{
|
||||
|
@ -208,13 +211,10 @@ int smoothScalingMethod(int scaleIsSpecial)
|
|||
|
||||
static void _blitBegin(FBO::ID fbo, const Vec2i &size, int scaleIsSpecial)
|
||||
{
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (HAVE_NATIVE_BLIT)
|
||||
{
|
||||
#endif // MKXPZ_RETRO
|
||||
FBO::boundFramebufferID = fbo;
|
||||
gl.BindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo.gl);
|
||||
#ifndef MKXPZ_RETRO
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -267,7 +267,6 @@ static void _blitBegin(FBO::ID fbo, const Vec2i &size, int scaleIsSpecial)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
int blitDstWidthLores = 1;
|
||||
|
@ -304,7 +303,15 @@ void blitBeginScreen(const Vec2i &size, int scaleIsSpecial)
|
|||
blitDstHeightLores = 1;
|
||||
blitDstHeightHires = 1;
|
||||
|
||||
_blitBegin(FBO::ID(0), size, scaleIsSpecial);
|
||||
_blitBegin(
|
||||
#ifdef MKXPZ_RETRO
|
||||
FBO::ID(mkxp_retro::hw_render.get_current_framebuffer()),
|
||||
#else
|
||||
FBO::ID(0),
|
||||
#endif // MKXPZ_RETRO
|
||||
size,
|
||||
scaleIsSpecial
|
||||
);
|
||||
}
|
||||
|
||||
void blitSource(TEXFBO &source, int scaleIsSpecial)
|
||||
|
@ -320,12 +327,9 @@ void blitSource(TEXFBO &source, int scaleIsSpecial)
|
|||
blitSrcHeightHires = blitSrcHeightLores;
|
||||
}
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (HAVE_NATIVE_BLIT)
|
||||
{
|
||||
#endif // MKXPZ_RETRO
|
||||
gl.BindFramebuffer(GL_READ_FRAMEBUFFER, source.fbo.gl);
|
||||
#ifndef MKXPZ_RETRO
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -371,7 +375,6 @@ void blitSource(TEXFBO &source, int scaleIsSpecial)
|
|||
TEX::bind(source.tex);
|
||||
}
|
||||
}
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
void blitRectangle(const IntRect &src, const Vec2i &dstPos)
|
||||
|
@ -395,17 +398,15 @@ void blitRectangle(const IntRect &src, const IntRect &dst, bool smooth)
|
|||
int scaledSrcHeight = src.h * blitSrcHeightHires / blitSrcHeightLores;
|
||||
IntRect srcScaled(scaledSrcX, scaledSrcY, scaledSrcWidth, scaledSrcHeight);
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (HAVE_NATIVE_BLIT)
|
||||
{
|
||||
#endif // MKXPZ_RETRO
|
||||
gl.BlitFramebuffer(srcScaled.x, srcScaled.y, srcScaled.x+srcScaled.w, srcScaled.y+srcScaled.h,
|
||||
dstScaled.x, dstScaled.y, dstScaled.x+dstScaled.w, dstScaled.y+dstScaled.h,
|
||||
GL_COLOR_BUFFER_BIT, smooth ? GL_LINEAR : GL_NEAREST);
|
||||
#ifndef MKXPZ_RETRO
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef MKXPZ_RETRO
|
||||
#ifdef MKXPZ_SSL
|
||||
if (shState->config().smoothScaling == xBRZ)
|
||||
{
|
||||
|
@ -413,6 +414,7 @@ void blitRectangle(const IntRect &src, const IntRect &dst, bool smooth)
|
|||
shader.setTargetScale(Vec2((float)(shState->config().xbrzScalingFactor), (float)(shState->config().xbrzScalingFactor)));
|
||||
}
|
||||
#endif
|
||||
#endif // MKXPZ_RETRO
|
||||
if (smooth)
|
||||
TEX::setSmooth(true);
|
||||
|
||||
|
@ -425,7 +427,6 @@ void blitRectangle(const IntRect &src, const IntRect &dst, bool smooth)
|
|||
if (smooth)
|
||||
TEX::setSmooth(false);
|
||||
}
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
void blitEnd()
|
||||
|
@ -440,11 +441,9 @@ void blitEnd()
|
|||
blitSrcHeightLores = 1;
|
||||
blitSrcHeightHires = 1;
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (!HAVE_NATIVE_BLIT) {
|
||||
glState.viewport.pop();
|
||||
}
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -101,12 +101,16 @@ namespace TEX
|
|||
|
||||
static inline void setSmooth(bool mode)
|
||||
{
|
||||
#ifndef MKXPZ_RETRO // TODO: get from config
|
||||
if (mode && shState->config().smoothScalingMipmaps) {
|
||||
gl.GenerateMipmap(GL_TEXTURE_2D);
|
||||
gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
} else {
|
||||
#endif // MKXPZ_RETRO
|
||||
gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, mode ? GL_LINEAR : GL_NEAREST);
|
||||
#ifndef MKXPZ_RETRO
|
||||
}
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mode ? GL_LINEAR : GL_NEAREST);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue