Removed glh_linear and glu dependencies from viewer.

This commit is contained in:
Shyotl
2014-07-03 02:11:45 -05:00
parent 21f677cf58
commit 9cbcf8fe34
11 changed files with 79 additions and 1839 deletions

View File

@@ -1383,6 +1383,35 @@ void flush_glerror()
glGetError();
}
const std::string getGLErrorString(GLenum error)
{
switch(error)
{
case GL_NO_ERROR:
return "No Error";
case GL_INVALID_ENUM:
return "Invalid Enum";
case GL_INVALID_VALUE:
return "Invalid Value";
case GL_INVALID_OPERATION:
return "Invalid Operation";
case GL_INVALID_FRAMEBUFFER_OPERATION:
return "Invalid Framebuffer Operation";
case GL_OUT_OF_MEMORY:
return "Out of Memory";
case GL_STACK_UNDERFLOW:
return "Stack Underflow";
case GL_STACK_OVERFLOW:
return "Stack Overflow";
#ifdef GL_TABLE_TOO_LARGE
case GL_TABLE_TOO_LARGE:
return "Table too large";
#endif
default:
return "UNKNOWN ERROR";
}
}
//this function outputs gl error to the log file, does not crash the code.
void log_glerror()
{
@@ -1395,17 +1424,8 @@ void log_glerror()
error = glGetError();
while (LL_UNLIKELY(error))
{
GLubyte const * gl_error_msg = gluErrorString(error);
if (NULL != gl_error_msg)
{
llwarns << "GL Error: " << error << " GL Error String: " << gl_error_msg << llendl ;
}
else
{
// gluErrorString returns NULL for some extensions' error codes.
// you'll probably have to grep for the number in glext.h.
llwarns << "GL Error: UNKNOWN 0x" << std::hex << error << std::dec << llendl;
}
std::string gl_error_msg = getGLErrorString(error);
llwarns << "GL Error: 0x" << std::hex << error << std::dec << " GL Error String: " << gl_error_msg << llendl;
error = glGetError();
}
}
@@ -1419,27 +1439,13 @@ void do_assert_glerror()
while (LL_UNLIKELY(error))
{
quit = TRUE;
GLubyte const * gl_error_msg = gluErrorString(error);
if (NULL != gl_error_msg)
std::string gl_error_msg = getGLErrorString(error);
LL_WARNS("RenderState") << "GL Error: 0x" << std::hex << error << std::dec << LL_ENDL;
LL_WARNS("RenderState") << "GL Error String: " << gl_error_msg << LL_ENDL;
if (gDebugSession)
{
LL_WARNS("RenderState") << "GL Error:" << error<< LL_ENDL;
LL_WARNS("RenderState") << "GL Error String:" << gl_error_msg << LL_ENDL;
if (gDebugSession)
{
gFailLog << "GL Error:" << gl_error_msg << std::endl;
}
}
else
{
// gluErrorString returns NULL for some extensions' error codes.
// you'll probably have to grep for the number in glext.h.
LL_WARNS("RenderState") << "GL Error: UNKNOWN 0x" << std::hex << error << std::dec << LL_ENDL;
if (gDebugSession)
{
gFailLog << "GL Error: UNKNOWN 0x" << std::hex << error << std::dec << std::endl;
}
gFailLog << "GL Error: 0x" << std::hex << error << std::dec << " GL Error String: " << gl_error_msg << std::endl;
}
error = glGetError();
}

View File

@@ -44,7 +44,6 @@
#include "llinstancetracker.h"
#include "llglheaders.h"
#include "glh/glh_linear.h"
extern BOOL gDebugGL;
extern BOOL gDebugSession;

View File

@@ -41,7 +41,6 @@
# include "GL/glx.h"
# define GL_GLEXT_PROTOTYPES 1
# include "GL/glext.h"
# include "GL/glu.h"
# include "GL/glx.h"
# define GLX_GLXEXT_PROTOTYPES 1
# include "GL/glxext.h"
@@ -266,7 +265,6 @@ extern PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT;
#define GL_GLEXT_PROTOTYPES 1
#include "GL/gl.h"
#include "GL/glext.h"
#include "GL/glu.h"
// The __APPLE__ kludge is to make glh_extensions.h not symbol-clash horribly
# define __APPLE__
@@ -282,7 +280,6 @@ extern PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT;
// quotes so we get libraries/.../GL/ version
#include "GL/gl.h"
#include "GL/glext.h"
#include "GL/glu.h"
#if LL_LINUX && !LL_MESA_HEADLESS
@@ -551,7 +548,6 @@ extern PFNGLBINDBUFFERRANGEPROC glBindBufferRange;
//----------------------------------------------------------------------------
#include <GL/gl.h>
#include <GL/glu.h>
// quotes so we get libraries/.../GL/ version
#include "GL/glext.h"
@@ -789,7 +785,6 @@ extern PFNGLGETDEBUGMESSAGELOGARBPROC glGetDebugMessageLogARB;
// LL_DARWIN
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#define GL_EXT_separate_specular_color 1
#include <OpenGL/glext.h>

View File

@@ -43,7 +43,6 @@
#include "llstrider.h"
#include "llpointer.h"
#include "llglheaders.h"
#include "glh/glh_linear.h"
#include "llrect.h"
class LLVertexBuffer;

File diff suppressed because it is too large Load Diff

View File

@@ -30,7 +30,6 @@
#if LL_MESA_HEADLESS
#include "llwindow.h"
#include "GL/glu.h"
#include "GL/osmesa.h"
class LLWindowMesaHeadless : public LLWindow

View File

@@ -1578,9 +1578,11 @@ bool LLModelLoader::doLoadModel()
mesh_scale *= normalized_transformation;
normalized_transformation = mesh_scale;
glh::matrix4f inv_mat((F32*) normalized_transformation.mMatrix);
inv_mat = inv_mat.inverse();
LLMatrix4 inverse_normalized_transformation(inv_mat.m);
LLMatrix4a inv_mat;
inv_mat.loadu(normalized_transformation);
inv_mat.invert();
LLMatrix4 inverse_normalized_transformation(inv_mat.getF32ptr());
domSkin::domBind_shape_matrix* bind_mat = skin->getBind_shape_matrix();

View File

@@ -73,7 +73,7 @@
const LLMatrix4a& glh_get_current_modelview();
const LLMatrix4a& glh_get_current_projection();
// Functions pulled from llviewerdisplay.cpp
bool get_hud_matrices(glh::matrix4f &proj, glh::matrix4f &model);
bool get_hud_matrices(LLMatrix4a &proj, LLMatrix4a &model);
// Warning: make sure these two match!
const LLPanelPrimMediaControls::EZoomLevel LLPanelPrimMediaControls::kZoomLevels[] = { ZOOM_NONE, ZOOM_MEDIUM };
@@ -615,15 +615,11 @@ void LLPanelPrimMediaControls::updateShape()
mat.setMul(glh_get_current_projection(),glh_get_current_modelview());
}
else {
glh::matrix4f proj, modelview;
LLMatrix4a proj, modelview;
if (get_hud_matrices(proj, modelview))
{
//mat = proj * modelview;
LLMatrix4a P;
P.loadu(proj.m);
LLMatrix4a M;
M.loadu(modelview.m);
mat.setMul(P,M);
mat.setMul(proj,modelview);
}
}
LLVector4a min;

View File

@@ -55,28 +55,6 @@
U32 LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
//glu pick matrix implementation borrowed from Mesa3D
glh::matrix4f gl_pick_matrix(GLfloat x, GLfloat y, GLfloat width, GLfloat height, GLint* viewport)
{
GLfloat m[16];
GLfloat sx, sy;
GLfloat tx, ty;
sx = viewport[2] / width;
sy = viewport[3] / height;
tx = (viewport[2] + 2.f * (viewport[0] - x)) / width;
ty = (viewport[3] + 2.f * (viewport[1] - y)) / height;
#define M(row,col) m[col*4+row]
M(0,0) = sx; M(0,1) = 0.f; M(0,2) = 0.f; M(0,3) = tx;
M(1,0) = 0.f; M(1,1) = sy; M(1,2) = 0.f; M(1,3) = ty;
M(2,0) = 0.f; M(2,1) = 0.f; M(2,2) = 1.f; M(2,3) = 0.f;
M(3,0) = 0.f; M(3,1) = 0.f; M(3,2) = 0.f; M(3,3) = 1.f;
#undef M
return glh::matrix4f(m);
}
LLViewerCamera::LLViewerCamera() : LLCamera()
{
calcProjection(getFar());
@@ -263,20 +241,24 @@ void LLViewerCamera::setPerspective(BOOL for_selection,
gGL.matrixMode( LLRender::MM_PROJECTION );
gGL.loadIdentity();
glh::matrix4f proj_mat;
LLMatrix4a proj_mat;
proj_mat.setIdentity();
if (for_selection)
{
// make a tiny little viewport
// anything drawn into this viewport will be "selected"
GLint viewport[4];
viewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft;
viewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom;
viewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth();
viewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight();
const LLRect& rect = gViewerWindow->getWorldViewRectRaw();
proj_mat = gl_pick_matrix(x+width/2.f, y_from_bot+height/2.f, (GLfloat) width, (GLfloat) height, viewport);
const F32 scale_x = rect.getWidth() / F32(width);
const F32 scale_y = rect.getHeight() / F32(height);
const F32 trans_x = scale_x + (2.f * (rect.mLeft - x)) / F32(width) - 1.f;
const F32 trans_y = scale_y + (2.f * (rect.mBottom - y_from_bot)) / F32(height) - 1.f;
//Generate a pick matrix
proj_mat.applyScale_affine(scale_x, scale_y, 1.f);
proj_mat.setTranslate_affine(LLVector3(trans_x, trans_y, 0.f));
if (limit_select_distance)
{
@@ -310,24 +292,18 @@ void LLViewerCamera::setPerspective(BOOL for_selection,
float offset = mZoomFactor - 1.f;
int pos_y = mZoomSubregion / llceil(mZoomFactor);
int pos_x = mZoomSubregion - (pos_y*llceil(mZoomFactor));
glh::matrix4f translate;
translate.set_translate(glh::vec3f(offset - (F32)pos_x * 2.f, offset - (F32)pos_y * 2.f, 0.f));
glh::matrix4f scale;
scale.set_scale(glh::vec3f(mZoomFactor, mZoomFactor, 1.f));
proj_mat = scale*proj_mat;
proj_mat = translate*proj_mat;
proj_mat.applyScale_affine(mZoomFactor,mZoomFactor,1.f);
proj_mat.applyTranslation_affine(offset - (F32)pos_x * 2.f, offset - (F32)pos_y * 2.f, 0.f);
}
calcProjection(z_far); // Update the projection matrix cache
LLMatrix4a proj_mata;
proj_mata.loadu(proj_mat.m);
proj_mata.mul(gGL.genPersp(fov_y,aspect,z_near,z_far));
proj_mat.mul(gGL.genPersp(fov_y,aspect,z_near,z_far));
gGL.loadMatrix(proj_mata);
gGL.loadMatrix(proj_mat);
gGLProjection = proj_mata;
gGLProjection = proj_mat;
gGL.matrixMode(LLRender::MM_MODELVIEW );

View File

@@ -1264,7 +1264,7 @@ LLRect get_whole_screen_region()
return whole_screen;
}
bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::matrix4f &model)
bool get_hud_matrices(const LLRect& screen_region, LLMatrix4a &proj, LLMatrix4a &model)
{
if (isAgentAvatarValid() && gAgentAvatarp->hasHUDAttachment())
{
@@ -1272,28 +1272,24 @@ bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::mat
LLBBox hud_bbox = gAgentAvatarp->getHUDBBox();
F32 hud_depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f);
proj.set_value(gGL.genOrtho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, hud_depth).getF32ptr());
proj.element(2,2) = -0.01f;
proj = gGL.genOrtho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, hud_depth);
proj.getRow<2>().copyComponent<2>(LLVector4a(-0.01f));
F32 aspect_ratio = LLViewerCamera::getInstance()->getAspect();
glh::matrix4f mat;
F32 scale_x = (F32)gViewerWindow->getWorldViewWidthScaled() / (F32)screen_region.getWidth();
F32 scale_y = (F32)gViewerWindow->getWorldViewHeightScaled() / (F32)screen_region.getHeight();
mat.set_scale(glh::vec3f(scale_x, scale_y, 1.f));
mat.set_translate(
glh::vec3f(clamp_rescale((F32)(screen_region.getCenterX() - screen_region.mLeft), 0.f, (F32)gViewerWindow->getWorldViewWidthScaled(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio),
clamp_rescale((F32)(screen_region.getCenterY() - screen_region.mBottom), 0.f, (F32)gViewerWindow->getWorldViewHeightScaled(), 0.5f * scale_y, -0.5f * scale_y),
0.f));
proj *= mat;
glh::matrix4f tmp_model((GLfloat*) OGL_TO_CFR_ROTATION.getF32ptr());
mat.set_scale(glh::vec3f(zoom_level, zoom_level, zoom_level));
mat.set_translate(glh::vec3f(-hud_bbox.getCenterLocal().mV[VX] + (hud_depth * 0.5f), 0.f, 0.f));
tmp_model *= mat;
model = tmp_model;
proj.applyTranslation_affine(
clamp_rescale((F32)(screen_region.getCenterX() - screen_region.mLeft), 0.f, (F32)gViewerWindow->getWorldViewWidthScaled(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio),
clamp_rescale((F32)(screen_region.getCenterY() - screen_region.mBottom), 0.f, (F32)gViewerWindow->getWorldViewHeightScaled(), 0.5f * scale_y, -0.5f * scale_y),
0.f);
proj.applyScale_affine(scale_x, scale_y, 1.f);
model = OGL_TO_CFR_ROTATION;
model.applyTranslation_affine(LLVector3(-hud_bbox.getCenterLocal().mV[VX] + (hud_depth * 0.5f), 0.f, 0.f));
model.applyScale_affine(zoom_level);
return TRUE;
}
else
@@ -1302,7 +1298,7 @@ bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::mat
}
}
bool get_hud_matrices(glh::matrix4f &proj, glh::matrix4f &model)
bool get_hud_matrices(LLMatrix4a &proj, LLMatrix4a &model)
{
LLRect whole_screen = get_whole_screen_region();
return get_hud_matrices(whole_screen, proj, model);
@@ -1316,14 +1312,9 @@ BOOL setup_hud_matrices()
BOOL setup_hud_matrices(const LLRect& screen_region)
{
glh::matrix4f P, M;
bool result = get_hud_matrices(screen_region, P, M);
LLMatrix4a proj, model;
bool result = get_hud_matrices(screen_region, proj, model);
if (!result) return result;
LLMatrix4a proj;
proj.loadu(P.m);
LLMatrix4a model;
model.loadu(M.m);
// set up transform to keep HUD objects in front of camera
gGL.matrixMode(LLRender::MM_PROJECTION);

View File

@@ -473,32 +473,6 @@
</map>
</map>
</map>
<key>freeglut</key>
<map>
<key>copyright</key>
<string>Copyright (c) 1999-2000 Pawel W. Olszta.</string>
<key>description</key>
<string>OpenSource alternative to OpenGL Utility Toolkit</string>
<key>license</key>
<string>freeglut</string>
<key>packages</key>
<map>
<key>windows</key>
<map>
<key>md5sum</key>
<string>74758efd7fc6246f704ea702c4b3e310</string>
<key>url</key>
<uri>https://bitbucket.org/SingularityViewer/libraries/downloads/freeglut-2.6.0-windows-20110214.tar.bz2</uri>
</map>
<key>windows64</key>
<map>
<key>md5sum</key>
<string>74758efd7fc6246f704ea702c4b3e310</string>
<key>url</key>
<uri>https://bitbucket.org/SingularityViewer/libraries/downloads/freeglut-2.6.0-windows-20110214.tar.bz2</uri>
</map>
</map>
</map>
<key>freetype</key>
<map>
<key>copyright</key>
@@ -1735,37 +1709,6 @@ your work.
<key>url</key>
<string>http://www.fmod.org/ifmodlicense.html</string>
</map>
<key>freeglut</key>
<map>
<key>text</key>
<string>Freeglut Copyright
------------------
Freeglut code without an explicit copyright is covered by the following
copyright:
Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Pawel W. Olszta shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Pawel W. Olszta.
</string>
</map>
<key>freetype</key>
<map>
<key>url</key>
@@ -1796,51 +1739,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
</string>
</map>
<key>glh_linear</key>
<map>
<key>text</key>
<string>glh - is a platform-indepenedent C++ OpenGL helper library
Copyright (c) 2000 Cass Everitt
Copyright (c) 2000 NVIDIA Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:
Redistributions of source code must retain the above
copyright notice, this list of conditions and the following
disclaimer.
Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials
provided with the distribution.
The names of contributors to this software may not be used
to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Cass Everitt - cass@r3.nu
</string>
</map>
<key>glut</key>
<map>
<key>url</key>
<string>http://www.xmission.com/~nate/glut/README-win32.txt</string>
</map>
<key>gpl</key>
<map>
<key>url</key>