1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-07-03 06:24:32 +00:00

More graphics init cleanup. Remove aspect ratio check. Fix screen transition effect that broke in prev. commits.

This commit is contained in:
fgenesis 2016-11-15 13:00:30 +01:00
parent 034cf6a69f
commit 0d8a5c191c
7 changed files with 34 additions and 63 deletions

View file

@ -38,19 +38,11 @@ AfterEffectManager::AfterEffectManager(int xDivs, int yDivs)
bRenderGridPoints = true;
shaderPipeline.resize(10, 0);
screenWidth = core->getWindowWidth();
screenHeight = core->getWindowHeight();
this->xDivs = 0;
this->yDivs = 0;
drawGrid = 0;
this->xDivs = xDivs;
this->yDivs = yDivs;
reloadDevice();
if (xDivs != 0 && yDivs != 0)
{
drawGrid = new Vector * [xDivs];
@ -60,6 +52,8 @@ AfterEffectManager::AfterEffectManager(int xDivs, int yDivs)
}
}
updateDevice();
loadShaders();
}
@ -378,7 +372,7 @@ void AfterEffectManager::unloadDevice()
unloadShaders();
}
void AfterEffectManager::reloadDevice()
void AfterEffectManager::_updateScreenSize()
{
screenWidth = core->getWindowWidth();
screenHeight = core->getWindowHeight();
@ -395,11 +389,19 @@ void AfterEffectManager::reloadDevice()
textureHeight = screenHeight;
sizePowerOf2Texture(textureHeight);
}
}
if(backupBuffer.isInited())
backupBuffer.reloadDevice();
else
backupBuffer.init(-1, -1, true);
void AfterEffectManager::updateDevice()
{
_updateScreenSize();
backupBuffer.init(-1, -1, true);
}
void AfterEffectManager::reloadDevice()
{
_updateScreenSize();
backupBuffer.reloadDevice();
for (size_t i = 0; i < loadedShaders.size(); ++i)
{
@ -409,11 +411,11 @@ void AfterEffectManager::reloadDevice()
if (!sh->isLoaded())
{
debugLog("AfterEffect::reloadDevice(): Failed to reload shader");
delete sh;
loadedShaders[i] = 0;
for(size_t j = 0; j < shaderPipeline.size(); ++j)
if(sh == shaderPipeline[j])
shaderPipeline[j] = 0;
delete sh;
}
}
}

View file

@ -97,6 +97,7 @@ public:
void unloadDevice();
void reloadDevice();
void updateDevice();
std::vector<Effect*> effects;
std::vector<int> openSpots;
@ -121,6 +122,7 @@ public:
void deleteShader(int handle);
protected:
void _updateScreenSize();
int _insertShader(Shader *sh);
std::vector<Shader*> shaderPipeline; // Shaders are applied in this order. Can contain the same pointer more than once.

View file

@ -139,8 +139,9 @@ void Core::setup_opengl()
setClearColor(clearColor);
clearBuffers();
showBuffer();
frameBuffer.init(-1, -1, true);
if(afterEffectManager)
afterEffectManager->updateDevice();
}
@ -1389,11 +1390,6 @@ void Core::setupGlobalResolutionScale()
glScalef(globalResolutionScale.x, globalResolutionScale.y, globalResolutionScale.z);
}
void Core::initFrameBuffer()
{
frameBuffer.init(-1, -1, true);
}
void Core::setMouseConstraint(bool on)
{

View file

@ -390,7 +390,6 @@ public:
void setup_opengl();
void setClearColor(const Vector &c);
int flipMouseButtons;
void initFrameBuffer();
FrameBuffer frameBuffer;
void updateRenderObjects(float dt);
bool joystickAsMouse;

View file

@ -25,15 +25,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
ScreenTransition::ScreenTransition() : RenderObject()
{
createTexture();
screen_texture = 0;
cull = false;
followCamera = 1;
alpha = 0;
createTexture();
}
void ScreenTransition::createTexture()
{
destroyTexture();
width = core->getVirtualWidth();
height = core->getVirtualHeight();
@ -46,20 +48,13 @@ void ScreenTransition::createTexture()
sizePowerOf2Texture(textureWidth);
sizePowerOf2Texture(textureHeight);
//create our texture
glGenTextures(1,&screen_texture);
glBindTexture(GL_TEXTURE_2D, screen_texture);
//GL_NEAREST
// vs
//GL_LINEAR
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR); //GL_NEAREST); //GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); //GL_NEAREST); //GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D,0,3, textureWidth, textureHeight, 0 , GL_RGB, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D,0);
}
void ScreenTransition::destroyTexture()
@ -85,10 +80,9 @@ void ScreenTransition::reloadDevice()
void ScreenTransition::capture()
{
assert(screen_texture);
core->render();
if (screen_texture)
{
glBindTexture(GL_TEXTURE_2D,screen_texture);
@ -127,24 +121,9 @@ void ScreenTransition::onRender()
const float pw = float(windowWidth)/float(textureWidth);
const float ph = float(windowHeight)/float(textureHeight);
glBindTexture(GL_TEXTURE_2D, screen_texture);
#if 0 //def BBGE_BUILD_MACOSX
float aspect = float(core->width) / float(core->height);
float checkAspect = 16.0f/10.0f;
if (fabsf(aspect - checkAspect) < 0.01f)
{
glTranslatef(0.5f,0.0f,0.0f);
}
#endif
glBegin(GL_QUADS);
glTexCoord2d(0, 0);
glVertex3f(-width2, height2, 0.0);
glTexCoord2d(pw, 0);