this repo has no description
0
fork

Configure Feed

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

Removed GPU_SubSurfaceCopy(). The functionality will likely be replaced with GPU_UpdateImage() and GPU_UpdateSubImage().

-166
-80
SDL_gpu/GL_common/SDL_gpu_GL_common.inl
··· 2553 2553 2554 2554 2555 2555 2556 - static void SubSurfaceCopy(GPU_Renderer* renderer, SDL_Surface* src, GPU_Rect* srcrect, GPU_Target* dest, Sint16 x, Sint16 y) 2557 - { 2558 - if(src == NULL || dest == NULL || dest->image == NULL) 2559 - return; 2560 - 2561 - if(renderer != dest->renderer) 2562 - return; 2563 - 2564 - GPU_Rect r; 2565 - if(srcrect != NULL) 2566 - r = *srcrect; 2567 - else 2568 - { 2569 - r.x = 0; 2570 - r.y = 0; 2571 - r.w = src->w; 2572 - r.h = src->h; 2573 - if(r.w < 0.0f || r.h < 0.0f) 2574 - { 2575 - GPU_PushErrorCode("GPU_SubSurfaceCopy", GPU_ERROR_USER_ERROR, "Given negative source rectangle."); 2576 - return; 2577 - } 2578 - } 2579 - 2580 - bindTexture(renderer, dest->image); 2581 - 2582 - //GLenum texture_format = GL_RGBA;//((GPU_IMAGE_DATA*)image->data)->format; 2583 - 2584 - SDL_Surface* temp = SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, src->format->BitsPerPixel, src->format->Rmask, src->format->Gmask, src->format->Bmask, src->format->Amask); 2585 - 2586 - if(temp == NULL) 2587 - { 2588 - GPU_PushErrorCode("GPU_SubSurfaceCopy", GPU_ERROR_BACKEND_ERROR, "Failed to create new surface."); 2589 - return; 2590 - } 2591 - 2592 - // Copy data to new surface 2593 - #ifdef SDL_GPU_USE_SDL2 2594 - SDL_BlendMode blendmode; 2595 - SDL_GetSurfaceBlendMode(src, &blendmode); 2596 - SDL_SetSurfaceBlendMode(src, SDL_BLENDMODE_NONE); 2597 - #else 2598 - Uint32 srcAlpha = src->flags & SDL_SRCALPHA; 2599 - SDL_SetAlpha(src, 0, src->format->alpha); 2600 - #endif 2601 - 2602 - SDL_Rect destrect = {r.x, r.y, r.w, r.h}; 2603 - SDL_BlitSurface(src, &destrect, temp, NULL); 2604 - // FIXME: What if destrect does not equal r anymore? 2605 - 2606 - #ifdef SDL_GPU_USE_SDL2 2607 - SDL_SetSurfaceBlendMode(src, blendmode); 2608 - #else 2609 - SDL_SetAlpha(src, srcAlpha, src->format->alpha); 2610 - #endif 2611 - 2612 - // Make surface into an image 2613 - GPU_Image* image = GPU_CopyImageFromSurface(temp); 2614 - if(image == NULL) 2615 - { 2616 - GPU_PushErrorCode("GPU_SubSurfaceCopy", GPU_ERROR_BACKEND_ERROR, "Failed to create new image."); 2617 - return; 2618 - } 2619 - 2620 - // Copy image to dest 2621 - GPU_FlushBlitBuffer(); 2622 - GPU_SetBlending(image, 0); 2623 - GPU_Blit(image, NULL, dest, x + r.w/2, y + r.h/2); 2624 - GPU_FlushBlitBuffer(); 2625 - 2626 - // Using glTexSubImage might be more efficient 2627 - //glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, r.w, r.h, texture_format, GL_UNSIGNED_BYTE, buffer); 2628 - 2629 - GPU_FreeImage(image); 2630 - 2631 - SDL_FreeSurface(temp); 2632 - } 2633 - 2634 - 2635 2556 static GPU_Target* LoadTarget(GPU_Renderer* renderer, GPU_Image* image) 2636 2557 { 2637 2558 if(image == NULL) ··· 5262 5183 renderer->CopyImageFromTarget = &CopyImageFromTarget; \ 5263 5184 renderer->CopySurfaceFromTarget = &CopySurfaceFromTarget; \ 5264 5185 renderer->CopySurfaceFromImage = &CopySurfaceFromImage; \ 5265 - renderer->SubSurfaceCopy = &SubSurfaceCopy; \ 5266 5186 renderer->FreeImage = &FreeImage; \ 5267 5187 \ 5268 5188 renderer->LoadTarget = &LoadTarget; \
-8
SDL_gpu/SDL_gpu.c
··· 678 678 } 679 679 680 680 681 - void GPU_SubSurfaceCopy(SDL_Surface* src, GPU_Rect* srcrect, GPU_Target* dest, Sint16 x, Sint16 y) 682 - { 683 - if(current_renderer == NULL || current_renderer->current_context_target == NULL || current_renderer->SubSurfaceCopy == NULL) 684 - return; 685 - 686 - current_renderer->SubSurfaceCopy(current_renderer, src, srcrect, dest, x, y); 687 - } 688 - 689 681 GPU_Target* GPU_GetContextTarget(void) 690 682 { 691 683 if(current_renderer == NULL)
-6
SDL_gpu/SDL_gpu.h
··· 518 518 /*! \see GPU_FreeImage() */ 519 519 void (*FreeImage)(GPU_Renderer* renderer, GPU_Image* image); 520 520 521 - /*! \see GPU_SubSurfaceCopy() */ 522 - void (*SubSurfaceCopy)(GPU_Renderer* renderer, SDL_Surface* src, GPU_Rect* srcrect, GPU_Target* dest, Sint16 x, Sint16 y); 523 - 524 521 /*! \see GPU_LoadTarget() */ 525 522 GPU_Target* (*LoadTarget)(GPU_Renderer* renderer, GPU_Image* image); 526 523 ··· 1051 1048 1052 1049 /*! Update an image from surface data. */ 1053 1050 void GPU_UpdateImage(GPU_Image* image, const GPU_Rect* rect, SDL_Surface* surface); 1054 - 1055 - /*! Copies software surface data to a hardware texture. Draws data with the upper left corner being (x,y). */ 1056 - void GPU_SubSurfaceCopy(SDL_Surface* src, GPU_Rect* srcrect, GPU_Target* dest, Sint16 x, Sint16 y); 1057 1051 1058 1052 /*! Save image to a file. The file type is deduced from the extension. Supported formats are: png, bmp, tga. Returns 0 on failure. */ 1059 1053 Uint8 GPU_SaveImage(GPU_Image* image, const char* filename);
-3
demos/CMakeLists.txt
··· 68 68 add_executable(npot-demo npot/main.c common/common.c common/demo-font.c) 69 69 target_link_libraries (npot-demo SDL_gpu) 70 70 71 - add_executable(subsurface-demo subsurface/main.c common/common.c common/demo-font.c) 72 - target_link_libraries (subsurface-demo SDL_gpu) 73 - 74 71 add_executable(features-demo features/main.c common/common.c common/demo-font.c) 75 72 target_link_libraries (features-demo SDL_gpu) 76 73
-69
demos/subsurface/main.c
··· 1 - #include "SDL.h" 2 - #include "SDL_gpu.h" 3 - #include "common.h" 4 - 5 - 6 - int main(int argc, char* argv[]) 7 - { 8 - printRenderers(); 9 - 10 - GPU_Target* screen = GPU_Init(800, 600, GPU_DEFAULT_INIT_FLAGS); 11 - if(screen == NULL) 12 - return -1; 13 - 14 - printCurrentRenderer(); 15 - 16 - SDL_Surface* surf = SDL_LoadBMP("data/test.bmp"); 17 - GPU_Image* image = GPU_CreateImage(100, 100, GPU_FORMAT_RGBA); 18 - GPU_Target* tgt = GPU_LoadTarget(image); 19 - GPU_Image* image2 = GPU_LoadImage("data/test.bmp"); 20 - if(image == NULL || surf == NULL || tgt == NULL || image2 == NULL) 21 - return -1; 22 - 23 - GPU_Rect rect = {71, 64, 96, 52}; 24 - GPU_SubSurfaceCopy(surf, &rect, tgt, 0, 0); 25 - GPU_FreeTarget(tgt); 26 - tgt = NULL; 27 - SDL_FreeSurface(surf); 28 - surf = NULL; 29 - 30 - Uint32 startTime = SDL_GetTicks(); 31 - long frameCount = 0; 32 - 33 - 34 - Uint8 done = 0; 35 - SDL_Event event; 36 - while(!done) 37 - { 38 - while(SDL_PollEvent(&event)) 39 - { 40 - if(event.type == SDL_QUIT) 41 - done = 1; 42 - else if(event.type == SDL_KEYDOWN) 43 - { 44 - if(event.key.keysym.sym == SDLK_ESCAPE) 45 - done = 1; 46 - } 47 - } 48 - 49 - GPU_Clear(screen); 50 - 51 - GPU_Blit(image, NULL, screen, screen->w/2, screen->h/2); 52 - GPU_Blit(image2, &rect, screen, rect.w/2, rect.h/2); 53 - 54 - GPU_Flip(screen); 55 - 56 - frameCount++; 57 - if(frameCount%500 == 0) 58 - printf("Average FPS: %.2f\n", 1000.0f*frameCount/(SDL_GetTicks() - startTime)); 59 - } 60 - 61 - printf("Average FPS: %.2f\n", 1000.0f*frameCount/(SDL_GetTicks() - startTime)); 62 - 63 - GPU_FreeImage(image); 64 - GPU_Quit(); 65 - 66 - return 0; 67 - } 68 - 69 -