this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Moved default shader IDs into context storage.

+20 -34
-3
SDL_gpu/GLES_1/SDL_gpu_GLES_1.h
··· 38 38 39 39 typedef struct ContextData_GLES_1 40 40 { 41 - Uint32 default_textured_shader_program; 42 - Uint32 default_untextured_shader_program; 43 - 44 41 SDL_Color last_color; 45 42 Uint8 last_use_blending; 46 43 GPU_BlendEnum last_blend_mode;
-3
SDL_gpu/GLES_2/SDL_gpu_GLES_2.h
··· 19 19 20 20 typedef struct ContextData_GLES_2 21 21 { 22 - Uint32 default_textured_shader_program; 23 - Uint32 default_untextured_shader_program; 24 - 25 22 SDL_Color last_color; 26 23 Uint8 last_use_blending; 27 24 GPU_BlendEnum last_blend_mode;
+15 -18
SDL_gpu/GL_common/SDL_gpu_GL_common.inl
··· 649 649 static void prepareToRenderImage(GPU_Renderer* renderer, GPU_Target* target, GPU_Image* image) 650 650 { 651 651 GPU_Context* context = renderer->current_context_target->context; 652 - CONTEXT_DATA* cdata = (CONTEXT_DATA*)context->data; 653 652 654 653 // TODO: Store this state and only call it from FlushBlitBuffer() 655 654 glEnable(GL_TEXTURE_2D); ··· 666 665 changeBlendMode(renderer, image->blend_mode); 667 666 668 667 // If we're using the untextured shader, switch it. 669 - if(context->current_shader_program == cdata->default_untextured_shader_program) 670 - renderer->ActivateShaderProgram(renderer, cdata->default_textured_shader_program, NULL); 668 + if(context->current_shader_program == context->default_untextured_shader_program) 669 + renderer->ActivateShaderProgram(renderer, context->default_textured_shader_program, NULL); 671 670 } 672 671 673 672 static void prepareToRenderShapes(GPU_Renderer* renderer) 674 673 { 675 674 GPU_Context* context = renderer->current_context_target->context; 676 - CONTEXT_DATA* cdata = (CONTEXT_DATA*)context->data; 677 675 678 676 // TODO: Store this state and only call it from FlushBlitBuffer() 679 677 glDisable(GL_TEXTURE_2D); ··· 684 682 changeBlendMode(renderer, context->shapes_blend_mode); 685 683 686 684 // If we're using the textured shader, switch it. 687 - if(context->current_shader_program == cdata->default_textured_shader_program) 688 - renderer->ActivateShaderProgram(renderer, cdata->default_untextured_shader_program, NULL); 685 + if(context->current_shader_program == context->default_textured_shader_program) 686 + renderer->ActivateShaderProgram(renderer, context->default_untextured_shader_program, NULL); 689 687 } 690 688 691 689 ··· 988 986 renderer->SetLineThickness(renderer, 1.0f); 989 987 990 988 991 - cdata->default_textured_shader_program = 0; 992 - cdata->default_untextured_shader_program = 0; 989 + target->context->default_textured_shader_program = 0; 990 + target->context->default_untextured_shader_program = 0; 993 991 target->context->current_shader_program = 0; 994 992 995 993 #ifndef SDL_GPU_DISABLE_SHADERS ··· 1012 1010 if(!p) 1013 1011 GPU_LogError("Failed to link default textured shader program: %s\n", renderer->GetShaderMessage(renderer)); 1014 1012 1015 - cdata->default_textured_shader_program = p; 1013 + target->context->default_textured_shader_program = p; 1016 1014 1017 1015 #ifdef SDL_GPU_USE_GL_TIER3 1018 1016 TARGET_DATA* data = ((TARGET_DATA*)target->data); ··· 1038 1036 1039 1037 glUseProgram(p); 1040 1038 1041 - cdata->default_untextured_shader_program = target->context->current_shader_program = p; 1039 + target->context->default_untextured_shader_program = target->context->current_shader_program = p; 1042 1040 1043 1041 #ifdef SDL_GPU_USE_GL_TIER3 1044 1042 // Get locations of the attributes in the shader ··· 3701 3699 3702 3700 static Uint8 IsDefaultShaderProgram(GPU_Renderer* renderer, Uint32 program_object) 3703 3701 { 3704 - CONTEXT_DATA* cdata = (CONTEXT_DATA*)renderer->current_context_target->context->data; 3705 - return (program_object == cdata->default_textured_shader_program || program_object == cdata->default_untextured_shader_program); 3702 + GPU_Context* context = renderer->current_context_target->context; 3703 + return (program_object == context->default_textured_shader_program || program_object == context->default_untextured_shader_program); 3706 3704 } 3707 3705 3708 3706 static void ActivateShaderProgram(GPU_Renderer* renderer, Uint32 program_object, GPU_ShaderBlock* block) ··· 3712 3710 if(target == NULL) 3713 3711 return; 3714 3712 3715 - CONTEXT_DATA* cdata = (CONTEXT_DATA*)target->context->data; 3716 3713 if(program_object == 0) // Implies default shader 3717 3714 { 3718 3715 // Already using a default shader? 3719 - if(target->context->current_shader_program == cdata->default_textured_shader_program 3720 - || target->context->current_shader_program == cdata->default_untextured_shader_program) 3716 + if(target->context->current_shader_program == target->context->default_textured_shader_program 3717 + || target->context->current_shader_program == target->context->default_untextured_shader_program) 3721 3718 return; 3722 3719 3723 - program_object = cdata->default_untextured_shader_program; 3720 + program_object = target->context->default_untextured_shader_program; 3724 3721 } 3725 3722 3726 3723 if(target == NULL || target->context->current_shader_program == program_object) ··· 3732 3729 #ifdef SDL_GPU_USE_GL_TIER3 3733 3730 // Set up our shader attribute and uniform locations 3734 3731 TARGET_DATA* data = ((TARGET_DATA*)target->data); 3735 - if(program_object == cdata->default_textured_shader_program) 3732 + if(program_object == target->context->default_textured_shader_program) 3736 3733 data->current_shader_block = data->shader_block[0]; 3737 - else if(program_object == cdata->default_untextured_shader_program) 3734 + else if(program_object == target->context->default_untextured_shader_program) 3738 3735 data->current_shader_block = data->shader_block[1]; 3739 3736 else 3740 3737 {
-3
SDL_gpu/OpenGL_1/SDL_gpu_OpenGL_1.h
··· 27 27 28 28 typedef struct ContextData_OpenGL_1 29 29 { 30 - Uint32 default_textured_shader_program; 31 - Uint32 default_untextured_shader_program; 32 - 33 30 SDL_Color last_color; 34 31 Uint8 last_use_blending; 35 32 GPU_BlendEnum last_blend_mode;
-3
SDL_gpu/OpenGL_2/SDL_gpu_OpenGL_2.h
··· 27 27 28 28 typedef struct ContextData_OpenGL_2 29 29 { 30 - Uint32 default_textured_shader_program; 31 - Uint32 default_untextured_shader_program; 32 - 33 30 SDL_Color last_color; 34 31 Uint8 last_use_blending; 35 32 GPU_BlendEnum last_blend_mode;
-3
SDL_gpu/OpenGL_3/SDL_gpu_OpenGL_3.h
··· 27 27 28 28 typedef struct ContextData_OpenGL_3 29 29 { 30 - Uint32 default_textured_shader_program; 31 - Uint32 default_untextured_shader_program; 32 - 33 30 SDL_Color last_color; 34 31 Uint8 last_use_blending; 35 32 GPU_BlendEnum last_blend_mode;
+3
SDL_gpu/SDL_gpu.h
··· 153 153 154 154 /*! Internal state */ 155 155 Uint32 current_shader_program; 156 + Uint32 default_textured_shader_program; 157 + Uint32 default_untextured_shader_program; 158 + 156 159 157 160 Uint8 shapes_use_blending; 158 161 GPU_BlendEnum shapes_blend_mode;
+2 -1
demos/blit-batch/main.c
··· 288 288 int floats_per_sprite = floats_per_vertex*4; 289 289 float* sprite_values = (float*)malloc(sizeof(float)*maxSprites*floats_per_sprite); 290 290 291 - // FIXME: Need a better way to be sure of which shader is current. 291 + // Load attributes for the textured shader 292 + GPU_ActivateShaderProgram(screen->context->default_textured_shader_program, NULL); 292 293 GPU_Attribute attributes[3] = { 293 294 GPU_MakeAttribute(GPU_GetAttributeLocation(screen->context->current_shader_program, "gpu_Vertex"), sprite_values, 294 295 GPU_MakeAttributeFormat(2, GPU_FLOAT, 0, floats_per_vertex*sizeof(float), 0)),