this repo has no description
0
fork

Configure Feed

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

Merge pull request #116 from kirilledelman/master

Added Polygon2, patched get_complete_color_mod

authored by

Jonathan Dearborn and committed by
GitHub
4c0c4abd c79e2f9a

+98 -16
+9
include/SDL_gpu.h
··· 1740 1740 */ 1741 1741 DECLSPEC void SDLCALL GPU_Polygon(GPU_Target* target, unsigned int num_vertices, float* vertices, SDL_Color color); 1742 1742 1743 + /*! Renders a colored polygon outline, optionally open or closed. 1744 + * \param target The destination render target 1745 + * \param num_vertices Number of vertices (x and y pairs) 1746 + * \param vertices An array of vertex positions stored as interlaced x and y coords, e.g. {x1, y1, x2, y2, ...} 1747 + * \param color The color of the shape to render 1748 + * \param open Skip last segment and draw an open polygon 1749 + */ 1750 + DECLSPEC void SDLCALL GPU_Polygon2(GPU_Target* target, unsigned int num_vertices, float* vertices, SDL_Color color, GPU_bool open); 1751 + 1743 1752 /*! Renders a colored filled polygon. The vertices are expected to define a convex polygon. 1744 1753 * \param target The destination render target 1745 1754 * \param num_vertices Number of vertices (x and y pairs)
+3
include/SDL_gpu_RendererImpl.h
··· 306 306 /*! \see GPU_Polygon() */ 307 307 void (SDLCALL *Polygon)(GPU_Renderer* renderer, GPU_Target* target, unsigned int num_vertices, float* vertices, SDL_Color color); 308 308 309 + /*! \see GPU_Polygon2() */ 310 + void (SDLCALL *Polygon2)(GPU_Renderer* renderer, GPU_Target* target, unsigned int num_vertices, float* vertices, SDL_Color color, GPU_bool open); 311 + 309 312 /*! \see GPU_PolygonFilled() */ 310 313 void (SDLCALL *PolygonFilled)(GPU_Renderer* renderer, GPU_Target* target, unsigned int num_vertices, float* vertices, SDL_Color color); 311 314
+6
src/SDL_gpu_shapes.c
··· 153 153 renderer->impl->Polygon(renderer, target, num_vertices, vertices, color); 154 154 } 155 155 156 + void GPU_Polygon2(GPU_Target* target, unsigned int num_vertices, float* vertices, SDL_Color color, GPU_bool open) 157 + { 158 + CHECK_RENDERER(); 159 + renderer->impl->Polygon2(renderer, target, num_vertices, vertices, color, open ); 160 + } 161 + 156 162 void GPU_PolygonFilled(GPU_Target* target, unsigned int num_vertices, float* vertices, SDL_Color color) 157 163 { 158 164 CHECK_RENDERER();
+24 -16
src/renderer_GL_common.inl
··· 1040 1040 1041 1041 static SDL_Color get_complete_mod_color(GPU_Renderer* renderer, GPU_Target* target, GPU_Image* image) 1042 1042 { 1043 - if(target->use_color) 1044 - { 1045 - SDL_Color color; 1046 - color.r = MIX_COLOR_COMPONENT(target->color.r, image->color.r); 1047 - color.g = MIX_COLOR_COMPONENT(target->color.g, image->color.g); 1048 - color.b = MIX_COLOR_COMPONENT(target->color.b, image->color.b); 1049 - GET_ALPHA(color) = MIX_COLOR_COMPONENT(GET_ALPHA(target->color), GET_ALPHA(image->color)); 1050 - 1051 - return color; 1052 - } 1053 - else 1054 - return image->color; 1043 + SDL_Color color = { 255, 255, 255, 255 }; 1044 + if(target->use_color) 1045 + { 1046 + if ( image != NULL ) 1047 + { 1048 + color.r = MIX_COLOR_COMPONENT(target->color.r, image->color.r); 1049 + color.g = MIX_COLOR_COMPONENT(target->color.g, image->color.g); 1050 + color.b = MIX_COLOR_COMPONENT(target->color.b, image->color.b); 1051 + GET_ALPHA(color) = MIX_COLOR_COMPONENT(GET_ALPHA(target->color), GET_ALPHA(image->color)); 1052 + } else { 1053 + color = target->color; 1054 + } 1055 + 1056 + return color; 1057 + } 1058 + else if ( image != NULL ) 1059 + return image->color; 1060 + else 1061 + return color; 1055 1062 } 1056 1063 1057 1064 static void prepareToRenderImage(GPU_Renderer* renderer, GPU_Target* target, GPU_Image* image) ··· 4997 5004 4998 5005 // Upload 4999 5006 if(indices == NULL) 5000 - glDrawArrays(GL_TRIANGLES, 0, num_indices); 5007 + glDrawArrays(primitive_type, 0, num_indices); 5001 5008 else 5002 - glDrawElements(GL_TRIANGLES, num_indices, GL_UNSIGNED_SHORT, indices); 5009 + glDrawElements(primitive_type, num_indices, GL_UNSIGNED_SHORT, indices); 5003 5010 5004 5011 // Disable 5005 5012 if(use_colors) ··· 5121 5128 upload_attribute_data(cdata, num_indices); 5122 5129 5123 5130 if(indices == NULL) 5124 - glDrawArrays(GL_TRIANGLES, 0, num_indices); 5131 + glDrawArrays(primitive_type, 0, num_indices); 5125 5132 else 5126 - glDrawElements(GL_TRIANGLES, num_indices, GL_UNSIGNED_SHORT, (void*)0); 5133 + glDrawElements(primitive_type, num_indices, GL_UNSIGNED_SHORT, (void*)0); 5127 5134 5128 5135 // Disable the vertex arrays again 5129 5136 if(use_vertices) ··· 6964 6971 impl->RectangleRound = &RectangleRound; \ 6965 6972 impl->RectangleRoundFilled = &RectangleRoundFilled; \ 6966 6973 impl->Polygon = &Polygon; \ 6974 + impl->Polygon2 = &Polygon2; \ 6967 6975 impl->PolygonFilled = &PolygonFilled; 6968 6976
+56
src/renderer_shapes_GL_common.inl
··· 1014 1014 } 1015 1015 } 1016 1016 1017 + static void Polygon2(GPU_Renderer* renderer, GPU_Target* target, unsigned int num_vertices, float* vertices, SDL_Color color, GPU_bool open) 1018 + { 1019 + if (num_vertices < 2) return; 1020 + 1021 + float t = GetLineThickness(renderer) * 0.5f; 1022 + float x1, x2, y1, y2, line_angle, tc, ts; 1023 + 1024 + int num_v = num_vertices * 4; 1025 + int num_i = num_v + 2; 1026 + int last_vert = num_vertices; 1027 + 1028 + if ( open ) 1029 + { 1030 + num_v -= 4; 1031 + num_i = num_v; 1032 + last_vert--; 1033 + } 1034 + 1035 + BEGIN_UNTEXTURED("GPU_Polygon", GL_TRIANGLE_STRIP, num_v, num_i ); 1036 + 1037 + int i = 0; 1038 + do 1039 + { 1040 + x1 = vertices[ i * 2 ]; 1041 + y1 = vertices[ i * 2 + 1 ]; 1042 + i++; 1043 + if ( i == num_vertices ) 1044 + { 1045 + x2 = vertices[ 0 ]; 1046 + y2 = vertices[ 1 ]; 1047 + } 1048 + else 1049 + { 1050 + x2 = vertices[ i * 2 ]; 1051 + y2 = vertices[ i * 2 + 1 ]; 1052 + } 1053 + 1054 + line_angle = atan2f(y2 - y1, x2 - x1); 1055 + tc = t * cosf(line_angle); 1056 + ts = t * sinf(line_angle); 1057 + 1058 + SET_UNTEXTURED_VERTEX(x1 + ts, y1 - tc, r, g, b, a); 1059 + SET_UNTEXTURED_VERTEX(x1 - ts, y1 + tc, r, g, b, a); 1060 + SET_UNTEXTURED_VERTEX(x2 + ts, y2 - tc, r, g, b, a); 1061 + SET_UNTEXTURED_VERTEX(x2 - ts, y2 + tc, r, g, b, a); 1062 + 1063 + } while ( i < last_vert ); 1064 + 1065 + if ( !open ) // end cap for closed 1066 + { 1067 + SET_INDEXED_VERTEX(0); 1068 + SET_INDEXED_VERTEX(1) 1069 + } 1070 + 1071 + } 1072 + 1017 1073 static void PolygonFilled(GPU_Renderer* renderer, GPU_Target* target, unsigned int num_vertices, float* vertices, SDL_Color color) 1018 1074 { 1019 1075 if(num_vertices < 3)