STARK: Simplify game window rendering
This commit is contained in:
parent
473113a4ed
commit
22d02ac502
7 changed files with 3 additions and 41 deletions
|
@ -44,7 +44,6 @@ public:
|
||||||
|
|
||||||
virtual void init() = 0;
|
virtual void init() = 0;
|
||||||
|
|
||||||
virtual void setGameViewport() = 0; // deprecated
|
|
||||||
virtual void setScreenViewport(bool noScaling) = 0; // deprecated
|
virtual void setScreenViewport(bool noScaling) = 0; // deprecated
|
||||||
|
|
||||||
virtual void setViewport(Common::Rect rect, bool noScaling) = 0;
|
virtual void setViewport(Common::Rect rect, bool noScaling) = 0;
|
||||||
|
@ -54,8 +53,6 @@ public:
|
||||||
|
|
||||||
Common::Rect gameViewport() const;
|
Common::Rect gameViewport() const;
|
||||||
|
|
||||||
virtual void setupCamera(const Math::Matrix4 &projection, const Math::Matrix4 &view) = 0;
|
|
||||||
|
|
||||||
virtual void clearScreen() = 0;
|
virtual void clearScreen() = 0;
|
||||||
virtual void flipBuffer() = 0;
|
virtual void flipBuffer() = 0;
|
||||||
|
|
||||||
|
|
|
@ -69,14 +69,6 @@ void OpenGLSDriver::init() {
|
||||||
_boxShader->enableVertexAttribute("texcoord", _boxVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0);
|
_boxShader->enableVertexAttribute("texcoord", _boxVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLSDriver::setGameViewport() {
|
|
||||||
_viewport = gameViewport();
|
|
||||||
_unscaledViewport = Common::Rect(kGameViewportWidth, kGameViewportHeight);
|
|
||||||
_unscaledViewport.translate(0, kBottomBorderHeight);
|
|
||||||
|
|
||||||
glViewport(_viewport.left, _viewport.top, _viewport.width(), _viewport.height());
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLSDriver::setScreenViewport(bool noScaling) {
|
void OpenGLSDriver::setScreenViewport(bool noScaling) {
|
||||||
if (noScaling) {
|
if (noScaling) {
|
||||||
_viewport = Common::Rect(g_system->getWidth(), g_system->getHeight());
|
_viewport = Common::Rect(g_system->getWidth(), g_system->getHeight());
|
||||||
|
@ -114,9 +106,6 @@ Math::Vector2d OpenGLSDriver::scaled(float x, float y) const {
|
||||||
return Math::Vector2d(x / (float) _unscaledViewport.width(), y / (float) _unscaledViewport.height());
|
return Math::Vector2d(x / (float) _unscaledViewport.width(), y / (float) _unscaledViewport.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLSDriver::setupCamera(const Math::Matrix4 &projection, const Math::Matrix4 &view) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLSDriver::clearScreen() {
|
void OpenGLSDriver::clearScreen() {
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,12 +47,9 @@ public:
|
||||||
|
|
||||||
void init() override;
|
void init() override;
|
||||||
|
|
||||||
void setGameViewport() override;
|
|
||||||
void setScreenViewport(bool noScaling) override;
|
void setScreenViewport(bool noScaling) override;
|
||||||
void setViewport(Common::Rect rect, bool noScaling) override;
|
void setViewport(Common::Rect rect, bool noScaling) override;
|
||||||
|
|
||||||
void setupCamera(const Math::Matrix4 &projection, const Math::Matrix4 &view) override;
|
|
||||||
|
|
||||||
void clearScreen();
|
void clearScreen();
|
||||||
void flipBuffer();
|
void flipBuffer();
|
||||||
|
|
||||||
|
|
|
@ -115,22 +115,4 @@ void Scene::makeRayFromMouse(const Common::Point &mouse, Math::Vector3d &origin,
|
||||||
direction.normalize();
|
direction.normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::render() {
|
|
||||||
// setup cam
|
|
||||||
_gfx->setGameViewport();
|
|
||||||
_gfx->setupCamera(_projectionMatrix, _viewMatrix);
|
|
||||||
|
|
||||||
// Draw bg
|
|
||||||
|
|
||||||
// Draw other things
|
|
||||||
|
|
||||||
// Render all the scene elements
|
|
||||||
|
|
||||||
// setup lights
|
|
||||||
|
|
||||||
// draw actors
|
|
||||||
|
|
||||||
// draw overlay
|
|
||||||
}
|
|
||||||
|
|
||||||
} // End of namespace Stark
|
} // End of namespace Stark
|
||||||
|
|
|
@ -47,11 +47,6 @@ public:
|
||||||
Scene(Gfx::Driver *gfx);
|
Scene(Gfx::Driver *gfx);
|
||||||
~Scene();
|
~Scene();
|
||||||
|
|
||||||
/**
|
|
||||||
* Render the scene
|
|
||||||
*/
|
|
||||||
void render();
|
|
||||||
|
|
||||||
void initCamera(const Math::Vector3d &position, const Math::Vector3d &lookAt,
|
void initCamera(const Math::Vector3d &position, const Math::Vector3d &lookAt,
|
||||||
float fov, Common::Rect viewSize, float nearClipPlane, float farClipPlane);
|
float fov, Common::Rect viewSize, float nearClipPlane, float farClipPlane);
|
||||||
|
|
||||||
|
|
|
@ -228,7 +228,6 @@ void StarkEngine::updateDisplayScene() {
|
||||||
// Render the current scene
|
// Render the current scene
|
||||||
// Update the UI state before displaying the scene
|
// Update the UI state before displaying the scene
|
||||||
_ui->update();
|
_ui->update();
|
||||||
_scene->render();
|
|
||||||
}
|
}
|
||||||
// Tell the UI to render, and update implicitly, if this leads to new mouse-over events.
|
// Tell the UI to render, and update implicitly, if this leads to new mouse-over events.
|
||||||
_ui->render();
|
_ui->render();
|
||||||
|
|
|
@ -50,8 +50,11 @@ GameWindow::GameWindow(Gfx::Driver *gfx, Cursor *cursor, ActionMenu *actionMenu)
|
||||||
|
|
||||||
void GameWindow::onRender() {
|
void GameWindow::onRender() {
|
||||||
Global *global = StarkServices::instance().global;
|
Global *global = StarkServices::instance().global;
|
||||||
|
|
||||||
|
// List the items to render
|
||||||
_renderEntries = global->getCurrent()->getLocation()->listRenderEntries();
|
_renderEntries = global->getCurrent()->getLocation()->listRenderEntries();
|
||||||
|
|
||||||
|
// Render all the scene items
|
||||||
Gfx::RenderEntryArray::iterator element = _renderEntries.begin();
|
Gfx::RenderEntryArray::iterator element = _renderEntries.begin();
|
||||||
while (element != _renderEntries.end()) {
|
while (element != _renderEntries.end()) {
|
||||||
// Draw the current element
|
// Draw the current element
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue