mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-09-10 12:02:53 +02:00
Start integrating the OpenGL code for sprites into libretro builds
This commit is contained in:
parent
613493c773
commit
7e4484a640
8 changed files with 90 additions and 108 deletions
|
@ -32,6 +32,7 @@ This stage produces the actual core file.
|
|||
Required software:
|
||||
* C and C++ compilers
|
||||
* [Git](https://git-scm.com)
|
||||
* [xxd](https://github.com/vim/vim/blob/master/runtime/doc/xxd.man)
|
||||
* [Meson](https://mesonbuild.com)
|
||||
* [Ninja](https://ninja-build.org)
|
||||
* [CMake](https://cmake.org)
|
||||
|
|
14
meson.build
14
meson.build
|
@ -34,6 +34,8 @@ global_args += '-DHAVE_NANOSLEEP'
|
|||
# Ext libs
|
||||
# ====================
|
||||
|
||||
global_sources += vcs_tag(command: ['git', 'rev-parse', '--short', 'HEAD'], fallback: 'unknown', input: 'src/git-hash.h.in', output: 'git-hash.h')
|
||||
|
||||
if is_libretro
|
||||
libretro_stage1_path = get_option('libretro_stage1_path')
|
||||
|
||||
|
@ -83,6 +85,8 @@ if is_libretro
|
|||
libretro_link_args += '-Wl,--version-script,' + meson.current_source_dir() / 'libretro/link.T'
|
||||
endif
|
||||
|
||||
subdir('shader')
|
||||
|
||||
cmake = import('cmake')
|
||||
|
||||
boost_options = cmake.subproject_options()
|
||||
|
@ -356,8 +360,7 @@ if is_libretro
|
|||
include_directories(libretro_stage1_path / 'mkxp-retro-ruby'),
|
||||
include_directories(libretro_stage1_path / 'sdl/include'),
|
||||
],
|
||||
sources: [
|
||||
vcs_tag(command: ['git', 'rev-parse', '--short', 'HEAD'], fallback: 'unknown', input: 'src/git-hash.h.in', output: 'git-hash.h'),
|
||||
sources: global_sources + [
|
||||
'src/core.cpp',
|
||||
'src/sharedstate.cpp',
|
||||
'src/audio/alstream.cpp',
|
||||
|
@ -378,8 +381,12 @@ if is_libretro
|
|||
'src/display/gl/gl-debug.cpp',
|
||||
'src/display/gl/gl-fun.cpp',
|
||||
'src/display/gl/gl-meta.cpp',
|
||||
'src/display/gl/glstate.cpp',
|
||||
'src/display/gl/scene.cpp',
|
||||
'src/display/gl/shader.cpp',
|
||||
'src/display/gl/texpool.cpp',
|
||||
'src/display/gl/tileatlas.cpp',
|
||||
'src/display/gl/vertex.cpp',
|
||||
'src/etc/etc.cpp',
|
||||
'src/etc/table.cpp',
|
||||
'src/filesystem/filesystem.cpp',
|
||||
|
@ -404,7 +411,6 @@ if is_libretro
|
|||
)
|
||||
else
|
||||
|
||||
global_sources += vcs_tag(command: ['git', 'rev-parse', '--short', 'HEAD'], fallback: 'unknown', input: 'src/git-hash.h.in', output: 'git-hash.h')
|
||||
if host_endian == 'big'
|
||||
global_args += '-DMKXPZ_BIG_ENDIAN'
|
||||
endif
|
||||
|
@ -413,8 +419,6 @@ if is_emscripten or not compilers['cpp'].compiles('struct E {}; int main() { thr
|
|||
libretro_defines += '-DBOOST_NO_EXCEPTIONS'
|
||||
endif
|
||||
|
||||
xxd = find_program('xxd', native: true)
|
||||
|
||||
# STEAMWORKS
|
||||
|
||||
steamworks = false
|
||||
|
|
11
src/core.cpp
11
src/core.cpp
|
@ -70,6 +70,7 @@ static LPALCRENDERSAMPLESSOFT alcRenderSamplesSOFT = NULL;
|
|||
static LPALCLOOPBACKOPENDEVICESOFT alcLoopbackOpenDeviceSOFT = NULL;
|
||||
static int16_t *sound_buf;
|
||||
static bool retro_framebuffer_supported;
|
||||
static bool shared_state_initialized;
|
||||
|
||||
static void fallback_log(enum retro_log_level level, const char *fmt, ...) {
|
||||
std::va_list va;
|
||||
|
@ -265,8 +266,6 @@ static bool init_sandbox() {
|
|||
|
||||
audio.emplace();
|
||||
|
||||
SharedState::initInstance(NULL);
|
||||
|
||||
try {
|
||||
mkxp_retro::sandbox.emplace();
|
||||
} catch (SandboxException) {
|
||||
|
@ -275,6 +274,8 @@ static bool init_sandbox() {
|
|||
return false;
|
||||
}
|
||||
|
||||
shared_state_initialized = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -373,6 +374,12 @@ extern "C" RETRO_API void retro_reset() {
|
|||
extern "C" RETRO_API void retro_run() {
|
||||
input_poll();
|
||||
|
||||
// We deferred initializing the shared state since the OpenGL symbols aren't available until the first call to `retro_run()`
|
||||
if (!shared_state_initialized) {
|
||||
SharedState::initInstance(NULL);
|
||||
shared_state_initialized = true;
|
||||
}
|
||||
|
||||
if (hw_render.context_type != RETRO_HW_CONTEXT_NONE) {
|
||||
gl.BindFramebuffer(GL_DRAW_FRAMEBUFFER, hw_render.get_current_framebuffer());
|
||||
}
|
||||
|
|
|
@ -29,21 +29,21 @@
|
|||
#include <SDL_surface.h>
|
||||
|
||||
#include <pixman.h>
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
#include "gl-util.h"
|
||||
#include "gl-meta.h"
|
||||
#include "quad.h"
|
||||
#include "quadarray.h"
|
||||
#endif // MKXPZ_RETRO
|
||||
#include "transform.h"
|
||||
#include "exception.h"
|
||||
|
||||
#include "sharedstate.h"
|
||||
#include "glstate.h"
|
||||
#ifndef MKXPZ_RETRO
|
||||
#include "texpool.h"
|
||||
#include "shader.h"
|
||||
#include "filesystem.h"
|
||||
#ifndef MKXPZ_RETRO
|
||||
#endif // MKXPZ_RETRO
|
||||
#include "font.h"
|
||||
#ifndef MKXPZ_RETRO
|
||||
|
@ -232,9 +232,7 @@ struct BitmapPrivate
|
|||
|
||||
sigslot::connection prepareCon;
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
TEXFBO gl;
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
Font *font;
|
||||
|
||||
|
@ -304,11 +302,13 @@ struct BitmapPrivate
|
|||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
TEXFBO &getGLTypes() {
|
||||
#ifdef MKXPZ_RETRO
|
||||
return gl; // TODO
|
||||
#else
|
||||
return (animation.enabled) ? animation.currentFrame() : gl;
|
||||
}
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
void prepare()
|
||||
{
|
||||
|
@ -1886,8 +1886,10 @@ bool Bitmap::getRaw(void *output, int output_size)
|
|||
memcpy(output, src, output_size);
|
||||
}
|
||||
else {
|
||||
#endif // MKXPZ_RETRO
|
||||
FBO::bind(getGLTypes().fbo);
|
||||
gl.ReadPixels(0,0,width(),height(),GL_RGBA,GL_UNSIGNED_BYTE,output);
|
||||
#ifndef MKXPZ_RETRO
|
||||
}
|
||||
#endif // MKXPZ_RETRO
|
||||
return true;
|
||||
|
@ -1910,10 +1912,8 @@ void Bitmap::replaceRaw(void *pixel_data, int size)
|
|||
if (size != w*h*4)
|
||||
throw Exception(Exception::MKXPError, "Replacement bitmap data is not large enough (given %i bytes, need %i)", size, requiredsize);
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
TEX::bind(getGLTypes().tex);
|
||||
TEX::uploadImage(w, h, pixel_data, GL_RGBA);
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
taintArea(IntRect(0,0,w,h));
|
||||
p->onModified();
|
||||
|
@ -2380,12 +2380,10 @@ void Bitmap::setInitFont(Font *value)
|
|||
p->font = value;
|
||||
}
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
TEXFBO &Bitmap::getGLTypes() const
|
||||
{
|
||||
return p->getGLTypes();
|
||||
}
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
SDL_Surface *Bitmap::surface() const
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@ void GLClearColor::apply(const Vec4 &value) {
|
|||
}
|
||||
|
||||
void GLScissorBox::apply(const IntRect &value) {
|
||||
#ifndef MKXPZ_RETRO
|
||||
// High-res: scale the scissorbox if we're rendering to the PingPong framebuffer.
|
||||
if (shState) {
|
||||
const double framebufferScalingFactor = shState->config().framebufferScalingFactor;
|
||||
|
@ -45,23 +46,31 @@ void GLScissorBox::apply(const IntRect &value) {
|
|||
gl.Scissor((int)lround(framebufferScalingFactor * value.x), (int)lround(framebufferScalingFactor * value.y), (int)lround(framebufferScalingFactor * value.w), (int)lround(framebufferScalingFactor * value.h));
|
||||
}
|
||||
else {
|
||||
#endif // MKXPZ_RETRO
|
||||
gl.Scissor(value.x, value.y, value.w, value.h);
|
||||
#ifndef MKXPZ_RETRO
|
||||
}
|
||||
}
|
||||
else {
|
||||
gl.Scissor(value.x, value.y, value.w, value.h);
|
||||
}
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
void GLScissorBox::setIntersect(const IntRect &value) {
|
||||
const IntRect ¤t = get();
|
||||
|
||||
SDL_Rect r1 = {current.x, current.y, current.w, current.h};
|
||||
SDL_Rect r2 = {value.x, value.y, value.w, value.h};
|
||||
|
||||
SDL_Rect result;
|
||||
if (!SDL_IntersectRect(&r1, &r2, &result))
|
||||
|
||||
// TODO: check if this is actually correct
|
||||
if (current.w <= 0 || current.h <= 0 || value.w <= 0 || value.h <= 0 || current.x < value.x + value.w || value.x < current.x + current.w || current.y < value.y + value.h || value.y < current.y + current.h) {
|
||||
result.w = result.h = 0;
|
||||
} else {
|
||||
result.x = std::min(current.x, value.x);
|
||||
result.y = std::min(current.y, value.y);
|
||||
result.w = std::max(current.x + current.w, value.x + value.w) - result.x;
|
||||
result.h = std::max(current.y + current.h, value.y + value.h) - result.y;
|
||||
}
|
||||
|
||||
set(IntRect(result.x, result.y, result.w, result.h));
|
||||
}
|
||||
|
@ -112,9 +121,15 @@ GLState::GLState(const Config &conf) {
|
|||
blendMode.init(BlendNormal);
|
||||
blend.init(true);
|
||||
scissorTest.init(false);
|
||||
#ifdef MKXPZ_RETRO
|
||||
scissorBox.init(IntRect(0, 0, 640, 480)); // TODO: get from config
|
||||
#else
|
||||
scissorBox.init(IntRect(0, 0, conf.defScreenW, conf.defScreenH));
|
||||
#endif // MKXPZ_RETRO
|
||||
program.init(0);
|
||||
|
||||
#ifndef MKXPZ_RETRO // TODO
|
||||
if (conf.maxTextureSize > 0)
|
||||
caps.maxTexSize = conf.maxTextureSize;
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
|
|
@ -301,12 +301,16 @@ void ShaderBase::applyViewportProj()
|
|||
{
|
||||
// High-res: scale the matrix if we're rendering to the PingPong framebuffer.
|
||||
const IntRect &vp = glState.viewport.get();
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (shState->config().enableHires && shState->graphics().isPingPongFramebufferActive() && framebufferScalingAllowed()) {
|
||||
projMat.set(Vec2i(shState->graphics().width(), shState->graphics().height()));
|
||||
}
|
||||
else {
|
||||
#endif // MKXPZ_RETRO
|
||||
projMat.set(Vec2i(vp.w, vp.h));
|
||||
#ifndef MKXPZ_RETRO
|
||||
}
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
bool ShaderBase::framebufferScalingAllowed()
|
||||
|
|
|
@ -29,14 +29,12 @@
|
|||
#include "etc-internal.h"
|
||||
#include "util.h"
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
#include "gl-util.h"
|
||||
#include "quad.h"
|
||||
#include "transform.h"
|
||||
#include "shader.h"
|
||||
#include "glstate.h"
|
||||
#include "quadarray.h"
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
#include <math.h>
|
||||
#ifndef M_PI
|
||||
|
@ -53,18 +51,8 @@ struct SpritePrivate
|
|||
|
||||
sigslot::connection bitmapDispCon;
|
||||
|
||||
#ifdef MKXPZ_RETRO
|
||||
// TODO: use the corresponding properties from `trans` instead of adding them here separately
|
||||
int x;
|
||||
int y;
|
||||
int ox;
|
||||
int oy;
|
||||
float zoom_x;
|
||||
float zoom_y;
|
||||
#else
|
||||
Quad quad;
|
||||
Transform trans;
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
Rect *srcRect;
|
||||
sigslot::connection srcRectCon;
|
||||
|
@ -106,25 +94,17 @@ struct SpritePrivate
|
|||
bool active;
|
||||
/* qArray needs updating */
|
||||
bool dirty;
|
||||
#ifndef MKXPZ_RETRO
|
||||
SimpleQuadArray qArray;
|
||||
#endif // MKXPZ_RETRO
|
||||
} wave;
|
||||
|
||||
EtcTemps tmp;
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
sigslot::connection prepareCon;
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
SpritePrivate()
|
||||
: bitmap(0),
|
||||
#ifdef MKXPZ_RETRO
|
||||
x(0),
|
||||
y(0),
|
||||
ox(0),
|
||||
oy(0),
|
||||
zoom_x(1.0f),
|
||||
zoom_y(1.0f),
|
||||
#endif // MKXPZ_RETRO
|
||||
srcRect(&tmp.rect),
|
||||
mirrored(false),
|
||||
bushDepth(0),
|
||||
|
@ -145,7 +125,9 @@ struct SpritePrivate
|
|||
|
||||
updateSrcRectCon();
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
prepareCon = shState->prepareDraw.connect
|
||||
#endif // MKXPZ_RETRO
|
||||
(&SpritePrivate::prepare, this);
|
||||
|
||||
patternScroll = Vec2(0,0);
|
||||
|
@ -161,7 +143,9 @@ struct SpritePrivate
|
|||
~SpritePrivate()
|
||||
{
|
||||
srcRectCon.disconnect();
|
||||
#ifndef MKXPZ_RETRO
|
||||
prepareCon.disconnect();
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
bitmapDisposal();
|
||||
}
|
||||
|
@ -178,11 +162,7 @@ struct SpritePrivate
|
|||
return;
|
||||
|
||||
/* Calculate effective (normalized) bush depth */
|
||||
#ifdef MKXPZ_RETRO
|
||||
float texBushDepth = bushDepth - // TODO
|
||||
#else
|
||||
float texBushDepth = (bushDepth / trans.getScale().y) -
|
||||
#endif // MKXPZ_RETRO
|
||||
(srcRect->y + srcRect->height) +
|
||||
bitmap->height();
|
||||
|
||||
|
@ -209,7 +189,6 @@ struct SpritePrivate
|
|||
rect.w = clamp<int>(rect.w, 0, bmSize.x-rect.x);
|
||||
rect.h = clamp<int>(rect.h, 0, bmSize.y-rect.y);
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (bmSizeHires.x && bmSizeHires.y && bmSize.x && bmSize.y)
|
||||
{
|
||||
FloatRect rectHires(rect.x * bmSizeHires.x / bmSize.x,
|
||||
|
@ -224,7 +203,6 @@ struct SpritePrivate
|
|||
}
|
||||
|
||||
quad.setPosRect(FloatRect(0, 0, rect.w, rect.h));
|
||||
#endif // MKXPZ_RETRO
|
||||
recomputeBushDepth();
|
||||
|
||||
wave.dirty = true;
|
||||
|
@ -261,28 +239,25 @@ struct SpritePrivate
|
|||
|
||||
/* If sprite is zoomed/rotated, just opt out for now
|
||||
* for simplicity's sake */
|
||||
#ifndef MKXPZ_RETRO
|
||||
const Vec2 &scale = trans.getScale();
|
||||
if (scale.x != 1 || scale.y != 1 || trans.getRotation() != 0)
|
||||
{
|
||||
isVisible = true;
|
||||
return;
|
||||
}
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
IntRect self;
|
||||
#ifndef MKXPZ_RETRO
|
||||
self.setPos(trans.getPositionI() - (trans.getOriginI() + sceneOrig));
|
||||
#endif // MKXPZ_RETRO
|
||||
self.w = bitmap->width();
|
||||
self.h = bitmap->height();
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
#ifdef MKXPZ_RETRO // TODO
|
||||
isVisible = true;
|
||||
#else
|
||||
isVisible = SDL_HasIntersection(&self, &sceneRect);
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
void emitWaveChunk(SVertex *&vert, float phase, int width,
|
||||
float zoomY, int chunkY, int chunkLength)
|
||||
{
|
||||
|
@ -366,15 +341,12 @@ struct SpritePrivate
|
|||
|
||||
wave.qArray.commit();
|
||||
}
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
void prepare()
|
||||
{
|
||||
if (wave.dirty)
|
||||
{
|
||||
#ifndef MKXPZ_RETRO
|
||||
updateWave();
|
||||
#endif // MKXPZ_RETRO
|
||||
wave.dirty = false;
|
||||
}
|
||||
|
||||
|
@ -395,14 +367,6 @@ Sprite::~Sprite()
|
|||
}
|
||||
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, Bitmap, Bitmap*, p->bitmap)
|
||||
#ifdef MKXPZ_RETRO
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, X, int, p->x)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, Y, int, p->y)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, OX, int, p->ox)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, OY, int, p->oy)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, ZoomX, float, p->zoom_x)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, ZoomY, float, p->zoom_y)
|
||||
#else
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, X, int, p->trans.getPosition().x)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, Y, int, p->trans.getPosition().y)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, OX, int, p->trans.getOrigin().x)
|
||||
|
@ -410,7 +374,6 @@ DEF_ATTR_RD_SIMPLE(Sprite, OY, int, p->trans.getOrigin().y)
|
|||
DEF_ATTR_RD_SIMPLE(Sprite, ZoomX, float, p->trans.getScale().x)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, ZoomY, float, p->trans.getScale().y)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, Angle, float, p->trans.getRotation())
|
||||
#endif // MKXPZ_RETRO
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, Mirror, bool, p->mirrored)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, BushDepth, int, p->bushDepth)
|
||||
DEF_ATTR_RD_SIMPLE(Sprite, BlendType, int, p->blendType)
|
||||
|
@ -459,9 +422,7 @@ void Sprite::setBitmap(Bitmap *bitmap)
|
|||
|
||||
*p->srcRect = bitmap->rect();
|
||||
p->onSrcRectChange();
|
||||
#ifndef MKXPZ_RETRO
|
||||
p->quad.setPosRect(p->srcRect->toFloatRect());
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
p->wave.dirty = true;
|
||||
}
|
||||
|
@ -470,24 +431,20 @@ void Sprite::setX(int value)
|
|||
{
|
||||
guardDisposed();
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (p->trans.getPosition().x == value)
|
||||
return;
|
||||
|
||||
p->trans.setPosition(Vec2(value, getY()));
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
void Sprite::setY(int value)
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (p->trans.getPosition().y == value)
|
||||
return;
|
||||
|
||||
p->trans.setPosition(Vec2(getX(), value));
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
if (rgssVer >= 2)
|
||||
{
|
||||
|
@ -500,48 +457,40 @@ void Sprite::setOX(int value)
|
|||
{
|
||||
guardDisposed();
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (p->trans.getOrigin().x == value)
|
||||
return;
|
||||
|
||||
p->trans.setOrigin(Vec2(value, getOY()));
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
void Sprite::setOY(int value)
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (p->trans.getOrigin().y == value)
|
||||
return;
|
||||
|
||||
p->trans.setOrigin(Vec2(getOX(), value));
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
void Sprite::setZoomX(float value)
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (p->trans.getScale().x == value)
|
||||
return;
|
||||
|
||||
p->trans.setScale(Vec2(value, getZoomY()));
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
void Sprite::setZoomY(float value)
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (p->trans.getScale().y == value)
|
||||
return;
|
||||
|
||||
p->trans.setScale(Vec2(getZoomX(), value));
|
||||
#endif // MKXPZ_RETRO
|
||||
p->recomputeBushDepth();
|
||||
|
||||
if (rgssVer >= 2)
|
||||
|
@ -552,12 +501,10 @@ void Sprite::setAngle(float value)
|
|||
{
|
||||
guardDisposed();
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (p->trans.getRotation() == value)
|
||||
return;
|
||||
|
||||
p->trans.setRotation(value);
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
void Sprite::setMirror(bool mirrored)
|
||||
|
@ -679,7 +626,6 @@ void Sprite::draw()
|
|||
if (emptyFlashFlag)
|
||||
return;
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
ShaderBase *base;
|
||||
|
||||
bool renderEffect = p->color->hasEffect() ||
|
||||
|
@ -694,7 +640,11 @@ void Sprite::draw()
|
|||
int sourceWidthHires = p->bitmap->hasHires() ? p->bitmap->getHires()->width() : p->bitmap->width();
|
||||
int sourceHeightHires = p->bitmap->hasHires() ? p->bitmap->getHires()->height() : p->bitmap->height();
|
||||
|
||||
#ifdef MKXPZ_RETRO
|
||||
double framebufferScalingFactor = 1.0; // TODO: get from config
|
||||
#else
|
||||
double framebufferScalingFactor = shState->config().enableHires ? shState->config().framebufferScalingFactor : 1.0;
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
int targetWidthHires = (int)lround(framebufferScalingFactor * p->bitmap->width() * p->trans.getScale().x);
|
||||
int targetHeightHires = (int)lround(framebufferScalingFactor * p->bitmap->height() * p->trans.getScale().y);
|
||||
|
@ -711,10 +661,13 @@ void Sprite::draw()
|
|||
scaleIsSpecial = DownScale;
|
||||
}
|
||||
|
||||
#ifndef MKXPZ_RETRO // TODO
|
||||
switch (scaleIsSpecial)
|
||||
{
|
||||
case SameScale:
|
||||
#endif // MKXPZ_RETRO
|
||||
scalingMethod = NearestNeighbor;
|
||||
#ifndef MKXPZ_RETRO
|
||||
break;
|
||||
case DownScale:
|
||||
scalingMethod = shState->config().bitmapSmoothScalingDown;
|
||||
|
@ -727,6 +680,7 @@ void Sprite::draw()
|
|||
{
|
||||
scalingMethod = shState->config().bitmapSmoothScaling;
|
||||
}
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
if (renderEffect)
|
||||
{
|
||||
|
@ -801,7 +755,11 @@ void Sprite::draw()
|
|||
shader.bind();
|
||||
|
||||
shader.setTexSize(Vec2i(sourceWidthHires, sourceHeightHires));
|
||||
#ifdef MKXPZ_RETRO
|
||||
shader.setSharpness(100); // TODO: get from config
|
||||
#else
|
||||
shader.setSharpness(shState->config().bicubicSharpness);
|
||||
#endif // MKXPZ_RETRO
|
||||
shader.setSpriteMat(p->trans.getMatrix());
|
||||
shader.applyViewportProj();
|
||||
base = &shader;
|
||||
|
@ -825,7 +783,11 @@ void Sprite::draw()
|
|||
shader.bind();
|
||||
|
||||
shader.setTexSize(Vec2i(sourceWidthHires, sourceHeightHires));
|
||||
#ifdef MKXPZ_RETRO
|
||||
shader.setTargetScale(Vec2(1.0f, 1.0f)); // TODO: get from config
|
||||
#else
|
||||
shader.setTargetScale(Vec2((float)(shState->config().xbrzScalingFactor), (float)(shState->config().xbrzScalingFactor)));
|
||||
#endif // MKXPZ_RETRO
|
||||
shader.setSpriteMat(p->trans.getMatrix());
|
||||
shader.applyViewportProj();
|
||||
base = &shader;
|
||||
|
@ -852,7 +814,11 @@ void Sprite::draw()
|
|||
if (scalingMethod == xBRZ)
|
||||
{
|
||||
XbrzShader &shader = shState->shaders().xbrz;
|
||||
#ifdef MKXPZ_RETRO
|
||||
shader.setTargetScale(Vec2(1.0f, 1.0f));
|
||||
#else
|
||||
shader.setTargetScale(Vec2((float)(shState->config().xbrzScalingFactor), (float)(shState->config().xbrzScalingFactor)));
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -866,16 +832,13 @@ void Sprite::draw()
|
|||
TEX::setSmooth(false);
|
||||
|
||||
glState.blendMode.pop();
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
void Sprite::onGeometryChange(const Scene::Geometry &geo)
|
||||
{
|
||||
/* Offset at which the sprite will be drawn
|
||||
* relative to screen origin */
|
||||
#ifndef MKXPZ_RETRO
|
||||
p->trans.setGlobalOffset(geo.offset());
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
p->sceneRect.setSize(geo.rect.size());
|
||||
p->sceneOrig = geo.orig;
|
||||
|
|
|
@ -32,17 +32,13 @@
|
|||
#include "audio.h"
|
||||
#endif // MKXPZ_RETRO
|
||||
#include "glstate.h"
|
||||
#ifndef MKXPZ_RETRO
|
||||
#include "shader.h"
|
||||
#include "texpool.h"
|
||||
#endif // MKXPZ_RETRO
|
||||
#include "font.h"
|
||||
#ifndef MKXPZ_RETRO
|
||||
#include "eventthread.h"
|
||||
#include "gl-util.h"
|
||||
#include "global-ibo.h"
|
||||
#include "quad.h"
|
||||
#endif // MKXPZ_RETRO
|
||||
#include "binding.h"
|
||||
#include "exception.h"
|
||||
#include "sharedmidistate.h"
|
||||
|
@ -90,6 +86,7 @@ struct SharedStatePrivate
|
|||
Graphics graphics;
|
||||
Input input;
|
||||
Audio audio;
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
GLState _glState;
|
||||
|
||||
|
@ -97,21 +94,20 @@ struct SharedStatePrivate
|
|||
|
||||
TexPool texPool;
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
SharedFontState fontState;
|
||||
Font *defaultFont;
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
TEX::ID globalTex;
|
||||
#endif // MKXPZ_RETRO
|
||||
int globalTexW, globalTexH;
|
||||
bool globalTexDirty;
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
TEXFBO gpTexFBO;
|
||||
|
||||
TEXFBO atlasTex;
|
||||
|
||||
Quad gpQuad;
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
unsigned int stampCounter;
|
||||
|
||||
|
@ -135,7 +131,9 @@ struct SharedStatePrivate
|
|||
graphics(threadData),
|
||||
input(*threadData),
|
||||
audio(*threadData),
|
||||
#endif // MKXPZ_RETRO
|
||||
_glState(threadData->config),
|
||||
#ifndef MKXPZ_RETRO
|
||||
fontState(threadData->config),
|
||||
#endif // MKXPZ_RETRO
|
||||
stampCounter(0)
|
||||
|
@ -146,11 +144,11 @@ struct SharedStatePrivate
|
|||
|
||||
startupTime = std::chrono::steady_clock::now();
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
/* Shaders have been compiled in ShaderSet's constructor */
|
||||
if (gl.ReleaseShaderCompiler)
|
||||
gl.ReleaseShaderCompiler();
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
std::string archPath = config.execName + gameArchExt();
|
||||
|
||||
for (size_t i = 0; i < config.patches.size(); ++i)
|
||||
|
@ -173,6 +171,7 @@ struct SharedStatePrivate
|
|||
fileSystem.createPathCache();
|
||||
|
||||
fileSystem.initFontSets(fontState);
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
globalTexW = 128;
|
||||
globalTexH = 64;
|
||||
|
@ -189,6 +188,7 @@ struct SharedStatePrivate
|
|||
TEXFBO::allocEmpty(gpTexFBO, globalTexW, globalTexH);
|
||||
TEXFBO::linkFBO(gpTexFBO);
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
/* RGSS3 games will call setup_midi, so there's
|
||||
* no need to do it on startup */
|
||||
if (rgssVer <= 2)
|
||||
|
@ -198,11 +198,9 @@ struct SharedStatePrivate
|
|||
|
||||
~SharedStatePrivate()
|
||||
{
|
||||
#ifndef MKXPZ_RETRO
|
||||
TEX::del(globalTex);
|
||||
TEXFBO::fini(gpTexFBO);
|
||||
TEXFBO::fini(atlasTex);
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -214,13 +212,13 @@ void SharedState::initInstance(RGSSThreadData *threadData)
|
|||
|
||||
#ifndef MKXPZ_RETRO
|
||||
rgssVersion = threadData->config.rgssVersion;
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
_globalIBO = new GlobalIBO();
|
||||
_globalIBO->ensureSize(1);
|
||||
|
||||
SharedState::instance = 0;
|
||||
Font *defaultFont = 0;
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -232,9 +230,7 @@ void SharedState::initInstance(RGSSThreadData *threadData)
|
|||
}
|
||||
catch (const Exception &exc)
|
||||
{
|
||||
#ifndef MKXPZ_RETRO
|
||||
delete _globalIBO;
|
||||
#endif // MKXPZ_RETRO
|
||||
delete SharedState::instance;
|
||||
#ifndef MKXPZ_RETRO
|
||||
delete defaultFont;
|
||||
|
@ -256,9 +252,7 @@ void SharedState::finiInstance()
|
|||
|
||||
delete SharedState::instance;
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
delete _globalIBO;
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
void SharedState::setScreen(Scene &screen)
|
||||
|
@ -285,10 +279,12 @@ GSATT(Config&, config)
|
|||
GSATT(Graphics&, graphics)
|
||||
GSATT(Input&, input)
|
||||
GSATT(Audio&, audio)
|
||||
#endif // MKXPZ_RETRO
|
||||
GSATT(GLState&, _glState)
|
||||
GSATT(ShaderSet&, shaders)
|
||||
GSATT(TexPool&, texPool)
|
||||
GSATT(Quad&, gpQuad)
|
||||
#ifndef MKXPZ_RETRO
|
||||
GSATT(SharedFontState&, fontState)
|
||||
#endif // MKXPZ_RETRO
|
||||
GSATT(SharedMidiState&, midiState)
|
||||
|
@ -300,9 +296,7 @@ void SharedState::setBindingData(void *data)
|
|||
|
||||
void SharedState::ensureQuadIBO(size_t minSize)
|
||||
{
|
||||
#ifndef MKXPZ_RETRO
|
||||
_globalIBO->ensureSize(minSize);
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
GlobalIBO &SharedState::globalIBO()
|
||||
|
@ -312,7 +306,6 @@ GlobalIBO &SharedState::globalIBO()
|
|||
|
||||
void SharedState::bindTex()
|
||||
{
|
||||
#ifndef MKXPZ_RETRO
|
||||
TEX::bind(p->globalTex);
|
||||
|
||||
if (p->globalTexDirty)
|
||||
|
@ -320,7 +313,6 @@ void SharedState::bindTex()
|
|||
TEX::allocEmpty(p->globalTexW, p->globalTexH);
|
||||
p->globalTexDirty = false;
|
||||
}
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
void SharedState::ensureTexSize(int minW, int minH, Vec2i ¤tSizeOut)
|
||||
|
@ -340,7 +332,6 @@ void SharedState::ensureTexSize(int minW, int minH, Vec2i ¤tSizeOut)
|
|||
currentSizeOut = Vec2i(p->globalTexW, p->globalTexH);
|
||||
}
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
TEXFBO &SharedState::gpTexFBO(int minW, int minH)
|
||||
{
|
||||
bool needResize = false;
|
||||
|
@ -395,7 +386,6 @@ void SharedState::releaseAtlasTex(TEXFBO &tex)
|
|||
|
||||
p->atlasTex = tex;
|
||||
}
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
void SharedState::checkShutdown()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue