Gawain: bind a shader for immediate mode

How to use:
1) set up vertex format
2) bind a shader
3) draw with immBegin … immEnd
4) unbind shader

TODO: expand this a little, so we can send uniform values to the bound
shader.
This commit is contained in:
Mike Erwin 2016-08-07 01:35:42 -04:00
parent 6fea42d677
commit 11ffbfb36a
2 changed files with 10 additions and 0 deletions

View File

@ -98,6 +98,8 @@ typedef enum GPUBuiltinShader {
GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader);
GPUShader *GPU_shader_get_builtin_fx_shader(int effects, bool persp);
void GPU_shader_bind_immediate(GPUBuiltinShader);
void GPU_shader_free_builtin_shaders(void);
/* Vertex attributes for shaders */

View File

@ -39,6 +39,7 @@
#include "GPU_glew.h"
#include "GPU_shader.h"
#include "GPU_texture.h"
#include "GPU_immediate.h"
/* TODO(sergey): Find better default values for this constants. */
#define MAX_DEFINE_LENGTH 1024
@ -463,6 +464,13 @@ void GPU_shader_bind(GPUShader *shader)
GPU_ASSERT_NO_GL_ERRORS("Post Shader Bind");
}
void GPU_shader_bind_immediate(GPUBuiltinShader shader_id)
{
GPUShader *shader = GPU_shader_get_builtin_shader(shader_id);
GPU_shader_bind(shader);
bind_attrib_locations(&immVertexFormat, shader->program);
}
void GPU_shader_unbind(void)
{
GPU_ASSERT_NO_GL_ERRORS("Pre Shader Unbind");