2007-05-29 07:46:07 +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
|
|
|
#include "GL/glew.h"
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include "BL_Shader.h"
|
|
|
|
#include "BL_Material.h"
|
|
|
|
|
|
|
|
#include "MT_assert.h"
|
|
|
|
#include "MT_Matrix4x4.h"
|
|
|
|
#include "MT_Matrix3x3.h"
|
|
|
|
#include "KX_PyMath.h"
|
2006-01-10 06:34:42 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
#include "RAS_GLExtensionManager.h"
|
2006-02-13 05:45:32 +00:00
|
|
|
#include "RAS_MeshObject.h"
|
|
|
|
#include "RAS_IRasterizer.h"
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
#define spit(x) std::cout << x << std::endl;
|
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
#define SORT_UNIFORMS 1
|
2009-02-25 03:26:02 +00:00
|
|
|
#define UNIFORM_MAX_LEN (int)sizeof(float)*16
|
2007-01-21 04:45:44 +00:00
|
|
|
#define MAX_LOG_LEN 262144 // bounds
|
2006-04-02 21:04:20 +00:00
|
|
|
|
|
|
|
BL_Uniform::BL_Uniform(int data_size)
|
|
|
|
: mLoc(-1),
|
|
|
|
mDirty(true),
|
|
|
|
mType(UNI_NONE),
|
|
|
|
mTranspose(0),
|
|
|
|
mDataLen(data_size)
|
|
|
|
{
|
|
|
|
#ifdef SORT_UNIFORMS
|
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((int)mDataLen <= UNIFORM_MAX_LEN);
|
2006-04-02 21:04:20 +00:00
|
|
|
mData = (void*)MEM_mallocN(mDataLen, "shader-uniform-alloc");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
BL_Uniform::~BL_Uniform()
|
|
|
|
{
|
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
if(mData) {
|
|
|
|
MEM_freeN(mData);
|
|
|
|
mData=0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_Uniform::Apply(class BL_Shader *shader)
|
|
|
|
{
|
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
MT_assert(mType > UNI_NONE && mType < UNI_MAX && mData);
|
|
|
|
|
|
|
|
if(!mDirty)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch(mType)
|
|
|
|
{
|
|
|
|
case UNI_FLOAT: {
|
|
|
|
float *f = (float*)mData;
|
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
|
|
|
glUniform1fARB(mLoc,(GLfloat)*f);
|
2006-04-02 21:04:20 +00:00
|
|
|
}break;
|
|
|
|
case UNI_INT: {
|
|
|
|
int *f = (int*)mData;
|
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
|
|
|
glUniform1iARB(mLoc, (GLint)*f);
|
2006-04-02 21:04:20 +00:00
|
|
|
}break;
|
|
|
|
case UNI_FLOAT2: {
|
|
|
|
float *f = (float*)mData;
|
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
|
|
|
glUniform2fvARB(mLoc,1, (GLfloat*)f);
|
2006-04-02 21:04:20 +00:00
|
|
|
}break;
|
|
|
|
case UNI_FLOAT3: {
|
|
|
|
float *f = (float*)mData;
|
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
|
|
|
glUniform3fvARB(mLoc,1,(GLfloat*)f);
|
2006-04-02 21:04:20 +00:00
|
|
|
}break;
|
|
|
|
case UNI_FLOAT4: {
|
|
|
|
float *f = (float*)mData;
|
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
|
|
|
glUniform4fvARB(mLoc,1,(GLfloat*)f);
|
2006-04-02 21:04:20 +00:00
|
|
|
}break;
|
|
|
|
case UNI_INT2: {
|
|
|
|
int *f = (int*)mData;
|
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
|
|
|
glUniform2ivARB(mLoc,1,(GLint*)f);
|
2006-04-02 21:04:20 +00:00
|
|
|
}break;
|
|
|
|
case UNI_INT3: {
|
|
|
|
int *f = (int*)mData;
|
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
|
|
|
glUniform3ivARB(mLoc,1,(GLint*)f);
|
2006-04-02 21:04:20 +00:00
|
|
|
}break;
|
|
|
|
case UNI_INT4: {
|
|
|
|
int *f = (int*)mData;
|
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
|
|
|
glUniform4ivARB(mLoc,1,(GLint*)f);
|
2006-04-02 21:04:20 +00:00
|
|
|
}break;
|
|
|
|
case UNI_MAT4: {
|
|
|
|
float *f = (float*)mData;
|
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
|
|
|
glUniformMatrix4fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f);
|
2006-04-02 21:04:20 +00:00
|
|
|
}break;
|
|
|
|
case UNI_MAT3: {
|
|
|
|
float *f = (float*)mData;
|
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
|
|
|
glUniformMatrix3fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f);
|
2006-04-02 21:04:20 +00:00
|
|
|
}break;
|
|
|
|
}
|
|
|
|
mDirty = false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_Uniform::SetData(int location, int type,bool transpose)
|
|
|
|
{
|
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
mType = type;
|
|
|
|
mLoc = location;
|
|
|
|
mDirty = true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-02-25 03:26:02 +00:00
|
|
|
bool BL_Shader::Ok()const
|
2006-01-08 09:11:17 +00:00
|
|
|
{
|
2006-01-10 06:34:42 +00:00
|
|
|
return (mShader !=0 && mOk && mUse);
|
2006-01-08 09:11:17 +00:00
|
|
|
}
|
|
|
|
|
2009-06-28 11:22:26 +00:00
|
|
|
BL_Shader::BL_Shader()
|
|
|
|
: PyObjectPlus(),
|
2006-01-06 03:46:54 +00:00
|
|
|
mShader(0),
|
|
|
|
mPass(1),
|
|
|
|
mOk(0),
|
2006-01-10 06:34:42 +00:00
|
|
|
mUse(0),
|
2006-04-11 05:57:30 +00:00
|
|
|
mAttr(0),
|
2006-01-10 06:34:42 +00:00
|
|
|
vertProg(""),
|
2006-01-18 06:04:11 +00:00
|
|
|
fragProg(""),
|
|
|
|
mError(0),
|
2006-04-02 21:04:20 +00:00
|
|
|
mDirty(true)
|
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 this class will not be used
|
2006-04-11 05:57:30 +00:00
|
|
|
//for (int i=0; i<MAXTEX; i++) {
|
|
|
|
// mSampler[i] = BL_Sampler();
|
|
|
|
//}
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BL_Shader::~BL_Shader()
|
|
|
|
{
|
2006-04-11 05:57:30 +00:00
|
|
|
//for (int i=0; i<MAXTEX; i++){
|
|
|
|
// if(mSampler[i].mOwn) {
|
|
|
|
// if(mSampler[i].mTexture)
|
|
|
|
// mSampler[i].mTexture->DeleteTex();
|
|
|
|
// }
|
|
|
|
//}
|
2006-04-02 21:04:20 +00:00
|
|
|
ClearUniforms();
|
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
if( mShader ) {
|
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
|
|
|
glDeleteObjectARB(mShader);
|
2006-01-06 03:46:54 +00:00
|
|
|
mShader = 0;
|
|
|
|
}
|
|
|
|
vertProg = 0;
|
|
|
|
fragProg = 0;
|
|
|
|
mOk = 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
|
|
|
glUseProgramObjectARB(0);
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
void BL_Shader::ClearUniforms()
|
|
|
|
{
|
|
|
|
BL_UniformVec::iterator it = mUniforms.begin();
|
|
|
|
while(it != mUniforms.end()){
|
|
|
|
delete (*it);
|
|
|
|
it++;
|
|
|
|
}
|
|
|
|
mUniforms.clear();
|
|
|
|
|
|
|
|
|
|
|
|
BL_UniformVecDef::iterator itp = mPreDef.begin();
|
|
|
|
while(itp != mPreDef.end()) {
|
|
|
|
delete (*itp);
|
|
|
|
itp++;
|
|
|
|
}
|
|
|
|
mPreDef.clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BL_Uniform *BL_Shader::FindUniform(const int location)
|
|
|
|
{
|
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
BL_UniformVec::iterator it = mUniforms.begin();
|
|
|
|
while(it != mUniforms.end()) {
|
|
|
|
if((*it)->GetLocation() == location)
|
|
|
|
return (*it);
|
|
|
|
it++;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_Shader::SetUniformfv(int location, int type, float *param,int size, bool transpose)
|
|
|
|
{
|
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
BL_Uniform *uni= FindUniform(location);
|
|
|
|
if(uni) {
|
|
|
|
memcpy(uni->getData(), param, size);
|
|
|
|
uni->SetData(location, type, transpose);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
uni = new BL_Uniform(size);
|
|
|
|
memcpy(uni->getData(), param, size);
|
|
|
|
|
|
|
|
uni->SetData(location, type, transpose);
|
|
|
|
mUniforms.push_back(uni);
|
|
|
|
}
|
|
|
|
mDirty = true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_Shader::SetUniformiv(int location, int type, int *param,int size, bool transpose)
|
|
|
|
{
|
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
BL_Uniform *uni= FindUniform(location);
|
|
|
|
if(uni) {
|
|
|
|
memcpy(uni->getData(), param, size);
|
|
|
|
uni->SetData(location, type, transpose);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
uni = new BL_Uniform(size);
|
|
|
|
memcpy(uni->getData(), param, size);
|
|
|
|
uni->SetData(location, type, transpose);
|
|
|
|
mUniforms.push_back(uni);
|
|
|
|
}
|
|
|
|
mDirty = true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BL_Shader::ApplyShader()
|
|
|
|
{
|
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
if(!mDirty)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for(unsigned int i=0; i<mUniforms.size(); i++)
|
|
|
|
mUniforms[i]->Apply(this);
|
|
|
|
|
|
|
|
mDirty = false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_Shader::UnloadShader()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
bool BL_Shader::LinkProgram()
|
|
|
|
{
|
2006-02-13 05:45:32 +00:00
|
|
|
int vertlen = 0, fraglen=0, proglen=0;
|
|
|
|
int vertstatus=0, fragstatus=0, progstatus=0;
|
2006-01-18 06:04:11 +00:00
|
|
|
unsigned int tmpVert=0, tmpFrag=0, tmpProg=0;
|
|
|
|
int char_len=0;
|
2007-01-21 04:45:44 +00:00
|
|
|
char *logInf =0;
|
2006-01-06 03:46:54 +00:00
|
|
|
|
2006-01-18 06:46:56 +00:00
|
|
|
if(mError)
|
|
|
|
goto programError;
|
|
|
|
|
2006-01-10 06:34:42 +00:00
|
|
|
if(!vertProg || !fragProg){
|
|
|
|
spit("Invalid GLSL sources");
|
|
|
|
return 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_fragment_shader) {
|
2006-01-18 06:04:11 +00:00
|
|
|
spit("Fragment shaders not supported");
|
2006-01-10 06:34:42 +00:00
|
|
|
return 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_vertex_shader) {
|
2006-01-18 06:04:11 +00:00
|
|
|
spit("Vertex shaders not supported");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -- vertex shader ------------------
|
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
|
|
|
tmpVert = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
|
|
|
|
glShaderSourceARB(tmpVert, 1, (const char**)&vertProg, 0);
|
|
|
|
glCompileShaderARB(tmpVert);
|
|
|
|
glGetObjectParameterivARB(tmpVert, GL_OBJECT_INFO_LOG_LENGTH_ARB,(GLint*) &vertlen);
|
2006-02-13 05:45:32 +00:00
|
|
|
|
2006-01-18 06:04:11 +00:00
|
|
|
// print info if any
|
2007-01-21 04:45:44 +00:00
|
|
|
if( vertlen > 0 && vertlen < MAX_LOG_LEN){
|
|
|
|
logInf = (char*)MEM_mallocN(vertlen, "vert-log");
|
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
|
|
|
glGetInfoLogARB(tmpVert, vertlen, (GLsizei*)&char_len, logInf);
|
2006-02-13 05:45:32 +00:00
|
|
|
if(char_len >0) {
|
|
|
|
spit("---- Vertex Shader Error ----");
|
2007-01-21 04:45:44 +00:00
|
|
|
spit(logInf);
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
2007-01-21 04:45:44 +00:00
|
|
|
MEM_freeN(logInf);
|
|
|
|
logInf=0;
|
2006-01-10 06:34:42 +00:00
|
|
|
}
|
2006-01-18 06:04:11 +00:00
|
|
|
// check for compile errors
|
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
|
|
|
glGetObjectParameterivARB(tmpVert, GL_OBJECT_COMPILE_STATUS_ARB,(GLint*)&vertstatus);
|
2006-02-13 05:45:32 +00:00
|
|
|
if(!vertstatus) {
|
|
|
|
spit("---- Vertex shader failed to compile ----");
|
2006-01-18 06:04:11 +00:00
|
|
|
goto programError;
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
2006-01-18 06:04:11 +00:00
|
|
|
|
|
|
|
// -- fragment shader ----------------
|
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
|
|
|
tmpFrag = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
|
|
|
|
glShaderSourceARB(tmpFrag, 1,(const char**)&fragProg, 0);
|
|
|
|
glCompileShaderARB(tmpFrag);
|
|
|
|
glGetObjectParameterivARB(tmpFrag, GL_OBJECT_INFO_LOG_LENGTH_ARB, (GLint*) &fraglen);
|
2007-01-21 04:45:44 +00:00
|
|
|
if(fraglen >0 && fraglen < MAX_LOG_LEN){
|
|
|
|
logInf = (char*)MEM_mallocN(fraglen, "frag-log");
|
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
|
|
|
glGetInfoLogARB(tmpFrag, fraglen,(GLsizei*) &char_len, logInf);
|
2006-02-13 05:45:32 +00:00
|
|
|
if(char_len >0) {
|
|
|
|
spit("---- Fragment Shader Error ----");
|
2007-01-21 04:45:44 +00:00
|
|
|
spit(logInf);
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
2007-01-21 04:45:44 +00:00
|
|
|
MEM_freeN(logInf);
|
|
|
|
logInf=0;
|
2006-01-10 06:34:42 +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
|
|
|
glGetObjectParameterivARB(tmpFrag, GL_OBJECT_COMPILE_STATUS_ARB, (GLint*) &fragstatus);
|
2006-02-13 05:45:32 +00:00
|
|
|
if(!fragstatus){
|
|
|
|
spit("---- Fragment shader failed to compile ----");
|
2006-01-18 06:04:11 +00:00
|
|
|
goto programError;
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
2006-01-06 03:46:54 +00:00
|
|
|
|
2006-01-18 06:04:11 +00:00
|
|
|
|
|
|
|
// -- program ------------------------
|
|
|
|
// set compiled vert/frag shader & link
|
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
|
|
|
tmpProg = glCreateProgramObjectARB();
|
|
|
|
glAttachObjectARB(tmpProg, tmpVert);
|
|
|
|
glAttachObjectARB(tmpProg, tmpFrag);
|
|
|
|
glLinkProgramARB(tmpProg);
|
|
|
|
glGetObjectParameterivARB(tmpProg, GL_OBJECT_INFO_LOG_LENGTH_ARB, (GLint*) &proglen);
|
|
|
|
glGetObjectParameterivARB(tmpProg, GL_OBJECT_LINK_STATUS_ARB, (GLint*) &progstatus);
|
2006-02-13 05:45:32 +00:00
|
|
|
|
2006-01-18 06:04:11 +00:00
|
|
|
|
2007-01-21 04:45:44 +00:00
|
|
|
if(proglen > 0 && proglen < MAX_LOG_LEN) {
|
|
|
|
logInf = (char*)MEM_mallocN(proglen, "prog-log");
|
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
|
|
|
glGetInfoLogARB(tmpProg, proglen, (GLsizei*)&char_len, logInf);
|
2006-02-13 05:45:32 +00:00
|
|
|
if(char_len >0) {
|
|
|
|
spit("---- GLSL Program ----");
|
2007-01-21 04:45:44 +00:00
|
|
|
spit(logInf);
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
2007-01-21 04:45:44 +00:00
|
|
|
MEM_freeN(logInf);
|
|
|
|
logInf=0;
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!progstatus){
|
|
|
|
spit("---- GLSL program failed to link ----");
|
|
|
|
goto programError;
|
2006-01-10 06:34:42 +00:00
|
|
|
}
|
2006-01-06 03:46:54 +00:00
|
|
|
|
2006-01-10 06:34:42 +00:00
|
|
|
// set
|
|
|
|
mShader = tmpProg;
|
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
|
|
|
glDeleteObjectARB(tmpVert);
|
|
|
|
glDeleteObjectARB(tmpFrag);
|
2006-01-06 03:46:54 +00:00
|
|
|
mOk = 1;
|
2006-02-13 05:45:32 +00:00
|
|
|
mError = 0;
|
2006-01-06 03:46:54 +00:00
|
|
|
return true;
|
2006-01-18 06:04:11 +00:00
|
|
|
|
|
|
|
programError:
|
|
|
|
if(tmpVert) {
|
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
|
|
|
glDeleteObjectARB(tmpVert);
|
2006-01-18 06:04:11 +00:00
|
|
|
tmpVert=0;
|
|
|
|
}
|
|
|
|
if(tmpFrag) {
|
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
|
|
|
glDeleteObjectARB(tmpFrag);
|
2006-01-18 06:04:11 +00:00
|
|
|
tmpFrag=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(tmpProg) {
|
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
|
|
|
glDeleteObjectARB(tmpProg);
|
2006-01-18 06:04:11 +00:00
|
|
|
tmpProg=0;
|
|
|
|
}
|
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
mOk = 0;
|
|
|
|
mUse = 0;
|
|
|
|
mError = 1;
|
2006-01-18 06:04:11 +00:00
|
|
|
return false;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
const char *BL_Shader::GetVertPtr()
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
|
|
|
return vertProg?vertProg:0;
|
|
|
|
}
|
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
const char *BL_Shader::GetFragPtr()
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
|
|
|
return fragProg?fragProg:0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_Shader::SetVertPtr( char *vert )
|
|
|
|
{
|
|
|
|
vertProg = vert;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_Shader::SetFragPtr( char *frag )
|
|
|
|
{
|
|
|
|
fragProg = frag;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int BL_Shader::GetProg()
|
|
|
|
{
|
|
|
|
return mShader;
|
|
|
|
}
|
2006-04-11 05:57:30 +00:00
|
|
|
//
|
|
|
|
//const BL_Sampler* BL_Shader::GetSampler(int i)
|
|
|
|
//{
|
|
|
|
// MT_assert(i<=MAXTEX);
|
|
|
|
// return &mSampler[i];
|
|
|
|
//}
|
2006-01-06 03:46:54 +00:00
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
void BL_Shader::SetSampler(int loc, int unit)
|
|
|
|
{
|
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 &&
|
|
|
|
GLEW_ARB_vertex_shader &&
|
|
|
|
GLEW_ARB_shader_objects
|
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
|
|
|
glUniform1iARB(loc, unit);
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-11 05:57:30 +00:00
|
|
|
//
|
|
|
|
//void BL_Shader::InitializeSampler(int unit, BL_Texture* texture)
|
|
|
|
//{
|
|
|
|
// MT_assert(unit<=MAXTEX);
|
|
|
|
// mSampler[unit].mTexture = texture;
|
|
|
|
// mSampler[unit].mLoc =-1;
|
|
|
|
// mSampler[unit].mOwn = 0;
|
|
|
|
//}
|
2006-02-13 05:45:32 +00:00
|
|
|
|
|
|
|
void BL_Shader::SetProg(bool enable)
|
|
|
|
{
|
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 &&
|
|
|
|
GLEW_ARB_vertex_shader &&
|
|
|
|
GLEW_ARB_shader_objects
|
2006-02-13 05:45:32 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
if( mShader != 0 && mOk && enable) {
|
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
|
|
|
glUseProgramObjectARB(mShader);
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
glUseProgramObjectARB(0);
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void BL_Shader::Update( const RAS_MeshSlot & ms, RAS_IRasterizer* rasty )
|
2006-02-13 05:45:32 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
if(!Ok() || !mPreDef.size())
|
|
|
|
return;
|
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
|
|
|
if( GLEW_ARB_fragment_shader &&
|
|
|
|
GLEW_ARB_vertex_shader &&
|
|
|
|
GLEW_ARB_shader_objects
|
2006-02-13 05:45:32 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
MT_Matrix4x4 model;
|
|
|
|
model.setValue(ms.m_OpenGLMatrix);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
const MT_Matrix4x4& view = rasty->GetViewMatrix();
|
2006-04-02 21:04:20 +00:00
|
|
|
|
2006-04-13 05:11:34 +00:00
|
|
|
if(mAttr==SHD_TANGENT)
|
|
|
|
ms.m_mesh->SetMeshModified(true);
|
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
BL_UniformVecDef::iterator it;
|
|
|
|
for(it = mPreDef.begin(); it!= mPreDef.end(); it++)
|
2006-02-13 05:45:32 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
BL_DefUniform *uni = (*it);
|
2006-04-11 05:57:30 +00:00
|
|
|
if(uni->mLoc == -1) continue;
|
2006-02-13 05:45:32 +00:00
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
switch (uni->mType)
|
|
|
|
{
|
|
|
|
case MODELMATRIX:
|
|
|
|
{
|
|
|
|
SetUniform(uni->mLoc, model);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MODELMATRIX_TRANSPOSE:
|
|
|
|
{
|
|
|
|
SetUniform(uni->mLoc, model, true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MODELMATRIX_INVERSE:
|
|
|
|
{
|
|
|
|
model.invert();
|
|
|
|
SetUniform(uni->mLoc, model);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MODELMATRIX_INVERSETRANSPOSE:
|
|
|
|
{
|
|
|
|
model.invert();
|
|
|
|
SetUniform(uni->mLoc, model, true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MODELVIEWMATRIX:
|
|
|
|
{
|
|
|
|
SetUniform(uni->mLoc, view*model);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case MODELVIEWMATRIX_TRANSPOSE:
|
|
|
|
{
|
|
|
|
MT_Matrix4x4 mat(view*model);
|
|
|
|
SetUniform(uni->mLoc, mat, true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MODELVIEWMATRIX_INVERSE:
|
|
|
|
{
|
|
|
|
MT_Matrix4x4 mat(view*model);
|
|
|
|
mat.invert();
|
|
|
|
SetUniform(uni->mLoc, mat);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MODELVIEWMATRIX_INVERSETRANSPOSE:
|
|
|
|
{
|
|
|
|
MT_Matrix4x4 mat(view*model);
|
|
|
|
mat.invert();
|
|
|
|
SetUniform(uni->mLoc, mat, true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CAM_POS:
|
|
|
|
{
|
|
|
|
MT_Point3 pos(rasty->GetCameraPosition());
|
|
|
|
SetUniform(uni->mLoc, pos);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VIEWMATRIX:
|
|
|
|
{
|
|
|
|
SetUniform(uni->mLoc, view);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VIEWMATRIX_TRANSPOSE:
|
|
|
|
{
|
|
|
|
SetUniform(uni->mLoc, view, true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VIEWMATRIX_INVERSE:
|
|
|
|
{
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
MT_Matrix4x4 viewinv = view;
|
|
|
|
viewinv.invert();
|
2006-04-02 21:04:20 +00:00
|
|
|
SetUniform(uni->mLoc, view);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VIEWMATRIX_INVERSETRANSPOSE:
|
|
|
|
{
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
MT_Matrix4x4 viewinv = view;
|
|
|
|
viewinv.invert();
|
2006-04-02 21:04:20 +00:00
|
|
|
SetUniform(uni->mLoc, view, true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CONSTANT_TIMER:
|
|
|
|
{
|
|
|
|
SetUniform(uni->mLoc, (float)rasty->GetTime());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2006-02-13 05:45:32 +00:00
|
|
|
break;
|
2006-04-02 21:04:20 +00:00
|
|
|
}
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int BL_Shader::GetAttribLocation(const STR_String& name)
|
|
|
|
{
|
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 &&
|
|
|
|
GLEW_ARB_vertex_shader &&
|
|
|
|
GLEW_ARB_shader_objects
|
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
|
|
|
return glGetAttribLocationARB(mShader, name.ReadPtr());
|
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
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_Shader::BindAttribute(const STR_String& attr, int loc)
|
|
|
|
{
|
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 &&
|
|
|
|
GLEW_ARB_vertex_shader &&
|
|
|
|
GLEW_ARB_shader_objects
|
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
|
|
|
glBindAttribLocationARB(mShader, loc, attr.ReadPtr());
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int BL_Shader::GetUniformLocation(const STR_String& name)
|
|
|
|
{
|
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 &&
|
|
|
|
GLEW_ARB_vertex_shader &&
|
|
|
|
GLEW_ARB_shader_objects
|
2006-02-13 05:45:32 +00:00
|
|
|
)
|
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
MT_assert(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
|
|
|
int location = glGetUniformLocationARB(mShader, name.ReadPtr());
|
2006-04-02 21:04:20 +00:00
|
|
|
if(location == -1)
|
|
|
|
spit("Invalid uniform value: " << name.ReadPtr() << ".");
|
|
|
|
return location;
|
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
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_Shader::SetUniform(int uniform, const MT_Tuple2& vec)
|
|
|
|
{
|
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 &&
|
|
|
|
GLEW_ARB_vertex_shader &&
|
|
|
|
GLEW_ARB_shader_objects
|
2006-02-13 05:45:32 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
float value[2];
|
|
|
|
vec.getValue(value);
|
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
|
|
|
glUniform2fvARB(uniform, 1, value);
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_Shader::SetUniform(int uniform, const MT_Tuple3& vec)
|
|
|
|
{
|
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 &&
|
|
|
|
GLEW_ARB_vertex_shader &&
|
|
|
|
GLEW_ARB_shader_objects
|
2006-02-13 05:45:32 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
float value[3];
|
|
|
|
vec.getValue(value);
|
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
|
|
|
glUniform3fvARB(uniform, 1, value);
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_Shader::SetUniform(int uniform, const MT_Tuple4& vec)
|
|
|
|
{
|
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 &&
|
|
|
|
GLEW_ARB_vertex_shader &&
|
|
|
|
GLEW_ARB_shader_objects
|
2006-02-13 05:45:32 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
float value[4];
|
|
|
|
vec.getValue(value);
|
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
|
|
|
glUniform4fvARB(uniform, 1, value);
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_Shader::SetUniform(int uniform, const unsigned int& val)
|
|
|
|
{
|
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 &&
|
|
|
|
GLEW_ARB_vertex_shader &&
|
|
|
|
GLEW_ARB_shader_objects
|
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
|
|
|
glUniform1iARB(uniform, val);
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
void BL_Shader::SetUniform(int uniform, const int val)
|
|
|
|
{
|
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 &&
|
|
|
|
GLEW_ARB_vertex_shader &&
|
|
|
|
GLEW_ARB_shader_objects
|
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
|
|
|
glUniform1iARB(uniform, val);
|
2006-04-02 21:04:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
void BL_Shader::SetUniform(int uniform, const float& val)
|
|
|
|
{
|
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 &&
|
|
|
|
GLEW_ARB_vertex_shader &&
|
|
|
|
GLEW_ARB_shader_objects
|
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
|
|
|
glUniform1fARB(uniform, val);
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_Shader::SetUniform(int uniform, const MT_Matrix4x4& vec, bool transpose)
|
|
|
|
{
|
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 &&
|
|
|
|
GLEW_ARB_vertex_shader &&
|
|
|
|
GLEW_ARB_shader_objects
|
2006-02-13 05:45:32 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
float value[16];
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
// note: getValue gives back column major as needed by OpenGL
|
2006-02-13 05:45:32 +00:00
|
|
|
vec.getValue(value);
|
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
|
|
|
glUniformMatrix4fvARB(uniform, 1, transpose?GL_TRUE:GL_FALSE, value);
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_Shader::SetUniform(int uniform, const MT_Matrix3x3& vec, bool transpose)
|
|
|
|
{
|
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 &&
|
|
|
|
GLEW_ARB_vertex_shader &&
|
|
|
|
GLEW_ARB_shader_objects
|
2006-02-13 05:45:32 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
float value[9];
|
2006-04-02 21:04:20 +00:00
|
|
|
value[0] = (float)vec[0][0]; value[1] = (float)vec[1][0]; value[2] = (float)vec[2][0];
|
|
|
|
value[3] = (float)vec[0][1]; value[4] = (float)vec[1][1]; value[5] = (float)vec[2][1];
|
|
|
|
value[6] = (float)vec[0][2]; value[7] = (float)vec[1][2]; value[7] = (float)vec[2][2];
|
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
|
|
|
glUniformMatrix3fvARB(uniform, 1, transpose?GL_TRUE:GL_FALSE, value);
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
void BL_Shader::SetUniform(int uniform, const float* val, int len)
|
|
|
|
{
|
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 &&
|
|
|
|
GLEW_ARB_vertex_shader &&
|
|
|
|
GLEW_ARB_shader_objects
|
2006-04-02 21:04:20 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
if(len == 2)
|
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
|
|
|
glUniform2fvARB(uniform, 1,(GLfloat*)val);
|
2006-04-02 21:04:20 +00:00
|
|
|
else if (len == 3)
|
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
|
|
|
glUniform3fvARB(uniform, 1,(GLfloat*)val);
|
2006-04-02 21:04:20 +00:00
|
|
|
else if (len == 4)
|
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
|
|
|
glUniform4fvARB(uniform, 1,(GLfloat*)val);
|
2006-04-02 21:04:20 +00:00
|
|
|
else
|
|
|
|
MT_assert(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_Shader::SetUniform(int uniform, const int* val, int len)
|
|
|
|
{
|
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 &&
|
|
|
|
GLEW_ARB_vertex_shader &&
|
|
|
|
GLEW_ARB_shader_objects
|
2006-04-02 21:04:20 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
if(len == 2)
|
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
|
|
|
glUniform2ivARB(uniform, 1, (GLint*)val);
|
2006-04-02 21:04:20 +00:00
|
|
|
else if (len == 3)
|
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
|
|
|
glUniform3ivARB(uniform, 1, (GLint*)val);
|
2006-04-02 21:04:20 +00:00
|
|
|
else if (len == 4)
|
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
|
|
|
glUniform4ivARB(uniform, 1, (GLint*)val);
|
2006-04-02 21:04:20 +00:00
|
|
|
else
|
|
|
|
MT_assert(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
PyMethodDef BL_Shader::Methods[] =
|
|
|
|
{
|
|
|
|
// creation
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, setSource ),
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, delSource ),
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, getVertexProg ),
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, getFragmentProg ),
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, setNumberOfPasses ),
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, validate),
|
|
|
|
/// access functions
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, isValid),
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, setUniform1f ),
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, setUniform2f ),
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, setUniform3f ),
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, setUniform4f ),
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, setUniform1i ),
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, setUniform2i ),
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, setUniform3i ),
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, setUniform4i ),
|
2006-04-11 05:57:30 +00:00
|
|
|
KX_PYMETHODTABLE( BL_Shader, setAttrib ),
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, setUniformfv ),
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, setUniformiv ),
|
2006-02-13 05:45:32 +00:00
|
|
|
KX_PYMETHODTABLE( BL_Shader, setUniformDef ),
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, setSampler ),
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, setUniformMatrix4 ),
|
|
|
|
KX_PYMETHODTABLE( BL_Shader, setUniformMatrix3 ),
|
|
|
|
|
|
|
|
{NULL,NULL} //Sentinel
|
|
|
|
};
|
|
|
|
|
2009-02-26 09:04:06 +00:00
|
|
|
PyAttributeDef BL_Shader::Attributes[] = {
|
|
|
|
{ NULL } //Sentinel
|
|
|
|
};
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
PyTypeObject BL_Shader::Type = {
|
2009-06-08 20:08:19 +00:00
|
|
|
PyVarObject_HEAD_INIT(NULL, 0)
|
2009-08-10 00:07:34 +00:00
|
|
|
"BL_Shader",
|
|
|
|
sizeof(PyObjectPlus_Proxy),
|
|
|
|
0,
|
|
|
|
py_base_dealloc,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
py_base_repr,
|
|
|
|
0,0,0,0,0,0,0,0,0,
|
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
|
|
|
|
0,0,0,0,0,0,0,
|
|
|
|
Methods,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
&PyObjectPlus::Type,
|
|
|
|
0,0,0,0,0,0,
|
|
|
|
py_base_new
|
2006-01-06 03:46:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, setSource," setSource(vertexProgram, fragmentProgram)" )
|
|
|
|
{
|
|
|
|
if(mShader !=0 && mOk )
|
|
|
|
{
|
|
|
|
// already set...
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
char *v,*f;
|
|
|
|
int apply=0;
|
2009-04-20 15:06:46 +00:00
|
|
|
if( PyArg_ParseTuple(args, "ssi:setSource", &v, &f, &apply) )
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
|
|
|
vertProg = v;
|
|
|
|
fragProg = f;
|
2006-01-10 06:34:42 +00:00
|
|
|
if( LinkProgram() ) {
|
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
|
|
|
glUseProgramObjectARB( mShader );
|
2006-01-06 03:46:54 +00:00
|
|
|
mUse = apply!=0;
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2006-01-10 06:34:42 +00:00
|
|
|
vertProg = 0;
|
|
|
|
fragProg = 0;
|
|
|
|
mUse = 0;
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2008-07-01 16:43:46 +00:00
|
|
|
return NULL;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, delSource, "delSource( )" )
|
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
ClearUniforms();
|
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
|
|
|
glUseProgramObjectARB(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
|
|
|
glDeleteObjectARB(mShader);
|
2006-01-06 03:46:54 +00:00
|
|
|
mShader = 0;
|
|
|
|
mOk = 0;
|
|
|
|
mUse = 0;
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, isValid, "isValid()" )
|
|
|
|
{
|
2009-06-29 02:25:54 +00:00
|
|
|
return PyLong_FromSsize_t( ( mShader !=0 && mOk ) );
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, getVertexProg ,"getVertexProg( )" )
|
|
|
|
{
|
2009-06-29 02:25:54 +00:00
|
|
|
return PyUnicode_FromString(vertProg?vertProg:"");
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, getFragmentProg ,"getFragmentProg( )" )
|
|
|
|
{
|
2009-06-29 02:25:54 +00:00
|
|
|
return PyUnicode_FromString(fragProg?fragProg:"");
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()")
|
|
|
|
{
|
2006-01-18 06:04:11 +00:00
|
|
|
if(mError) {
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-18 06:04:11 +00:00
|
|
|
}
|
2006-01-15 11:34:55 +00:00
|
|
|
if(mShader==0) {
|
2009-04-20 15:06:46 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "shader.validate(): BL_Shader, invalid shader object");
|
2006-01-06 03:46:54 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2006-02-13 05:45:32 +00:00
|
|
|
int stat = 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
|
|
|
glValidateProgramARB(mShader);
|
|
|
|
glGetObjectParameterivARB(mShader, GL_OBJECT_VALIDATE_STATUS_ARB,(GLint*) &stat);
|
2006-02-13 05:45:32 +00:00
|
|
|
|
2007-01-21 04:45:44 +00:00
|
|
|
|
|
|
|
if(stat > 0 && stat < MAX_LOG_LEN) {
|
2006-02-13 05:45:32 +00:00
|
|
|
int char_len=0;
|
2007-01-21 04:45:44 +00:00
|
|
|
char *logInf = (char*)MEM_mallocN(stat, "validate-log");
|
|
|
|
|
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
|
|
|
glGetInfoLogARB(mShader, stat,(GLsizei*) &char_len, logInf);
|
2006-02-13 05:45:32 +00:00
|
|
|
if(char_len >0) {
|
|
|
|
spit("---- GLSL Validation ----");
|
2007-01-21 04:45:44 +00:00
|
|
|
spit(logInf);
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
2007-01-21 04:45:44 +00:00
|
|
|
MEM_freeN(logInf);
|
|
|
|
logInf=0;
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, setSampler, "setSampler(name, index)" )
|
|
|
|
{
|
2006-01-18 06:04:11 +00:00
|
|
|
if(mError) {
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-18 06:04:11 +00:00
|
|
|
}
|
|
|
|
|
2008-09-20 11:08:35 +00:00
|
|
|
const char *uniform="";
|
2006-01-06 03:46:54 +00:00
|
|
|
int index=-1;
|
2009-04-20 15:06:46 +00:00
|
|
|
if(PyArg_ParseTuple(args, "si:setSampler", &uniform, &index))
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
int loc = GetUniformLocation(uniform);
|
|
|
|
if(loc != -1) {
|
2006-04-11 05:57:30 +00:00
|
|
|
if(index >= MAXTEX && index < 0)
|
2006-01-06 03:46:54 +00:00
|
|
|
spit("Invalid texture sample index: " << index);
|
2006-04-11 05:57:30 +00:00
|
|
|
|
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
SetUniformiv(loc, BL_Uniform::UNI_INT, &index, (sizeof(int)) );
|
|
|
|
#else
|
|
|
|
SetUniform(loc, index);
|
|
|
|
#endif
|
|
|
|
//if(index <= MAXTEX)
|
|
|
|
// mSampler[index].mLoc = loc;
|
|
|
|
//else
|
|
|
|
// spit("Invalid texture sample index: " << index);
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, setNumberOfPasses, "setNumberOfPasses( max-pass )" )
|
|
|
|
{
|
|
|
|
int pass = 1;
|
2009-04-20 15:06:46 +00:00
|
|
|
if(!PyArg_ParseTuple(args, "i:setNumberOfPasses", &pass))
|
2006-01-06 03:46:54 +00:00
|
|
|
return NULL;
|
|
|
|
|
2006-01-15 11:34:55 +00:00
|
|
|
mPass = 1;
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// access functions
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, setUniform1f, "setUniform1f(name, fx)" )
|
|
|
|
{
|
2006-01-18 06:04:11 +00:00
|
|
|
if(mError) {
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-18 06:04:11 +00:00
|
|
|
}
|
|
|
|
|
2008-09-20 11:08:35 +00:00
|
|
|
const char *uniform="";
|
2006-01-06 03:46:54 +00:00
|
|
|
float value=0;
|
2009-04-20 15:06:46 +00:00
|
|
|
if(PyArg_ParseTuple(args, "sf:setUniform1f", &uniform, &value ))
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
int loc = GetUniformLocation(uniform);
|
|
|
|
if(loc != -1)
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
SetUniformfv(loc, BL_Uniform::UNI_FLOAT, &value, sizeof(float));
|
|
|
|
#else
|
|
|
|
SetUniform( loc, (float)value );
|
|
|
|
#endif
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f , "setUniform2f(name, fx, fy)")
|
|
|
|
{
|
2006-01-18 06:04:11 +00:00
|
|
|
if(mError) {
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-18 06:04:11 +00:00
|
|
|
}
|
2008-09-20 11:08:35 +00:00
|
|
|
const char *uniform="";
|
2006-01-06 03:46:54 +00:00
|
|
|
float array[2]={ 0,0 };
|
2009-04-20 15:06:46 +00:00
|
|
|
if(PyArg_ParseTuple(args, "sff:setUniform2f", &uniform, &array[0],&array[1] ))
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
int loc = GetUniformLocation(uniform);
|
|
|
|
if(loc != -1)
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
SetUniformfv(loc, BL_Uniform::UNI_FLOAT2, array, (sizeof(float)*2) );
|
|
|
|
#else
|
|
|
|
SetUniform(loc, array, 2);
|
|
|
|
#endif
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, setUniform3f, "setUniform3f(name, fx,fy,fz) ")
|
|
|
|
{
|
2006-01-18 06:04:11 +00:00
|
|
|
if(mError) {
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-18 06:04:11 +00:00
|
|
|
}
|
2008-09-20 11:08:35 +00:00
|
|
|
const char *uniform="";
|
2006-01-06 03:46:54 +00:00
|
|
|
float array[3]={0,0,0};
|
2009-04-20 15:06:46 +00:00
|
|
|
if(PyArg_ParseTuple(args, "sfff:setUniform3f", &uniform, &array[0],&array[1],&array[2]))
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
int loc = GetUniformLocation(uniform);
|
|
|
|
if(loc != -1)
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
SetUniformfv(loc, BL_Uniform::UNI_FLOAT3, array, (sizeof(float)*3) );
|
|
|
|
#else
|
|
|
|
SetUniform(loc, array, 3);
|
|
|
|
#endif
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, setUniform4f, "setUniform4f(name, fx,fy,fz, fw) ")
|
|
|
|
{
|
2006-01-18 06:04:11 +00:00
|
|
|
if(mError) {
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-18 06:04:11 +00:00
|
|
|
}
|
2008-09-20 11:08:35 +00:00
|
|
|
const char *uniform="";
|
2006-01-06 03:46:54 +00:00
|
|
|
float array[4]={0,0,0,0};
|
2009-04-20 15:06:46 +00:00
|
|
|
if(PyArg_ParseTuple(args, "sffff:setUniform4f", &uniform, &array[0],&array[1],&array[2], &array[3]))
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
int loc = GetUniformLocation(uniform);
|
|
|
|
if(loc != -1)
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
SetUniformfv(loc, BL_Uniform::UNI_FLOAT4, array, (sizeof(float)*4) );
|
|
|
|
#else
|
|
|
|
SetUniform(loc, array, 4);
|
|
|
|
#endif
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, setUniform1i, "setUniform1i(name, ix)" )
|
|
|
|
{
|
2006-01-18 06:04:11 +00:00
|
|
|
if(mError) {
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-18 06:04:11 +00:00
|
|
|
}
|
2008-09-20 11:08:35 +00:00
|
|
|
const char *uniform="";
|
2006-01-06 03:46:54 +00:00
|
|
|
int value=0;
|
2009-04-20 15:06:46 +00:00
|
|
|
if(PyArg_ParseTuple(args, "si:setUniform1i", &uniform, &value ))
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
int loc = GetUniformLocation(uniform);
|
|
|
|
if(loc != -1)
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
SetUniformiv(loc, BL_Uniform::UNI_INT, &value, sizeof(int));
|
|
|
|
#else
|
|
|
|
SetUniform(loc, (int)value);
|
|
|
|
#endif
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i , "setUniform2i(name, ix, iy)")
|
|
|
|
{
|
2006-01-18 06:04:11 +00:00
|
|
|
if(mError) {
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-18 06:04:11 +00:00
|
|
|
}
|
2008-09-20 11:08:35 +00:00
|
|
|
const char *uniform="";
|
2006-01-06 03:46:54 +00:00
|
|
|
int array[2]={ 0,0 };
|
2009-04-20 15:06:46 +00:00
|
|
|
if(PyArg_ParseTuple(args, "sii:setUniform2i", &uniform, &array[0],&array[1] ))
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
int loc = GetUniformLocation(uniform);
|
|
|
|
if(loc != -1)
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
SetUniformiv(loc, BL_Uniform::UNI_INT2, array, sizeof(int)*2);
|
|
|
|
#else
|
|
|
|
SetUniform(loc, array, 2);
|
|
|
|
#endif
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, setUniform3i, "setUniform3i(name, ix,iy,iz) ")
|
|
|
|
{
|
2006-01-18 06:04:11 +00:00
|
|
|
if(mError) {
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-18 06:04:11 +00:00
|
|
|
}
|
2006-04-02 21:04:20 +00:00
|
|
|
|
2008-09-20 11:08:35 +00:00
|
|
|
const char *uniform="";
|
2006-01-06 03:46:54 +00:00
|
|
|
int array[3]={0,0,0};
|
2009-04-20 15:06:46 +00:00
|
|
|
if(PyArg_ParseTuple(args, "siii:setUniform3i", &uniform, &array[0],&array[1],&array[2]))
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
int loc = GetUniformLocation(uniform);
|
|
|
|
if(loc != -1)
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
SetUniformiv(loc, BL_Uniform::UNI_INT3, array, sizeof(int)*3);
|
|
|
|
#else
|
|
|
|
SetUniform(loc, array, 3);
|
|
|
|
#endif
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, setUniform4i, "setUniform4i(name, ix,iy,iz, iw) ")
|
|
|
|
{
|
2006-01-18 06:04:11 +00:00
|
|
|
if(mError) {
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-18 06:04:11 +00:00
|
|
|
}
|
2008-09-20 11:08:35 +00:00
|
|
|
const char *uniform="";
|
2006-01-06 03:46:54 +00:00
|
|
|
int array[4]={0,0,0, 0};
|
2009-04-20 15:06:46 +00:00
|
|
|
if(PyArg_ParseTuple(args, "siiii:setUniform4i", &uniform, &array[0],&array[1],&array[2], &array[3] ))
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
int loc = GetUniformLocation(uniform);
|
|
|
|
if(loc != -1)
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
SetUniformiv(loc, BL_Uniform::UNI_INT4, array, sizeof(int)*4);
|
|
|
|
#else
|
|
|
|
SetUniform(loc, array, 4);
|
|
|
|
#endif
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv , "setUniformfv( float (list2 or list3 or list4) )")
|
|
|
|
{
|
2006-01-18 06:04:11 +00:00
|
|
|
if(mError) {
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-18 06:04:11 +00:00
|
|
|
}
|
2008-09-20 11:08:35 +00:00
|
|
|
const char *uniform = "";
|
2006-01-06 03:46:54 +00:00
|
|
|
PyObject *listPtr =0;
|
|
|
|
float array_data[4] = {0.f,0.f,0.f,0.f};
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
if(PyArg_ParseTuple(args, "sO:setUniformfv", &uniform, &listPtr))
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
int loc = GetUniformLocation(uniform);
|
|
|
|
if(loc != -1)
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
|
|
|
if(PySequence_Check(listPtr))
|
|
|
|
{
|
|
|
|
unsigned int list_size = PySequence_Size(listPtr);
|
|
|
|
|
2007-01-21 04:45:44 +00:00
|
|
|
for(unsigned int i=0; (i<list_size && i<4); i++)
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
|
|
|
PyObject *item = PySequence_GetItem(listPtr, i);
|
|
|
|
array_data[i] = (float)PyFloat_AsDouble(item);
|
|
|
|
Py_DECREF(item);
|
|
|
|
}
|
2006-04-02 21:04:20 +00:00
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
switch(list_size)
|
|
|
|
{
|
|
|
|
case 2:
|
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
float array2[2] = { array_data[0],array_data[1] };
|
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
SetUniformfv(loc, BL_Uniform::UNI_FLOAT2, array2, sizeof(float)*2);
|
|
|
|
#else
|
|
|
|
SetUniform(loc, array2, 2);
|
|
|
|
#endif
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
} break;
|
|
|
|
case 3:
|
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
float array3[3] = { array_data[0],array_data[1],array_data[2] };
|
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
SetUniformfv(loc, BL_Uniform::UNI_FLOAT3, array3, sizeof(float)*3);
|
|
|
|
#else
|
|
|
|
SetUniform(loc, array3, 3);
|
|
|
|
#endif
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}break;
|
|
|
|
case 4:
|
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
float array4[4] = { array_data[0],array_data[1],array_data[2],array_data[3] };
|
|
|
|
#ifdef SORT_UNIFORMS
|
|
|
|
SetUniformfv(loc, BL_Uniform::UNI_FLOAT4, array4, sizeof(float)*4);
|
|
|
|
#else
|
|
|
|
SetUniform(loc, array4, 4);
|
|
|
|
#endif
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}break;
|
|
|
|
default:
|
|
|
|
{
|
2009-04-20 15:06:46 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "shader.setUniform4i(name, ix,iy,iz, iw): BL_Shader. invalid list size");
|
2006-01-06 03:46:54 +00:00
|
|
|
return NULL;
|
|
|
|
}break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, setUniformiv, "setUniformiv( uniform_name, (list2 or list3 or list4) )")
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-01-18 06:04:11 +00:00
|
|
|
if(mError) {
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-18 06:04:11 +00:00
|
|
|
}
|
2008-09-20 11:08:35 +00:00
|
|
|
const char *uniform = "";
|
2006-01-06 03:46:54 +00:00
|
|
|
PyObject *listPtr =0;
|
|
|
|
int array_data[4] = {0,0,0,0};
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
if(!PyArg_ParseTuple(args, "sO:setUniformiv", &uniform, &listPtr))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
int loc = GetUniformLocation(uniform);
|
|
|
|
|
|
|
|
if(loc == -1) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "shader.setUniformiv(...): BL_Shader, first string argument is not a valid uniform value");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!PySequence_Check(listPtr)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "shader.setUniformiv(...): BL_Shader, second argument is not a sequence");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int list_size = PySequence_Size(listPtr);
|
|
|
|
|
|
|
|
for(unsigned int i=0; (i<list_size && i<4); i++)
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2009-04-20 15:06:46 +00:00
|
|
|
PyObject *item = PySequence_GetItem(listPtr, i);
|
2009-06-29 02:25:54 +00:00
|
|
|
array_data[i] = PyLong_AsSsize_t(item);
|
2009-04-20 15:06:46 +00:00
|
|
|
Py_DECREF(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(PyErr_Occurred()) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "shader.setUniformiv(...): BL_Shader, one or more values in the list is not an int");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sanity checks done! */
|
|
|
|
|
|
|
|
switch(list_size)
|
|
|
|
{
|
|
|
|
case 2:
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2009-04-20 15:06:46 +00:00
|
|
|
int array2[2] = { array_data[0],array_data[1]};
|
2006-04-02 21:04:20 +00:00
|
|
|
#ifdef SORT_UNIFORMS
|
2009-04-20 15:06:46 +00:00
|
|
|
SetUniformiv(loc, BL_Uniform::UNI_INT2, array2, sizeof(int)*2);
|
2006-04-02 21:04:20 +00:00
|
|
|
#else
|
2009-04-20 15:06:46 +00:00
|
|
|
SetUniform(loc, array2, 2);
|
2006-04-02 21:04:20 +00:00
|
|
|
#endif
|
2009-04-20 15:06:46 +00:00
|
|
|
Py_RETURN_NONE;
|
|
|
|
} break;
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
int array3[3] = { array_data[0],array_data[1],array_data[2] };
|
2006-04-02 21:04:20 +00:00
|
|
|
#ifdef SORT_UNIFORMS
|
2009-04-20 15:06:46 +00:00
|
|
|
SetUniformiv(loc, BL_Uniform::UNI_INT3, array3, sizeof(int)*3);
|
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
#else
|
2009-04-20 15:06:46 +00:00
|
|
|
SetUniform(loc, array3, 3);
|
2006-04-02 21:04:20 +00:00
|
|
|
#endif
|
2009-04-20 15:06:46 +00:00
|
|
|
Py_RETURN_NONE;
|
|
|
|
}break;
|
|
|
|
case 4:
|
|
|
|
{
|
|
|
|
int array4[4] = { array_data[0],array_data[1],array_data[2],array_data[3] };
|
2006-04-02 21:04:20 +00:00
|
|
|
#ifdef SORT_UNIFORMS
|
2009-04-20 15:06:46 +00:00
|
|
|
SetUniformiv(loc, BL_Uniform::UNI_INT4, array4, sizeof(int)*4);
|
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
#else
|
2009-04-20 15:06:46 +00:00
|
|
|
SetUniform(loc, array4, 4);
|
2006-04-02 21:04:20 +00:00
|
|
|
#endif
|
2009-04-20 15:06:46 +00:00
|
|
|
Py_RETURN_NONE;
|
|
|
|
}break;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_TypeError, "shader.setUniformiv(...): BL_Shader, second argument, invalid list size, expected an int list between 2 and 4");
|
|
|
|
return NULL;
|
|
|
|
}break;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2009-04-20 15:06:46 +00:00
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix4,
|
2009-04-20 15:06:46 +00:00
|
|
|
"setUniformMatrix4(uniform_name, mat-4x4, transpose(row-major=true, col-major=false)" )
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-01-18 06:04:11 +00:00
|
|
|
if(mError) {
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-18 06:04:11 +00:00
|
|
|
}
|
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
float matr[16] = {
|
|
|
|
1,0,0,0,
|
|
|
|
0,1,0,0,
|
|
|
|
0,0,1,0,
|
|
|
|
0,0,0,1
|
|
|
|
};
|
|
|
|
|
2008-09-20 11:08:35 +00:00
|
|
|
const char *uniform="";
|
2006-01-06 03:46:54 +00:00
|
|
|
PyObject *matrix=0;
|
|
|
|
int transp=1; // MT_ is row major so transpose by default....
|
2009-04-20 15:06:46 +00:00
|
|
|
|
|
|
|
if(!PyArg_ParseTuple(args, "sO|i:setUniformMatrix4",&uniform, &matrix,&transp))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
int loc = GetUniformLocation(uniform);
|
|
|
|
|
|
|
|
if(loc == -1) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "shader.setUniformMatrix4(...): BL_Shader, first string argument is not a valid uniform value");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
MT_Matrix4x4 mat;
|
|
|
|
|
|
|
|
if (!PyMatTo(matrix, mat)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "shader.setUniformMatrix4(...): BL_Shader, second argument cannot be converted into a 4x4 matrix");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sanity checks done! */
|
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
#ifdef SORT_UNIFORMS
|
2009-04-20 15:06:46 +00:00
|
|
|
mat.getValue(matr);
|
|
|
|
SetUniformfv(loc, BL_Uniform::UNI_MAT4, matr, (sizeof(float)*16), (transp!=0) );
|
2006-04-02 21:04:20 +00:00
|
|
|
#else
|
2009-04-20 15:06:46 +00:00
|
|
|
SetUniform(loc,mat,(transp!=0));
|
2006-04-02 21:04:20 +00:00
|
|
|
#endif
|
2009-04-20 15:06:46 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix3,
|
2009-04-20 15:06:46 +00:00
|
|
|
"setUniformMatrix3(uniform_name, list[3x3], transpose(row-major=true, col-major=false)" )
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2006-01-18 06:04:11 +00:00
|
|
|
if(mError) {
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-18 06:04:11 +00:00
|
|
|
}
|
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
float matr[9] = {
|
|
|
|
1,0,0,
|
|
|
|
0,1,0,
|
|
|
|
0,0,1,
|
|
|
|
};
|
|
|
|
|
2008-09-20 11:08:35 +00:00
|
|
|
const char *uniform="";
|
2006-01-06 03:46:54 +00:00
|
|
|
PyObject *matrix=0;
|
|
|
|
int transp=1; // MT_ is row major so transpose by default....
|
2009-04-20 15:06:46 +00:00
|
|
|
if(!PyArg_ParseTuple(args, "sO|i:setUniformMatrix3",&uniform, &matrix,&transp))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
int loc = GetUniformLocation(uniform);
|
|
|
|
|
|
|
|
if(loc == -1) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "shader.setUniformMatrix3(...): BL_Shader, first string argument is not a valid uniform value");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MT_Matrix3x3 mat;
|
|
|
|
|
|
|
|
if (!PyMatTo(matrix, mat)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "shader.setUniformMatrix3(...): BL_Shader, second argument cannot be converted into a 3x3 matrix");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
#ifdef SORT_UNIFORMS
|
2009-04-20 15:06:46 +00:00
|
|
|
mat.getValue(matr);
|
|
|
|
SetUniformfv(loc, BL_Uniform::UNI_MAT3, matr, (sizeof(float)*9), (transp!=0) );
|
2006-04-02 21:04:20 +00:00
|
|
|
#else
|
2009-04-20 15:06:46 +00:00
|
|
|
SetUniform(loc,mat,(transp!=0));
|
2006-04-02 21:04:20 +00:00
|
|
|
#endif
|
2009-04-20 15:06:46 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-01-06 03:46:54 +00:00
|
|
|
}
|
2006-02-13 05:45:32 +00:00
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" )
|
|
|
|
{
|
2006-04-11 05:57:30 +00:00
|
|
|
if(mError) {
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-04-11 05:57:30 +00:00
|
|
|
}
|
2009-04-20 15:06:46 +00:00
|
|
|
|
2006-04-11 05:57:30 +00:00
|
|
|
int attr=0;
|
2009-04-20 15:06:46 +00:00
|
|
|
|
|
|
|
if(!PyArg_ParseTuple(args, "i:setAttrib", &attr ))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if(mShader==0) {
|
|
|
|
PyErr_SetString(PyExc_ValueError, "shader.setAttrib() BL_Shader, invalid shader object");
|
|
|
|
return NULL;
|
2006-04-11 05:57:30 +00:00
|
|
|
}
|
2009-04-20 15:06:46 +00:00
|
|
|
mAttr=SHD_TANGENT; /* What the heck is going on here - attr is just ignored??? - Campbell */
|
|
|
|
glUseProgramObjectARB(mShader);
|
|
|
|
glBindAttribLocationARB(mShader, mAttr, "Tangent");
|
|
|
|
Py_RETURN_NONE;
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
|
2006-02-13 05:45:32 +00:00
|
|
|
KX_PYMETHODDEF_DOC( BL_Shader, setUniformDef, "setUniformDef(name, enum)" )
|
|
|
|
{
|
|
|
|
if(mError) {
|
2008-08-14 03:23:36 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
|
|
|
|
2008-09-20 11:08:35 +00:00
|
|
|
const char *uniform="";
|
2006-04-02 21:04:20 +00:00
|
|
|
int nloc=0;
|
2009-04-20 15:06:46 +00:00
|
|
|
if(PyArg_ParseTuple(args, "si:setUniformDef",&uniform, &nloc))
|
2006-02-13 05:45:32 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
int loc = GetUniformLocation(uniform);
|
|
|
|
if(loc != -1)
|
2006-02-13 05:45:32 +00:00
|
|
|
{
|
2006-04-02 21:04:20 +00:00
|
|
|
bool defined = false;
|
|
|
|
BL_UniformVecDef::iterator it = mPreDef.begin();
|
|
|
|
while(it != mPreDef.end()) {
|
|
|
|
if((*it)->mLoc == loc) {
|
|
|
|
defined = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
it++;
|
|
|
|
}
|
|
|
|
if(defined)
|
|
|
|
{
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-04-02 21:04:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BL_DefUniform *uni = new BL_DefUniform();
|
|
|
|
uni->mLoc = loc;
|
|
|
|
uni->mType = nloc;
|
|
|
|
uni->mFlag = 0;
|
|
|
|
mPreDef.push_back(uni);
|
2009-02-21 12:43:24 +00:00
|
|
|
Py_RETURN_NONE;
|
2006-02-13 05:45:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-04-02 21:04:20 +00:00
|
|
|
// eof
|