convert last remaining GLU calls in BGE
Focus is on getting rid of GLU. We expect UPBGE to replace current BGE. Part of T49042
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "glew-mx.h"
|
||||
#include "GPU_matrix.h"
|
||||
#include "KX_Camera.h"
|
||||
#include "KX_Scene.h"
|
||||
#include "KX_PythonInit.h"
|
||||
@@ -1048,19 +1048,21 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, getScreenPosition,
|
||||
}
|
||||
|
||||
const GLint *viewport;
|
||||
GLdouble win[3];
|
||||
GLdouble modelmatrix[16];
|
||||
GLdouble projmatrix[16];
|
||||
GLfloat vec[3];
|
||||
GLfloat win[3];
|
||||
GLfloat modelmatrix[4][4];
|
||||
GLfloat projmatrix[4][4];
|
||||
|
||||
MT_Matrix4x4 m_modelmatrix = this->GetWorldToCamera();
|
||||
MT_Matrix4x4 m_projmatrix = this->GetProjectionMatrix();
|
||||
|
||||
m_modelmatrix.getValue(modelmatrix);
|
||||
m_projmatrix.getValue(projmatrix);
|
||||
vect.getValue(vec);
|
||||
m_modelmatrix.getValue((float*) modelmatrix);
|
||||
m_projmatrix.getValue((float*) projmatrix);
|
||||
|
||||
viewport = KX_GetActiveEngine()->GetCanvas()->GetViewPort();
|
||||
|
||||
gluProject(vect[0], vect[1], vect[2], modelmatrix, projmatrix, viewport, &win[0], &win[1], &win[2]);
|
||||
gpuProject(vec, modelmatrix, projmatrix, viewport, win);
|
||||
|
||||
vect[0] = (win[0] - viewport[0]) / viewport[2];
|
||||
vect[1] = (win[1] - viewport[1]) / viewport[3];
|
||||
@@ -1087,36 +1089,33 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, getScreenVect,
|
||||
|
||||
y = 1.0 - y; //to follow Blender window coordinate system (Top-Down)
|
||||
|
||||
MT_Vector3 vect;
|
||||
MT_Point3 campos, screenpos;
|
||||
|
||||
const GLint *viewport;
|
||||
GLdouble win[3];
|
||||
GLdouble modelmatrix[16];
|
||||
GLdouble projmatrix[16];
|
||||
GLfloat vec[3];
|
||||
GLfloat win[3];
|
||||
GLfloat modelmatrix[4][4];
|
||||
GLfloat projmatrix[4][4];
|
||||
|
||||
MT_Matrix4x4 m_modelmatrix = this->GetWorldToCamera();
|
||||
MT_Matrix4x4 m_projmatrix = this->GetProjectionMatrix();
|
||||
|
||||
m_modelmatrix.getValue(modelmatrix);
|
||||
m_projmatrix.getValue(projmatrix);
|
||||
m_modelmatrix.getValue((float*) modelmatrix);
|
||||
m_projmatrix.getValue((float*) projmatrix);
|
||||
|
||||
viewport = KX_GetActiveEngine()->GetCanvas()->GetViewPort();
|
||||
|
||||
vect[0] = x * viewport[2];
|
||||
vect[1] = y * viewport[3];
|
||||
vec[0] = x * viewport[2];
|
||||
vec[1] = y * viewport[3];
|
||||
|
||||
vect[0] += viewport[0];
|
||||
vect[1] += viewport[1];
|
||||
vec[0] += viewport[0];
|
||||
vec[1] += viewport[1];
|
||||
|
||||
vect[2] = 0.f;
|
||||
vec[2] = 0.f;
|
||||
|
||||
gluUnProject(vect[0], vect[1], vect[2], modelmatrix, projmatrix, viewport, &win[0], &win[1], &win[2]);
|
||||
|
||||
campos = this->GetCameraLocation();
|
||||
screenpos = MT_Point3(win[0], win[1], win[2]);
|
||||
vect = campos-screenpos;
|
||||
gpuUnProject(vec, modelmatrix, projmatrix, viewport, win);
|
||||
|
||||
MT_Point3 campos = this->GetCameraLocation();
|
||||
MT_Point3 screenpos(win[0], win[1], win[2]);
|
||||
MT_Vector3 vect = campos - screenpos;
|
||||
vect.normalize();
|
||||
return PyObjectFrom(vect);
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@
|
||||
#include "RAS_CameraData.h"
|
||||
#include "BLI_math.h"
|
||||
|
||||
#include "glew-mx.h"
|
||||
#include "GPU_matrix.h"
|
||||
|
||||
// constructor
|
||||
KX_Dome::KX_Dome (
|
||||
@@ -1685,7 +1685,7 @@ void KX_Dome::DrawEnvMap(void)
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
gluLookAt(0.0f,0.0f,1.0f, 0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f);
|
||||
gpuLookAt(0.0f,0.0f,1.0f, 0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f);
|
||||
|
||||
glPolygonMode(GL_FRONT, GL_FILL);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
@@ -1830,7 +1830,7 @@ void KX_Dome::DrawDomeFisheye(void)
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
gluLookAt(0.0f,-1.0f,0.0f, 0.0f,0.0f,0.0f, 0.0f,0.0f,1.0f);
|
||||
gpuLookAt(0.0f,-1.0f,0.0f, 0.0f,0.0f,0.0f, 0.0f,0.0f,1.0f);
|
||||
|
||||
if (m_drawingmode == RAS_IRasterizer::KX_WIREFRAME)
|
||||
glPolygonMode(GL_FRONT, GL_LINE);
|
||||
@@ -1913,7 +1913,7 @@ void KX_Dome::DrawPanorama(void)
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
gluLookAt(0.0f,-1.0f,0.0f, 0.0f,0.0f,0.0f, 0.0f,0.0f,1.0f);
|
||||
gpuLookAt(0.0f,-1.0f,0.0f, 0.0f,0.0f,0.0f, 0.0f,0.0f,1.0f);
|
||||
|
||||
if (m_drawingmode == RAS_IRasterizer::KX_WIREFRAME)
|
||||
glPolygonMode(GL_FRONT, GL_LINE);
|
||||
@@ -1981,7 +1981,7 @@ void KX_Dome::DrawDomeWarped(void)
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
gluLookAt(0.0f, 0.0f, 1.0f, 0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f);
|
||||
gpuLookAt(0.0f, 0.0f, 1.0f, 0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f);
|
||||
|
||||
if (m_drawingmode == RAS_IRasterizer::KX_WIREFRAME)
|
||||
glPolygonMode(GL_FRONT, GL_LINE);
|
||||
|
Reference in New Issue
Block a user