| 
									
										
										
										
											2016-09-13 02:18:33 -04:00
										 |  |  |  | /*
 | 
					
						
							|  |  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							| 
									
										
										
										
											2018-04-22 08:44:23 +02:00
										 |  |  |  |  * of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2016-09-13 02:18:33 -04:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							|  |  |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * The Original Code is Copyright (C) 2016 Blender Foundation. | 
					
						
							|  |  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  |  */ | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-18 08:08:12 +11:00
										 |  |  |  | /** \file
 | 
					
						
							|  |  |  |  |  * \ingroup gpu | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  |  |  * GPU immediate mode work-alike | 
					
						
							| 
									
										
										
										
											2016-09-13 02:18:33 -04:00
										 |  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2016-08-04 15:36:20 -04:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-13 19:10:55 +10:00
										 |  |  |  | #pragma once
 | 
					
						
							| 
									
										
										
										
											2016-08-04 15:36:20 -04:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | #include "GPU_batch.h"
 | 
					
						
							|  |  |  |  | #include "GPU_immediate_util.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-19 09:33:03 +01:00
										 |  |  |  | #include "GPU_primitive.h"
 | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | #include "GPU_shader.h"
 | 
					
						
							| 
									
										
										
										
											2020-07-17 03:20:43 +02:00
										 |  |  |  | #include "GPU_texture.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-19 09:33:03 +01:00
										 |  |  |  | #include "GPU_vertex_format.h"
 | 
					
						
							| 
									
										
										
										
											2017-03-16 23:32:35 -04:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-02 15:28:47 +01:00
										 |  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  |  | extern "C" { | 
					
						
							|  |  |  |  | #endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-29 07:46:25 +11:00
										 |  |  |  | /** Returns a cleared vertex format, ready for #add_attr. */ | 
					
						
							|  |  |  |  | GPUVertFormat *immVertexFormat(void); | 
					
						
							| 
									
										
										
										
											2017-03-16 23:32:35 -04:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-29 07:46:25 +11:00
										 |  |  |  | /** Every immBegin must have a program bound first. */ | 
					
						
							| 
									
										
										
										
											2020-07-30 01:07:29 +02:00
										 |  |  |  | void immBindShader(GPUShader *shader); | 
					
						
							| 
									
										
										
										
											2019-01-29 07:46:25 +11:00
										 |  |  |  | /** Call after your last immEnd, or before binding another program. */ | 
					
						
							|  |  |  |  | void immUnbindProgram(void); | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-29 07:46:25 +11:00
										 |  |  |  | /** Must supply exactly vertex_len vertices. */ | 
					
						
							|  |  |  |  | void immBegin(GPUPrimType, uint vertex_len); | 
					
						
							|  |  |  |  | /** Can supply fewer vertices. */ | 
					
						
							|  |  |  |  | void immBeginAtMost(GPUPrimType, uint max_vertex_len); | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | void immEnd(void); /* finishes and draws. */ | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-22 01:45:43 +10:00
										 |  |  |  | /* immBegin a batch, then use standard immFunctions as usual. */ | 
					
						
							|  |  |  |  | /* immEnd will finalize the batch instead of drawing. */ | 
					
						
							|  |  |  |  | /* Then you can draw it as many times as you like!
 | 
					
						
							|  |  |  |  |  * Partially replaces the need for display lists. */ | 
					
						
							| 
									
										
										
										
											2018-07-18 23:09:31 +10:00
										 |  |  |  | GPUBatch *immBeginBatch(GPUPrimType, uint vertex_len); | 
					
						
							|  |  |  |  | GPUBatch *immBeginBatchAtMost(GPUPrimType, uint vertex_len); | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | /* Provide attribute values that can change per vertex. */ | 
					
						
							|  |  |  |  | /* First vertex after immBegin must have all its attributes specified. */ | 
					
						
							| 
									
										
										
										
											2018-10-09 10:49:44 +11:00
										 |  |  |  | /* Skipped attributes will continue using the previous value for that attr_id. */ | 
					
						
							| 
									
										
										
										
											2018-10-09 11:01:50 +11:00
										 |  |  |  | void immAttr1f(uint attr_id, float x); | 
					
						
							|  |  |  |  | void immAttr2f(uint attr_id, float x, float y); | 
					
						
							|  |  |  |  | void immAttr3f(uint attr_id, float x, float y, float z); | 
					
						
							|  |  |  |  | void immAttr4f(uint attr_id, float x, float y, float z, float w); | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 11:01:50 +11:00
										 |  |  |  | void immAttr2i(uint attr_id, int x, int y); | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 11:01:50 +11:00
										 |  |  |  | void immAttr1u(uint attr_id, uint x); | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 11:01:50 +11:00
										 |  |  |  | void immAttr2s(uint attr_id, short x, short y); | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 11:01:50 +11:00
										 |  |  |  | void immAttr2fv(uint attr_id, const float data[2]); | 
					
						
							|  |  |  |  | void immAttr3fv(uint attr_id, const float data[3]); | 
					
						
							|  |  |  |  | void immAttr4fv(uint attr_id, const float data[4]); | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 11:01:50 +11:00
										 |  |  |  | void immAttr3ub(uint attr_id, unsigned char r, unsigned char g, unsigned char b); | 
					
						
							|  |  |  |  | void immAttr4ub(uint attr_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a); | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-28 16:21:24 +11:00
										 |  |  |  | void immAttr3ubv(uint attr_id, const unsigned char data[3]); | 
					
						
							| 
									
										
										
										
											2018-10-09 11:01:50 +11:00
										 |  |  |  | void immAttr4ubv(uint attr_id, const unsigned char data[4]); | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | /* Explicitly skip an attribute. */ | 
					
						
							| 
									
										
										
										
											2018-10-09 10:49:44 +11:00
										 |  |  |  | /* This advanced option kills automatic value copying for this attr_id. */ | 
					
						
							| 
									
										
										
										
											2018-10-09 11:01:50 +11:00
										 |  |  |  | void immAttrSkip(uint attr_id); | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | /* Provide one last attribute value & end the current vertex. */ | 
					
						
							|  |  |  |  | /* This is most often used for 2D or 3D position (similar to glVertex). */ | 
					
						
							| 
									
										
										
										
											2018-10-09 10:49:44 +11:00
										 |  |  |  | void immVertex2f(uint attr_id, float x, float y); | 
					
						
							|  |  |  |  | void immVertex3f(uint attr_id, float x, float y, float z); | 
					
						
							|  |  |  |  | void immVertex4f(uint attr_id, float x, float y, float z, float w); | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 10:49:44 +11:00
										 |  |  |  | void immVertex2i(uint attr_id, int x, int y); | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 10:49:44 +11:00
										 |  |  |  | void immVertex2s(uint attr_id, short x, short y); | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 10:49:44 +11:00
										 |  |  |  | void immVertex2fv(uint attr_id, const float data[2]); | 
					
						
							|  |  |  |  | void immVertex3fv(uint attr_id, const float data[3]); | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 10:49:44 +11:00
										 |  |  |  | void immVertex2iv(uint attr_id, const int data[2]); | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | /* Provide uniform values that don't change for the entire draw call. */ | 
					
						
							| 
									
										
										
										
											2018-07-18 23:09:31 +10:00
										 |  |  |  | void immUniform1i(const char *name, int x); | 
					
						
							|  |  |  |  | void immUniform1f(const char *name, float x); | 
					
						
							|  |  |  |  | void immUniform2f(const char *name, float x, float y); | 
					
						
							|  |  |  |  | void immUniform2fv(const char *name, const float data[2]); | 
					
						
							|  |  |  |  | void immUniform3f(const char *name, float x, float y, float z); | 
					
						
							|  |  |  |  | void immUniform3fv(const char *name, const float data[3]); | 
					
						
							|  |  |  |  | void immUniform4f(const char *name, float x, float y, float z, float w); | 
					
						
							|  |  |  |  | void immUniform4fv(const char *name, const float data[4]); | 
					
						
							|  |  |  |  | void immUniformArray4fv(const char *bare_name, const float *data, int count); | 
					
						
							|  |  |  |  | void immUniformMatrix4fv(const char *name, const float data[4][4]); | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-17 03:20:43 +02:00
										 |  |  |  | void immBindTexture(const char *name, GPUTexture *tex); | 
					
						
							|  |  |  |  | void immBindTextureSampler(const char *name, GPUTexture *tex, eGPUSamplerState state); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | /* Convenience functions for setting "uniform vec4 color". */ | 
					
						
							|  |  |  |  | /* The rgb functions have implicit alpha = 1.0. */ | 
					
						
							|  |  |  |  | void immUniformColor4f(float r, float g, float b, float a); | 
					
						
							|  |  |  |  | void immUniformColor4fv(const float rgba[4]); | 
					
						
							|  |  |  |  | void immUniformColor3f(float r, float g, float b); | 
					
						
							|  |  |  |  | void immUniformColor3fv(const float rgb[3]); | 
					
						
							|  |  |  |  | void immUniformColor3fvAlpha(const float rgb[3], float a); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | void immUniformColor3ub(unsigned char r, unsigned char g, unsigned char b); | 
					
						
							|  |  |  |  | void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a); | 
					
						
							|  |  |  |  | void immUniformColor3ubv(const unsigned char rgb[3]); | 
					
						
							|  |  |  |  | void immUniformColor3ubvAlpha(const unsigned char rgb[3], unsigned char a); | 
					
						
							|  |  |  |  | void immUniformColor4ubv(const unsigned char rgba[4]); | 
					
						
							| 
									
										
										
										
											2016-09-15 18:41:28 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-14 10:48:42 +02:00
										 |  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2020-07-30 01:07:29 +02:00
										 |  |  |  |  * Extend #immBindShader to use Blender’s library of built-in shader programs. | 
					
						
							| 
									
										
										
										
											2019-04-14 10:48:42 +02:00
										 |  |  |  |  * Use #immUnbindProgram() when done. | 
					
						
							|  |  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2019-01-23 14:15:43 +11:00
										 |  |  |  | void immBindBuiltinProgram(eGPUBuiltinShader shader_id); | 
					
						
							| 
									
										
										
										
											2016-10-12 23:01:59 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-17 21:11:23 +02:00
										 |  |  |  | /* Extend immUniformColor to take Blender's themes */ | 
					
						
							| 
									
										
										
										
											2016-10-16 17:04:17 -04:00
										 |  |  |  | void immUniformThemeColor(int color_id); | 
					
						
							| 
									
										
										
										
											2020-08-06 18:28:22 +10:00
										 |  |  |  | void immUniformThemeColorAlpha(int color_id, float a); | 
					
						
							| 
									
										
										
										
											2017-04-05 10:59:46 +02:00
										 |  |  |  | void immUniformThemeColor3(int color_id); | 
					
						
							| 
									
										
										
										
											2016-10-16 17:04:17 -04:00
										 |  |  |  | void immUniformThemeColorShade(int color_id, int offset); | 
					
						
							|  |  |  |  | void immUniformThemeColorShadeAlpha(int color_id, int color_offset, int alpha_offset); | 
					
						
							|  |  |  |  | void immUniformThemeColorBlendShade(int color_id1, int color_id2, float fac, int offset); | 
					
						
							| 
									
										
										
										
											2016-12-13 16:45:59 -05:00
										 |  |  |  | void immUniformThemeColorBlend(int color_id1, int color_id2, float fac); | 
					
						
							| 
									
										
										
										
											2017-01-15 19:26:35 -05:00
										 |  |  |  | void immThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-02 15:28:47 +01:00
										 |  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | #endif
 |