mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-24 15:04:00 +00:00
More graphics init cleanup. Remove aspect ratio check. Fix screen transition effect that broke in prev. commits.
This commit is contained in:
parent
034cf6a69f
commit
0d8a5c191c
7 changed files with 34 additions and 63 deletions
|
@ -242,6 +242,12 @@ void DSQ::onSwitchScreenMode()
|
|||
toggleFullscreen();
|
||||
}
|
||||
|
||||
void DSQ::onWindowResize(int w, int h)
|
||||
{
|
||||
Core::onWindowResize(w, h);
|
||||
screenTransition->reloadDevice();
|
||||
}
|
||||
|
||||
void DSQ::rumble(float leftMotor, float rightMotor, float time, int source)
|
||||
{
|
||||
if (this->inputMode == INPUT_JOYSTICK)
|
||||
|
@ -873,16 +879,6 @@ This build is not yet final, and as such there are a couple things lacking. They
|
|||
particleManager->setSize(user.video.numParticles);
|
||||
|
||||
fullscreen = user.video.full;
|
||||
|
||||
float asp = float(user.video.resx)/float(user.video.resy);
|
||||
|
||||
if(asp < 1.0f)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "Aspect ratio for resolution [" << user.video.resx << ", " << user.video.resy << "] not supported.";
|
||||
exit_error(os.str());
|
||||
}
|
||||
|
||||
useFrameBuffer = user.video.fbuffer;
|
||||
|
||||
if (isDeveloperKeys())
|
||||
|
@ -912,8 +908,6 @@ This build is not yet final, and as such there are a couple things lacking. They
|
|||
|
||||
debugLog("Init Graphics Library...");
|
||||
initGraphicsLibrary(user.video.resx, user.video.resy, fullscreen, user.video.vsync, user.video.bits);
|
||||
core->enable2DWide(user.video.resx, user.video.resy);
|
||||
core->initFrameBuffer();
|
||||
debugLog("OK");
|
||||
|
||||
setInputGrab(0);
|
||||
|
@ -924,7 +918,6 @@ This build is not yet final, and as such there are a couple things lacking. They
|
|||
sound->setVoiceFader(0.5);
|
||||
sound->event_playVoice.set(MakeFunctionEvent(DSQ, onPlayVoice));
|
||||
sound->event_stopVoice.set(MakeFunctionEvent(DSQ, onStopVoice));
|
||||
|
||||
debugLog("OK");
|
||||
|
||||
debugLog("Init Input Library...");
|
||||
|
@ -1261,8 +1254,6 @@ This build is not yet final, and as such there are a couple things lacking. They
|
|||
}
|
||||
addRenderObject(tfader, LR_TRANSITION);
|
||||
|
||||
screenTransition = 0;
|
||||
|
||||
screenTransition = new AquariaScreenTransition();
|
||||
{
|
||||
screenTransition->position = Vector(400,300);
|
||||
|
@ -4368,6 +4359,7 @@ void DSQ::updatepecue(float dt)
|
|||
|
||||
void AquariaScreenTransition::capture()
|
||||
{
|
||||
assert(screen_texture);
|
||||
this->alpha = 0;
|
||||
InterpolatedVector oldAlpha = dsq->cursor->alpha;
|
||||
dsq->cursor->alpha.x = 0;
|
||||
|
|
|
@ -508,6 +508,7 @@ protected:
|
|||
void reloadDevice();
|
||||
|
||||
void onSwitchScreenMode();
|
||||
virtual void onWindowResize(int w, int h);
|
||||
|
||||
void onPlayVoice();
|
||||
void onStopVoice();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue