mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-12 03:56:20 +00:00
TETRAEDGE: Fixes for TinyGL rendering, almost works
This commit is contained in:
parent
894a24dd63
commit
7a782f5b24
@ -195,8 +195,8 @@ void Te3DTextureOpenGL::update(const TeImage &img, uint xoff, uint yoff) {
|
||||
|
||||
setAccessName(img.getAccessName().append(".3dtex"));
|
||||
glBindTexture(GL_TEXTURE_2D, _glTexture);
|
||||
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
|
||||
glPixelStorei(GL_UNPACK_LSB_FIRST, 0);
|
||||
glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
|
||||
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
|
||||
|
@ -132,12 +132,13 @@ bool Te3DTextureTinyGL::load(const TeImage &img) {
|
||||
_texHeight = _height;
|
||||
|
||||
tglBindTexture(TGL_TEXTURE_2D, _glTexture);
|
||||
// Note: these are unsupported in TGL but should be the defaults?
|
||||
//tglPixelStorei(TGL_UNPACK_SWAP_BYTES, TGL_FALSE);
|
||||
//tglPixelStorei(TGL_UNPACK_LSB_FIRST, TGL_FALSE);
|
||||
//tglPixelStorei(TGL_UNPACK_ROW_LENGTH, 0);
|
||||
//tglPixelStorei(TGL_UNPACK_SKIP_ROWS, 0);
|
||||
//tglPixelStorei(TGL_UNPACK_SKIP_PIXELS, 0);
|
||||
//tglPixelStorei(TGL_UNPACK_ALIGNMENT, 1);
|
||||
tglPixelStorei(TGL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
const void *imgdata = img.getPixels();
|
||||
if (_format == TeImage::RGB8) {
|
||||
@ -185,11 +186,12 @@ void Te3DTextureTinyGL::update(const TeImage &img, uint xoff, uint yoff) {
|
||||
|
||||
setAccessName(img.getAccessName().append(".3dtex"));
|
||||
tglBindTexture(TGL_TEXTURE_2D, _glTexture);
|
||||
tglPixelStorei(TGL_UNPACK_SWAP_BYTES, 0);
|
||||
tglPixelStorei(TGL_UNPACK_LSB_FIRST, 0);
|
||||
tglPixelStorei(TGL_UNPACK_ROW_LENGTH, 0);
|
||||
tglPixelStorei(TGL_UNPACK_SKIP_ROWS, 0);
|
||||
tglPixelStorei(TGL_UNPACK_SKIP_PIXELS, 0);
|
||||
// Note: these are unsupported in TGL but should be the defaults?
|
||||
//tglPixelStorei(TGL_UNPACK_SWAP_BYTES, TGL_FALSE);
|
||||
//tglPixelStorei(TGL_UNPACK_LSB_FIRST, TGL_FALSE);
|
||||
//tglPixelStorei(TGL_UNPACK_ROW_LENGTH, 0);
|
||||
//tglPixelStorei(TGL_UNPACK_SKIP_ROWS, 0);
|
||||
//tglPixelStorei(TGL_UNPACK_SKIP_PIXELS, 0);
|
||||
tglPixelStorei(TGL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
//const void *imgdata = img.getPixels();
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
namespace Tetraedge {
|
||||
|
||||
TeMeshTinyGL::TeMeshTinyGL() : _glMeshMode(TGL_POINTS), _gltexEnvMode(TGL_MODULATE) {
|
||||
TeMeshTinyGL::TeMeshTinyGL() : _glMeshMode(TGL_POINTS), _gltexEnvMode(TGL_DECAL) {
|
||||
}
|
||||
|
||||
void TeMeshTinyGL::draw() {
|
||||
@ -141,8 +141,8 @@ void TeMeshTinyGL::draw() {
|
||||
if (!renderer->scissorEnabled())
|
||||
tglDisable(TGL_SCISSOR_TEST);
|
||||
|
||||
// TODO: not supported in TGL
|
||||
//tglTexEnvi(TGL_TEXTURE_ENV, TGL_TEXTURE_ENV_MODE, TGL_MODULATE);
|
||||
// TODO: GL_MODULATE not supported in TGL
|
||||
//tglTexEnvi(TGL_TEXTURE_ENV, TGL_TEXTURE_ENV_MODE, TGL_DECAL);
|
||||
tglDisableClientState(TGL_VERTEX_ARRAY);
|
||||
tglDisableClientState(TGL_NORMAL_ARRAY);
|
||||
tglDisableClientState(TGL_COLOR_ARRAY);
|
||||
@ -151,19 +151,19 @@ void TeMeshTinyGL::draw() {
|
||||
|
||||
if (_drawWires && !normals.empty()) {
|
||||
renderer->disableAllLights();
|
||||
error("TODO: Properly implement _drawWires case in TeMesh::draw");
|
||||
/*
|
||||
//error("TODO: Properly implement _drawWires case in TeMesh::draw");
|
||||
///*
|
||||
// TODO: Reimplement without glBegin/glEnd
|
||||
glBegin(TGL_LINES);
|
||||
tglBegin(TGL_LINES);
|
||||
renderer->setCurrentColor(TeColor(255, 255, 255, 255));
|
||||
for (uint i = 0; i < verticies.size(); i++) {
|
||||
glVertex3f(verticies[i].x(), verticies[i].y(), verticies[i].z());
|
||||
glVertex3f(verticies[i].x() + normals[i].x(),
|
||||
tglVertex3f(verticies[i].x(), verticies[i].y(), verticies[i].z());
|
||||
tglVertex3f(verticies[i].x() + normals[i].x(),
|
||||
verticies[i].y() + normals[i].y(),
|
||||
verticies[i].z() + normals[i].z());
|
||||
}
|
||||
glEnd();
|
||||
*/
|
||||
tglEnd();
|
||||
//*/
|
||||
}
|
||||
|
||||
renderer->setMatrixMode(TeRenderer::MM_GL_MODELVIEW);
|
||||
|
@ -134,6 +134,7 @@ public:
|
||||
void dumpTransparentMeshData() const;
|
||||
const TeColor ¤tColor() const { return _currentColor; }
|
||||
|
||||
virtual void updateScreen() = 0;
|
||||
virtual void updateGlobalLight() = 0;
|
||||
virtual void applyMaterial(const TeMaterial &m) = 0;
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "common/textconsole.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/system.h"
|
||||
|
||||
#include "graphics/opengl/system_headers.h"
|
||||
|
||||
@ -99,7 +100,8 @@ void TeRendererOpenGL::init(uint width, uint height) {
|
||||
// Note: original doesn't separate but blends are nicer that way.
|
||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_DONT_CARE);
|
||||
// Original does this, probably not needed?
|
||||
//glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_DONT_CARE);
|
||||
glClearDepth(1.0);
|
||||
glClearStencil(0);
|
||||
_clearColor = TeColor(0, 0, 0, 255);
|
||||
@ -382,6 +384,10 @@ void TeRendererOpenGL::updateGlobalLight() {
|
||||
TeLightOpenGL::updateGlobal();
|
||||
}
|
||||
|
||||
void TeRendererOpenGL::updateScreen() {
|
||||
g_system->updateScreen();
|
||||
}
|
||||
|
||||
Common::String TeRendererOpenGL::vendor() {
|
||||
return Common::String((const char *)glGetString(GL_VENDOR));
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
Common::String vendor() override;
|
||||
void applyMaterial(const TeMaterial &m) override;
|
||||
void updateGlobalLight() override;
|
||||
void updateScreen() override;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -90,9 +90,9 @@ void TeRendererTinyGL::enableZBuffer() {
|
||||
}
|
||||
|
||||
void TeRendererTinyGL::init(uint width, uint height) {
|
||||
Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
|
||||
initGraphics(width, height, &pixelFormat);
|
||||
initGraphics(width, height, nullptr);
|
||||
|
||||
const Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
|
||||
debug(2, "INFO: TinyGL front buffer pixel format: %s", pixelFormat.toString().c_str());
|
||||
TinyGL::createContext(width, height, pixelFormat, 256, true, ConfMan.getBool("dirtyrects"));
|
||||
|
||||
@ -107,9 +107,10 @@ void TeRendererTinyGL::init(uint width, uint height) {
|
||||
tglEnable(TGL_BLEND);
|
||||
tglBlendFunc(TGL_SRC_ALPHA, TGL_ONE_MINUS_SRC_ALPHA);
|
||||
tglDepthFunc(TGL_LEQUAL);
|
||||
tglHint(TGL_PERSPECTIVE_CORRECTION_HINT, TGL_DONT_CARE);
|
||||
// Original does this, probably not needed?
|
||||
//tglHint(TGL_PERSPECTIVE_CORRECTION_HINT, TGL_DONT_CARE);
|
||||
tglClearDepth(1.0);
|
||||
tglClearStencil(0);
|
||||
//tglClearStencil(0);
|
||||
_clearColor = TeColor(0, 0, 0, 255);
|
||||
tglClearColor(0, 0, 0, 1.0);
|
||||
//TeOpenGLExtensions::loadExtensions(); // this does nothing in the game?
|
||||
@ -196,7 +197,7 @@ void TeRendererTinyGL::renderTransparentMeshes() {
|
||||
|
||||
if (meshProperties._scissorEnabled) {
|
||||
tglEnable(TGL_SCISSOR_TEST);
|
||||
// No scissoring in TGL..
|
||||
// TODO: No scissoring in TGL..
|
||||
/*
|
||||
tglScissor(meshProperties._scissorX,
|
||||
meshProperties._scissorY,
|
||||
@ -204,7 +205,7 @@ void TeRendererTinyGL::renderTransparentMeshes() {
|
||||
meshProperties._scissorHeight);*/
|
||||
}
|
||||
// TODO: not supported in TGL
|
||||
//tglTexEnvi(TGL_TEXTURE_ENV, TGL_TEXTURE_ENV_MODE, meshProperties._glTexEnvMode);
|
||||
//tglTexEnvi(TGL_TEXTURE_ENV, TGL_TEXTURE_ENV_MODE, TGL_DECAL/*meshProperties._glTexEnvMode*/);
|
||||
tglDrawElements(TGL_TRIANGLES, meshProperties._vertexCount, TGL_UNSIGNED_SHORT,
|
||||
_transparentMeshVertexNums.data() + vertsDrawn);
|
||||
|
||||
@ -215,7 +216,7 @@ void TeRendererTinyGL::renderTransparentMeshes() {
|
||||
tglEnableClientState(TGL_COLOR_ARRAY);
|
||||
}
|
||||
// TODO: not supported in TGL
|
||||
//tglTexEnvi(TGL_TEXTURE_ENV, TGL_TEXTURE_ENV_MODE, TGL_MODULATE);
|
||||
//tglTexEnvi(TGL_TEXTURE_ENV, TGL_TEXTURE_ENV_MODE, TGL_DECAL);
|
||||
if (meshProperties._scissorEnabled) {
|
||||
tglDisable(TGL_SCISSOR_TEST);
|
||||
}
|
||||
@ -328,8 +329,8 @@ void TeRendererTinyGL::applyMaterial(const TeMaterial &m) {
|
||||
tglTexEnvi(TGL_TEXTURE_ENV, TGL_OPERAND0_ALPHA, TGL_SRC_ALPHA);
|
||||
*/
|
||||
} else {
|
||||
// TODO: not supported in TGL
|
||||
//tglTexEnvi(TGL_TEXTURE_ENV, TGL_TEXTURE_ENV_MODE, TGL_MODULATE);
|
||||
// TODO: GL_MODULATE supported in TGL
|
||||
//tglTexEnvi(TGL_TEXTURE_ENV, TGL_TEXTURE_ENV_MODE, TGL_DECAL);
|
||||
if (m._mode != TeMaterial::MaterialMode1) {
|
||||
tglEnable(TGL_ALPHA_TEST);
|
||||
tglAlphaFunc(TGL_GREATER, 0.5);
|
||||
@ -360,8 +361,8 @@ void TeRendererTinyGL::applyMaterial(const TeMaterial &m) {
|
||||
static const float fullColor[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
TeLightTinyGL::disableAll();
|
||||
tglDisable(TGL_ALPHA_TEST);
|
||||
// TODO: not supported in TGL
|
||||
//tglTexEnvi(TGL_TEXTURE_ENV, TGL_TEXTURE_ENV_MODE, TGL_MODULATE);
|
||||
// TODO: GL_MODULATE not supported in TGL
|
||||
//tglTexEnvi(TGL_TEXTURE_ENV, TGL_TEXTURE_ENV_MODE, TGL_DECAL);
|
||||
tglMaterialfv(TGL_FRONT_AND_BACK, TGL_AMBIENT, fullColor);
|
||||
tglMaterialfv(TGL_FRONT_AND_BACK, TGL_DIFFUSE, fullColor);
|
||||
tglMaterialfv(TGL_FRONT_AND_BACK, TGL_SPECULAR, fullColor);
|
||||
@ -374,8 +375,8 @@ void TeRendererTinyGL::applyMaterial(const TeMaterial &m) {
|
||||
tglDisable(TGL_TEXTURE_GEN_R);
|
||||
tglDisable(TGL_TEXTURE_GEN_Q);
|
||||
} else {
|
||||
// TODO: not supported in TGL
|
||||
//tglTexEnvi(TGL_TEXTURE_ENV, TGL_TEXTURE_ENV_MODE, TGL_MODULATE);
|
||||
// TODO: GL_MODULATE not supported in TGL
|
||||
//tglTexEnvi(TGL_TEXTURE_ENV, TGL_TEXTURE_ENV_MODE, TGL_DECAL);
|
||||
tglEnable(TGL_TEXTURE_GEN_S);
|
||||
tglEnable(TGL_TEXTURE_GEN_T);
|
||||
tglEnable(TGL_TEXTURE_GEN_R);
|
||||
@ -384,8 +385,8 @@ void TeRendererTinyGL::applyMaterial(const TeMaterial &m) {
|
||||
TeLightTinyGL::disableAll();
|
||||
tglDisable(TGL_ALPHA_TEST);
|
||||
enableTexture();
|
||||
// TODO: not supported in TGL
|
||||
//tglTexEnvi(TGL_TEXTURE_ENV, TGL_TEXTURE_ENV_MODE, TGL_MODULATE);
|
||||
// TODO: GL_MODULATE not supported in TGL
|
||||
//tglTexEnvi(TGL_TEXTURE_ENV, TGL_TEXTURE_ENV_MODE, TGL_DECAL);
|
||||
|
||||
const float diffuse[4] = { m._diffuseColor.r() / 255.0f, m._diffuseColor.g() / 255.0f,
|
||||
m._diffuseColor.b() / 255.0f, m._diffuseColor.a() / 255.0f };
|
||||
@ -401,6 +402,23 @@ void TeRendererTinyGL::updateGlobalLight() {
|
||||
TeLightTinyGL::updateGlobal();
|
||||
}
|
||||
|
||||
void TeRendererTinyGL::updateScreen() {
|
||||
Common::List<Common::Rect> dirtyAreas;
|
||||
TinyGL::presentBuffer(dirtyAreas);
|
||||
|
||||
Graphics::Surface glBuffer;
|
||||
TinyGL::getSurfaceRef(glBuffer);
|
||||
|
||||
if (!dirtyAreas.empty()) {
|
||||
for (Common::List<Common::Rect>::iterator itRect = dirtyAreas.begin(); itRect != dirtyAreas.end(); ++itRect) {
|
||||
g_system->copyRectToScreen(glBuffer.getBasePtr((*itRect).left, (*itRect).top), glBuffer.pitch,
|
||||
(*itRect).left, (*itRect).top, (*itRect).width(), (*itRect).height());
|
||||
}
|
||||
}
|
||||
|
||||
g_system->updateScreen();
|
||||
}
|
||||
|
||||
Common::String TeRendererTinyGL::vendor() {
|
||||
return "TinyGL vendor";
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
void shadowMode(enum ShadowMode mode) override;
|
||||
void applyMaterial(const TeMaterial &m) override;
|
||||
void updateGlobalLight() override;
|
||||
void updateScreen() override;
|
||||
Common::String vendor() override;
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user