diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-02-26 04:49:42 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-02-26 04:49:42 +0400 |
commit | 4643d61ffbbd99cf7c194fb73b77e7f2a256249f (patch) | |
tree | 04f88f46833d7c06d7ab51b43ca58a77bf5f43ce /source/blender/gpu/GPU_extensions.h | |
parent | a9facca8999bbf3278ebb10d36099e581c0b528b (diff) |
OpenGL: implemenation of fixed function lighting as per pixel GLSL shaders. The
code is still unused, but the intention is to use this to solve the double sided
lighting problem on NVidia, and to make the materials work on OpenGL ES 2.0
eventually.
The code works and matches the fixed function lighting pretty much exactly, but
still needs optimizations. The actual integration in object draw will be
committed later when more fixing & testing, there's lots of different combinations
and unclear OpenGL state here.
Diffstat (limited to 'source/blender/gpu/GPU_extensions.h')
-rw-r--r-- | source/blender/gpu/GPU_extensions.h | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index 66a7c917a55..7492304bd40 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -32,6 +32,8 @@ #ifndef __GPU_EXTENSIONS_H__ #define __GPU_EXTENSIONS_H__ +#include "BLI_utildefines.h" + #ifdef __cplusplus extern "C" { #endif @@ -160,17 +162,17 @@ void GPU_offscreen_read_pixels(GPUOffScreen *ofs, int type, void *pixels); * - only for fragment shaders now * - must call texture bind before setting a texture as uniform! */ -GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, const char *libcode); /*GPUShader *lib);*/ -/*GPUShader *GPU_shader_create_lib(const char *code);*/ +GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, const char *libcode, const char *defines); void GPU_shader_free(GPUShader *shader); void GPU_shader_bind(GPUShader *shader); -void GPU_shader_unbind(GPUShader *shader); +void GPU_shader_unbind(void); int GPU_shader_get_uniform(GPUShader *shader, const char *name); void GPU_shader_uniform_vector(GPUShader *shader, int location, int length, int arraysize, float *value); void GPU_shader_uniform_texture(GPUShader *shader, int location, GPUTexture *tex); +void GPU_shader_uniform_int(GPUShader *shader, int location, int value); int GPU_shader_get_attribute(GPUShader *shader, const char *name); @@ -199,6 +201,30 @@ typedef struct GPUVertexAttribs { int totlayer; } GPUVertexAttribs; +/* Fixed Function Materials */ + +typedef enum GPUFixedMaterialOption { + GPU_FIXED_COLOR_MATERIAL = (1<<0), /* replace diffuse with glcolor */ + GPU_FIXED_SOLID_LIGHTING = (1<<1), /* use solid lighting (only 3 directional lights) */ + GPU_FIXED_SCENE_LIGHTING = (1<<2), /* use scene lighting (up to 8 arbitrary lights) */ + GPU_FIXED_TWO_SIDED = (1<<3), /* flip normals towards viewer */ + GPU_FIXED_TEXTURE_2D = (1<<4), /* use 2D texture to replace diffuse color */ + + GPU_FIXED_OPTIONS_NUM = 5, + GPU_FIXED_OPTION_COMBINATIONS = (1<<GPU_FIXED_OPTIONS_NUM) +} GPUFixedMaterialOption; + +void GPU_fixed_materials_init(void); +void GPU_fixed_materials_exit(void); + +void GPU_fixed_material_shader_bind(int options); +void GPU_fixed_material_shader_unbind(void); + +void GPU_fixed_material_colors(const float diffuse[3], const float specular[3], + int shininess, float alpha); + +bool GPU_fixed_material_need_normals(void); + #ifdef __cplusplus } #endif |