prepare for software renderer
do not use or your Furnace will need a replacement
This commit is contained in:
parent
c527eaa946
commit
b6fcba2ba3
10 changed files with 1020 additions and 2 deletions
|
|
@ -74,7 +74,8 @@ enum FurnaceGUIRenderBackend {
|
|||
GUI_BACKEND_GL2,
|
||||
GUI_BACKEND_GL1,
|
||||
GUI_BACKEND_DX11,
|
||||
GUI_BACKEND_DX9
|
||||
GUI_BACKEND_DX9,
|
||||
GUI_BACKEND_SOFTWARE
|
||||
};
|
||||
|
||||
#ifdef HAVE_RENDER_DX11
|
||||
|
|
@ -99,7 +100,8 @@ enum FurnaceGUIRenderBackend {
|
|||
#define GUI_BACKEND_DEFAULT GUI_BACKEND_SDL
|
||||
#define GUI_BACKEND_DEFAULT_NAME "SDL"
|
||||
#else
|
||||
#error how did you manage to do that?
|
||||
#define GUI_BACKEND_DEFAULT GUI_BACKEND_SOFTWARE
|
||||
#define GUI_BACKEDN_DEFAULT_NAME "Software"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#ifdef HAVE_RENDER_DX11
|
||||
#include "render/renderDX11.h"
|
||||
#endif
|
||||
#include "render/renderSoftware.h"
|
||||
|
||||
bool FurnaceGUI::initRender() {
|
||||
if (rend!=NULL) return false;
|
||||
|
|
@ -49,6 +50,8 @@ bool FurnaceGUI::initRender() {
|
|||
renderBackend=GUI_BACKEND_DX9;
|
||||
} else if (settings.renderBackend=="SDL") {
|
||||
renderBackend=GUI_BACKEND_SDL;
|
||||
} else if (settings.renderBackend=="Software") {
|
||||
renderBackend=GUI_BACKEND_SOFTWARE;
|
||||
} else {
|
||||
renderBackend=GUI_BACKEND_DEFAULT;
|
||||
}
|
||||
|
|
@ -99,6 +102,10 @@ bool FurnaceGUI::initRender() {
|
|||
rend=new FurnaceGUIRenderSDL;
|
||||
break;
|
||||
#endif
|
||||
case GUI_BACKEND_SOFTWARE:
|
||||
logI("render backend: Software");
|
||||
rend=new FurnaceGUIRenderSoftware;
|
||||
break;
|
||||
default:
|
||||
logE("invalid render backend!");
|
||||
return false;
|
||||
|
|
|
|||
144
src/gui/render/renderSoftware.cpp
Normal file
144
src/gui/render/renderSoftware.cpp
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
/**
|
||||
* Furnace Tracker - multi-system chiptune tracker
|
||||
* Copyright (C) 2021-2024 tildearrow and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "renderSoftware.h"
|
||||
#include "imgui_sw.hpp"
|
||||
#include "../../ta-log.h"
|
||||
|
||||
class FurnaceSoftwareTexture: public FurnaceGUITexture {
|
||||
public:
|
||||
SWTexture* tex;
|
||||
FurnaceSoftwareTexture():
|
||||
tex(NULL) {}
|
||||
};
|
||||
|
||||
ImTextureID FurnaceGUIRenderSoftware::getTextureID(FurnaceGUITexture* which) {
|
||||
FurnaceSoftwareTexture* t=(FurnaceSoftwareTexture*)which;
|
||||
return t->tex;
|
||||
}
|
||||
|
||||
bool FurnaceGUIRenderSoftware::lockTexture(FurnaceGUITexture* which, void** data, int* pitch) {
|
||||
FurnaceSoftwareTexture* t=(FurnaceSoftwareTexture*)which;
|
||||
if (!t->tex->managed) return false;
|
||||
*data=t->tex->pixels;
|
||||
*pitch=t->tex->width*(t->tex->isAlpha?1:4);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FurnaceGUIRenderSoftware::unlockTexture(FurnaceGUITexture* which) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FurnaceGUIRenderSoftware::updateTexture(FurnaceGUITexture* which, void* data, int pitch) {
|
||||
FurnaceSoftwareTexture* t=(FurnaceSoftwareTexture*)which;
|
||||
if (!t->tex->managed) return false;
|
||||
memcpy(t->tex->pixels,data,pitch*t->tex->height);
|
||||
return true;
|
||||
}
|
||||
|
||||
FurnaceGUITexture* FurnaceGUIRenderSoftware::createTexture(bool dynamic, int width, int height, bool interpolate) {
|
||||
FurnaceSoftwareTexture* ret=new FurnaceSoftwareTexture;
|
||||
ret->tex=new SWTexture(width,height);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool FurnaceGUIRenderSoftware::destroyTexture(FurnaceGUITexture* which) {
|
||||
FurnaceSoftwareTexture* t=(FurnaceSoftwareTexture*)which;
|
||||
|
||||
delete t->tex;
|
||||
delete t;
|
||||
return true;
|
||||
}
|
||||
|
||||
void FurnaceGUIRenderSoftware::setTextureBlendMode(FurnaceGUITexture* which, FurnaceGUIBlendMode mode) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void FurnaceGUIRenderSoftware::setBlendMode(FurnaceGUIBlendMode mode) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void FurnaceGUIRenderSoftware::clear(ImVec4 color) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
bool FurnaceGUIRenderSoftware::newFrame() {
|
||||
return ImGui_ImplSW_NewFrame();
|
||||
}
|
||||
|
||||
bool FurnaceGUIRenderSoftware::canVSync() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void FurnaceGUIRenderSoftware::createFontsTexture() {
|
||||
ImGui_ImplSW_CreateFontsTexture();
|
||||
}
|
||||
|
||||
void FurnaceGUIRenderSoftware::destroyFontsTexture() {
|
||||
ImGui_ImplSW_DestroyFontsTexture();
|
||||
}
|
||||
|
||||
void FurnaceGUIRenderSoftware::renderGUI() {
|
||||
ImGui_ImplSW_RenderDrawData(ImGui::GetDrawData());
|
||||
}
|
||||
|
||||
void FurnaceGUIRenderSoftware::wipe(float alpha) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void FurnaceGUIRenderSoftware::present() {
|
||||
// TODO?
|
||||
}
|
||||
|
||||
bool FurnaceGUIRenderSoftware::getOutputSize(int& w, int& h) {
|
||||
SDL_Surface* surf=SDL_GetWindowSurface(sdlWin);
|
||||
if (surf==NULL) return false;
|
||||
w=surf->w;
|
||||
h=surf->h;
|
||||
return true;
|
||||
}
|
||||
|
||||
int FurnaceGUIRenderSoftware::getWindowFlags() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FurnaceGUIRenderSoftware::setSwapInterval(int swapInterval) {
|
||||
}
|
||||
|
||||
void FurnaceGUIRenderSoftware::preInit() {
|
||||
}
|
||||
|
||||
bool FurnaceGUIRenderSoftware::init(SDL_Window* win, int swapInterval) {
|
||||
sdlWin=win;
|
||||
return true;
|
||||
}
|
||||
|
||||
void FurnaceGUIRenderSoftware::initGUI(SDL_Window* win) {
|
||||
// hack
|
||||
ImGui_ImplSDL2_InitForMetal(win);
|
||||
ImGui_ImplSW_Init(win);
|
||||
}
|
||||
|
||||
void FurnaceGUIRenderSoftware::quitGUI() {
|
||||
ImGui_ImplSW_Shutdown();
|
||||
}
|
||||
|
||||
bool FurnaceGUIRenderSoftware::quit() {
|
||||
return true;
|
||||
}
|
||||
51
src/gui/render/renderSoftware.h
Normal file
51
src/gui/render/renderSoftware.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* Furnace Tracker - multi-system chiptune tracker
|
||||
* Copyright (C) 2021-2024 tildearrow and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "../gui.h"
|
||||
|
||||
class FurnaceGUIRenderSoftware: public FurnaceGUIRender {
|
||||
SDL_Window* sdlWin;
|
||||
public:
|
||||
ImTextureID getTextureID(FurnaceGUITexture* which);
|
||||
bool lockTexture(FurnaceGUITexture* which, void** data, int* pitch);
|
||||
bool unlockTexture(FurnaceGUITexture* which);
|
||||
bool updateTexture(FurnaceGUITexture* which, void* data, int pitch);
|
||||
FurnaceGUITexture* createTexture(bool dynamic, int width, int height, bool interpolate=true);
|
||||
bool destroyTexture(FurnaceGUITexture* which);
|
||||
void setTextureBlendMode(FurnaceGUITexture* which, FurnaceGUIBlendMode mode);
|
||||
void setBlendMode(FurnaceGUIBlendMode mode);
|
||||
void clear(ImVec4 color);
|
||||
bool newFrame();
|
||||
bool canVSync();
|
||||
void createFontsTexture();
|
||||
void destroyFontsTexture();
|
||||
void renderGUI();
|
||||
void wipe(float alpha);
|
||||
void present();
|
||||
bool getOutputSize(int& w, int& h);
|
||||
int getWindowFlags();
|
||||
void setSwapInterval(int swapInterval);
|
||||
void preInit();
|
||||
bool init(SDL_Window* win, int swapInterval);
|
||||
void initGUI(SDL_Window* win);
|
||||
void quitGUI();
|
||||
bool quit();
|
||||
FurnaceGUIRenderSoftware():
|
||||
sdlWin(NULL) {}
|
||||
};
|
||||
|
|
@ -428,6 +428,10 @@ void FurnaceGUI::drawSettings() {
|
|||
settingsChanged=true;
|
||||
}
|
||||
#endif
|
||||
if (ImGui::Selectable("Software",curRenderBackend=="Software")) {
|
||||
settings.renderBackend="Software";
|
||||
settingsChanged=true;
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue