Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-04-24 10:40:15 +0400
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-04-24 10:40:15 +0400
commit63048b6cf4358dc9231e0704e03e0f8d5729a174 (patch)
tree33a1047d2d9007021a78ab2c2fbb8fc5d06727c5 /source/gameengine/Rasterizer
parenta46f456e92b14d986022b301757a7bad3c4c76b5 (diff)
Synchronise game engine with Tuhopuu2 tree.
Diffstat (limited to 'source/gameengine/Rasterizer')
-rw-r--r--source/gameengine/Rasterizer/RAS_IRasterizer.h109
-rw-r--r--source/gameengine/Rasterizer/RAS_MeshObject.cpp90
-rw-r--r--source/gameengine/Rasterizer/RAS_MeshObject.h8
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp32
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h1
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py12
6 files changed, 158 insertions, 94 deletions
diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h
index 9871c0b67d6..44823836450 100644
--- a/source/gameengine/Rasterizer/RAS_IRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h
@@ -46,7 +46,6 @@ class RAS_IPolyMaterial;
/**
* 3D rendering device context interface.
*/
-
class RAS_IRasterizer
{
@@ -54,9 +53,14 @@ public:
RAS_IRasterizer(RAS_ICanvas* canv){};
virtual ~RAS_IRasterizer(){};
+ /**
+ */
enum {
RAS_RENDER_3DPOLYGON_TEXT = 16384
};
+ /**
+ * Drawing types
+ */
enum {
KX_BOUNDINGBOX = 1,
KX_WIREFRAME,
@@ -65,47 +69,101 @@ public:
KX_TEXTURED
};
+ /**
+ * Valid SetDepthMask parameters
+ */
enum {
KX_DEPTHMASK_ENABLED =1,
KX_DEPTHMASK_DISABLED
};
+ /**
+ */
enum {
KX_TWOSIDE = 512,
KX_LINES = 32768
};
+ /**
+ * Stereo mode types
+ */
enum {
RAS_STEREO_NOSTEREO = 1,
RAS_STEREO_QUADBUFFERED,
RAS_STEREO_ABOVEBELOW,
RAS_STEREO_INTERLACED
};
+ /**
+ * Render pass identifiers for stereo.
+ */
enum {
RAS_STEREO_LEFTEYE = 1,
RAS_STEREO_RIGHTEYE
};
+ /**
+ * SetDepthMask enables or disables writing a fragment's depth value
+ * to the Z buffer.
+ */
virtual void SetDepthMask(int depthmask)=0;
+ /**
+ * SetMaterial sets the material settings for subsequent primitives
+ * to be rendered with.
+ * The material will be cached.
+ */
virtual void SetMaterial(const RAS_IPolyMaterial& mat)=0;
+ /**
+ * Init initialises the renderer.
+ */
virtual bool Init()=0;
+ /**
+ * Exit cleans up the renderer.
+ */
virtual void Exit()=0;
+ /**
+ * BeginFrame is called at the start of each frame.
+ */
virtual bool BeginFrame(int drawingmode, double time)=0;
+ /**
+ * ClearDepthBuffer clears the depth buffer.
+ */
virtual void ClearDepthBuffer()=0;
+ /**
+ * ClearCachingInfo clears the currently cached material.
+ */
virtual void ClearCachingInfo(void)=0;
+ /**
+ * EndFrame is called at the end of each frame.
+ */
virtual void EndFrame()=0;
/**
- * SetRenderArea sets the render area in the 2d canvas
+ * SetRenderArea sets the render area from the 2d canvas
*/
virtual void SetRenderArea()=0;
// Stereo Functions
+ /**
+ * SetStereoMode will set the stereo mode
+ */
virtual void SetStereoMode(const int stereomode)=0;
+ /**
+ * Stereo can be used to query if the rasterizer is in stereo mode.
+ * @return true if stereo mode is enabled.
+ */
virtual bool Stereo()=0;
+ /**
+ * Sets which eye buffer subsequent primitives will be rendered to.
+ */
virtual void SetEye(const int eye)=0;
+ /**
+ */
virtual void SetEyeSeparation(const float eyeseparation)=0;
+ /**
+ */
virtual void SetFocalLength(const float focallength)=0;
-
+ /**
+ * SwapBuffers swaps the back buffer with the front buffer.
+ */
virtual void SwapBuffers()=0;
// Drawing Functions
@@ -129,7 +187,7 @@ public:
bool useObjectColor,
const MT_Vector4& rgbacolor)=0;
/**
- * IndexPrimitivesEx: See IndexPrimitives.
+ * @copydoc IndexPrimitives
* IndexPrimitivesEx will renormalize faces if @param vertexarrays[i].getFlag() & TV_CALCFACENORMAL
*/
virtual void IndexPrimitives_Ex( const vecVertexArray& vertexarrays,
@@ -159,13 +217,21 @@ public:
* @param mat The projection matrix.
*/
virtual void SetProjectionMatrix(MT_Matrix4x4 & mat)=0;
+ /**
+ * Sets the modelview matrix.
+ */
virtual void SetViewMatrix(const MT_Matrix4x4 & mat,
const MT_Vector3& campos,
const MT_Point3 &camLoc,
const MT_Quaternion &camOrientQuat)=0;
+ /**
+ */
virtual const MT_Point3& GetCameraPosition()=0;
+ /**
+ */
virtual void LoadViewMatrix()=0;
-
+ /**
+ */
virtual void SetFog(float start,
float dist,
float r,
@@ -177,9 +243,14 @@ public:
float b)=0;
virtual void SetFogStart(float start)=0;
+ /**
+ */
virtual void SetFogEnd(float end)=0;
-
+ /**
+ */
virtual void DisplayFog()=0;
+ /**
+ */
virtual void DisableFog()=0;
virtual void SetBackColor(float red,
@@ -191,18 +262,34 @@ public:
* @param drawingmode = KX_BOUNDINGBOX, KX_WIREFRAME, KX_SOLID, KX_SHADED or KX_TEXTURED.
*/
virtual void SetDrawingMode(int drawingmode)=0;
- virtual int GetDrawingMode()=0;
-
+ /**
+ * @return the current drawing mode: KX_BOUNDINGBOX, KX_WIREFRAME, KX_SOLID, KX_SHADED or KX_TEXTURED.
+ */
+ virtual int GetDrawingMode()=0;
+ /**
+ */
virtual void EnableTextures(bool enable)=0;
-
+ /**
+ * Sets face culling
+ */
virtual void SetCullFace(bool enable)=0;
/**
* Sets wireframe mode.
*/
virtual void SetLines(bool enable)=0;
-
+ /**
+ */
virtual double GetTime()=0;
-
+ /**
+ * Generates a projection matrix from the specified frustum.
+ * @param left the left clipping plane
+ * @param right the right clipping plane
+ * @param bottom the bottom clipping plane
+ * @param top the top clipping plane
+ * @param frustnear the near clipping plane
+ * @param frustfar the far clipping plane
+ * @return a 4x4 matrix representing the projection transform.
+ */
virtual MT_Matrix4x4 GetFrustumMatrix(
float left,
float right,
diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp
index ce86d52d2bb..79ec632ce73 100644
--- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp
+++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp
@@ -43,16 +43,14 @@ STR_String RAS_MeshObject::s_emptyname = "";
KX_ArrayOptimizer::~KX_ArrayOptimizer()
{
- int i = 0;
-
for (vector<KX_VertexArray*>::iterator itv = m_VertexArrayCache1.begin();
- !(itv == m_VertexArrayCache1.end());itv++)
+ !(itv == m_VertexArrayCache1.end());++itv)
{
delete (*itv);
}
for (vector<KX_IndexArray*>::iterator iti = m_IndexArrayCache1.begin();
- !(iti == m_IndexArrayCache1.end());iti++)
+ !(iti == m_IndexArrayCache1.end());++iti)
{
delete (*iti);
}
@@ -99,43 +97,23 @@ int RAS_MeshObject::NumMaterials()
return m_materials.size();
}
-
-
const STR_String& RAS_MeshObject::GetMaterialName(unsigned int matid)
{
- if (m_materials.size() > 0 && (matid < m_materials.size()))
- {
- BucketMaterialSet::iterator it = m_materials.begin();
-
- for (unsigned int i = 1; i < m_materials.size(); i++)
- {
- it++;
- }
- return (*it)->GetPolyMaterial()->GetMaterialName();
- }
-
- return s_emptyname;
+ RAS_MaterialBucket* bucket = GetMaterialBucket(matid);
+
+ return bucket?bucket->GetPolyMaterial()->GetMaterialName():s_emptyname;
}
-
-
RAS_MaterialBucket* RAS_MeshObject::GetMaterialBucket(unsigned int matid)
{
- RAS_MaterialBucket* bucket = NULL;
-
if (m_materials.size() > 0 && (matid < m_materials.size()))
{
- BucketMaterialSet::iterator it = m_materials.begin();
- int i = matid;
- while (i > 0)
- {
- i--;
- it++;
- }
- bucket = *it;
+ BucketMaterialSet::const_iterator it = m_materials.begin();
+ while (matid--) ++it;
+ return *it;
}
- return bucket;
+ return NULL;
}
@@ -184,18 +162,9 @@ const STR_String& RAS_MeshObject::GetName()
const STR_String& RAS_MeshObject::GetTextureName(unsigned int matid)
{
- if (m_materials.size() > 0 && (matid < m_materials.size()))
- {
- BucketMaterialSet::iterator it = m_materials.begin();
- for (unsigned int i = 1; i < m_materials.size(); i++)
- {
- it++;
- }
-
- return (*it)->GetPolyMaterial()->GetTextureName();
- }
-
- return s_emptyname;
+ RAS_MaterialBucket* bucket = GetMaterialBucket(matid);
+
+ return bucket?bucket->GetPolyMaterial()->GetTextureName():s_emptyname;
}
@@ -232,7 +201,6 @@ void RAS_MeshObject::SchedulePoly(const KX_VertexIndex& idx,
RAS_IPolyMaterial* mat)
{
//int indexpos = m_IndexArrayCount[idx.m_vtxarray];
- int indexidx = 0;
//m_IndexArrayCount[idx.m_vtxarray] = indexpos + 3;
KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);
@@ -345,7 +313,7 @@ int RAS_MeshObject::GetVertexArrayLength(RAS_IPolyMaterial* mat)
const vecVertexArray & vertexvec = GetVertexCache(mat);
vector<KX_VertexArray*>::const_iterator it = vertexvec.begin();
- for (; it != vertexvec.end(); it++)
+ for (; it != vertexvec.end(); ++it)
{
len += (*it)->size();
}
@@ -369,7 +337,7 @@ RAS_TexVert* RAS_MeshObject::GetVertex(unsigned int matid,
const vecVertexArray & vertexvec = GetVertexCache(mat);
vector<KX_VertexArray*>::const_iterator it = vertexvec.begin();
- for (unsigned int len = 0; it != vertexvec.end(); it++)
+ for (unsigned int len = 0; it != vertexvec.end(); ++it)
{
if (index < len + (*it)->size())
{
@@ -428,12 +396,11 @@ void RAS_MeshObject::Bucketize(double* oglmatrix,
ms.m_bObjectColor = useObjectColor;
ms.m_RGBAcolor = rgbavec;
- int i=0;
- for (BucketMaterialSet::iterator it = m_materials.begin();it!=m_materials.end();it++)
+ for (BucketMaterialSet::iterator it = m_materials.begin();it!=m_materials.end();++it)
{
RAS_MaterialBucket* bucket = *it;
bucket->SchedulePolygons(0);
- KX_ArrayOptimizer* oa = GetArrayOptimizer(bucket->GetPolyMaterial());
+// KX_ArrayOptimizer* oa = GetArrayOptimizer(bucket->GetPolyMaterial());
bucket->SetMeshSlot(ms);
}
@@ -454,11 +421,11 @@ void RAS_MeshObject::MarkVisible(double* oglmatrix,
ms.m_RGBAcolor = rgbavec;
ms.m_bObjectColor= useObjectColor;
- for (BucketMaterialSet::iterator it = m_materials.begin();it!=m_materials.end();it++)
+ for (BucketMaterialSet::iterator it = m_materials.begin();it!=m_materials.end();++it)
{
RAS_MaterialBucket* bucket = *it;
bucket->SchedulePolygons(0);
- KX_ArrayOptimizer* oa = GetArrayOptimizer(bucket->GetPolyMaterial());
+// KX_ArrayOptimizer* oa = GetArrayOptimizer(bucket->GetPolyMaterial());
bucket->MarkVisibleMeshSlot(ms,visible,useObjectColor,rgbavec);
}
}
@@ -473,10 +440,10 @@ void RAS_MeshObject::RemoveFromBuckets(double* oglmatrix,
ms.m_mesh = this;
ms.m_OpenGLMatrix = oglmatrix;
- for (BucketMaterialSet::iterator it = m_materials.begin();it!=m_materials.end();it++)
+ for (BucketMaterialSet::iterator it = m_materials.begin();it!=m_materials.end();++it)
{
RAS_MaterialBucket* bucket = *it;
- RAS_IPolyMaterial* polymat = bucket->GetPolyMaterial();
+// RAS_IPolyMaterial* polymat = bucket->GetPolyMaterial();
bucket->SchedulePolygons(0);
//KX_ArrayOptimizer* oa = GetArrayOptimizer(polymat);
bucket->RemoveMeshSlot(ms);
@@ -502,8 +469,9 @@ RAS_TexVert* RAS_MeshObject::GetVertex(short array,
void RAS_MeshObject::ClearArrayData()
{
- for (int i=0;i<m_matVertexArrayS.size();i++)
- { KX_ArrayOptimizer** ao = m_matVertexArrayS.at(i);
+ for (unsigned int i=0;i<m_matVertexArrayS.size();i++)
+ {
+ KX_ArrayOptimizer** ao = m_matVertexArrayS.at(i);
if (ao)
delete *ao;
}
@@ -517,7 +485,7 @@ void RAS_MeshObject::ClearArrayData()
int RAS_MeshObject::FindVertexArray(int numverts,
RAS_IPolyMaterial* polymat)
{
- bool found=false;
+// bool found=false;
int array=-1;
KX_ArrayOptimizer* ao = GetArrayOptimizer(polymat);
@@ -577,26 +545,24 @@ void RAS_MeshObject::RelativeTransform(const MT_Vector3& vec)
void RAS_MeshObject::UpdateMaterialList()
{
m_materials.clear();
- int numpolys = m_Polygons.size();
+ unsigned int numpolys = m_Polygons.size();
// for all polygons, find out which material they use, and add it to the set of materials
- for (int i=0;i<numpolys;i++)
+ for (unsigned int i=0;i<numpolys;i++)
{
m_materials.insert(m_Polygons[i]->GetMaterial());
}
- int nummaterials = m_materials.size();
-
}
void RAS_MeshObject::SchedulePolygons(int drawingmode,RAS_IRasterizer* rasty)
{
- int nummaterials = m_materials.size();
+// int nummaterials = m_materials.size();
int i;
if (m_bModified)
{
- for (BucketMaterialSet::iterator it = m_materials.begin();it!=m_materials.end();it++)
+ for (BucketMaterialSet::iterator it = m_materials.begin();it!=m_materials.end();++it)
{
RAS_MaterialBucket* bucket = *it;
diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h
index e26715ef210..87a5e6be77c 100644
--- a/source/gameengine/Rasterizer/RAS_MeshObject.h
+++ b/source/gameengine/Rasterizer/RAS_MeshObject.h
@@ -100,7 +100,9 @@ inline bool operator <( const RAS_MatArrayIndex& rhs,const RAS_MatArrayIndex& l
return ( rhs.Less(lhs));
}
-
+/**
+ * RAS_MeshObject stores mesh data for the renderer.
+ */
class RAS_MeshObject
{
@@ -176,8 +178,8 @@ public:
void ClearArrayData();
- set<RAS_MaterialBucket*>::iterator GetFirstMaterial();
- set<RAS_MaterialBucket*>::iterator GetLastMaterial();
+ BucketMaterialSet::iterator GetFirstMaterial();
+ BucketMaterialSet::iterator GetLastMaterial();
virtual RAS_TexVert* GetVertex(
short array,
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp
index 134c3ca90d3..eaed233b86c 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp
@@ -76,7 +76,16 @@
the GL function entry
*/
-#ifdef __APPLE__
+#if defined(BGL_NO_EXTENSIONS)
+static void bglInitEntryPoints (void) {}
+static void bglDeallocEntryPoints (void) {}
+
+static void *bglGetProcAddress(const GLubyte* entry)
+{
+ /* No Extensions! */
+ return NULL;
+}
+#elif defined(__APPLE__)
/* http://developer.apple.com/qa/qa2001/qa1188.html */
CFBundleRef gBundleRefOpenGL = NULL;
@@ -207,11 +216,11 @@ static void *bglGetProcAddress(const GLubyte* entry)
GL Extension Manager.
*/
-static std::vector<STR_String> extensions;
-/* Bit array of available extensions */
+ /* Bit array of available extensions */
static unsigned int enabled_extensions[(bgl::NUM_EXTENSIONS + 8*sizeof(unsigned int) - 1)/(8*sizeof(unsigned int))];
+static std::vector<STR_String> extensions;
static int m_debug;
-
+
static void LinkExtensions();
static void EnableExtension(bgl::ExtensionName name)
@@ -259,15 +268,12 @@ bool QueryVersion(int major, int minor)
int i = gl_version.Find('.');
gl_major = gl_version.Left(i).ToInt();
gl_minor = gl_version.Mid(i+1, gl_version.FindOneOf(". ", i+1) - i - 1).ToInt();
-
- if (m_debug)
+
+ static bool doQueryVersion = m_debug;
+ if (doQueryVersion)
{
- static bool doQueryVersion = true;
- if (doQueryVersion)
- {
- doQueryVersion = false;
- std::cout << "GL_VERSION: " << gl_major << "." << gl_minor << " (" << gl_version << ")" << std::endl;
- }
+ doQueryVersion = false;
+ std::cout << "GL_VERSION: " << gl_major << "." << gl_minor << " (" << gl_version << ")" << std::endl;
}
}
@@ -317,7 +323,7 @@ Use EnableExtension(_GL_EXT_...) to allow Blender to use the extension.
******************************************************************************/
static void LinkExtensions()
{
- static bool doDebugMessages = true;
+ static bool doDebugMessages = m_debug;
extensions = STR_String((const char *) glGetString(GL_EXTENSIONS)).Explode(' ');
doDebugMessages = false;
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h
index c249a488826..50a67ee7d6b 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h
@@ -48,6 +48,7 @@ namespace bgl
*/
typedef enum {
/* ARB Extensions */
+ _GL_ARB_imaging,
_GL_ARB_multitexture ,
_GLX_ARB_get_proc_address ,
_GL_ARB_transpose_matrix ,
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py
index 24f257b62ce..912b4785da1 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py
@@ -362,8 +362,8 @@ Example code output:
if (glUnlockArraysEXT && glLockArraysEXT)
{
EnableExtension(_GL_EXT_compiled_vertex_array);
- if (m_debug && doDebugMessages)
- std::cout << "Enabled GL_EXT_compiled_vertex_array" << std::endl;
+ if (doDebugMessages)
+ std::cout << "Detected GL_EXT_compiled_vertex_array" << std::endl;
} else {
std::cout << "ERROR: GL_EXT_compiled_vertex_array implementation is broken!" << std::endl;
}
@@ -374,11 +374,13 @@ def writeext(ext, fnlist):
if (find(blacklist, ext)):
return
if (len(fnlist) == 0):
+ # This extension has no functions to detect - don't need to wrap in
+ # #ifdef GL_extension names
print "\tif (QueryExtension(\"" + ext + "\"))"
print "\t{"
print "\t\tEnableExtension(_" + ext + ");"
- print "\t\tif (m_debug && doDebugMessages)"
- print "\t\t\tstd::cout << \"Enabled " + ext + "\" << std::endl;"
+ print "\t\tif (doDebugMessages)"
+ print "\t\t\tstd::cout << \"Detected " + ext + "\" << std::endl;"
print "\t}"
print
return
@@ -395,7 +397,7 @@ def writeext(ext, fnlist):
errcheck = errcheck + " && " + fn[0]
print "\t\tif (" + errcheck + ") {"
print "\t\t\tEnableExtension(_" + ext + ");"
- print "\t\t\tif (m_debug && doDebugMessages)"
+ print "\t\t\tif (doDebugMessages)"
print "\t\t\t\tstd::cout << \"Enabled " + ext + "\" << std::endl;"
print "\t\t} else {"
print "\t\t\tstd::cout << \"ERROR: " + ext + " implementation is broken!\" << std::endl;"