scummvm/graphics/tinygl/get.cpp

113 lines
2.8 KiB
C++
Raw Normal View History

2021-12-26 21:19:38 +01:00
/* ScummVM - Graphic Adventure Engine
2014-08-13 18:52:52 +02:00
*
2021-12-26 21:19:38 +01:00
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
2014-08-13 18:52:52 +02:00
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
2014-08-13 18:52:52 +02:00
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2014-08-13 18:52:52 +02:00
*
*/
/*
* This file is based on, or a modified version of code from TinyGL (C) 1997-2022 Fabrice Bellard,
* which is licensed under the MIT license (see LICENSE).
2014-08-13 18:52:52 +02:00
* It also has modifications by the ResidualVM-team, which are covered under the GPLv2 (or later).
*/
2009-05-08 07:32:33 +00:00
#include "graphics/tinygl/zgl.h"
namespace TinyGL {
void GLContext::gl_GetIntegerv(TGLenum pname, TGLint *data) {
2008-07-29 19:28:19 +00:00
switch (pname) {
2006-05-16 14:52:36 +00:00
case TGL_VIEWPORT:
data[0] = viewport.xmin;
data[1] = viewport.ymin;
data[2] = viewport.xsize;
data[3] = viewport.ysize;
2006-05-16 14:52:36 +00:00
break;
2008-07-29 19:28:19 +00:00
case TGL_MAX_MODELVIEW_STACK_DEPTH:
2021-12-27 13:22:38 +01:00
*data = MAX_MODELVIEW_STACK_DEPTH;
2008-07-29 19:28:19 +00:00
break;
case TGL_MAX_PROJECTION_STACK_DEPTH:
2021-12-27 13:22:38 +01:00
*data = MAX_PROJECTION_STACK_DEPTH;
2008-07-29 19:28:19 +00:00
break;
case TGL_MAX_LIGHTS:
2021-12-27 13:22:38 +01:00
*data = T_MAX_LIGHTS;
2008-07-29 19:28:19 +00:00
break;
case TGL_MAX_TEXTURE_SIZE:
*data = _textureSize;
2008-07-29 19:28:19 +00:00
break;
case TGL_MAX_TEXTURE_STACK_DEPTH:
2021-12-27 13:22:38 +01:00
*data = MAX_TEXTURE_STACK_DEPTH;
2008-07-29 19:28:19 +00:00
break;
case TGL_BLEND:
*data = blending_enabled;
break;
2014-07-04 08:43:19 +02:00
case TGL_ALPHA_TEST:
*data = alpha_test_enabled;
2014-07-04 08:43:19 +02:00
break;
case TGL_DEPTH_TEST:
*data = depth_test_enabled;
break;
case TGL_STENCIL_TEST:
*data = stencil_test_enabled;
break;
2008-07-29 19:28:19 +00:00
default:
2014-07-04 08:43:19 +02:00
error("tglGet: option not implemented");
2008-07-29 19:28:19 +00:00
break;
}
}
void GLContext::gl_GetFloatv(TGLenum pname, TGLfloat *data) {
int mnr = 0; // just a trick to return the correct matrix
2008-07-29 19:28:19 +00:00
switch (pname) {
case TGL_TEXTURE_MATRIX:
mnr++;
// fall through
2008-07-29 19:28:19 +00:00
case TGL_PROJECTION_MATRIX:
mnr++;
// fall through
case TGL_MODELVIEW_MATRIX: {
float *p = &matrix_stack_ptr[mnr]->_m[0][0];
for (int i = 0; i < 4; i++) {
*data++ = p[0];
*data++ = p[4];
*data++ = p[8];
*data++ = p[12];
p++;
}
}
break;
2008-07-29 19:28:19 +00:00
case TGL_LINE_WIDTH:
2021-12-27 13:22:38 +01:00
*data = 1.0f;
2008-07-29 19:28:19 +00:00
break;
case TGL_LINE_WIDTH_RANGE:
2021-12-27 13:22:38 +01:00
data[0] = data[1] = 1.0f;
2008-07-29 19:28:19 +00:00
break;
case TGL_POINT_SIZE:
2021-12-27 13:22:38 +01:00
*data = 1.0f;
2008-07-29 19:28:19 +00:00
break;
case TGL_POINT_SIZE_RANGE:
2021-12-27 13:22:38 +01:00
data[0] = data[1] = 1.0f;
2013-12-08 11:29:11 -08:00
break;
2008-07-29 19:28:19 +00:00
default:
warning("gl_GetFloatv: unknown pname");
2008-07-29 19:28:19 +00:00
break;
}
}
} // end of namespace TinyGL