this repo has no description
0
fork

Configure Feed

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

Removed explicit z-coordinates from all position data.

+86 -190
-2
SDL_gpu/GLES_1/SDL_gpu_GLES_1.h
··· 46 46 GPU_BlendEnum last_blend_mode; 47 47 GPU_Camera last_camera; 48 48 49 - float z; 50 - 51 49 GPU_Image* last_image; 52 50 GPU_Target* last_target; 53 51 float* blit_buffer; // Holds sets of 4 vertices and 4 tex coords interleaved (e.g. [x0, y0, z0, s0, t0, ...]).
-2
SDL_gpu/GLES_2/SDL_gpu_GLES_2.h
··· 27 27 GPU_BlendEnum last_blend_mode; 28 28 GPU_Camera last_camera; 29 29 30 - float z; 31 - 32 30 GPU_Image* last_image; 33 31 GPU_Target* last_target; 34 32 float* blit_buffer; // Holds sets of 4 vertices, each with interleaved position, tex coords, and colors (e.g. [x0, y0, z0, s0, t0, r0, g0, b0, a0, ...]).
+18 -24
SDL_gpu/GL_common/SDL_gpuShapes_GL_common.inl
··· 26 26 27 27 #ifdef SDL_GPU_USE_GL_TIER3 28 28 29 - #define SDL_GPU_SHAPE_FLOATS_PER_VERTEX 7 29 + #define SDL_GPU_SHAPE_FLOATS_PER_VERTEX 6 30 30 31 31 #define SET_VERTEX(_x, _y) \ 32 32 do { \ 33 33 glverts[_vertex_array_index++] = (_x); \ 34 34 glverts[_vertex_array_index++] = (_y); \ 35 - glverts[_vertex_array_index++] = z; \ 36 35 glverts[_vertex_array_index++] = r; \ 37 36 glverts[_vertex_array_index++] = g; \ 38 37 glverts[_vertex_array_index++] = b; \ ··· 43 42 do { \ 44 43 glverts[_vertex_array_index++] = (_x); \ 45 44 glverts[_vertex_array_index++] = (_y); \ 46 - glverts[_vertex_array_index++] = z; \ 47 45 glverts[_vertex_array_index++] = r; \ 48 46 glverts[_vertex_array_index++] = g; \ 49 47 glverts[_vertex_array_index++] = b; \ ··· 68 66 69 67 #else 70 68 71 - #define SDL_GPU_SHAPE_FLOATS_PER_VERTEX 3 69 + #define SDL_GPU_SHAPE_FLOATS_PER_VERTEX 2 72 70 73 71 #define SET_VERTEX(_x, _y) \ 74 72 do { \ 75 73 glverts[_vertex_array_index++] = (_x); \ 76 74 glverts[_vertex_array_index++] = (_y); \ 77 - glverts[_vertex_array_index++] = z; \ 78 75 } while(0); 79 76 80 77 #define SET_VERTEX_TEXTURED(_x, _y, _s, _t) \ 81 78 do { \ 82 79 glverts[_vertex_array_index++] = (_x); \ 83 80 glverts[_vertex_array_index++] = (_y); \ 84 - glverts[_vertex_array_index++] = z; \ 85 81 glverts[_vertex_array_index++] = (_s); \ 86 82 glverts[_vertex_array_index++] = (_t); \ 87 83 } while(0); ··· 133 129 return; \ 134 130 if(renderer != target->renderer) \ 135 131 return; \ 136 - float z = ((CONTEXT_DATA*)renderer->current_context_target->context->data)->z; \ 137 132 \ 138 133 renderer->FlushBlitBuffer(renderer); \ 139 134 makeContextCurrent(renderer, target); \ ··· 170 165 return; \ 171 166 if(renderer != target->renderer) \ 172 167 return; \ 173 - float z = ((CONTEXT_DATA*)renderer->current_context_target->context->data)->z; \ 174 168 \ 175 169 renderer->FlushBlitBuffer(renderer); \ 176 170 makeContextCurrent(renderer, target); \ ··· 227 221 { 228 222 #ifdef SDL_GPU_USE_GL_TIER1 229 223 glBegin(prim_type); 230 - int size = 3*num_vertices; 224 + int size = 2*num_vertices; 231 225 int i; 232 - for(i = 0; i < size; i += 3) 226 + for(i = 0; i < size; i += 2) 233 227 { 234 - glVertex3f(glverts[i], glverts[i+1], glverts[i+2]); 228 + glVertex3f(glverts[i], glverts[i+1], 0.0f); 235 229 } 236 230 glEnd(); 237 231 #elif defined(SDL_GPU_USE_GL_TIER2) 238 - glVertexPointer(3, GL_FLOAT, 0, glverts); 232 + glVertexPointer(2, GL_FLOAT, 0, glverts); 239 233 glEnableClientState(GL_VERTEX_ARRAY); 240 234 glDrawArrays(prim_type, 0, num_vertices); 241 235 glDisableClientState(GL_VERTEX_ARRAY); ··· 247 241 248 242 TARGET_DATA* data = ((TARGET_DATA*)target->data); 249 243 250 - int floats_per_vertex = 7; // position (3), color (4) 244 + int floats_per_vertex = 6; // position (2), color (4) 251 245 int buffer_stride = floats_per_vertex * sizeof(float); 252 246 253 247 // Upload our modelviewprojection matrix ··· 274 268 if(data->current_shader_block.position_loc >= 0) 275 269 { 276 270 glEnableVertexAttribArray(data->current_shader_block.position_loc); // Tell GL to use client-side attribute data 277 - glVertexAttribPointer(data->current_shader_block.position_loc, 3, GL_FLOAT, GL_FALSE, buffer_stride, 0); // Tell how the data is formatted 271 + glVertexAttribPointer(data->current_shader_block.position_loc, 2, GL_FLOAT, GL_FALSE, buffer_stride, 0); // Tell how the data is formatted 278 272 } 279 273 if(data->current_shader_block.color_loc >= 0) 280 274 { 281 275 glEnableVertexAttribArray(data->current_shader_block.color_loc); 282 - glVertexAttribPointer(data->current_shader_block.color_loc, 4, GL_FLOAT, GL_FALSE, buffer_stride, (void*)(3 * sizeof(float))); 276 + glVertexAttribPointer(data->current_shader_block.color_loc, 4, GL_FLOAT, GL_FALSE, buffer_stride, (void*)(2 * sizeof(float))); 283 277 } 284 278 285 279 glDrawArrays(prim_type, 0, num_vertices); ··· 295 289 { 296 290 #ifdef SDL_GPU_USE_GL_TIER1 297 291 glBegin(prim_type); 298 - int size = 5*num_vertices; 292 + int size = 4*num_vertices; 299 293 int i; 300 294 for(i = 0; i < size; i += 5) 301 295 { 302 - glTexCoord2f(glverts[i+3], glverts[i+4]); 303 - glVertex3f(glverts[i], glverts[i+1], glverts[i+2]); 296 + glTexCoord2f(glverts[i+2], glverts[i+3]); 297 + glVertex3f(glverts[i], glverts[i+1], 0.0f); 304 298 } 305 299 glEnd(); 306 300 #elif defined(SDL_GPU_USE_GL_TIER2) 307 - glVertexPointer(3, GL_FLOAT, 5*sizeof(float), glverts); 308 - glTexCoordPointer(2, GL_FLOAT, 5*sizeof(float), (glverts + 3)); 301 + glVertexPointer(2, GL_FLOAT, 5*sizeof(float), glverts); 302 + glTexCoordPointer(2, GL_FLOAT, 5*sizeof(float), (glverts + 2)); 309 303 glEnableClientState(GL_VERTEX_ARRAY); 310 304 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 311 305 glDrawArrays(prim_type, 0, num_vertices); ··· 319 313 320 314 TARGET_DATA* data = ((TARGET_DATA*)target->data); 321 315 322 - int floats_per_vertex = 9; // position (3), color (4), texcoord (2) 316 + int floats_per_vertex = 8; // position (2), color (4), texcoord (2) 323 317 int buffer_stride = floats_per_vertex * sizeof(float); 324 318 325 319 // Upload our modelviewprojection matrix ··· 346 340 if(data->current_shader_block.position_loc >= 0) 347 341 { 348 342 glEnableVertexAttribArray(data->current_shader_block.position_loc); // Tell GL to use client-side attribute data 349 - glVertexAttribPointer(data->current_shader_block.position_loc, 3, GL_FLOAT, GL_FALSE, buffer_stride, 0); // Tell how the data is formatted 343 + glVertexAttribPointer(data->current_shader_block.position_loc, 2, GL_FLOAT, GL_FALSE, buffer_stride, 0); // Tell how the data is formatted 350 344 } 351 345 if(data->current_shader_block.color_loc >= 0) 352 346 { 353 347 glEnableVertexAttribArray(data->current_shader_block.color_loc); 354 - glVertexAttribPointer(data->current_shader_block.color_loc, 4, GL_FLOAT, GL_FALSE, buffer_stride, (void*)(3 * sizeof(float))); 348 + glVertexAttribPointer(data->current_shader_block.color_loc, 4, GL_FLOAT, GL_FALSE, buffer_stride, (void*)(2 * sizeof(float))); 355 349 } 356 350 if(data->current_shader_block.texcoord_loc >= 0) 357 351 { 358 352 glEnableVertexAttribArray(data->current_shader_block.texcoord_loc); 359 - glVertexAttribPointer(data->current_shader_block.texcoord_loc, 2, GL_FLOAT, GL_FALSE, buffer_stride, (void*)(7 * sizeof(float))); 353 + glVertexAttribPointer(data->current_shader_block.texcoord_loc, 2, GL_FLOAT, GL_FALSE, buffer_stride, (void*)(6 * sizeof(float))); 360 354 } 361 355 362 356 glDrawArrays(prim_type, 0, num_vertices);
+46 -72
SDL_gpu/GL_common/SDL_gpu_GL_common.inl
··· 23 23 #define GPU_BLIT_BUFFER_INIT_MAX_NUM_VERTICES (GPU_BLIT_BUFFER_VERTICES_PER_SPRITE*1000) 24 24 25 25 #ifndef SDL_GPU_USE_GL_TIER3 26 - // x, y, z, s, t 27 - #define GPU_BLIT_BUFFER_FLOATS_PER_VERTEX 5 26 + // x, y, s, t 27 + #define GPU_BLIT_BUFFER_FLOATS_PER_VERTEX 4 28 28 #else 29 - // x, y, z, s, t, r, g, b, a 30 - #define GPU_BLIT_BUFFER_FLOATS_PER_VERTEX 9 29 + // x, y, s, t, r, g, b, a 30 + #define GPU_BLIT_BUFFER_FLOATS_PER_VERTEX 8 31 31 #endif 32 32 33 33 // bytes per vertex 34 34 #define GPU_BLIT_BUFFER_STRIDE (sizeof(float)*GPU_BLIT_BUFFER_FLOATS_PER_VERTEX) 35 35 #define GPU_BLIT_BUFFER_VERTEX_OFFSET 0 36 - #define GPU_BLIT_BUFFER_TEX_COORD_OFFSET 3 37 - #define GPU_BLIT_BUFFER_COLOR_OFFSET 5 36 + #define GPU_BLIT_BUFFER_TEX_COORD_OFFSET 2 37 + #define GPU_BLIT_BUFFER_COLOR_OFFSET 4 38 38 39 39 40 40 #include <math.h> ··· 117 117 #define TEXTURED_VERTEX_SHADER_SOURCE \ 118 118 "#version 130\n\ 119 119 \ 120 - attribute vec3 gpu_Vertex;\n\ 120 + attribute vec2 gpu_Vertex;\n\ 121 121 attribute vec2 gpu_TexCoord;\n\ 122 122 attribute vec4 gpu_Color;\n\ 123 123 uniform mat4 modelViewProjection;\n\ ··· 129 129 {\n\ 130 130 color = gpu_Color;\n\ 131 131 texCoord = vec2(gpu_TexCoord);\n\ 132 - gl_Position = modelViewProjection * vec4(gpu_Vertex, 1.0);\n\ 132 + gl_Position = modelViewProjection * vec4(gpu_Vertex, 0.0, 1.0);\n\ 133 133 }" 134 134 135 135 // Tier 3 uses shader attributes to send position, texcoord, and color data for each vertex. 136 136 #define UNTEXTURED_VERTEX_SHADER_SOURCE \ 137 137 "#version 130\n\ 138 138 \ 139 - attribute vec3 gpu_Vertex;\n\ 139 + attribute vec2 gpu_Vertex;\n\ 140 140 attribute vec4 gpu_Color;\n\ 141 141 uniform mat4 modelViewProjection;\n\ 142 142 \ ··· 145 145 void main(void)\n\ 146 146 {\n\ 147 147 color = gpu_Color;\n\ 148 - gl_Position = modelViewProjection * vec4(gpu_Vertex, 1.0);\n\ 148 + gl_Position = modelViewProjection * vec4(gpu_Vertex, 0.0, 1.0);\n\ 149 149 }" 150 150 151 151 ··· 178 178 precision mediump float;\n\ 179 179 precision mediump int;\n\ 180 180 \ 181 - attribute vec3 gpu_Vertex;\n\ 181 + attribute vec2 gpu_Vertex;\n\ 182 182 attribute vec2 gpu_TexCoord;\n\ 183 183 attribute vec4 gpu_Color;\n\ 184 184 uniform mat4 modelViewProjection;\n\ ··· 190 190 {\n\ 191 191 color = gpu_Color;\n\ 192 192 texCoord = vec2(gpu_TexCoord);\n\ 193 - gl_Position = modelViewProjection * vec4(gpu_Vertex, 1.0);\n\ 193 + gl_Position = modelViewProjection * vec4(gpu_Vertex, 0.0, 1.0);\n\ 194 194 }" 195 195 196 196 // Tier 3 uses shader attributes to send position, texcoord, and color data for each vertex. ··· 199 199 precision mediump float;\n\ 200 200 precision mediump int;\n\ 201 201 \ 202 - attribute vec3 gpu_Vertex;\n\ 202 + attribute vec2 gpu_Vertex;\n\ 203 203 attribute vec4 gpu_Color;\n\ 204 204 uniform mat4 modelViewProjection;\n\ 205 205 \ ··· 208 208 void main(void)\n\ 209 209 {\n\ 210 210 color = gpu_Color;\n\ 211 - gl_Position = modelViewProjection * vec4(gpu_Vertex, 1.0);\n\ 211 + gl_Position = modelViewProjection * vec4(gpu_Vertex, 0.0, 1.0);\n\ 212 212 }" 213 213 214 214 ··· 958 958 target->context->shapes_blend_mode = GPU_BLEND_NORMAL; 959 959 960 960 SDL_Color white = {255, 255, 255, 255}; 961 - cdata->z = 0; 962 961 cdata->last_color = white; 963 962 cdata->last_use_blending = 0; 964 963 cdata->last_blend_mode = GPU_BLEND_NORMAL; ··· 2441 2440 int tex_index = GPU_BLIT_BUFFER_TEX_COORD_OFFSET + cdata->blit_buffer_num_vertices*GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 2442 2441 blit_buffer[vert_index] = dx1; 2443 2442 blit_buffer[vert_index+1] = dy1; 2444 - blit_buffer[vert_index+2] = 0.0f; 2445 2443 blit_buffer[tex_index] = x1; 2446 2444 blit_buffer[tex_index+1] = y1; 2447 2445 #ifdef SDL_GPU_USE_GL_TIER3 ··· 2456 2454 tex_index += GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 2457 2455 blit_buffer[vert_index] = dx2; 2458 2456 blit_buffer[vert_index+1] = dy1; 2459 - blit_buffer[vert_index+2] = 0.0f; 2460 2457 blit_buffer[tex_index] = x2; 2461 2458 blit_buffer[tex_index+1] = y1; 2462 2459 #ifdef SDL_GPU_USE_GL_TIER3 ··· 2472 2469 tex_index += GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 2473 2470 blit_buffer[vert_index] = dx2; 2474 2471 blit_buffer[vert_index+1] = dy2; 2475 - blit_buffer[vert_index+2] = 0.0f; 2476 2472 blit_buffer[tex_index] = x2; 2477 2473 blit_buffer[tex_index+1] = y2; 2478 2474 #ifdef SDL_GPU_USE_GL_TIER3 ··· 2488 2484 tex_index += GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 2489 2485 blit_buffer[vert_index] = dx1; 2490 2486 blit_buffer[vert_index+1] = dy2; 2491 - blit_buffer[vert_index+2] = 0.0f; 2492 2487 blit_buffer[tex_index] = x1; 2493 2488 blit_buffer[tex_index+1] = y2; 2494 2489 #ifdef SDL_GPU_USE_GL_TIER3 ··· 2681 2676 int tex_index = GPU_BLIT_BUFFER_TEX_COORD_OFFSET + cdata->blit_buffer_num_vertices*GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 2682 2677 blit_buffer[vert_index] = dx1; 2683 2678 blit_buffer[vert_index+1] = dy1; 2684 - blit_buffer[vert_index+2] = 0.0f; 2685 2679 blit_buffer[tex_index] = x1; 2686 2680 blit_buffer[tex_index+1] = y1; 2687 2681 #ifdef SDL_GPU_USE_GL_TIER3 ··· 2696 2690 tex_index += GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 2697 2691 blit_buffer[vert_index] = dx3; 2698 2692 blit_buffer[vert_index+1] = dy3; 2699 - blit_buffer[vert_index+2] = 0.0f; 2700 2693 blit_buffer[tex_index] = x2; 2701 2694 blit_buffer[tex_index+1] = y1; 2702 2695 #ifdef SDL_GPU_USE_GL_TIER3 ··· 2712 2705 tex_index += GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 2713 2706 blit_buffer[vert_index] = dx2; 2714 2707 blit_buffer[vert_index+1] = dy2; 2715 - blit_buffer[vert_index+2] = 0.0f; 2716 2708 blit_buffer[tex_index] = x2; 2717 2709 blit_buffer[tex_index+1] = y2; 2718 2710 #ifdef SDL_GPU_USE_GL_TIER3 ··· 2728 2720 tex_index += GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 2729 2721 blit_buffer[vert_index] = dx4; 2730 2722 blit_buffer[vert_index+1] = dy4; 2731 - blit_buffer[vert_index+2] = 0.0f; 2732 2723 blit_buffer[tex_index] = x1; 2733 2724 blit_buffer[tex_index+1] = y2; 2734 2725 #ifdef SDL_GPU_USE_GL_TIER3 ··· 2845 2836 2846 2837 renderer->FlushBlitBuffer(renderer); 2847 2838 2839 + int floats_per_vertex = 8; 2840 + 2848 2841 // Only do so many at a time 2849 2842 int partial_num_sprites = cdata->blit_buffer_max_num_vertices/4; 2850 2843 while(1) ··· 2873 2866 #ifdef SDL_GPU_USE_GL_TIER1 2874 2867 2875 2868 float* vertex_pointer = values; 2876 - float* texcoord_pointer = values + 3; 2877 - float* color_pointer = values + 5; 2869 + float* texcoord_pointer = values + 2; 2870 + float* color_pointer = values + 4; 2878 2871 2879 2872 glBegin(GL_QUADS); 2880 2873 for(i = 0; i < numSprites; i++) 2881 2874 { 2882 2875 glColor4f( *color_pointer, *(color_pointer+1), *(color_pointer+2), *(color_pointer+3) ); 2883 2876 glTexCoord2f( *texcoord_pointer, *(texcoord_pointer+1) ); 2884 - glVertex3f( *vertex_pointer, *(vertex_pointer+1), *(vertex_pointer+2) ); 2885 - color_pointer += 9; 2886 - texcoord_pointer += 9; 2887 - vertex_pointer += 9; 2877 + glVertex3f( *vertex_pointer, *(vertex_pointer+1), 0.0f ); 2878 + color_pointer += floats_per_vertex; 2879 + texcoord_pointer += floats_per_vertex; 2880 + vertex_pointer += floats_per_vertex; 2888 2881 2889 2882 glColor4f( *color_pointer, *(color_pointer+1), *(color_pointer+2), *(color_pointer+3) ); 2890 2883 glTexCoord2f( *texcoord_pointer, *(texcoord_pointer+1) ); 2891 - glVertex3f( *vertex_pointer, *(vertex_pointer+1), *(vertex_pointer+2) ); 2892 - color_pointer += 9; 2893 - texcoord_pointer += 9; 2894 - vertex_pointer += 9; 2884 + glVertex3f( *vertex_pointer, *(vertex_pointer+1), 0.0f ); 2885 + color_pointer += floats_per_vertex; 2886 + texcoord_pointer += floats_per_vertex; 2887 + vertex_pointer += floats_per_vertex; 2895 2888 2896 2889 glColor4f( *color_pointer, *(color_pointer+1), *(color_pointer+2), *(color_pointer+3) ); 2897 2890 glTexCoord2f( *texcoord_pointer, *(texcoord_pointer+1) ); 2898 - glVertex3f( *vertex_pointer, *(vertex_pointer+1), *(vertex_pointer+2) ); 2899 - color_pointer += 9; 2900 - texcoord_pointer += 9; 2901 - vertex_pointer += 9; 2891 + glVertex3f( *vertex_pointer, *(vertex_pointer+1), 0.0f ); 2892 + color_pointer += floats_per_vertex; 2893 + texcoord_pointer += floats_per_vertex; 2894 + vertex_pointer += floats_per_vertex; 2902 2895 2903 2896 glColor4f( *color_pointer, *(color_pointer+1), *(color_pointer+2), *(color_pointer+3) ); 2904 2897 glTexCoord2f( *texcoord_pointer, *(texcoord_pointer+1) ); 2905 - glVertex3f( *vertex_pointer, *(vertex_pointer+1), *(vertex_pointer+2) ); 2906 - color_pointer += 9; 2907 - texcoord_pointer += 9; 2908 - vertex_pointer += 9; 2898 + glVertex3f( *vertex_pointer, *(vertex_pointer+1), 0.0f ); 2899 + color_pointer += floats_per_vertex; 2900 + texcoord_pointer += floats_per_vertex; 2901 + vertex_pointer += floats_per_vertex; 2909 2902 } 2910 2903 glEnd(); 2911 2904 #elif defined(SDL_GPU_USE_GL_TIER2) ··· 2914 2907 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 2915 2908 glEnableClientState(GL_COLOR_ARRAY); 2916 2909 2917 - glVertexPointer(3, GL_FLOAT, GPU_BLIT_BUFFER_STRIDE, values + GPU_BLIT_BUFFER_VERTEX_OFFSET); 2918 - glTexCoordPointer(2, GL_FLOAT, GPU_BLIT_BUFFER_STRIDE, values + GPU_BLIT_BUFFER_TEX_COORD_OFFSET); 2919 - glColorPointer(4, GL_FLOAT, GPU_BLIT_BUFFER_STRIDE, values + GPU_BLIT_BUFFER_COLOR_OFFSET); 2910 + int stride = 8*sizeof(float); 2911 + glVertexPointer(2, GL_FLOAT, stride, values + GPU_BLIT_BUFFER_VERTEX_OFFSET); 2912 + glTexCoordPointer(2, GL_FLOAT, stride, values + GPU_BLIT_BUFFER_TEX_COORD_OFFSET); 2913 + glColorPointer(4, GL_FLOAT, stride, values + GPU_BLIT_BUFFER_COLOR_OFFSET); 2920 2914 2921 2915 glDrawElements(GL_TRIANGLES, cdata->index_buffer_num_vertices, GL_UNSIGNED_SHORT, cdata->index_buffer); 2922 2916 ··· 2952 2946 if(data->current_shader_block.position_loc >= 0) 2953 2947 { 2954 2948 glEnableVertexAttribArray(data->current_shader_block.position_loc); // Tell GL to use client-side attribute data 2955 - glVertexAttribPointer(data->current_shader_block.position_loc, 3, GL_FLOAT, GL_FALSE, GPU_BLIT_BUFFER_STRIDE, 0); // Tell how the data is formatted 2949 + glVertexAttribPointer(data->current_shader_block.position_loc, 2, GL_FLOAT, GL_FALSE, GPU_BLIT_BUFFER_STRIDE, 0); // Tell how the data is formatted 2956 2950 } 2957 2951 if(data->current_shader_block.texcoord_loc >= 0) 2958 2952 { ··· 2973 2967 2974 2968 #endif 2975 2969 2976 - values += partial_num_sprites*4*9; // 9 floats per vertex 2970 + values += partial_num_sprites*4*floats_per_vertex; 2977 2971 2978 2972 numSprites -= partial_num_sprites; 2979 2973 ··· 3176 3170 return 0; 3177 3171 } 3178 3172 3179 - static float SetZ(GPU_Renderer* renderer, float z) 3180 - { 3181 - if(renderer == NULL) 3182 - return 0.0f; 3183 - 3184 - float oldZ = ((CONTEXT_DATA*)renderer->current_context_target->context->data)->z; 3185 - ((CONTEXT_DATA*)renderer->current_context_target->context->data)->z = z; 3186 - 3187 - return oldZ; 3188 - } 3189 - 3190 - static float GetZ(GPU_Renderer* renderer) 3191 - { 3192 - if(renderer == NULL) 3193 - return 0.0f; 3194 - return ((CONTEXT_DATA*)renderer->current_context_target->context->data)->z; 3195 - } 3196 - 3197 3173 static void GenerateMipmaps(GPU_Renderer* renderer, GPU_Image* image) 3198 3174 { 3199 3175 #ifndef __IPHONEOS__ ··· 3448 3424 for(i = 0; i < cdata->blit_buffer_num_vertices; i += GPU_BLIT_BUFFER_VERTICES_PER_SPRITE) 3449 3425 { 3450 3426 glTexCoord2f( *texcoord_pointer, *(texcoord_pointer+1) ); 3451 - glVertex3f( *vertex_pointer, *(vertex_pointer+1), *(vertex_pointer+2) ); 3427 + glVertex3f( *vertex_pointer, *(vertex_pointer+1), 0.0f ); 3452 3428 texcoord_pointer += GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 3453 3429 vertex_pointer += GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 3454 3430 3455 3431 glTexCoord2f( *texcoord_pointer, *(texcoord_pointer+1) ); 3456 - glVertex3f( *vertex_pointer, *(vertex_pointer+1), *(vertex_pointer+2) ); 3432 + glVertex3f( *vertex_pointer, *(vertex_pointer+1), 0.0f ); 3457 3433 texcoord_pointer += GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 3458 3434 vertex_pointer += GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 3459 3435 3460 3436 glTexCoord2f( *texcoord_pointer, *(texcoord_pointer+1) ); 3461 - glVertex3f( *vertex_pointer, *(vertex_pointer+1), *(vertex_pointer+2) ); 3437 + glVertex3f( *vertex_pointer, *(vertex_pointer+1), 0.0f ); 3462 3438 texcoord_pointer += GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 3463 3439 vertex_pointer += GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 3464 3440 3465 3441 glTexCoord2f( *texcoord_pointer, *(texcoord_pointer+1) ); 3466 - glVertex3f( *vertex_pointer, *(vertex_pointer+1), *(vertex_pointer+2) ); 3442 + glVertex3f( *vertex_pointer, *(vertex_pointer+1), 0.0f ); 3467 3443 texcoord_pointer += GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 3468 3444 vertex_pointer += GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 3469 3445 } ··· 3472 3448 3473 3449 glEnableClientState(GL_VERTEX_ARRAY); 3474 3450 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 3475 - glVertexPointer(3, GL_FLOAT, GPU_BLIT_BUFFER_STRIDE, cdata->blit_buffer + GPU_BLIT_BUFFER_VERTEX_OFFSET); 3451 + glVertexPointer(2, GL_FLOAT, GPU_BLIT_BUFFER_STRIDE, cdata->blit_buffer + GPU_BLIT_BUFFER_VERTEX_OFFSET); 3476 3452 glTexCoordPointer(2, GL_FLOAT, GPU_BLIT_BUFFER_STRIDE, cdata->blit_buffer + GPU_BLIT_BUFFER_TEX_COORD_OFFSET); 3477 3453 3478 3454 glDrawElements(GL_TRIANGLES, cdata->index_buffer_num_vertices, GL_UNSIGNED_SHORT, cdata->index_buffer); ··· 3508 3484 if(data->current_shader_block.position_loc >= 0) 3509 3485 { 3510 3486 glEnableVertexAttribArray(data->current_shader_block.position_loc); // Tell GL to use client-side attribute data 3511 - glVertexAttribPointer(data->current_shader_block.position_loc, 3, GL_FLOAT, GL_FALSE, GPU_BLIT_BUFFER_STRIDE, 0); // Tell how the data is formatted 3487 + glVertexAttribPointer(data->current_shader_block.position_loc, 2, GL_FLOAT, GL_FALSE, GPU_BLIT_BUFFER_STRIDE, 0); // Tell how the data is formatted 3512 3488 } 3513 3489 if(data->current_shader_block.texcoord_loc >= 0) 3514 3490 { ··· 4078 4054 renderer->BlitBatch = &BlitBatch; \ 4079 4055 renderer->BlitBatchAttributes = &BlitBatchAttributes; \ 4080 4056 \ 4081 - renderer->SetZ = &SetZ; \ 4082 - renderer->GetZ = &GetZ; \ 4083 4057 renderer->GenerateMipmaps = &GenerateMipmaps; \ 4084 4058 \ 4085 4059 renderer->SetClip = &SetClip; \
-2
SDL_gpu/OpenGL_1/SDL_gpu_OpenGL_1.h
··· 35 35 GPU_BlendEnum last_blend_mode; 36 36 GPU_Camera last_camera; 37 37 38 - float z; 39 - 40 38 GPU_Image* last_image; 41 39 GPU_Target* last_target; 42 40 float* blit_buffer; // Holds sets of 4 vertices and 4 tex coords interleaved (e.g. [x0, y0, z0, s0, t0, ...]).
-2
SDL_gpu/OpenGL_2/SDL_gpu_OpenGL_2.h
··· 35 35 GPU_BlendEnum last_blend_mode; 36 36 GPU_Camera last_camera; 37 37 38 - float z; 39 - 40 38 GPU_Image* last_image; 41 39 GPU_Target* last_target; 42 40 float* blit_buffer; // Holds sets of 4 vertices and 4 tex coords interleaved (e.g. [x0, y0, z0, s0, t0, ...]).
-2
SDL_gpu/OpenGL_3/SDL_gpu_OpenGL_3.h
··· 35 35 GPU_BlendEnum last_blend_mode; 36 36 GPU_Camera last_camera; 37 37 38 - float z; 39 - 40 38 GPU_Image* last_image; 41 39 GPU_Target* last_target; 42 40 float* blit_buffer; // Holds sets of 4 vertices, each with interleaved position, tex coords, and colors (e.g. [x0, y0, z0, s0, t0, r0, g0, b0, a0, ...]).
+16 -56
SDL_gpu/SDL_gpu.c
··· 594 594 } 595 595 596 596 if(pass_vertices) 597 - src_position_floats_per_sprite = 12; // 4 vertices of x, y, z 597 + src_position_floats_per_sprite = 8; // 4 vertices of x, y 598 598 if(pass_texcoords) 599 599 src_rect_floats_per_sprite = 8; // 4 vertices of s, t 600 600 if(pass_colors) ··· 608 608 609 609 int src_floats_per_sprite = src_position_floats_per_sprite + src_rect_floats_per_sprite + src_color_floats_per_sprite; 610 610 611 - int size = numSprites*(12 + 8 + 16); 611 + int size = numSprites*(8 + 8 + 16); 612 612 float* new_values = (float*)malloc(sizeof(float)*size); 613 613 614 614 int n; // The sprite number iteration variable. ··· 618 618 int color_n = src_position_floats_per_sprite + src_rect_floats_per_sprite; 619 619 // Dest indices 620 620 int vert_i = 0; 621 - int texcoord_i = 3; 622 - int color_i = 5; 621 + int texcoord_i = 2; 622 + int color_i = 4; 623 623 // Dest float stride 624 - int floats_per_vertex = 9; 624 + int floats_per_vertex = 8; 625 625 626 626 float w2 = 0.5f*src->w; // texcoord helpers for position expansion 627 627 float h2 = 0.5f*src->h; ··· 702 702 { 703 703 new_values[vert_i] = 0.0f; 704 704 new_values[vert_i+1] = 0.0f; 705 - new_values[vert_i+2] = 0; 706 705 vert_i += floats_per_vertex; 707 706 new_values[vert_i] = 0.0f; 708 707 new_values[vert_i+1] = 0.0f; 709 - new_values[vert_i+2] = 0; 710 708 vert_i += floats_per_vertex; 711 709 new_values[vert_i] = 0.0f; 712 710 new_values[vert_i+1] = 0.0f; 713 - new_values[vert_i+2] = 0; 714 711 vert_i += floats_per_vertex; 715 712 new_values[vert_i] = 0.0f; 716 713 new_values[vert_i+1] = 0.0f; 717 - new_values[vert_i+2] = 0; 718 714 vert_i += floats_per_vertex; 719 715 } 720 716 else ··· 728 724 729 725 new_values[vert_i] = x - w2; 730 726 new_values[vert_i+1] = y - h2; 731 - new_values[vert_i+2] = 0; 732 727 vert_i += floats_per_vertex; 733 728 new_values[vert_i] = x + w2; 734 729 new_values[vert_i+1] = y - h2; 735 - new_values[vert_i+2] = 0; 736 730 vert_i += floats_per_vertex; 737 731 new_values[vert_i] = x + w2; 738 732 new_values[vert_i+1] = y + h2; 739 - new_values[vert_i+2] = 0; 740 733 vert_i += floats_per_vertex; 741 734 new_values[vert_i] = x - w2; 742 735 new_values[vert_i+1] = y + h2; 743 - new_values[vert_i+2] = 0; 744 736 vert_i += floats_per_vertex; 745 737 } 746 738 else ··· 748 740 // 4 vertices all in a row 749 741 new_values[vert_i] = values[pos_n]; 750 742 new_values[vert_i+1] = values[pos_n+1]; 751 - new_values[vert_i+2] = values[pos_n+2]; 752 743 vert_i += floats_per_vertex; 753 - new_values[vert_i] = values[pos_n+3]; 754 - new_values[vert_i+1] = values[pos_n+4]; 755 - new_values[vert_i+2] = values[pos_n+5]; 744 + new_values[vert_i] = values[pos_n+2]; 745 + new_values[vert_i+1] = values[pos_n+3]; 746 + vert_i += floats_per_vertex; 747 + new_values[vert_i] = values[pos_n+4]; 748 + new_values[vert_i+1] = values[pos_n+5]; 756 749 vert_i += floats_per_vertex; 757 750 new_values[vert_i] = values[pos_n+6]; 758 751 new_values[vert_i+1] = values[pos_n+7]; 759 - new_values[vert_i+2] = values[pos_n+8]; 760 - vert_i += floats_per_vertex; 761 - new_values[vert_i] = values[pos_n+9]; 762 - new_values[vert_i+1] = values[pos_n+10]; 763 - new_values[vert_i+2] = values[pos_n+11]; 764 752 vert_i += floats_per_vertex; 765 753 pos_n += src_floats_per_sprite; 766 754 } ··· 873 861 Uint8 pass_texcoords = (flags & GPU_PASSTHROUGH_TEXCOORDS); 874 862 Uint8 pass_colors = (flags & GPU_PASSTHROUGH_COLORS); 875 863 if(pass_vertices) 876 - src_position_floats_per_sprite = 12; // 4 vertices of x, y, z 864 + src_position_floats_per_sprite = 8; // 4 vertices of x, y 877 865 if(pass_texcoords) 878 866 src_rect_floats_per_sprite = 8; // 4 vertices of s, t 879 867 if(pass_colors) 880 868 src_color_floats_per_sprite = 16; // 4 vertices of r, g, b, a 881 869 882 870 int src_floats_per_sprite = src_position_floats_per_sprite + src_rect_floats_per_sprite + src_color_floats_per_sprite; 883 - int size = numSprites*(12 + 8 + 16); 871 + int size = numSprites*(8 + 8 + 16); 884 872 float* values = (float*)malloc(sizeof(float)*size); 885 873 886 874 int n; // The sprite number iteration variable. ··· 890 878 int color_n = 0; 891 879 // Dest indices 892 880 int vert_i = 0; 893 - int texcoord_i = 3; 894 - int color_i = 5; 881 + int texcoord_i = 2; 882 + int color_i = 4; 895 883 // Dest float stride 896 - int floats_per_vertex = 9; 884 + int floats_per_vertex = 8; 897 885 898 886 float w2 = 0.5f*src->w; // texcoord helpers for position expansion 899 887 float h2 = 0.5f*src->h; ··· 974 962 { 975 963 values[vert_i] = 0.0f; 976 964 values[vert_i+1] = 0.0f; 977 - values[vert_i+2] = 0; 978 965 vert_i += floats_per_vertex; 979 966 values[vert_i] = 0.0f; 980 967 values[vert_i+1] = 0.0f; 981 - values[vert_i+2] = 0; 982 968 vert_i += floats_per_vertex; 983 969 values[vert_i] = 0.0f; 984 970 values[vert_i+1] = 0.0f; 985 - values[vert_i+2] = 0; 986 971 vert_i += floats_per_vertex; 987 972 values[vert_i] = 0.0f; 988 973 values[vert_i+1] = 0.0f; 989 - values[vert_i+2] = 0; 990 974 vert_i += floats_per_vertex; 991 975 } 992 976 else ··· 998 982 float y = positions[pos_n++]; 999 983 values[vert_i] = x - w2; 1000 984 values[vert_i+1] = y - h2; 1001 - values[vert_i+2] = 0; 1002 985 vert_i += floats_per_vertex; 1003 986 values[vert_i] = x + w2; 1004 987 values[vert_i+1] = y - h2; 1005 - values[vert_i+2] = 0; 1006 988 vert_i += floats_per_vertex; 1007 989 values[vert_i] = x + w2; 1008 990 values[vert_i+1] = y + h2; 1009 - values[vert_i+2] = 0; 1010 991 vert_i += floats_per_vertex; 1011 992 values[vert_i] = x - w2; 1012 993 values[vert_i+1] = y + h2; 1013 - values[vert_i+2] = 0; 1014 994 vert_i += floats_per_vertex; 1015 995 } 1016 996 else ··· 1018 998 // 4 vertices all in a row 1019 999 values[vert_i] = positions[pos_n++]; 1020 1000 values[vert_i+1] = positions[pos_n++]; 1021 - values[vert_i+2] = positions[pos_n++]; 1022 1001 vert_i += floats_per_vertex; 1023 1002 values[vert_i] = positions[pos_n++]; 1024 1003 values[vert_i+1] = positions[pos_n++]; 1025 - values[vert_i+2] = positions[pos_n++]; 1026 1004 vert_i += floats_per_vertex; 1027 1005 values[vert_i] = positions[pos_n++]; 1028 1006 values[vert_i+1] = positions[pos_n++]; 1029 - values[vert_i+2] = positions[pos_n++]; 1030 1007 vert_i += floats_per_vertex; 1031 1008 values[vert_i] = positions[pos_n++]; 1032 1009 values[vert_i+1] = positions[pos_n++]; 1033 - values[vert_i+2] = positions[pos_n++]; 1034 1010 vert_i += floats_per_vertex; 1035 1011 } 1036 1012 } 1013 + 1037 1014 if(colors == NULL) 1038 1015 { 1039 1016 values[color_i] = 1.0f; ··· 1126 1103 return 0; 1127 1104 1128 1105 return current_renderer->BlitBatchAttributes(current_renderer, src, dest, numSprites, numAttributes, attributes); 1129 - } 1130 - 1131 - 1132 - float GPU_SetZ(float z) 1133 - { 1134 - if(current_renderer == NULL || current_renderer->SetZ == NULL) 1135 - return 0.0f; 1136 - 1137 - return current_renderer->SetZ(current_renderer, z); 1138 - } 1139 - 1140 - float GPU_GetZ(void) 1141 - { 1142 - if(current_renderer == NULL || current_renderer->GetZ == NULL) 1143 - return 0.0f; 1144 - 1145 - return current_renderer->GetZ(current_renderer); 1146 1106 } 1147 1107 1148 1108 void GPU_GenerateMipmaps(GPU_Image* image)
-14
SDL_gpu/SDL_gpu.h
··· 363 363 /*! \see GPU_BlitBatchAttributes() */ 364 364 int (*BlitBatchAttributes)(GPU_Renderer* renderer, GPU_Image* src, GPU_Target* dest, unsigned int numSprites, unsigned int numAttributes, GPU_Attribute* attributes); 365 365 366 - /*! \see GPU_SetX() */ 367 - float (*SetZ)(GPU_Renderer* renderer, float z); 368 - 369 - /*! \see GPU_GetZ() */ 370 - float (*GetZ)(GPU_Renderer* renderer); 371 - 372 366 /*! \see GPU_GenerateMipmaps() */ 373 367 void (*GenerateMipmaps)(GPU_Renderer* renderer, GPU_Image* image); 374 368 ··· 760 754 * \param attributes Array of 'numAttributes' shader attribute specifiers 761 755 */ 762 756 int GPU_BlitBatchAttributes(GPU_Image* src, GPU_Target* dest, unsigned int numSprites, unsigned int numAttributes, GPU_Attribute* attributes); 763 - 764 - /*! Sets the renderer's z-depth. 765 - * \return The previous z-depth */ 766 - float GPU_SetZ(float z); 767 - 768 - /*! Gets the renderer's z-depth. 769 - * \return The current z-depth */ 770 - float GPU_GetZ(void); 771 757 772 758 /*! Loads mipmaps for the given image, if supported by the renderer. */ 773 759 void GPU_GenerateMipmaps(GPU_Image* image);
+6 -14
demos/blit-batch/main.c
··· 283 283 int maxSprites = 50000; 284 284 int numSprites = 101; 285 285 286 - // 3 pos floats per vertex, 2 texcoords, 4 color components 287 - int floats_per_vertex = 3 + 2 + 4; 286 + // 2 pos floats per vertex, 2 texcoords, 4 color components 287 + int floats_per_vertex = 2 + 2 + 4; 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 291 // FIXME: Need a better way to be sure of which shader is current. 292 292 GPU_Attribute attributes[3] = { 293 293 GPU_MakeAttribute(GPU_GetAttributeLocation(screen->context->current_shader_program, "gpu_Vertex"), sprite_values, 294 - GPU_MakeAttributeFormat(3, GPU_FLOAT, 0, floats_per_vertex*sizeof(float), 0)), 294 + GPU_MakeAttributeFormat(2, GPU_FLOAT, 0, floats_per_vertex*sizeof(float), 0)), 295 295 GPU_MakeAttribute(GPU_GetAttributeLocation(screen->context->current_shader_program, "gpu_TexCoord"), sprite_values, 296 - GPU_MakeAttributeFormat(2, GPU_FLOAT, 0, floats_per_vertex*sizeof(float), 3*sizeof(float))), 296 + GPU_MakeAttributeFormat(2, GPU_FLOAT, 0, floats_per_vertex*sizeof(float), 2*sizeof(float))), 297 297 GPU_MakeAttribute(GPU_GetAttributeLocation(screen->context->current_shader_program, "gpu_Color"), sprite_values, 298 - GPU_MakeAttributeFormat(4, GPU_FLOAT, 0, floats_per_vertex*sizeof(float), 5*sizeof(float))) 298 + GPU_MakeAttributeFormat(4, GPU_FLOAT, 0, floats_per_vertex*sizeof(float), 4*sizeof(float))) 299 299 }; 300 300 301 301 float* velx = (float*)malloc(sizeof(float)*maxSprites); ··· 308 308 float y = rand()%screen->h; 309 309 sprite_values[val_n++] = x - image->w/2; 310 310 sprite_values[val_n++] = y - image->h/2; 311 - sprite_values[val_n++] = 0; 312 311 313 312 sprite_values[val_n++] = 0; 314 313 sprite_values[val_n++] = 0; ··· 320 319 321 320 sprite_values[val_n++] = x + image->w/2; 322 321 sprite_values[val_n++] = y - image->h/2; 323 - sprite_values[val_n++] = 0; 324 322 325 323 sprite_values[val_n++] = 1; 326 324 sprite_values[val_n++] = 0; ··· 332 330 333 331 sprite_values[val_n++] = x + image->w/2; 334 332 sprite_values[val_n++] = y + image->h/2; 335 - sprite_values[val_n++] = 0; 336 333 337 334 sprite_values[val_n++] = 1; 338 335 sprite_values[val_n++] = 1; ··· 344 341 345 342 sprite_values[val_n++] = x - image->w/2; 346 343 sprite_values[val_n++] = y + image->h/2; 347 - sprite_values[val_n++] = 0; 348 344 349 345 sprite_values[val_n++] = 0; 350 346 sprite_values[val_n++] = 1; ··· 435 431 436 432 sprite_values[val_n] = x - image->w/2; 437 433 sprite_values[val_n+1] = y - image->h/2; 438 - sprite_values[val_n+2] = 0; 439 434 val_n += floats_per_vertex; 440 435 sprite_values[val_n] = x + image->w/2; 441 436 sprite_values[val_n+1] = y - image->h/2; 442 - sprite_values[val_n+2] = 0; 443 437 val_n += floats_per_vertex; 444 438 sprite_values[val_n] = x + image->w/2; 445 439 sprite_values[val_n+1] = y + image->h/2; 446 - sprite_values[val_n+2] = 0; 447 440 val_n += floats_per_vertex; 448 441 sprite_values[val_n] = x - image->w/2; 449 - sprite_values[val_n+1] = y + image->h/2; 450 - sprite_values[val_n+2] = 0; 442 + sprite_values[val_n+1] = y + image->h/2; 451 443 } 452 444 453 445 GPU_BlitBatchAttributes(image, screen, numSprites, 3, attributes);