23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
25 * POSSIBILITY OF SUCH DAMAGE. |
25 * POSSIBILITY OF SUCH DAMAGE. |
26 */ |
26 */ |
27 |
27 |
|
28 #include "ascension/shader.h" |
|
29 |
28 #include "ascension/context.h" |
30 #include "ascension/context.h" |
29 #include "ascension/error.h" |
31 #include "ascension/error.h" |
30 #include "ascension/shader.h" |
|
31 #include "ascension/filesystem.h" |
32 #include "ascension/filesystem.h" |
32 |
33 |
33 #include <string.h> |
34 #include <string.h> |
34 #include <stdio.h> |
35 #include <stdio.h> |
35 #include <GL/glew.h> |
36 #include <GL/glew.h> |
260 void asc_shader_clear_registry(void) { |
261 void asc_shader_clear_registry(void) { |
261 cxListClear(asc_active_glctx->shaders); |
262 cxListClear(asc_active_glctx->shaders); |
262 // also clear the active program to avoid accidental matches with newly created shaders |
263 // also clear the active program to avoid accidental matches with newly created shaders |
263 asc_shader_use(NULL, NULL); |
264 asc_shader_use(NULL, NULL); |
264 } |
265 } |
|
266 |
|
267 void asc_shader_upload_model_matrix(const AscShaderProgram *shader, const AscSceneNode *node) { |
|
268 glUniformMatrix4fv(shader->model, 1,GL_FALSE, node->world_transform); |
|
269 } |
|
270 |
|
271 void asc_shader_upload_col4f(int uniform_id, asc_col4f color) { |
|
272 glUniform4f(uniform_id, color.red, color.green, color.blue, color.alpha); |
|
273 } |
|
274 |
|
275 void asc_shader_upload_float(int uniform_id, float value) { |
|
276 glUniform1f(uniform_id, value); |
|
277 } |
|
278 |
|
279 void asc_shader_upload_vec2f(int uniform_id, asc_vec2f value) { |
|
280 glUniform2f(uniform_id, value.x, value.y); |
|
281 } |