PLAYGROUND3D: Added viewport test
This commit is contained in:
parent
d5648a0a8c
commit
0c5e091215
9 changed files with 169 additions and 29 deletions
|
@ -54,9 +54,11 @@ public:
|
||||||
|
|
||||||
void computeScreenViewport();
|
void computeScreenViewport();
|
||||||
|
|
||||||
|
virtual void setupViewport(int x, int y, int width, int height) = 0;
|
||||||
virtual void drawCube(const Math::Vector3d &pos, const Math::Vector3d &roll) = 0;
|
virtual void drawCube(const Math::Vector3d &pos, const Math::Vector3d &roll) = 0;
|
||||||
virtual void drawPolyOffsetTest(const Math::Vector3d &pos, const Math::Vector3d &roll) = 0;
|
virtual void drawPolyOffsetTest(const Math::Vector3d &pos, const Math::Vector3d &roll) = 0;
|
||||||
virtual void dimRegionInOut(float fade) = 0;
|
virtual void dimRegionInOut(float fade) = 0;
|
||||||
|
virtual void drawInViewport() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
OSystem *_system;
|
OSystem *_system;
|
||||||
|
|
|
@ -41,6 +41,14 @@ static const GLfloat dimRegionVertices[] = {
|
||||||
0.5f, -0.5f,
|
0.5f, -0.5f,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const GLfloat boxVertices[] = {
|
||||||
|
// X Y
|
||||||
|
-1.0f, 1.0f,
|
||||||
|
1.0f, 1.0f,
|
||||||
|
-1.0f, -1.0f,
|
||||||
|
1.0f, -1.0f,
|
||||||
|
};
|
||||||
|
|
||||||
Renderer *CreateGfxOpenGL(OSystem *system) {
|
Renderer *CreateGfxOpenGL(OSystem *system) {
|
||||||
return new OpenGLRenderer(system);
|
return new OpenGLRenderer(system);
|
||||||
}
|
}
|
||||||
|
@ -78,6 +86,10 @@ void OpenGLRenderer::clear(const Math::Vector4d &clearColor) {
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenGLRenderer::setupViewport(int x, int y, int width, int height) {
|
||||||
|
glViewport(x, y, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
void OpenGLRenderer::drawFace(uint face) {
|
void OpenGLRenderer::drawFace(uint face) {
|
||||||
glBegin(GL_TRIANGLE_STRIP);
|
glBegin(GL_TRIANGLE_STRIP);
|
||||||
for (uint i = 0; i < 4; i++) {
|
for (uint i = 0; i < 4; i++) {
|
||||||
|
@ -89,9 +101,6 @@ void OpenGLRenderer::drawFace(uint face) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLRenderer::drawCube(const Math::Vector3d &pos, const Math::Vector3d &roll) {
|
void OpenGLRenderer::drawCube(const Math::Vector3d &pos, const Math::Vector3d &roll) {
|
||||||
Common::Rect vp = viewport();
|
|
||||||
glViewport(vp.left, _system->getHeight() - vp.top - vp.height(), vp.width(), vp.height());
|
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadMatrixf(_projectionMatrix.getData());
|
glLoadMatrixf(_projectionMatrix.getData());
|
||||||
|
|
||||||
|
@ -109,9 +118,6 @@ void OpenGLRenderer::drawCube(const Math::Vector3d &pos, const Math::Vector3d &r
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLRenderer::drawPolyOffsetTest(const Math::Vector3d &pos, const Math::Vector3d &roll) {
|
void OpenGLRenderer::drawPolyOffsetTest(const Math::Vector3d &pos, const Math::Vector3d &roll) {
|
||||||
Common::Rect vp = viewport();
|
|
||||||
glViewport(vp.left, _system->getHeight() - vp.top - vp.height(), vp.width(), vp.height());
|
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadMatrixf(_projectionMatrix.getData());
|
glLoadMatrixf(_projectionMatrix.getData());
|
||||||
|
|
||||||
|
@ -140,9 +146,6 @@ void OpenGLRenderer::drawPolyOffsetTest(const Math::Vector3d &pos, const Math::V
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLRenderer::dimRegionInOut(float fade) {
|
void OpenGLRenderer::dimRegionInOut(float fade) {
|
||||||
Common::Rect vp = viewport();
|
|
||||||
glViewport(vp.left, _system->getHeight() - vp.top - vp.height(), vp.width(), vp.height());
|
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -158,7 +161,7 @@ void OpenGLRenderer::dimRegionInOut(float fade) {
|
||||||
|
|
||||||
glColor4f(0.0f, 0.0f, 0.0f, 1.0f - fade);
|
glColor4f(0.0f, 0.0f, 0.0f, 1.0f - fade);
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glVertexPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &dimRegionVertices[0]);
|
glVertexPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), dimRegionVertices);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
|
||||||
|
@ -169,6 +172,59 @@ void OpenGLRenderer::dimRegionInOut(float fade) {
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenGLRenderer::drawInViewport() {
|
||||||
|
static GLfloat box2Vertices[] = {
|
||||||
|
// X Y
|
||||||
|
-0.1f, 0.1f,
|
||||||
|
0.1f, 0.1f,
|
||||||
|
-0.1f, -0.1f,
|
||||||
|
0.1f, -0.1f,
|
||||||
|
};
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPushMatrix();
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glPushMatrix();
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
glDepthMask(GL_FALSE);
|
||||||
|
|
||||||
|
glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glVertexPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &boxVertices[0]);
|
||||||
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
_pos.x() += 0.01;
|
||||||
|
_pos.y() += 0.01;
|
||||||
|
if (_pos.x() >= 1.0f) {
|
||||||
|
_pos.x() = -1.0;
|
||||||
|
_pos.y() = -1.0;
|
||||||
|
}
|
||||||
|
glTranslatef(_pos.x(), _pos.y(), 0);
|
||||||
|
|
||||||
|
glPolygonOffset(-1.0f, 0.0f);
|
||||||
|
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||||
|
glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glVertexPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &box2Vertices[0]);
|
||||||
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glPopMatrix();
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Playground3d
|
} // End of namespace Playground3d
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -43,11 +43,15 @@ public:
|
||||||
|
|
||||||
virtual void clear(const Math::Vector4d &clearColor) override;
|
virtual void clear(const Math::Vector4d &clearColor) override;
|
||||||
|
|
||||||
|
virtual void setupViewport(int x, int y, int width, int height) override;
|
||||||
virtual void drawCube(const Math::Vector3d &pos, const Math::Vector3d &roll) override;
|
virtual void drawCube(const Math::Vector3d &pos, const Math::Vector3d &roll) override;
|
||||||
virtual void drawPolyOffsetTest(const Math::Vector3d &pos, const Math::Vector3d &roll) override;
|
virtual void drawPolyOffsetTest(const Math::Vector3d &pos, const Math::Vector3d &roll) override;
|
||||||
virtual void dimRegionInOut(float fade) override;
|
virtual void dimRegionInOut(float fade) override;
|
||||||
|
virtual void drawInViewport() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Math::Vector3d _pos;
|
||||||
|
|
||||||
void drawFace(uint face);
|
void drawFace(uint face);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -94,10 +94,11 @@ void ShaderRenderer::clear(const Math::Vector4d &clearColor) {
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderRenderer::drawCube(const Math::Vector3d &pos, const Math::Vector3d &roll) {
|
void ShaderRenderer::setupViewport(int x, int y, int width, int height) {
|
||||||
Common::Rect vp = viewport();
|
glViewport(x, y, width, height);
|
||||||
glViewport(vp.left, _system->getHeight() - vp.top - vp.height(), vp.width(), vp.height());
|
}
|
||||||
|
|
||||||
|
void ShaderRenderer::drawCube(const Math::Vector3d &pos, const Math::Vector3d &roll) {
|
||||||
auto rotateMatrix = (Math::Quaternion::fromEuler(roll.x(), roll.y(), roll.z(), Math::EO_XYZ)).inverse().toMatrix();
|
auto rotateMatrix = (Math::Quaternion::fromEuler(roll.x(), roll.y(), roll.z(), Math::EO_XYZ)).inverse().toMatrix();
|
||||||
_cubeShader->use();
|
_cubeShader->use();
|
||||||
_cubeShader->setUniform("textured", false);
|
_cubeShader->setUniform("textured", false);
|
||||||
|
@ -118,9 +119,6 @@ void ShaderRenderer::drawPolyOffsetTest(const Math::Vector3d &pos, const Math::V
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderRenderer::dimRegionInOut(float fade) {
|
void ShaderRenderer::dimRegionInOut(float fade) {
|
||||||
Common::Rect vp = viewport();
|
|
||||||
glViewport(vp.left, _system->getHeight() - vp.top - vp.height(), vp.width(), vp.height());
|
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
@ -132,6 +130,10 @@ void ShaderRenderer::dimRegionInOut(float fade) {
|
||||||
_fadeShader->unbind();
|
_fadeShader->unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShaderRenderer::drawInViewport() {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Playground3d
|
} // End of namespace Playground3d
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -43,9 +43,11 @@ public:
|
||||||
|
|
||||||
virtual void clear(const Math::Vector4d &clearColor) override;
|
virtual void clear(const Math::Vector4d &clearColor) override;
|
||||||
|
|
||||||
|
virtual void setupViewport(int x, int y, int width, int height) override;
|
||||||
virtual void drawCube(const Math::Vector3d &pos, const Math::Vector3d &roll) override;
|
virtual void drawCube(const Math::Vector3d &pos, const Math::Vector3d &roll) override;
|
||||||
virtual void drawPolyOffsetTest(const Math::Vector3d &pos, const Math::Vector3d &roll) override;
|
virtual void drawPolyOffsetTest(const Math::Vector3d &pos, const Math::Vector3d &roll) override;
|
||||||
virtual void dimRegionInOut(float fade) override;
|
virtual void dimRegionInOut(float fade) override;
|
||||||
|
virtual void drawInViewport() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OpenGL::ShaderGL *_cubeShader;
|
OpenGL::ShaderGL *_cubeShader;
|
||||||
|
|
|
@ -47,6 +47,14 @@ static const TGLuint dimRegionIndices[] = {
|
||||||
0, 1, 2, 3
|
0, 1, 2, 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const TGLfloat boxVertices[] = {
|
||||||
|
// X Y
|
||||||
|
-1.0f, 1.0f,
|
||||||
|
1.0f, 1.0f,
|
||||||
|
-1.0f, -1.0f,
|
||||||
|
1.0f, -1.0f,
|
||||||
|
};
|
||||||
|
|
||||||
Renderer *CreateGfxTinyGL(OSystem *system) {
|
Renderer *CreateGfxTinyGL(OSystem *system) {
|
||||||
return new TinyGLRenderer(system);
|
return new TinyGLRenderer(system);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +74,7 @@ void TinyGLRenderer::init() {
|
||||||
|
|
||||||
_fb = new TinyGL::FrameBuffer(kOriginalWidth, kOriginalHeight, g_system->getScreenFormat());
|
_fb = new TinyGL::FrameBuffer(kOriginalWidth, kOriginalHeight, g_system->getScreenFormat());
|
||||||
TinyGL::glInit(_fb, 512);
|
TinyGL::glInit(_fb, 512);
|
||||||
tglEnableDirtyRects(ConfMan.getBool("dirtyrects"));
|
tglEnableDirtyRects(false/*ConfMan.getBool("dirtyrects")*/);
|
||||||
|
|
||||||
tglMatrixMode(TGL_PROJECTION);
|
tglMatrixMode(TGL_PROJECTION);
|
||||||
tglLoadIdentity();
|
tglLoadIdentity();
|
||||||
|
@ -83,6 +91,10 @@ void TinyGLRenderer::clear(const Math::Vector4d &clearColor) {
|
||||||
tglClear(TGL_COLOR_BUFFER_BIT | TGL_DEPTH_BUFFER_BIT);
|
tglClear(TGL_COLOR_BUFFER_BIT | TGL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TinyGLRenderer::setupViewport(int x, int y, int width, int height) {
|
||||||
|
tglViewport(x, y, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
void TinyGLRenderer::drawFace(uint face) {
|
void TinyGLRenderer::drawFace(uint face) {
|
||||||
tglBegin(TGL_TRIANGLE_STRIP);
|
tglBegin(TGL_TRIANGLE_STRIP);
|
||||||
for (uint i = 0; i < 4; i++) {
|
for (uint i = 0; i < 4; i++) {
|
||||||
|
@ -94,9 +106,6 @@ void TinyGLRenderer::drawFace(uint face) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TinyGLRenderer::drawCube(const Math::Vector3d &pos, const Math::Vector3d &roll) {
|
void TinyGLRenderer::drawCube(const Math::Vector3d &pos, const Math::Vector3d &roll) {
|
||||||
Common::Rect vp = viewport();
|
|
||||||
tglViewport(vp.left, _system->getHeight() - vp.top - vp.height(), vp.width(), vp.height());
|
|
||||||
|
|
||||||
tglMatrixMode(TGL_PROJECTION);
|
tglMatrixMode(TGL_PROJECTION);
|
||||||
tglLoadMatrixf(_projectionMatrix.getData());
|
tglLoadMatrixf(_projectionMatrix.getData());
|
||||||
|
|
||||||
|
@ -114,9 +123,6 @@ void TinyGLRenderer::drawCube(const Math::Vector3d &pos, const Math::Vector3d &r
|
||||||
}
|
}
|
||||||
|
|
||||||
void TinyGLRenderer::drawPolyOffsetTest(const Math::Vector3d &pos, const Math::Vector3d &roll) {
|
void TinyGLRenderer::drawPolyOffsetTest(const Math::Vector3d &pos, const Math::Vector3d &roll) {
|
||||||
Common::Rect vp = viewport();
|
|
||||||
tglViewport(vp.left, _system->getHeight() - vp.top - vp.height(), vp.width(), vp.height());
|
|
||||||
|
|
||||||
tglMatrixMode(TGL_PROJECTION);
|
tglMatrixMode(TGL_PROJECTION);
|
||||||
tglLoadMatrixf(_projectionMatrix.getData());
|
tglLoadMatrixf(_projectionMatrix.getData());
|
||||||
|
|
||||||
|
@ -150,9 +156,6 @@ void TinyGLRenderer::flipBuffer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TinyGLRenderer::dimRegionInOut(float fade) {
|
void TinyGLRenderer::dimRegionInOut(float fade) {
|
||||||
Common::Rect vp = viewport();
|
|
||||||
tglViewport(vp.left, _system->getHeight() - vp.top - vp.height(), vp.width(), vp.height());
|
|
||||||
|
|
||||||
tglMatrixMode(TGL_PROJECTION);
|
tglMatrixMode(TGL_PROJECTION);
|
||||||
tglPushMatrix();
|
tglPushMatrix();
|
||||||
tglLoadIdentity();
|
tglLoadIdentity();
|
||||||
|
@ -167,7 +170,6 @@ void TinyGLRenderer::dimRegionInOut(float fade) {
|
||||||
tglDepthMask(TGL_FALSE);
|
tglDepthMask(TGL_FALSE);
|
||||||
|
|
||||||
tglColor4f(0.0f, 0.0f, 0.0f, 1.0f - fade);
|
tglColor4f(0.0f, 0.0f, 0.0f, 1.0f - fade);
|
||||||
|
|
||||||
tglEnableClientState(TGL_VERTEX_ARRAY);
|
tglEnableClientState(TGL_VERTEX_ARRAY);
|
||||||
tglVertexPointer(2, TGL_FLOAT, 0, dimRegionVertices);
|
tglVertexPointer(2, TGL_FLOAT, 0, dimRegionVertices);
|
||||||
tglDrawElements(TGL_TRIANGLE_STRIP, 4, TGL_UNSIGNED_INT, dimRegionIndices);
|
tglDrawElements(TGL_TRIANGLE_STRIP, 4, TGL_UNSIGNED_INT, dimRegionIndices);
|
||||||
|
@ -181,4 +183,57 @@ void TinyGLRenderer::dimRegionInOut(float fade) {
|
||||||
tglPopMatrix();
|
tglPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TinyGLRenderer::drawInViewport() {
|
||||||
|
static TGLfloat box2Vertices[] = {
|
||||||
|
// X Y
|
||||||
|
-0.1f, 0.1f,
|
||||||
|
0.1f, 0.1f,
|
||||||
|
-0.1f, -0.1f,
|
||||||
|
0.1f, -0.1f,
|
||||||
|
};
|
||||||
|
tglMatrixMode(TGL_PROJECTION);
|
||||||
|
tglPushMatrix();
|
||||||
|
tglLoadIdentity();
|
||||||
|
|
||||||
|
tglMatrixMode(TGL_MODELVIEW);
|
||||||
|
tglPushMatrix();
|
||||||
|
tglLoadIdentity();
|
||||||
|
|
||||||
|
tglEnable(TGL_BLEND);
|
||||||
|
tglBlendFunc(TGL_ONE, TGL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
tglDisable(TGL_DEPTH_TEST);
|
||||||
|
tglDepthMask(TGL_FALSE);
|
||||||
|
|
||||||
|
tglColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||||
|
tglEnableClientState(TGL_VERTEX_ARRAY);
|
||||||
|
tglVertexPointer(2, TGL_FLOAT, 2 * sizeof(TGLfloat), &boxVertices[0]);
|
||||||
|
tglDrawArrays(TGL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
tglDisableClientState(TGL_VERTEX_ARRAY);
|
||||||
|
|
||||||
|
tglPushMatrix();
|
||||||
|
_pos.x() += 0.01;
|
||||||
|
_pos.y() += 0.01;
|
||||||
|
if (_pos.x() >= 1.0f) {
|
||||||
|
_pos.x() = -1.0;
|
||||||
|
_pos.y() = -1.0;
|
||||||
|
}
|
||||||
|
tglTranslatef(_pos.x(), _pos.y(), 0);
|
||||||
|
|
||||||
|
tglPolygonOffset(-1.0f, 0.0f);
|
||||||
|
tglEnable(TGL_POLYGON_OFFSET_FILL);
|
||||||
|
tglColor4f(1.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
tglEnableClientState(TGL_VERTEX_ARRAY);
|
||||||
|
tglVertexPointer(2, TGL_FLOAT, 2 * sizeof(TGLfloat), &box2Vertices[0]);
|
||||||
|
tglDrawArrays(TGL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
tglDisableClientState(TGL_VERTEX_ARRAY);
|
||||||
|
tglDisable(TGL_POLYGON_OFFSET_FILL);
|
||||||
|
|
||||||
|
tglMatrixMode(TGL_MODELVIEW);
|
||||||
|
tglPopMatrix();
|
||||||
|
tglPopMatrix();
|
||||||
|
|
||||||
|
tglMatrixMode(TGL_PROJECTION);
|
||||||
|
tglPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Playground3d
|
} // End of namespace Playground3d
|
||||||
|
|
|
@ -43,16 +43,19 @@ public:
|
||||||
|
|
||||||
virtual void clear(const Math::Vector4d &clearColor) override;
|
virtual void clear(const Math::Vector4d &clearColor) override;
|
||||||
|
|
||||||
|
virtual void setupViewport(int x, int y, int width, int height) override;
|
||||||
virtual void drawCube(const Math::Vector3d &pos, const Math::Vector3d &roll) override;
|
virtual void drawCube(const Math::Vector3d &pos, const Math::Vector3d &roll) override;
|
||||||
virtual void drawPolyOffsetTest(const Math::Vector3d &pos, const Math::Vector3d &roll) override;
|
virtual void drawPolyOffsetTest(const Math::Vector3d &pos, const Math::Vector3d &roll) override;
|
||||||
virtual void dimRegionInOut(float fade) override;
|
virtual void dimRegionInOut(float fade) override;
|
||||||
|
virtual void drawInViewport() override;
|
||||||
|
|
||||||
virtual void flipBuffer() override;
|
virtual void flipBuffer() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void drawFace(uint face);
|
|
||||||
|
|
||||||
TinyGL::FrameBuffer *_fb;
|
TinyGL::FrameBuffer *_fb;
|
||||||
|
Math::Vector3d _pos;
|
||||||
|
|
||||||
|
void drawFace(uint face);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Playground3d
|
} // End of namespace Playground3d
|
||||||
|
|
|
@ -66,6 +66,7 @@ Common::Error Playground3dEngine::run() {
|
||||||
// 1 - rotated colorfull cube
|
// 1 - rotated colorfull cube
|
||||||
// 2 - rotated two triangles with depth offset
|
// 2 - rotated two triangles with depth offset
|
||||||
// 3 - fade in/out
|
// 3 - fade in/out
|
||||||
|
// 4 - moving filled rectangle in viewport
|
||||||
int testId = 1;
|
int testId = 1;
|
||||||
|
|
||||||
switch (testId) {
|
switch (testId) {
|
||||||
|
@ -79,6 +80,9 @@ Common::Error Playground3dEngine::run() {
|
||||||
case 3:
|
case 3:
|
||||||
_clearColor = Math::Vector4d(1.0f, 0.0f, 0.0f, 1.0f);
|
_clearColor = Math::Vector4d(1.0f, 0.0f, 0.0f, 1.0f);
|
||||||
break;
|
break;
|
||||||
|
case 4:
|
||||||
|
_clearColor = Math::Vector4d(0.5f, 0.5f, 0.5f, 1.0f);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
@ -140,6 +144,10 @@ void Playground3dEngine::dimRegionInOut() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Playground3dEngine::drawInViewport() {
|
||||||
|
_gfx->drawInViewport();
|
||||||
|
}
|
||||||
|
|
||||||
void Playground3dEngine::drawFrame(int testId) {
|
void Playground3dEngine::drawFrame(int testId) {
|
||||||
_gfx->clear(_clearColor);
|
_gfx->clear(_clearColor);
|
||||||
|
|
||||||
|
@ -148,6 +156,9 @@ void Playground3dEngine::drawFrame(int testId) {
|
||||||
float fov = 45.0f;
|
float fov = 45.0f;
|
||||||
_gfx->setupCameraPerspective(pitch, heading, fov);
|
_gfx->setupCameraPerspective(pitch, heading, fov);
|
||||||
|
|
||||||
|
Common::Rect vp = _gfx->viewport();
|
||||||
|
_gfx->setupViewport(vp.left, _system->getHeight() - vp.top - vp.height(), vp.width(), vp.height());
|
||||||
|
|
||||||
switch (testId) {
|
switch (testId) {
|
||||||
case 1:
|
case 1:
|
||||||
drawAndRotateCube();
|
drawAndRotateCube();
|
||||||
|
@ -158,6 +169,10 @@ void Playground3dEngine::drawFrame(int testId) {
|
||||||
case 3:
|
case 3:
|
||||||
dimRegionInOut();
|
dimRegionInOut();
|
||||||
break;
|
break;
|
||||||
|
case 4:
|
||||||
|
_gfx->setupViewport(vp.left + 40, _system->getHeight() - vp.top - vp.height() + 40, vp.width() - 80, vp.height() - 80);
|
||||||
|
drawInViewport();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ private:
|
||||||
void drawAndRotateCube();
|
void drawAndRotateCube();
|
||||||
void drawPolyOffsetTest();
|
void drawPolyOffsetTest();
|
||||||
void dimRegionInOut();
|
void dimRegionInOut();
|
||||||
|
void drawInViewport();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Playground3d
|
} // End of namespace Playground3d
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue