forked from bartvdbraak/blender
272a91f754
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.
179 lines
3.0 KiB
C++
179 lines
3.0 KiB
C++
#ifndef __BL_MATERIAL_H__
|
|
#define __BL_MATERIAL_H__
|
|
|
|
#include "STR_String.h"
|
|
#include "MT_Point2.h"
|
|
|
|
// --
|
|
struct MTex;
|
|
struct Material;
|
|
struct Image;
|
|
struct MTFace;
|
|
struct MTex;
|
|
struct Material;
|
|
struct EnvMap;
|
|
// --
|
|
|
|
/** max units
|
|
this will default to users available units
|
|
to build with more available, just increment this value
|
|
although the more you add the slower the search time will be.
|
|
we will go for three, which should be enough
|
|
*/
|
|
#define MAXTEX 3 //match in RAS_TexVert & RAS_OpenGLRasterizer
|
|
|
|
// different mapping modes
|
|
class BL_Mapping
|
|
{
|
|
public:
|
|
int mapping;
|
|
float scale[3];
|
|
float offsets[3];
|
|
int projplane[3];
|
|
STR_String objconame;
|
|
STR_String uvCoName;
|
|
};
|
|
|
|
// base material struct
|
|
class BL_Material
|
|
{
|
|
private:
|
|
int num_users;
|
|
bool share;
|
|
|
|
public:
|
|
// -----------------------------------
|
|
BL_Material();
|
|
|
|
int IdMode;
|
|
unsigned int ras_mode;
|
|
bool glslmat;
|
|
|
|
STR_String texname[MAXTEX];
|
|
unsigned int flag[MAXTEX];
|
|
int tile,tilexrep[MAXTEX],tileyrep[MAXTEX];
|
|
STR_String matname;
|
|
STR_String mtexname[MAXTEX];
|
|
|
|
float matcolor[4];
|
|
float speccolor[3];
|
|
short transp, pad;
|
|
|
|
float hard, spec_f;
|
|
float alpha, emit, color_blend[MAXTEX], ref;
|
|
float amb;
|
|
|
|
int blend_mode[MAXTEX];
|
|
|
|
int mode;
|
|
int num_enabled;
|
|
|
|
int material_index;
|
|
|
|
BL_Mapping mapping[MAXTEX];
|
|
STR_String imageId[MAXTEX];
|
|
|
|
|
|
Material* material;
|
|
MTFace* tface;
|
|
Image* img[MAXTEX];
|
|
EnvMap* cubemap[MAXTEX];
|
|
|
|
unsigned int rgb[4];
|
|
MT_Point2 uv[4];
|
|
MT_Point2 uv2[4];
|
|
|
|
void SetConversionRGB(unsigned int *rgb);
|
|
void GetConversionRGB(unsigned int *rgb);
|
|
|
|
void SetConversionUV(MT_Point2 *uv);
|
|
void GetConversionUV(MT_Point2 *uv);
|
|
|
|
void SetConversionUV2(MT_Point2 *uv);
|
|
void GetConversionUV2(MT_Point2 *uv);
|
|
|
|
void SetSharedMaterial(bool v);
|
|
bool IsShared();
|
|
void SetUsers(int num);
|
|
};
|
|
|
|
// BL_Material::IdMode
|
|
enum BL_IdMode {
|
|
DEFAULT_BLENDER=-1,
|
|
TEXFACE,
|
|
ONETEX,
|
|
TWOTEX,
|
|
GREATERTHAN2
|
|
};
|
|
|
|
// BL_Material::blend_mode[index]
|
|
enum BL_BlendMode
|
|
{
|
|
BLEND_MIX=1,
|
|
BLEND_ADD,
|
|
BLEND_SUB,
|
|
BLEND_MUL,
|
|
BLEND_SCR
|
|
};
|
|
|
|
// -------------------------------------
|
|
// BL_Material::flag[index]
|
|
enum BL_flag
|
|
{
|
|
MIPMAP=1, // set to use mipmaps
|
|
CALCALPHA=2, // additive
|
|
USEALPHA=4, // use actual alpha channel
|
|
TEXALPHA=8, // use alpha combiner functions
|
|
TEXNEG=16, // negate blending
|
|
HASIPO=32,
|
|
USENEGALPHA=64,
|
|
ALPHA_TEST=128
|
|
};
|
|
|
|
// BL_Material::ras_mode
|
|
enum BL_ras_mode
|
|
{
|
|
POLY_VIS=1,
|
|
COLLIDER=2,
|
|
ZSORT=4,
|
|
TRANSP=8,
|
|
TRIANGLE=16,
|
|
USE_LIGHT=32,
|
|
WIRE=64
|
|
};
|
|
|
|
// -------------------------------------
|
|
// BL_Material::mapping[index]::mapping
|
|
enum BL_MappingFlag
|
|
{
|
|
USEENV =1,
|
|
// --
|
|
USEREFL =2,
|
|
USEOBJ =4,
|
|
USENORM =8,
|
|
USEORCO =16,
|
|
USEUV =32,
|
|
USETANG =64,
|
|
DISABLE =128,
|
|
USECUSTOMUV=256
|
|
};
|
|
|
|
// BL_Material::BL_Mapping::projplane
|
|
enum BL_MappingProj
|
|
{
|
|
PROJN=0,
|
|
PROJX,
|
|
PROJY,
|
|
PROJZ
|
|
};
|
|
|
|
// ------------------------------------
|
|
//extern void initBL_Material(BL_Material* mat);
|
|
extern MTex* getImageFromMaterial(Material *mat, int index);
|
|
extern int getNumTexChannels( Material *mat );
|
|
// ------------------------------------
|
|
|
|
#endif
|
|
|
|
|