mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-24 23:14:01 +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();
|
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)
|
void DSQ::rumble(float leftMotor, float rightMotor, float time, int source)
|
||||||
{
|
{
|
||||||
if (this->inputMode == INPUT_JOYSTICK)
|
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);
|
particleManager->setSize(user.video.numParticles);
|
||||||
|
|
||||||
fullscreen = user.video.full;
|
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;
|
useFrameBuffer = user.video.fbuffer;
|
||||||
|
|
||||||
if (isDeveloperKeys())
|
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...");
|
debugLog("Init Graphics Library...");
|
||||||
initGraphicsLibrary(user.video.resx, user.video.resy, fullscreen, user.video.vsync, user.video.bits);
|
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");
|
debugLog("OK");
|
||||||
|
|
||||||
setInputGrab(0);
|
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->setVoiceFader(0.5);
|
||||||
sound->event_playVoice.set(MakeFunctionEvent(DSQ, onPlayVoice));
|
sound->event_playVoice.set(MakeFunctionEvent(DSQ, onPlayVoice));
|
||||||
sound->event_stopVoice.set(MakeFunctionEvent(DSQ, onStopVoice));
|
sound->event_stopVoice.set(MakeFunctionEvent(DSQ, onStopVoice));
|
||||||
|
|
||||||
debugLog("OK");
|
debugLog("OK");
|
||||||
|
|
||||||
debugLog("Init Input Library...");
|
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);
|
addRenderObject(tfader, LR_TRANSITION);
|
||||||
|
|
||||||
screenTransition = 0;
|
|
||||||
|
|
||||||
screenTransition = new AquariaScreenTransition();
|
screenTransition = new AquariaScreenTransition();
|
||||||
{
|
{
|
||||||
screenTransition->position = Vector(400,300);
|
screenTransition->position = Vector(400,300);
|
||||||
|
@ -4368,6 +4359,7 @@ void DSQ::updatepecue(float dt)
|
||||||
|
|
||||||
void AquariaScreenTransition::capture()
|
void AquariaScreenTransition::capture()
|
||||||
{
|
{
|
||||||
|
assert(screen_texture);
|
||||||
this->alpha = 0;
|
this->alpha = 0;
|
||||||
InterpolatedVector oldAlpha = dsq->cursor->alpha;
|
InterpolatedVector oldAlpha = dsq->cursor->alpha;
|
||||||
dsq->cursor->alpha.x = 0;
|
dsq->cursor->alpha.x = 0;
|
||||||
|
|
|
@ -508,6 +508,7 @@ protected:
|
||||||
void reloadDevice();
|
void reloadDevice();
|
||||||
|
|
||||||
void onSwitchScreenMode();
|
void onSwitchScreenMode();
|
||||||
|
virtual void onWindowResize(int w, int h);
|
||||||
|
|
||||||
void onPlayVoice();
|
void onPlayVoice();
|
||||||
void onStopVoice();
|
void onStopVoice();
|
||||||
|
|
|
@ -38,19 +38,11 @@ AfterEffectManager::AfterEffectManager(int xDivs, int yDivs)
|
||||||
bRenderGridPoints = true;
|
bRenderGridPoints = true;
|
||||||
shaderPipeline.resize(10, 0);
|
shaderPipeline.resize(10, 0);
|
||||||
|
|
||||||
screenWidth = core->getWindowWidth();
|
|
||||||
screenHeight = core->getWindowHeight();
|
|
||||||
|
|
||||||
this->xDivs = 0;
|
|
||||||
this->yDivs = 0;
|
|
||||||
|
|
||||||
drawGrid = 0;
|
drawGrid = 0;
|
||||||
|
|
||||||
this->xDivs = xDivs;
|
this->xDivs = xDivs;
|
||||||
this->yDivs = yDivs;
|
this->yDivs = yDivs;
|
||||||
|
|
||||||
reloadDevice();
|
|
||||||
|
|
||||||
if (xDivs != 0 && yDivs != 0)
|
if (xDivs != 0 && yDivs != 0)
|
||||||
{
|
{
|
||||||
drawGrid = new Vector * [xDivs];
|
drawGrid = new Vector * [xDivs];
|
||||||
|
@ -60,6 +52,8 @@ AfterEffectManager::AfterEffectManager(int xDivs, int yDivs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateDevice();
|
||||||
|
|
||||||
loadShaders();
|
loadShaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +372,7 @@ void AfterEffectManager::unloadDevice()
|
||||||
unloadShaders();
|
unloadShaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AfterEffectManager::reloadDevice()
|
void AfterEffectManager::_updateScreenSize()
|
||||||
{
|
{
|
||||||
screenWidth = core->getWindowWidth();
|
screenWidth = core->getWindowWidth();
|
||||||
screenHeight = core->getWindowHeight();
|
screenHeight = core->getWindowHeight();
|
||||||
|
@ -395,11 +389,19 @@ void AfterEffectManager::reloadDevice()
|
||||||
textureHeight = screenHeight;
|
textureHeight = screenHeight;
|
||||||
sizePowerOf2Texture(textureHeight);
|
sizePowerOf2Texture(textureHeight);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(backupBuffer.isInited())
|
void AfterEffectManager::updateDevice()
|
||||||
backupBuffer.reloadDevice();
|
{
|
||||||
else
|
_updateScreenSize();
|
||||||
backupBuffer.init(-1, -1, true);
|
backupBuffer.init(-1, -1, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AfterEffectManager::reloadDevice()
|
||||||
|
{
|
||||||
|
_updateScreenSize();
|
||||||
|
|
||||||
|
backupBuffer.reloadDevice();
|
||||||
|
|
||||||
for (size_t i = 0; i < loadedShaders.size(); ++i)
|
for (size_t i = 0; i < loadedShaders.size(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -409,11 +411,11 @@ void AfterEffectManager::reloadDevice()
|
||||||
if (!sh->isLoaded())
|
if (!sh->isLoaded())
|
||||||
{
|
{
|
||||||
debugLog("AfterEffect::reloadDevice(): Failed to reload shader");
|
debugLog("AfterEffect::reloadDevice(): Failed to reload shader");
|
||||||
delete sh;
|
|
||||||
loadedShaders[i] = 0;
|
loadedShaders[i] = 0;
|
||||||
for(size_t j = 0; j < shaderPipeline.size(); ++j)
|
for(size_t j = 0; j < shaderPipeline.size(); ++j)
|
||||||
if(sh == shaderPipeline[j])
|
if(sh == shaderPipeline[j])
|
||||||
shaderPipeline[j] = 0;
|
shaderPipeline[j] = 0;
|
||||||
|
delete sh;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,7 @@ public:
|
||||||
|
|
||||||
void unloadDevice();
|
void unloadDevice();
|
||||||
void reloadDevice();
|
void reloadDevice();
|
||||||
|
void updateDevice();
|
||||||
|
|
||||||
std::vector<Effect*> effects;
|
std::vector<Effect*> effects;
|
||||||
std::vector<int> openSpots;
|
std::vector<int> openSpots;
|
||||||
|
@ -121,6 +122,7 @@ public:
|
||||||
void deleteShader(int handle);
|
void deleteShader(int handle);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void _updateScreenSize();
|
||||||
int _insertShader(Shader *sh);
|
int _insertShader(Shader *sh);
|
||||||
|
|
||||||
std::vector<Shader*> shaderPipeline; // Shaders are applied in this order. Can contain the same pointer more than once.
|
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);
|
setClearColor(clearColor);
|
||||||
|
|
||||||
clearBuffers();
|
frameBuffer.init(-1, -1, true);
|
||||||
showBuffer();
|
if(afterEffectManager)
|
||||||
|
afterEffectManager->updateDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1389,11 +1390,6 @@ void Core::setupGlobalResolutionScale()
|
||||||
glScalef(globalResolutionScale.x, globalResolutionScale.y, globalResolutionScale.z);
|
glScalef(globalResolutionScale.x, globalResolutionScale.y, globalResolutionScale.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::initFrameBuffer()
|
|
||||||
{
|
|
||||||
frameBuffer.init(-1, -1, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Core::setMouseConstraint(bool on)
|
void Core::setMouseConstraint(bool on)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -390,7 +390,6 @@ public:
|
||||||
void setup_opengl();
|
void setup_opengl();
|
||||||
void setClearColor(const Vector &c);
|
void setClearColor(const Vector &c);
|
||||||
int flipMouseButtons;
|
int flipMouseButtons;
|
||||||
void initFrameBuffer();
|
|
||||||
FrameBuffer frameBuffer;
|
FrameBuffer frameBuffer;
|
||||||
void updateRenderObjects(float dt);
|
void updateRenderObjects(float dt);
|
||||||
bool joystickAsMouse;
|
bool joystickAsMouse;
|
||||||
|
|
|
@ -25,15 +25,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
ScreenTransition::ScreenTransition() : RenderObject()
|
ScreenTransition::ScreenTransition() : RenderObject()
|
||||||
{
|
{
|
||||||
createTexture();
|
screen_texture = 0;
|
||||||
|
|
||||||
cull = false;
|
cull = false;
|
||||||
followCamera = 1;
|
followCamera = 1;
|
||||||
alpha = 0;
|
alpha = 0;
|
||||||
|
createTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenTransition::createTexture()
|
void ScreenTransition::createTexture()
|
||||||
{
|
{
|
||||||
|
destroyTexture();
|
||||||
|
|
||||||
width = core->getVirtualWidth();
|
width = core->getVirtualWidth();
|
||||||
height = core->getVirtualHeight();
|
height = core->getVirtualHeight();
|
||||||
|
|
||||||
|
@ -46,20 +48,13 @@ void ScreenTransition::createTexture()
|
||||||
sizePowerOf2Texture(textureWidth);
|
sizePowerOf2Texture(textureWidth);
|
||||||
sizePowerOf2Texture(textureHeight);
|
sizePowerOf2Texture(textureHeight);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//create our texture
|
//create our texture
|
||||||
glGenTextures(1,&screen_texture);
|
glGenTextures(1,&screen_texture);
|
||||||
glBindTexture(GL_TEXTURE_2D, 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_MIN_FILTER, GL_LINEAR); //GL_NEAREST); //GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_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);
|
glTexImage2D(GL_TEXTURE_2D,0,3, textureWidth, textureHeight, 0 , GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||||
glBindTexture(GL_TEXTURE_2D,0);
|
glBindTexture(GL_TEXTURE_2D,0);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenTransition::destroyTexture()
|
void ScreenTransition::destroyTexture()
|
||||||
|
@ -85,10 +80,9 @@ void ScreenTransition::reloadDevice()
|
||||||
|
|
||||||
void ScreenTransition::capture()
|
void ScreenTransition::capture()
|
||||||
{
|
{
|
||||||
|
assert(screen_texture);
|
||||||
core->render();
|
core->render();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (screen_texture)
|
if (screen_texture)
|
||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D,screen_texture);
|
glBindTexture(GL_TEXTURE_2D,screen_texture);
|
||||||
|
@ -127,24 +121,9 @@ void ScreenTransition::onRender()
|
||||||
const float pw = float(windowWidth)/float(textureWidth);
|
const float pw = float(windowWidth)/float(textureWidth);
|
||||||
const float ph = float(windowHeight)/float(textureHeight);
|
const float ph = float(windowHeight)/float(textureHeight);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, screen_texture);
|
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);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
|
|
||||||
glTexCoord2d(0, 0);
|
glTexCoord2d(0, 0);
|
||||||
glVertex3f(-width2, height2, 0.0);
|
glVertex3f(-width2, height2, 0.0);
|
||||||
glTexCoord2d(pw, 0);
|
glTexCoord2d(pw, 0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue