2006-01-07 00:14:37 +00:00
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
// ------------------------------------
|
|
|
|
// ...
|
|
|
|
// ------------------------------------
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
#include "GL/glew.h"
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
#include "KX_BlenderMaterial.h"
|
|
|
|
#include "BL_Material.h"
|
|
|
|
#include "KX_Scene.h"
|
|
|
|
#include "KX_Light.h"
|
|
|
|
#include "KX_GameObject.h"
|
2006-01-15 11:34:55 +00:00
|
|
|
#include "KX_MeshProxy.h"
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
#include "MT_Vector3.h"
|
|
|
|
#include "MT_Vector4.h"
|
|
|
|
#include "MT_Matrix4x4.h"
|
|
|
|
|
|
|
|
#include "RAS_MeshObject.h"
|
|
|
|
#include "RAS_IRasterizer.h"
|
2006-01-06 20:35:02 +00:00
|
|
|
#include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h"
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include "BDR_drawmesh.h"
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "STR_HashedString.h"
|
|
|
|
|
|
|
|
// ------------------------------------
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_material_types.h"
|
|
|
|
#include "DNA_image_types.h"
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
2006-01-06 03:46:54 +00:00
|
|
|
#include "BKE_mesh.h"
|
|
|
|
// ------------------------------------
|
|
|
|
#define spit(x) std::cout << x << std::endl;
|
|
|
|
|
2006-01-10 06:34:42 +00:00
|
|
|
//static PyObject *gTextureDict = 0;
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
KX_BlenderMaterial::KX_BlenderMaterial(
|
|
|
|
KX_Scene *scene,
|
|
|
|
BL_Material *data,
|
|
|
|
bool skin,
|
|
|
|
int lightlayer,
|
|
|
|
void *clientobject,
|
|
|
|
PyTypeObject *T
|
|
|
|
)
|
|
|
|
: PyObjectPlus(T),
|
|
|
|
RAS_IPolyMaterial(
|
|
|
|
STR_String( data->texname[0] ),
|
|
|
|
STR_String( data->matname ), // needed for physics!
|
|
|
|
data->tile,
|
|
|
|
data->tilexrep[0],
|
|
|
|
data->tileyrep[0],
|
|
|
|
data->mode,
|
|
|
|
((data->ras_mode &TRANSP)!=0),
|
|
|
|
((data->ras_mode &ZSORT)!=0),
|
|
|
|
lightlayer,
|
|
|
|
((data->ras_mode &TRIANGLE)!=0),
|
|
|
|
clientobject
|
|
|
|
),
|
|
|
|
mMaterial(data),
|
|
|
|
mShader(0),
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
mBlenderShader(0),
|
2006-01-10 06:34:42 +00:00
|
|
|
mScene(scene),
|
2006-01-15 11:34:55 +00:00
|
|
|
mUserDefBlend(0),
|
2006-01-18 06:04:11 +00:00
|
|
|
mModified(0),
|
2008-05-04 21:14:38 +00:00
|
|
|
mConstructed(false),
|
2006-01-06 03:46:54 +00:00
|
|
|
mPass(0)
|
2006-01-15 11:34:55 +00:00
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
|
|
|
// --------------------------------
|
|
|
|
// RAS_IPolyMaterial variables...
|
|
|
|
m_flag |=RAS_BLENDERMAT;
|
|
|
|
m_flag |=(mMaterial->IdMode>=ONETEX)?RAS_MULTITEX:0;
|
|
|
|
m_flag |=(mMaterial->ras_mode & USE_LIGHT)!=0?RAS_MULTILIGHT:0;
|
2006-04-11 05:57:30 +00:00
|
|
|
m_flag |=(mMaterial->ras_mode &ALPHA_TEST)!=0?RAS_FORCEALPHA:0;
|
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
// figure max
|
|
|
|
int enabled = mMaterial->num_enabled;
|
2006-02-13 05:45:32 +00:00
|
|
|
int max = BL_Texture::GetMaxUnits();
|
|
|
|
mMaterial->num_enabled = enabled>=max?max:enabled;
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
// test the sum of the various modes for equality
|
|
|
|
// so we can ether accept or reject this material
|
|
|
|
// as being equal, this is rather important to
|
|
|
|
// prevent material bleeding
|
|
|
|
for(int i=0; i<mMaterial->num_enabled; i++) {
|
|
|
|
m_multimode +=
|
2006-01-15 11:34:55 +00:00
|
|
|
( mMaterial->flag[i] +
|
|
|
|
mMaterial->blend_mode[i]
|
2006-01-06 03:46:54 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
m_multimode += mMaterial->IdMode+mMaterial->ras_mode;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
KX_BlenderMaterial::~KX_BlenderMaterial()
|
|
|
|
{
|
|
|
|
// cleanup work
|
2008-05-04 21:14:38 +00:00
|
|
|
if (mConstructed)
|
|
|
|
// clean only if material was actually used
|
|
|
|
OnExit();
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
MTFace* KX_BlenderMaterial::GetMTFace(void) const
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
|
|
|
// fonts on polys
|
|
|
|
MT_assert(mMaterial->tface);
|
|
|
|
return mMaterial->tface;
|
|
|
|
}
|
|
|
|
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
unsigned int* KX_BlenderMaterial::GetMCol(void) const
|
|
|
|
{
|
|
|
|
// fonts on polys
|
|
|
|
return mMaterial->rgb;
|
|
|
|
}
|
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
void KX_BlenderMaterial::OnConstruction()
|
|
|
|
{
|
2008-05-04 21:14:38 +00:00
|
|
|
if (mConstructed)
|
|
|
|
// when material are reused between objects
|
|
|
|
return;
|
2006-01-06 03:46:54 +00:00
|
|
|
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
if(mMaterial->glslmat) {
|
|
|
|
SetBlenderGLSLShader();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// for each unique material...
|
|
|
|
int i;
|
|
|
|
for(i=0; i<mMaterial->num_enabled; i++) {
|
|
|
|
if( mMaterial->mapping[i].mapping & USEENV ) {
|
|
|
|
if(!GLEW_ARB_texture_cube_map) {
|
|
|
|
spit("CubeMap textures not supported");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(!mTextures[i].InitCubeMap(i, mMaterial->cubemap[i] ) )
|
2006-01-06 03:46:54 +00:00
|
|
|
spit("unable to initialize image("<<i<<") in "<<
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
mMaterial->matname<< ", image will not be available");
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
if( mMaterial->img[i] ) {
|
|
|
|
if( ! mTextures[i].InitFromImage(i, mMaterial->img[i], (mMaterial->flag[i] &MIPMAP)!=0 ))
|
|
|
|
spit("unable to initialize image("<<i<<") in "<<
|
|
|
|
mMaterial->matname<< ", image will not be available");
|
|
|
|
}
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-01-15 11:34:55 +00:00
|
|
|
mBlendFunc[0] =0;
|
|
|
|
mBlendFunc[1] =0;
|
2008-05-04 21:14:38 +00:00
|
|
|
mConstructed = true;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KX_BlenderMaterial::OnExit()
|
|
|
|
{
|
2006-02-13 05:45:32 +00:00
|
|
|
if( mShader ) {
|
2006-01-06 03:46:54 +00:00
|
|
|
//note, the shader here is allocated, per unique material
|
|
|
|
//and this function is called per face
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
mShader->SetProg(false);
|
2006-01-06 03:46:54 +00:00
|
|
|
delete mShader;
|
|
|
|
mShader = 0;
|
|
|
|
}
|
|
|
|
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
if( mBlenderShader ) {
|
|
|
|
mBlenderShader->SetProg(false);
|
|
|
|
delete mBlenderShader;
|
|
|
|
mBlenderShader = 0;
|
|
|
|
}
|
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
BL_Texture::ActivateFirst();
|
2006-01-06 03:46:54 +00:00
|
|
|
for(int i=0; i<mMaterial->num_enabled; i++) {
|
2006-02-13 05:45:32 +00:00
|
|
|
BL_Texture::ActivateUnit(i);
|
2006-01-06 03:46:54 +00:00
|
|
|
mTextures[i].DeleteTex();
|
2006-02-13 05:45:32 +00:00
|
|
|
mTextures[i].DisableUnit();
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( mMaterial->tface )
|
|
|
|
set_tpage(mMaterial->tface);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
void KX_BlenderMaterial::setShaderData( bool enable, RAS_IRasterizer *ras)
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
MT_assert(GLEW_ARB_shader_objects && mShader);
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
int i;
|
|
|
|
if( !enable || !mShader->Ok() ) {
|
|
|
|
// frame cleanup.
|
2006-02-13 05:45:32 +00:00
|
|
|
mShader->SetProg(false);
|
|
|
|
BL_Texture::DisableAllTextures();
|
2006-01-06 03:46:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
BL_Texture::DisableAllTextures();
|
|
|
|
mShader->SetProg(true);
|
2006-01-06 03:46:54 +00:00
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
BL_Texture::ActivateFirst();
|
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
mShader->ApplyShader();
|
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
// for each enabled unit
|
|
|
|
for(i=0; i<mMaterial->num_enabled; i++) {
|
2006-04-11 05:57:30 +00:00
|
|
|
if(!mTextures[i].Ok()) continue;
|
|
|
|
mTextures[i].ActivateTexture();
|
|
|
|
mTextures[0].SetMapping(mMaterial->mapping[i].mapping);
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2006-04-11 05:57:30 +00:00
|
|
|
|
2006-01-15 11:34:55 +00:00
|
|
|
if(!mUserDefBlend) {
|
|
|
|
setDefaultBlending();
|
2006-04-11 05:57:30 +00:00
|
|
|
}
|
|
|
|
else {
|
2006-01-15 11:34:55 +00:00
|
|
|
// tested to be valid enums
|
2006-02-13 05:45:32 +00:00
|
|
|
glEnable(GL_BLEND);
|
2006-01-15 11:34:55 +00:00
|
|
|
glBlendFunc(mBlendFunc[0], mBlendFunc[1]);
|
|
|
|
}
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
void KX_BlenderMaterial::setBlenderShaderData( bool enable, RAS_IRasterizer *ras)
|
|
|
|
{
|
|
|
|
if( !enable || !mBlenderShader->Ok() ) {
|
|
|
|
// frame cleanup.
|
|
|
|
mBlenderShader->SetProg(false);
|
|
|
|
BL_Texture::DisableAllTextures();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
BL_Texture::DisableAllTextures();
|
|
|
|
mBlenderShader->SetProg(true);
|
|
|
|
mBlenderShader->ApplyShader();
|
|
|
|
}
|
2006-01-06 03:46:54 +00:00
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
void KX_BlenderMaterial::setTexData( bool enable, RAS_IRasterizer *ras)
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
if(GLEW_ARB_shader_objects && mShader)
|
2006-02-13 05:45:32 +00:00
|
|
|
mShader->SetProg(false);
|
2006-01-06 03:46:54 +00:00
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
BL_Texture::DisableAllTextures();
|
|
|
|
if( !enable )
|
2006-01-06 03:46:54 +00:00
|
|
|
return;
|
2006-02-13 05:45:32 +00:00
|
|
|
|
|
|
|
BL_Texture::ActivateFirst();
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
if( mMaterial->IdMode == DEFAULT_BLENDER ) {
|
|
|
|
setDefaultBlending();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( mMaterial->IdMode == TEXFACE ) {
|
|
|
|
// no material connected to the object
|
2006-02-13 05:45:32 +00:00
|
|
|
if( mTextures[0].Ok() ) {
|
|
|
|
mTextures[0].ActivateTexture();
|
|
|
|
mTextures[0].setTexEnv(0, true);
|
|
|
|
mTextures[0].SetMapping(mMaterial->mapping[0].mapping);
|
2006-01-06 03:46:54 +00:00
|
|
|
setDefaultBlending();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
int mode = 0,i=0;
|
2007-01-21 04:45:44 +00:00
|
|
|
for(i=0; (i<mMaterial->num_enabled && i<MAXTEX); i++) {
|
2006-01-06 03:46:54 +00:00
|
|
|
if( !mTextures[i].Ok() ) continue;
|
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
mTextures[i].ActivateTexture();
|
|
|
|
mTextures[i].setTexEnv(mMaterial);
|
|
|
|
mode = mMaterial->mapping[i].mapping;
|
2006-01-06 03:46:54 +00:00
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
if(mode &USEOBJ)
|
|
|
|
setObjectMatrixData(i, ras);
|
|
|
|
else
|
|
|
|
mTextures[i].SetMapping(mode);
|
|
|
|
|
|
|
|
if(!(mode &USEOBJ))
|
|
|
|
setTexMatrixData( i );
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2006-02-13 05:45:32 +00:00
|
|
|
|
2006-01-15 11:34:55 +00:00
|
|
|
if(!mUserDefBlend) {
|
|
|
|
setDefaultBlending();
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
|
|
|
else {
|
2006-01-15 11:34:55 +00:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glBlendFunc(mBlendFunc[0], mBlendFunc[1]);
|
|
|
|
}
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
KX_BlenderMaterial::ActivatShaders(
|
|
|
|
RAS_IRasterizer* rasty,
|
|
|
|
TCachingInfo& cachingInfo)const
|
|
|
|
{
|
2006-02-13 05:45:32 +00:00
|
|
|
KX_BlenderMaterial *tmp = const_cast<KX_BlenderMaterial*>(this);
|
2006-04-02 21:04:20 +00:00
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
// reset...
|
|
|
|
if(tmp->mMaterial->IsShared())
|
|
|
|
cachingInfo =0;
|
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
if (GetCachingInfo() != cachingInfo) {
|
|
|
|
|
|
|
|
if (!cachingInfo)
|
2006-02-13 05:45:32 +00:00
|
|
|
tmp->setShaderData( false, rasty);
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
cachingInfo = GetCachingInfo();
|
|
|
|
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
if(rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED)
|
2006-02-13 05:45:32 +00:00
|
|
|
tmp->setShaderData( true, rasty);
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
else
|
|
|
|
tmp->setShaderData( false, rasty);
|
|
|
|
|
|
|
|
if(mMaterial->mode & RAS_IRasterizer::KX_TWOSIDE)
|
|
|
|
rasty->SetCullFace(false);
|
|
|
|
else
|
|
|
|
rasty->SetCullFace(true);
|
|
|
|
|
|
|
|
if (((mMaterial->ras_mode &WIRE)!=0) || mMaterial->mode & RAS_IRasterizer::KX_LINES)
|
|
|
|
{
|
|
|
|
if((mMaterial->ras_mode &WIRE)!=0)
|
|
|
|
rasty->SetCullFace(false);
|
|
|
|
rasty->SetLines(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rasty->SetLines(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
ActivatGLMaterials(rasty);
|
|
|
|
ActivateTexGen(rasty);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
KX_BlenderMaterial::ActivateBlenderShaders(
|
|
|
|
RAS_IRasterizer* rasty,
|
|
|
|
TCachingInfo& cachingInfo)const
|
|
|
|
{
|
|
|
|
KX_BlenderMaterial *tmp = const_cast<KX_BlenderMaterial*>(this);
|
|
|
|
|
|
|
|
// reset...
|
|
|
|
if(tmp->mMaterial->IsShared())
|
|
|
|
cachingInfo =0;
|
|
|
|
|
|
|
|
if (GetCachingInfo() != cachingInfo) {
|
|
|
|
if (!cachingInfo)
|
|
|
|
tmp->setBlenderShaderData(false, rasty);
|
|
|
|
|
|
|
|
cachingInfo = GetCachingInfo();
|
|
|
|
|
|
|
|
if(rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) {
|
|
|
|
tmp->setBlenderShaderData(true, rasty);
|
2006-01-06 03:46:54 +00:00
|
|
|
rasty->EnableTextures(true);
|
|
|
|
}
|
|
|
|
else {
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
tmp->setBlenderShaderData(false, rasty);
|
2006-01-06 03:46:54 +00:00
|
|
|
rasty->EnableTextures(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(mMaterial->mode & RAS_IRasterizer::KX_TWOSIDE)
|
|
|
|
rasty->SetCullFace(false);
|
|
|
|
else
|
|
|
|
rasty->SetCullFace(true);
|
|
|
|
|
2006-01-10 06:34:42 +00:00
|
|
|
if (((mMaterial->ras_mode &WIRE)!=0) || mMaterial->mode & RAS_IRasterizer::KX_LINES)
|
2006-04-02 21:04:20 +00:00
|
|
|
{
|
|
|
|
if((mMaterial->ras_mode &WIRE)!=0)
|
|
|
|
rasty->SetCullFace(false);
|
2006-01-06 03:46:54 +00:00
|
|
|
rasty->SetLines(true);
|
2006-04-02 21:04:20 +00:00
|
|
|
}
|
2006-01-06 03:46:54 +00:00
|
|
|
else
|
|
|
|
rasty->SetLines(false);
|
|
|
|
}
|
2006-02-13 05:45:32 +00:00
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
ActivatGLMaterials(rasty);
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
mBlenderShader->SetTexCoords(rasty);
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
KX_BlenderMaterial::ActivateMat(
|
|
|
|
RAS_IRasterizer* rasty,
|
|
|
|
TCachingInfo& cachingInfo
|
|
|
|
)const
|
|
|
|
{
|
2006-02-13 05:45:32 +00:00
|
|
|
KX_BlenderMaterial *tmp = const_cast<KX_BlenderMaterial*>(this);
|
2006-01-06 03:46:54 +00:00
|
|
|
if (GetCachingInfo() != cachingInfo) {
|
|
|
|
if (!cachingInfo)
|
2006-02-13 05:45:32 +00:00
|
|
|
tmp->setTexData( false,rasty );
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
cachingInfo = GetCachingInfo();
|
|
|
|
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED)
|
2006-02-13 05:45:32 +00:00
|
|
|
tmp->setTexData( true,rasty );
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
else
|
2006-02-13 05:45:32 +00:00
|
|
|
tmp->setTexData( false,rasty);
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
if(mMaterial->mode & RAS_IRasterizer::KX_TWOSIDE)
|
|
|
|
rasty->SetCullFace(false);
|
|
|
|
else
|
|
|
|
rasty->SetCullFace(true);
|
|
|
|
|
2006-01-10 06:34:42 +00:00
|
|
|
if (((mMaterial->ras_mode &WIRE)!=0) || mMaterial->mode & RAS_IRasterizer::KX_LINES)
|
2006-04-02 21:04:20 +00:00
|
|
|
{
|
|
|
|
if((mMaterial->ras_mode &WIRE)!=0)
|
|
|
|
rasty->SetCullFace(false);
|
2006-01-06 03:46:54 +00:00
|
|
|
rasty->SetLines(true);
|
2006-04-02 21:04:20 +00:00
|
|
|
}
|
2006-01-06 03:46:54 +00:00
|
|
|
else
|
|
|
|
rasty->SetLines(false);
|
|
|
|
}
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
ActivatGLMaterials(rasty);
|
|
|
|
ActivateTexGen(rasty);
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
KX_BlenderMaterial::Activate(
|
|
|
|
RAS_IRasterizer* rasty,
|
|
|
|
TCachingInfo& cachingInfo
|
|
|
|
)const
|
|
|
|
{
|
|
|
|
bool dopass = false;
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
if( GLEW_ARB_shader_objects && ( mShader && mShader->Ok() ) ) {
|
2006-01-06 03:46:54 +00:00
|
|
|
if( (mPass++) < mShader->getNumPass() ) {
|
|
|
|
ActivatShaders(rasty, cachingInfo);
|
|
|
|
dopass = true;
|
|
|
|
return dopass;
|
|
|
|
}
|
|
|
|
else {
|
2006-02-13 05:45:32 +00:00
|
|
|
mShader->SetProg(false);
|
2006-01-06 03:46:54 +00:00
|
|
|
mPass = 0;
|
|
|
|
dopass = false;
|
|
|
|
return dopass;
|
|
|
|
}
|
|
|
|
}
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
else if( GLEW_ARB_shader_objects && ( mBlenderShader && mBlenderShader->Ok() ) ) {
|
|
|
|
if( (mPass++) == 0 ) {
|
|
|
|
ActivateBlenderShaders(rasty, cachingInfo);
|
|
|
|
dopass = true;
|
|
|
|
return dopass;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mPass = 0;
|
|
|
|
dopass = false;
|
|
|
|
return dopass;
|
|
|
|
}
|
|
|
|
}
|
2006-01-06 03:46:54 +00:00
|
|
|
else {
|
|
|
|
switch (mPass++)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
ActivateMat(rasty, cachingInfo);
|
|
|
|
dopass = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mPass = 0;
|
|
|
|
dopass = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dopass;
|
|
|
|
}
|
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
void KX_BlenderMaterial::ActivateMeshSlot(const KX_MeshSlot & ms, RAS_IRasterizer* rasty) const
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
if(mShader && GLEW_ARB_shader_objects)
|
2006-02-13 05:45:32 +00:00
|
|
|
mShader->Update(ms, rasty);
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
if(mBlenderShader && GLEW_ARB_shader_objects)
|
|
|
|
mBlenderShader->Update(ms, rasty);
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
void KX_BlenderMaterial::ActivatGLMaterials( RAS_IRasterizer* rasty )const
|
|
|
|
{
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
if(!mBlenderShader) {
|
|
|
|
rasty->SetSpecularity(
|
|
|
|
mMaterial->speccolor[0]*mMaterial->spec_f,
|
|
|
|
mMaterial->speccolor[1]*mMaterial->spec_f,
|
|
|
|
mMaterial->speccolor[2]*mMaterial->spec_f,
|
|
|
|
mMaterial->spec_f
|
|
|
|
);
|
|
|
|
|
|
|
|
rasty->SetShinyness( mMaterial->hard );
|
2006-04-02 21:04:20 +00:00
|
|
|
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
rasty->SetDiffuse(
|
|
|
|
mMaterial->matcolor[0]*mMaterial->ref+mMaterial->emit,
|
|
|
|
mMaterial->matcolor[1]*mMaterial->ref+mMaterial->emit,
|
|
|
|
mMaterial->matcolor[2]*mMaterial->ref+mMaterial->emit,
|
|
|
|
1.0f);
|
2006-04-02 21:04:20 +00:00
|
|
|
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
rasty->SetEmissive(
|
|
|
|
mMaterial->matcolor[0]*mMaterial->emit,
|
|
|
|
mMaterial->matcolor[1]*mMaterial->emit,
|
|
|
|
mMaterial->matcolor[2]*mMaterial->emit,
|
|
|
|
1.0 );
|
2006-04-02 21:04:20 +00:00
|
|
|
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
rasty->SetAmbient(mMaterial->amb);
|
|
|
|
}
|
2006-04-11 05:57:30 +00:00
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
if (mMaterial->material)
|
|
|
|
rasty->SetPolygonOffset(-mMaterial->material->zoffs, 0.0);
|
|
|
|
}
|
|
|
|
|
2006-04-11 05:57:30 +00:00
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
void KX_BlenderMaterial::ActivateTexGen(RAS_IRasterizer *ras) const
|
|
|
|
{
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
if(ras->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) {
|
|
|
|
ras->SetAttribNum(0);
|
|
|
|
if(mShader && GLEW_ARB_shader_objects) {
|
|
|
|
if(mShader->GetAttribute() == BL_Shader::SHD_TANGENT) {
|
|
|
|
ras->SetAttrib(RAS_IRasterizer::RAS_TEXTANGENT, 1);
|
|
|
|
ras->SetAttribNum(2);
|
|
|
|
}
|
|
|
|
}
|
2006-04-02 21:04:20 +00:00
|
|
|
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
ras->SetTexCoordNum(mMaterial->num_enabled);
|
2007-01-07 04:39:39 +00:00
|
|
|
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
for(int i=0; i<mMaterial->num_enabled; i++) {
|
|
|
|
int mode = mMaterial->mapping[i].mapping;
|
|
|
|
|
|
|
|
if (mode &USECUSTOMUV)
|
|
|
|
{
|
|
|
|
STR_String str = mMaterial->mapping[i].uvCoName;
|
|
|
|
if (!str.IsEmpty())
|
|
|
|
ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_UV2, i);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( mode &(USEREFL|USEOBJ))
|
|
|
|
ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_GEN, i);
|
|
|
|
else if(mode &USEORCO)
|
|
|
|
ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_ORCO, i);
|
|
|
|
else if(mode &USENORM)
|
|
|
|
ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_NORM, i);
|
|
|
|
else if(mode &USEUV)
|
|
|
|
ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_UV1, i);
|
|
|
|
else if(mode &USETANG)
|
|
|
|
ras->SetTexCoord(RAS_IRasterizer::RAS_TEXTANGENT, i);
|
|
|
|
else
|
|
|
|
ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_DISABLE, i);
|
2007-01-07 04:39:39 +00:00
|
|
|
}
|
|
|
|
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
ras->EnableTextures(true);
|
2006-04-02 21:04:20 +00:00
|
|
|
}
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
else
|
|
|
|
ras->EnableTextures(false);
|
2006-04-02 21:04:20 +00:00
|
|
|
}
|
2006-02-13 05:45:32 +00:00
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
bool KX_BlenderMaterial::setDefaultBlending()
|
|
|
|
{
|
|
|
|
if( mMaterial->transp &TF_ADD) {
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glBlendFunc(GL_ONE, GL_ONE);
|
2008-06-09 15:45:46 +00:00
|
|
|
glDisable ( GL_ALPHA_TEST );
|
2006-01-06 03:46:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( mMaterial->transp & TF_ALPHA ) {
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
2008-06-09 15:45:46 +00:00
|
|
|
glDisable ( GL_ALPHA_TEST );
|
2006-01-06 03:46:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-06-09 15:45:46 +00:00
|
|
|
if( mMaterial->transp & TF_CLIP ) {
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
glEnable ( GL_ALPHA_TEST );
|
|
|
|
glAlphaFunc(GL_GREATER, 0.5f);
|
2008-06-15 09:43:24 +00:00
|
|
|
return false;
|
2008-06-09 15:45:46 +00:00
|
|
|
}
|
2006-01-06 03:46:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KX_BlenderMaterial::setTexMatrixData(int i)
|
|
|
|
{
|
|
|
|
glMatrixMode(GL_TEXTURE);
|
|
|
|
glLoadIdentity();
|
|
|
|
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
if( GLEW_ARB_texture_cube_map &&
|
2006-05-11 20:41:28 +00:00
|
|
|
mTextures[i].GetTextureType() == GL_TEXTURE_CUBE_MAP_ARB &&
|
|
|
|
mMaterial->mapping[i].mapping & USEREFL) {
|
|
|
|
glScalef(
|
|
|
|
mMaterial->mapping[i].scale[0],
|
|
|
|
-mMaterial->mapping[i].scale[1],
|
|
|
|
-mMaterial->mapping[i].scale[2]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
glScalef(
|
|
|
|
mMaterial->mapping[i].scale[0],
|
|
|
|
mMaterial->mapping[i].scale[1],
|
|
|
|
mMaterial->mapping[i].scale[2]
|
|
|
|
);
|
|
|
|
}
|
2006-01-06 03:46:54 +00:00
|
|
|
glTranslatef(
|
|
|
|
mMaterial->mapping[i].offsets[0],
|
|
|
|
mMaterial->mapping[i].offsets[1],
|
|
|
|
mMaterial->mapping[i].offsets[2]
|
|
|
|
);
|
|
|
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void GetProjPlane(BL_Material *mat, int index,int num, float*param)
|
|
|
|
{
|
|
|
|
param[0]=param[1]=param[2]=param[3]=0.f;
|
|
|
|
if( mat->mapping[index].projplane[num] == PROJX )
|
|
|
|
param[0] = 1.f;
|
|
|
|
else if( mat->mapping[index].projplane[num] == PROJY )
|
|
|
|
param[1] = 1.f;
|
|
|
|
else if( mat->mapping[index].projplane[num] == PROJZ)
|
|
|
|
param[2] = 1.f;
|
|
|
|
}
|
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
void KX_BlenderMaterial::setObjectMatrixData(int i, RAS_IRasterizer *ras)
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
|
|
|
KX_GameObject *obj =
|
|
|
|
(KX_GameObject*)
|
|
|
|
mScene->GetObjectList()->FindValue(mMaterial->mapping[i].objconame);
|
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
if(!obj) return;
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );
|
|
|
|
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );
|
|
|
|
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );
|
|
|
|
|
|
|
|
GLenum plane = GL_EYE_PLANE;
|
|
|
|
|
|
|
|
// figure plane gen
|
|
|
|
float proj[4]= {0.f,0.f,0.f,0.f};
|
|
|
|
GetProjPlane(mMaterial, i, 0, proj);
|
|
|
|
glTexGenfv(GL_S, plane, proj);
|
|
|
|
|
|
|
|
GetProjPlane(mMaterial, i, 1, proj);
|
|
|
|
glTexGenfv(GL_T, plane, proj);
|
|
|
|
|
|
|
|
GetProjPlane(mMaterial, i, 2, proj);
|
|
|
|
glTexGenfv(GL_R, plane, proj);
|
|
|
|
|
|
|
|
glEnable(GL_TEXTURE_GEN_S);
|
|
|
|
glEnable(GL_TEXTURE_GEN_T);
|
|
|
|
glEnable(GL_TEXTURE_GEN_R);
|
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
MT_Matrix4x4 mvmat;
|
|
|
|
ras->GetViewMatrix(mvmat);
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
glMatrixMode(GL_TEXTURE);
|
|
|
|
glLoadIdentity();
|
|
|
|
glScalef(
|
|
|
|
mMaterial->mapping[i].scale[0],
|
|
|
|
mMaterial->mapping[i].scale[1],
|
|
|
|
mMaterial->mapping[i].scale[2]
|
|
|
|
);
|
|
|
|
|
|
|
|
MT_Point3 pos = obj->NodeGetWorldPosition();
|
|
|
|
MT_Vector4 matmul = MT_Vector4(pos[0], pos[1], pos[2], 1.f);
|
|
|
|
MT_Vector4 t = mvmat*matmul;
|
|
|
|
|
|
|
|
glTranslatef( (float)(-t[0]), (float)(-t[1]), (float)(-t[2]) );
|
|
|
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------
|
|
|
|
void KX_BlenderMaterial::UpdateIPO(
|
|
|
|
MT_Vector4 rgba,
|
|
|
|
MT_Vector3 specrgb,
|
|
|
|
MT_Scalar hard,
|
|
|
|
MT_Scalar spec,
|
|
|
|
MT_Scalar ref,
|
|
|
|
MT_Scalar emit,
|
|
|
|
MT_Scalar alpha
|
|
|
|
)
|
|
|
|
{
|
|
|
|
// only works one deep now
|
|
|
|
mMaterial->speccolor[0] = (float)(specrgb)[0];
|
|
|
|
mMaterial->speccolor[1] = (float)(specrgb)[1];
|
|
|
|
mMaterial->speccolor[2] = (float)(specrgb)[2];
|
|
|
|
mMaterial->matcolor[0] = (float)(rgba[0]);
|
|
|
|
mMaterial->matcolor[1] = (float)(rgba[1]);
|
|
|
|
mMaterial->matcolor[2] = (float)(rgba[2]);
|
|
|
|
mMaterial->alpha = (float)(alpha);
|
|
|
|
mMaterial->hard = (float)(hard);
|
|
|
|
mMaterial->emit = (float)(emit);
|
|
|
|
mMaterial->spec_f = (float)(spec);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PyMethodDef KX_BlenderMaterial::Methods[] =
|
|
|
|
{
|
|
|
|
KX_PYMETHODTABLE( KX_BlenderMaterial, getShader ),
|
|
|
|
KX_PYMETHODTABLE( KX_BlenderMaterial, getMaterialIndex ),
|
2006-01-15 11:34:55 +00:00
|
|
|
KX_PYMETHODTABLE( KX_BlenderMaterial, setBlending ),
|
2006-01-06 03:46:54 +00:00
|
|
|
{NULL,NULL} //Sentinel
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
PyTypeObject KX_BlenderMaterial::Type = {
|
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
0,
|
|
|
|
"KX_BlenderMaterial",
|
|
|
|
sizeof(KX_BlenderMaterial),
|
|
|
|
0,
|
|
|
|
PyDestructor,
|
|
|
|
0,
|
|
|
|
__getattr,
|
|
|
|
__setattr,
|
|
|
|
0,
|
|
|
|
__repr,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
PyParentObject KX_BlenderMaterial::Parents[] = {
|
|
|
|
&PyObjectPlus::Type,
|
|
|
|
&KX_BlenderMaterial::Type,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
PyObject* KX_BlenderMaterial::_getattr(const STR_String& attr)
|
|
|
|
{
|
|
|
|
_getattr_up(PyObjectPlus);
|
|
|
|
}
|
|
|
|
|
|
|
|
int KX_BlenderMaterial::_setattr(const STR_String& attr, PyObject *pyvalue)
|
|
|
|
{
|
|
|
|
return PyObjectPlus::_setattr(attr, pyvalue);
|
|
|
|
}
|
|
|
|
|
2006-01-18 06:04:11 +00:00
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()")
|
|
|
|
{
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
if( !GLEW_ARB_fragment_shader) {
|
2006-01-18 06:04:11 +00:00
|
|
|
if(!mModified)
|
|
|
|
spit("Fragment shaders not supported");
|
|
|
|
|
|
|
|
mModified = true;
|
|
|
|
Py_Return;
|
|
|
|
}
|
|
|
|
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
if( !GLEW_ARB_vertex_shader) {
|
2006-01-18 06:04:11 +00:00
|
|
|
if(!mModified)
|
|
|
|
spit("Vertex shaders not supported");
|
|
|
|
|
|
|
|
mModified = true;
|
|
|
|
Py_Return;
|
|
|
|
}
|
|
|
|
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
if(!GLEW_ARB_shader_objects) {
|
2006-01-18 06:04:11 +00:00
|
|
|
if(!mModified)
|
|
|
|
spit("GLSL not supported");
|
|
|
|
mModified = true;
|
|
|
|
Py_Return;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
else {
|
2006-01-18 06:04:11 +00:00
|
|
|
// returns Py_None on error
|
|
|
|
// the calling script will need to check
|
|
|
|
|
|
|
|
if(!mShader && !mModified) {
|
2006-01-15 11:34:55 +00:00
|
|
|
mShader = new BL_Shader();
|
2006-01-18 06:04:11 +00:00
|
|
|
mModified = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(mShader && !mShader->GetError()) {
|
2006-02-13 05:45:32 +00:00
|
|
|
mMaterial->SetSharedMaterial(true);
|
2006-01-18 06:04:11 +00:00
|
|
|
Py_INCREF(mShader);
|
|
|
|
return mShader;
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
// decref all references to the object
|
|
|
|
// then delete it!
|
|
|
|
// We will then go back to fixed functionality
|
|
|
|
// for this material
|
|
|
|
if(mShader) {
|
|
|
|
if(mShader->ob_refcnt > 1) {
|
|
|
|
Py_DECREF(mShader);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
delete mShader;
|
|
|
|
mShader=0;
|
|
|
|
}
|
|
|
|
}
|
2006-01-15 11:34:55 +00:00
|
|
|
}
|
2006-01-18 06:04:11 +00:00
|
|
|
Py_Return;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2006-01-18 06:04:11 +00:00
|
|
|
PyErr_Format(PyExc_ValueError, "GLSL Error");
|
|
|
|
return NULL;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
void KX_BlenderMaterial::SetBlenderGLSLShader(void)
|
|
|
|
{
|
|
|
|
if(!mBlenderShader)
|
|
|
|
mBlenderShader = new BL_BlenderShader(mMaterial->material);
|
|
|
|
|
|
|
|
if(!mBlenderShader->Ok()) {
|
|
|
|
delete mBlenderShader;
|
|
|
|
mBlenderShader = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getMaterialIndex, "getMaterialIndex()")
|
|
|
|
{
|
|
|
|
return PyInt_FromLong( mMaterial->material_index );
|
|
|
|
}
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getTexture, "getTexture( index )" )
|
|
|
|
{
|
2006-01-10 06:34:42 +00:00
|
|
|
// TODO: enable python switching
|
2006-01-06 03:46:54 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( KX_BlenderMaterial, setTexture , "setTexture( index, tex)")
|
|
|
|
{
|
2006-01-10 06:34:42 +00:00
|
|
|
// TODO: enable python switching
|
2006-01-06 03:46:54 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-01-15 11:34:55 +00:00
|
|
|
static unsigned int GL_array[11] = {
|
|
|
|
GL_ZERO,
|
|
|
|
GL_ONE,
|
|
|
|
GL_SRC_COLOR,
|
|
|
|
GL_ONE_MINUS_SRC_COLOR,
|
|
|
|
GL_DST_COLOR,
|
|
|
|
GL_ONE_MINUS_DST_COLOR,
|
|
|
|
GL_SRC_ALPHA,
|
|
|
|
GL_ONE_MINUS_SRC_ALPHA,
|
|
|
|
GL_DST_ALPHA,
|
|
|
|
GL_ONE_MINUS_DST_ALPHA,
|
|
|
|
GL_SRC_ALPHA_SATURATE
|
|
|
|
};
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( KX_BlenderMaterial, setBlending , "setBlending( GameLogic.src, GameLogic.dest)")
|
|
|
|
{
|
|
|
|
unsigned int b[2];
|
|
|
|
if(PyArg_ParseTuple(args, "ii", &b[0], &b[1]))
|
|
|
|
{
|
|
|
|
bool value_found[2] = {false, false};
|
|
|
|
for(int i=0; i<11; i++)
|
|
|
|
{
|
|
|
|
if(b[0] == GL_array[i]) {
|
|
|
|
value_found[0] = true;
|
|
|
|
mBlendFunc[0] = b[0];
|
|
|
|
}
|
|
|
|
if(b[1] == GL_array[i]) {
|
|
|
|
value_found[1] = true;
|
|
|
|
mBlendFunc[1] = b[1];
|
|
|
|
}
|
|
|
|
if(value_found[0] && value_found[1]) break;
|
|
|
|
}
|
|
|
|
if(!value_found[0] || !value_found[1]) {
|
|
|
|
PyErr_Format(PyExc_ValueError, "invalid enum.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
mUserDefBlend = true;
|
|
|
|
Py_Return;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|