this repo has no description
0
fork

Configure Feed

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

Factored out MVP upload and fixed TriangleBatch() to use it.

+34 -61
+34 -61
src/renderer_GL_common.inl
··· 4654 4654 4655 4655 static void SetAttributefv(GPU_Renderer* renderer, int location, int num_elements, float* value); 4656 4656 4657 + #ifdef SDL_GPU_USE_BUFFER_PIPELINE 4658 + static void gpu_upload_modelviewprojection(GPU_Target* dest, GPU_Context* context) 4659 + { 4660 + GPU_CONTEXT_DATA* cdata = (GPU_CONTEXT_DATA*)context->data; 4661 + if(context->current_shader_block.modelViewProjection_loc >= 0) 4662 + { 4663 + float p[16]; 4664 + float mv[16]; 4665 + float mvp[16]; 4666 + 4667 + GPU_MatrixCopy(p, GPU_GetProjection()); 4668 + GPU_MatrixCopy(mv, GPU_GetModelView()); 4669 + 4670 + if(dest->use_camera) 4671 + { 4672 + float cam_matrix[16]; 4673 + get_camera_matrix(cam_matrix, cdata->last_camera); 4674 + 4675 + GPU_MultiplyAndAssign(cam_matrix, p); 4676 + GPU_MatrixCopy(p, cam_matrix); 4677 + } 4678 + 4679 + // MVP = P * MV 4680 + GPU_Multiply4x4(mvp, p, mv); 4681 + 4682 + glUniformMatrix4fv(context->current_shader_block.modelViewProjection_loc, 1, 0, mvp); 4683 + } 4684 + } 4685 + #endif 4686 + 4687 + 4657 4688 // Assumes the right format 4658 4689 static void TriangleBatchX(GPU_Renderer* renderer, GPU_Image* image, GPU_Target* target, unsigned short num_vertices, void* values, unsigned int num_indices, unsigned short* indices, GPU_BatchFlagEnum flags) 4659 4690 { ··· 4918 4949 glBindVertexArray(cdata->blit_VAO); 4919 4950 #endif 4920 4951 4921 - // Upload our modelviewprojection matrix 4922 - if(context->current_shader_block.modelViewProjection_loc >= 0) 4923 - { 4924 - float mvp[16]; 4925 - float cam_matrix[16]; 4926 - GPU_GetModelViewProjection(mvp); 4927 - get_camera_matrix(cam_matrix, cdata->last_camera); 4928 - 4929 - GPU_MultiplyAndAssign(mvp, cam_matrix); 4930 - 4931 - glUniformMatrix4fv(context->current_shader_block.modelViewProjection_loc, 1, 0, mvp); 4932 - } 4952 + gpu_upload_modelviewprojection(target, context); 4933 4953 4934 4954 if(values != NULL) 4935 4955 { ··· 5344 5364 5345 5365 5346 5366 5347 - 5348 5367 #ifdef SDL_GPU_USE_BUFFER_PIPELINE 5349 5368 { 5350 5369 // Update the vertex array object's buffers ··· 5352 5371 glBindVertexArray(cdata->blit_VAO); 5353 5372 #endif 5354 5373 5355 - // Upload our modelviewprojection matrix 5356 - if(context->current_shader_block.modelViewProjection_loc >= 0) 5357 - { 5358 - float p[16]; 5359 - float mv[16]; 5360 - float mvp[16]; 5361 - 5362 - GPU_MatrixCopy(p, GPU_GetProjection()); 5363 - GPU_MatrixCopy(mv, GPU_GetModelView()); 5364 - 5365 - if(dest->use_camera) 5366 - { 5367 - float cam_matrix[16]; 5368 - get_camera_matrix(cam_matrix, cdata->last_camera); 5369 - 5370 - GPU_MultiplyAndAssign(cam_matrix, p); 5371 - GPU_MatrixCopy(p, cam_matrix); 5372 - } 5373 - 5374 - // MVP = P * MV 5375 - GPU_Multiply4x4(mvp, p, mv); 5376 - 5377 - glUniformMatrix4fv(context->current_shader_block.modelViewProjection_loc, 1, 0, mvp); 5378 - } 5374 + gpu_upload_modelviewprojection(dest, context); 5379 5375 5380 5376 // Upload blit buffer to a single buffer object 5381 5377 glBindBuffer(GL_ARRAY_BUFFER, cdata->blit_VBO[cdata->blit_VBO_flop]); ··· 5472 5468 glBindVertexArray(cdata->blit_VAO); 5473 5469 #endif 5474 5470 5475 - // Upload our modelviewprojection matrix 5476 - if(context->current_shader_block.modelViewProjection_loc >= 0) 5477 - { 5478 - float p[16]; 5479 - float mv[16]; 5480 - float mvp[16]; 5481 - 5482 - GPU_MatrixCopy(p, GPU_GetProjection()); 5483 - GPU_MatrixCopy(mv, GPU_GetModelView()); 5484 - 5485 - if(dest->use_camera) 5486 - { 5487 - float cam_matrix[16]; 5488 - get_camera_matrix(cam_matrix, cdata->last_camera); 5489 - 5490 - GPU_MultiplyAndAssign(cam_matrix, p); 5491 - GPU_MatrixCopy(p, cam_matrix); 5492 - } 5493 - 5494 - // MVP = P * MV 5495 - GPU_Multiply4x4(mvp, p, mv); 5496 - 5497 - glUniformMatrix4fv(context->current_shader_block.modelViewProjection_loc, 1, 0, mvp); 5498 - } 5471 + gpu_upload_modelviewprojection(dest, context); 5499 5472 5500 5473 // Upload blit buffer to a single buffer object 5501 5474 glBindBuffer(GL_ARRAY_BUFFER, cdata->blit_VBO[cdata->blit_VBO_flop]);