synched with trunk at revision 34793
This commit is contained in:
@@ -24,9 +24,7 @@
|
||||
#
|
||||
# ***** END GPL LICENSE BLOCK *****
|
||||
|
||||
FILE(GLOB SRC *.cpp)
|
||||
|
||||
SET(INC
|
||||
set(INC
|
||||
../../../../source/kernel/gen_system
|
||||
../../../../intern/string
|
||||
../../../../intern/moto/include
|
||||
@@ -41,6 +39,18 @@ SET(INC
|
||||
../../../../source/blender/blenloader
|
||||
)
|
||||
|
||||
ADD_DEFINITIONS(-DGLEW_STATIC)
|
||||
set(SRC
|
||||
RAS_GLExtensionManager.cpp
|
||||
RAS_ListRasterizer.cpp
|
||||
RAS_OpenGLRasterizer.cpp
|
||||
RAS_VAOpenGLRasterizer.cpp
|
||||
|
||||
BLENDERLIB(bf_oglrasterizer "${SRC}" "${INC}")
|
||||
RAS_GLExtensionManager.h
|
||||
RAS_ListRasterizer.h
|
||||
RAS_OpenGLRasterizer.h
|
||||
RAS_VAOpenGLRasterizer.h
|
||||
)
|
||||
|
||||
add_definitions(-DGLEW_STATIC)
|
||||
|
||||
blender_add_lib(ge_oglrasterizer "${SRC}" "${INC}")
|
||||
|
@@ -1,53 +0,0 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
#
|
||||
# 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 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# 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, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
# All rights reserved.
|
||||
#
|
||||
# The Original Code is: all of this file.
|
||||
#
|
||||
# Contributor(s): none yet.
|
||||
#
|
||||
# ***** END GPL LICENSE BLOCK *****
|
||||
#
|
||||
# Bounce make to subdirectories.
|
||||
#
|
||||
|
||||
LIBNAME = OpenGLrasterizer
|
||||
DIR = $(OCGDIR)/gameengine/$(LIBNAME)
|
||||
|
||||
include nan_compile.mk
|
||||
|
||||
CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
|
||||
|
||||
CPPFLAGS += -I$(NAN_GLEW)/include
|
||||
CPPFLAGS += -I$(OPENGL_HEADERS)
|
||||
CPPFLAGS += -I$(NAN_STRING)/include
|
||||
CPPFLAGS += -I$(NAN_MOTO)/include
|
||||
CPPFLAGS += -I../../../kernel/gen_system
|
||||
CPPFLAGS += -I../../../blender/gpu
|
||||
CPPFLAGS += -I../../../blender/makesdna
|
||||
CPPFLAGS += -I../../../blender/blenlib
|
||||
CPPFLAGS += -I../../../blender/blenkernel
|
||||
CPPFLAGS += -I../../BlenderRoutines
|
||||
CPPFLAGS += -I../../Ketsji
|
||||
CPPFLAGS += -I../../SceneGraph
|
||||
CPPFLAGS += -I..
|
||||
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
|
||||
|
@@ -13,7 +13,7 @@
|
||||
#include "RAS_TexVert.h"
|
||||
#include "MT_assert.h"
|
||||
|
||||
//#ifndef NDEBUG
|
||||
//#if defined(DEBUG)
|
||||
//#ifdef WIN32
|
||||
//#define spit(x) std::cout << x << std::endl;
|
||||
//#endif //WIN32
|
||||
|
@@ -382,7 +382,7 @@ void RAS_OpenGLRasterizer::FlushDebugShapes()
|
||||
continue;
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glColor4f(m_debugShapes[i].m_color[0],m_debugShapes[i].m_color[1],m_debugShapes[i].m_color[2],1.f);
|
||||
|
||||
|
||||
static const MT_Vector3 worldUp(0.,0.,1.);
|
||||
MT_Vector3 norm = m_debugShapes[i].m_param;
|
||||
MT_Matrix3x3 tr;
|
||||
@@ -396,8 +396,8 @@ void RAS_OpenGLRasterizer::FlushDebugShapes()
|
||||
xaxis = MT_cross(norm, worldUp);
|
||||
yaxis = MT_cross(xaxis, norm);
|
||||
tr.setValue(xaxis.x(), xaxis.y(), xaxis.z(),
|
||||
yaxis.x(), yaxis.y(), yaxis.z(),
|
||||
norm.x(), norm.y(), norm.z());
|
||||
yaxis.x(), yaxis.y(), yaxis.z(),
|
||||
norm.x(), norm.y(), norm.z());
|
||||
}
|
||||
MT_Scalar rad = m_debugShapes[i].m_param2.x();
|
||||
int n = (int) m_debugShapes[i].m_param2.y();
|
||||
@@ -413,40 +413,14 @@ void RAS_OpenGLRasterizer::FlushDebugShapes()
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
if(light) glEnable(GL_LIGHTING);
|
||||
if(tex) glEnable(GL_TEXTURE_2D);
|
||||
|
||||
m_debugShapes.clear();
|
||||
}
|
||||
|
||||
void RAS_OpenGLRasterizer::DrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color)
|
||||
{
|
||||
OglDebugShape line;
|
||||
line.m_type = OglDebugShape::LINE;
|
||||
line.m_pos= from;
|
||||
line.m_param = to;
|
||||
line.m_color = color;
|
||||
m_debugShapes.push_back(line);
|
||||
}
|
||||
|
||||
void RAS_OpenGLRasterizer::DrawDebugCircle(const MT_Vector3& center, const MT_Scalar radius, const MT_Vector3& color,
|
||||
const MT_Vector3& normal, int nsector)
|
||||
{
|
||||
OglDebugShape line;
|
||||
line.m_type = OglDebugShape::CIRCLE;
|
||||
line.m_pos= center;
|
||||
line.m_param = normal;
|
||||
line.m_color = color;
|
||||
line.m_param2.x() = radius;
|
||||
line.m_param2.y() = (float) nsector;
|
||||
m_debugShapes.push_back(line);
|
||||
}
|
||||
|
||||
void RAS_OpenGLRasterizer::EndFrame()
|
||||
{
|
||||
|
||||
|
||||
FlushDebugShapes();
|
||||
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
@@ -799,6 +773,7 @@ static RAS_MeshSlot *current_ms;
|
||||
static RAS_MeshObject *current_mesh;
|
||||
static int current_blmat_nr;
|
||||
static GPUVertexAttribs current_gpu_attribs;
|
||||
static Image *current_image;
|
||||
static int CheckMaterialDM(int matnr, void *attribs)
|
||||
{
|
||||
// only draw the current material
|
||||
@@ -809,6 +784,8 @@ static int CheckMaterialDM(int matnr, void *attribs)
|
||||
memcpy(gattribs, ¤t_gpu_attribs, sizeof(GPUVertexAttribs));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
static int CheckTexfaceDM(void *mcol, int index)
|
||||
{
|
||||
|
||||
@@ -836,6 +813,34 @@ static int CheckTexfaceDM(void *mcol, int index)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
static int CheckTexDM(MTFace *tface, MCol *mcol, int matnr)
|
||||
{
|
||||
|
||||
// index is the original face index, retrieve the polygon
|
||||
if (matnr == current_blmat_nr &&
|
||||
(tface == NULL || tface->tpage == current_image)) {
|
||||
// must handle color.
|
||||
if (current_wireframe)
|
||||
return 2;
|
||||
if (current_ms->m_bObjectColor) {
|
||||
MT_Vector4& rgba = current_ms->m_RGBAcolor;
|
||||
glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
// don't use mcol
|
||||
return 2;
|
||||
}
|
||||
if (!mcol) {
|
||||
// we have to set the color from the material
|
||||
unsigned char rgba[4];
|
||||
current_polymat->GetMaterialRGBAColor(rgba);
|
||||
glColor4ubv((const GLubyte *)rgba);
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RAS_OpenGLRasterizer::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
|
||||
{
|
||||
@@ -851,7 +856,14 @@ void RAS_OpenGLRasterizer::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
|
||||
current_ms = &ms;
|
||||
current_mesh = ms.m_mesh;
|
||||
current_wireframe = wireframe;
|
||||
MCol *mcol = (MCol*)ms.m_pDerivedMesh->getFaceDataArray(ms.m_pDerivedMesh, CD_MCOL);
|
||||
// MCol *mcol = (MCol*)ms.m_pDerivedMesh->getFaceDataArray(ms.m_pDerivedMesh, CD_MCOL); /* UNUSED */
|
||||
|
||||
// handle two-side
|
||||
if (current_polymat->GetDrawingMode() & RAS_IRasterizer::KX_TWOSIDE)
|
||||
this->SetCullFace(false);
|
||||
else
|
||||
this->SetCullFace(true);
|
||||
|
||||
if (current_polymat->GetFlag() & RAS_BLENDERGLSL) {
|
||||
// GetMaterialIndex return the original mface material index,
|
||||
// increment by 1 to match what derived mesh is doing
|
||||
@@ -868,7 +880,10 @@ void RAS_OpenGLRasterizer::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
|
||||
ms.m_pDerivedMesh->drawFacesGLSL(ms.m_pDerivedMesh, CheckMaterialDM);
|
||||
GPU_set_material_blend_mode(current_blend_mode);
|
||||
} else {
|
||||
ms.m_pDerivedMesh->drawMappedFacesTex(ms.m_pDerivedMesh, CheckTexfaceDM, mcol);
|
||||
//ms.m_pDerivedMesh->drawMappedFacesTex(ms.m_pDerivedMesh, CheckTexfaceDM, mcol);
|
||||
current_blmat_nr = current_polymat->GetMaterialIndex();
|
||||
current_image = current_polymat->GetBlenderImage();
|
||||
ms.m_pDerivedMesh->drawFacesTex(ms.m_pDerivedMesh, CheckTexDM);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@@ -255,10 +255,29 @@ public:
|
||||
virtual void SetPolygonOffset(float mult, float add);
|
||||
|
||||
virtual void FlushDebugShapes();
|
||||
virtual void DrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color);
|
||||
virtual void DrawDebugCircle(const MT_Vector3& center, const MT_Scalar radius, const MT_Vector3& color,
|
||||
const MT_Vector3& normal, int nsector);
|
||||
|
||||
virtual void DrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color)
|
||||
{
|
||||
OglDebugShape line;
|
||||
line.m_type = OglDebugShape::LINE;
|
||||
line.m_pos= from;
|
||||
line.m_param = to;
|
||||
line.m_color = color;
|
||||
m_debugShapes.push_back(line);
|
||||
}
|
||||
|
||||
virtual void DrawDebugCircle(const MT_Vector3& center, const MT_Scalar radius, const MT_Vector3& color,
|
||||
const MT_Vector3& normal, int nsector)
|
||||
{
|
||||
OglDebugShape line;
|
||||
line.m_type = OglDebugShape::CIRCLE;
|
||||
line.m_pos= center;
|
||||
line.m_param = normal;
|
||||
line.m_color = color;
|
||||
line.m_param2.x() = radius;
|
||||
line.m_param2.y() = (float) nsector;
|
||||
m_debugShapes.push_back(line);
|
||||
}
|
||||
|
||||
std::vector <OglDebugShape> m_debugShapes;
|
||||
|
||||
|
@@ -10,4 +10,11 @@ incs += ' #source/blender/gpu #extern/glew/include ' + env['BF_OPENGL_INC']
|
||||
incs += ' #source/blender/gameengine/Ketsji #source/gameengine/SceneGraph #source/blender/makesdna #source/blender/blenkernel'
|
||||
incs += ' #intern/guardedalloc #source/blender/blenlib'
|
||||
|
||||
env.BlenderLib ( 'bf_oglrasterizer', Split(sources), Split(incs), defines = defs, libtype=['core','player'], priority=[350,75], cxx_compileflags=env['BGE_CXXFLAGS'])
|
||||
if env['WITH_BF_CXX_GUARDEDALLOC']:
|
||||
defs.append('WITH_CXX_GUARDEDALLOC')
|
||||
|
||||
if env['WITH_BF_PYTHON']:
|
||||
incs += ' ' + env['BF_PYTHON_INC']
|
||||
defs.append('WITH_PYTHON')
|
||||
|
||||
env.BlenderLib ( 'ge_oglrasterizer', Split(sources), Split(incs), defines = defs, libtype=['core','player'], priority=[350,75], cxx_compileflags=env['BGE_CXXFLAGS'])
|
||||
|
Reference in New Issue
Block a user