![]() |
Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2005 Blender Foundation. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: all of this file. 00022 * 00023 * Contributor(s): Brecht Van Lommel. 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 */ 00027 00032 #ifndef GPU_EXTENSIONS_H 00033 #define GPU_EXTENSIONS_H 00034 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif 00038 00039 struct Image; 00040 struct ImageUser; 00041 00042 struct GPUTexture; 00043 typedef struct GPUTexture GPUTexture; 00044 00045 struct GPUFrameBuffer; 00046 typedef struct GPUFrameBuffer GPUFrameBuffer; 00047 00048 struct GPUOffScreen; 00049 typedef struct GPUOffScreen GPUOffScreen; 00050 00051 struct GPUShader; 00052 typedef struct GPUShader GPUShader; 00053 00054 /* GPU extensions support */ 00055 00056 void GPU_extensions_disable(void); 00057 void GPU_extensions_init(void); /* call this before running any of the functions below */ 00058 void GPU_extensions_exit(void); 00059 int GPU_print_error(const char *str); 00060 00061 int GPU_glsl_support(void); 00062 int GPU_non_power_of_two_support(void); 00063 int GPU_color_depth(void); 00064 void GPU_code_generate_glsl_lib(void); 00065 int GPU_bicubic_bump_support(void); 00066 00067 /* GPU Types */ 00068 00069 typedef enum GPUDeviceType { 00070 GPU_DEVICE_NVIDIA = (1<<0), 00071 GPU_DEVICE_ATI = (1<<1), 00072 GPU_DEVICE_INTEL = (1<<2), 00073 GPU_DEVICE_SOFTWARE = (1<<3), 00074 GPU_DEVICE_UNKNOWN = (1<<4), 00075 GPU_DEVICE_ANY = (0xff) 00076 } GPUDeviceType; 00077 00078 typedef enum GPUOSType { 00079 GPU_OS_WIN = (1<<8), 00080 GPU_OS_MAC = (1<<9), 00081 GPU_OS_UNIX = (1<<10), 00082 GPU_OS_ANY = (0xff00) 00083 } GPUOSType; 00084 00085 typedef enum GPUDriverType { 00086 GPU_DRIVER_OFFICIAL = (1<<16), 00087 GPU_DRIVER_OPENSOURCE = (1<<17), 00088 GPU_DRIVER_SOFTWARE = (1<<18), 00089 GPU_DRIVER_ANY = (0xff0000) 00090 } GPUDriverType; 00091 00092 int GPU_type_matches(GPUDeviceType device, GPUOSType os, GPUDriverType driver); 00093 00094 /* GPU Texture 00095 - always returns unsigned char RGBA textures 00096 - if texture with non square dimensions is created, depending on the 00097 graphics card capabilities the texture may actually be stored in a 00098 larger texture with power of two dimensions. the actual dimensions 00099 may be queried with GPU_texture_opengl_width/height. GPU_texture_coord_2f 00100 calls glTexCoord2f with the coordinates adjusted for this. 00101 - can use reference counting: 00102 - reference counter after GPU_texture_create is 1 00103 - GPU_texture_ref increases by one 00104 - GPU_texture_free decreases by one, and frees if 0 00105 - if created with from_blender, will not free the texture 00106 */ 00107 00108 GPUTexture *GPU_texture_create_1D(int w, float *pixels, char err_out[256]); 00109 GPUTexture *GPU_texture_create_2D(int w, int h, float *pixels, char err_out[256]); 00110 GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels); 00111 GPUTexture *GPU_texture_create_depth(int w, int h, char err_out[256]); 00112 GPUTexture *GPU_texture_from_blender(struct Image *ima, 00113 struct ImageUser *iuser, double time, int mipmap); 00114 void GPU_texture_free(GPUTexture *tex); 00115 00116 void GPU_texture_ref(GPUTexture *tex); 00117 00118 void GPU_texture_bind(GPUTexture *tex, int number); 00119 void GPU_texture_unbind(GPUTexture *tex); 00120 00121 GPUFrameBuffer *GPU_texture_framebuffer(GPUTexture *tex); 00122 00123 int GPU_texture_target(GPUTexture *tex); 00124 int GPU_texture_opengl_width(GPUTexture *tex); 00125 int GPU_texture_opengl_height(GPUTexture *tex); 00126 int GPU_texture_opengl_bindcode(GPUTexture *tex); 00127 00128 /* GPU Framebuffer 00129 - this is a wrapper for an OpenGL framebuffer object (FBO). in practice 00130 multiple FBO's may be created, to get around limitations on the number 00131 of attached textures and the dimension requirements. 00132 - after any of the GPU_framebuffer_* functions, GPU_framebuffer_restore must 00133 be called before rendering to the window framebuffer again */ 00134 00135 GPUFrameBuffer *GPU_framebuffer_create(void); 00136 int GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, GPUTexture *tex, char err_out[256]); 00137 void GPU_framebuffer_texture_detach(GPUFrameBuffer *fb, GPUTexture *tex); 00138 void GPU_framebuffer_texture_bind(GPUFrameBuffer *fb, GPUTexture *tex, int w, int h); 00139 void GPU_framebuffer_texture_unbind(GPUFrameBuffer *fb, GPUTexture *tex); 00140 void GPU_framebuffer_free(GPUFrameBuffer *fb); 00141 00142 void GPU_framebuffer_restore(void); 00143 00144 /* GPU OffScreen 00145 - wrapper around framebuffer and texture for simple offscreen drawing 00146 - changes size if graphics card can't support it */ 00147 00148 GPUOffScreen *GPU_offscreen_create(int width, int height, char err_out[256]); 00149 void GPU_offscreen_free(GPUOffScreen *ofs); 00150 void GPU_offscreen_bind(GPUOffScreen *ofs); 00151 void GPU_offscreen_unbind(GPUOffScreen *ofs); 00152 void GPU_offscreen_read_pixels(GPUOffScreen *ofs, int type, void *pixels); 00153 00154 /* GPU Shader 00155 - only for fragment shaders now 00156 - must call texture bind before setting a texture as uniform! */ 00157 00158 GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, const char *libcode); /*GPUShader *lib);*/ 00159 /*GPUShader *GPU_shader_create_lib(const char *code);*/ 00160 void GPU_shader_free(GPUShader *shader); 00161 00162 void GPU_shader_bind(GPUShader *shader); 00163 void GPU_shader_unbind(GPUShader *shader); 00164 00165 int GPU_shader_get_uniform(GPUShader *shader, const char *name); 00166 void GPU_shader_uniform_vector(GPUShader *shader, int location, int length, 00167 int arraysize, float *value); 00168 void GPU_shader_uniform_texture(GPUShader *shader, int location, GPUTexture *tex); 00169 00170 int GPU_shader_get_attribute(GPUShader *shader, const char *name); 00171 00172 /* Vertex attributes for shaders */ 00173 00174 #define GPU_MAX_ATTRIB 32 00175 00176 typedef struct GPUVertexAttribs { 00177 struct { 00178 int type; 00179 int glindex; 00180 int gltexco; 00181 int attribid; 00182 char name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ 00183 } layer[GPU_MAX_ATTRIB]; 00184 00185 int totlayer; 00186 } GPUVertexAttribs; 00187 00188 #ifdef __cplusplus 00189 } 00190 #endif 00191 00192 #endif 00193