comparison src/video/win32/SDL_gdirender.c @ 3599:0f958e527e5e

Updated to compile on Windows
author Sam Lantinga <slouken@libsdl.org>
date Thu, 24 Dec 2009 19:18:05 +0000
parents 0267b8b1595c
children 64ce267332c6
comparison
equal deleted inserted replaced
3598:427ff6d745df 3599:0f958e527e5e
59 static int GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, 59 static int GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
60 const SDL_Rect * rect, int markDirty, 60 const SDL_Rect * rect, int markDirty,
61 void **pixels, int *pitch); 61 void **pixels, int *pitch);
62 static void GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); 62 static void GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
63 static int GDI_SetDrawBlendMode(SDL_Renderer * renderer); 63 static int GDI_SetDrawBlendMode(SDL_Renderer * renderer);
64 static int GDI_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, 64 static int GDI_RenderDrawPoints(SDL_Renderer * renderer,
65 int count); 65 const SDL_Point * points, int count);
66 static int GDI_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, 66 static int GDI_RenderDrawLines(SDL_Renderer * renderer,
67 int count); 67 const SDL_Point * points, int count);
68 static int GDI_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects, 68 static int GDI_RenderDrawRects(SDL_Renderer * renderer,
69 int count); 69 const SDL_Rect ** rects, int count);
70 static int GDI_RenderFillRects(SDL_Renderer * renderer,
71 const SDL_Rect ** rects, int count);
70 static int GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, 72 static int GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
71 const SDL_Rect * srcrect, const SDL_Rect * dstrect); 73 const SDL_Rect * srcrect, const SDL_Rect * dstrect);
72 static int GDI_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, 74 static int GDI_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
73 Uint32 format, void * pixels, int pitch); 75 Uint32 format, void * pixels, int pitch);
74 static int GDI_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, 76 static int GDI_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
192 renderer->SetTextureScaleMode = GDI_SetTextureScaleMode; 194 renderer->SetTextureScaleMode = GDI_SetTextureScaleMode;
193 renderer->UpdateTexture = GDI_UpdateTexture; 195 renderer->UpdateTexture = GDI_UpdateTexture;
194 renderer->LockTexture = GDI_LockTexture; 196 renderer->LockTexture = GDI_LockTexture;
195 renderer->UnlockTexture = GDI_UnlockTexture; 197 renderer->UnlockTexture = GDI_UnlockTexture;
196 renderer->SetDrawBlendMode = GDI_SetDrawBlendMode; 198 renderer->SetDrawBlendMode = GDI_SetDrawBlendMode;
197 renderer->RenderPoints = GDI_RenderPoints; 199 renderer->RenderDrawPoints = GDI_RenderDrawPoints;
198 renderer->RenderLines = GDI_RenderLines; 200 renderer->RenderDrawLines = GDI_RenderDrawLines;
199 renderer->RenderRects = GDI_RenderRects; 201 renderer->RenderDrawRects = GDI_RenderDrawRects;
202 renderer->RenderFillRects = GDI_RenderFillRects;
200 renderer->RenderCopy = GDI_RenderCopy; 203 renderer->RenderCopy = GDI_RenderCopy;
201 renderer->RenderReadPixels = GDI_RenderReadPixels; 204 renderer->RenderReadPixels = GDI_RenderReadPixels;
202 renderer->RenderWritePixels = GDI_RenderWritePixels; 205 renderer->RenderWritePixels = GDI_RenderWritePixels;
203 renderer->RenderPresent = GDI_RenderPresent; 206 renderer->RenderPresent = GDI_RenderPresent;
204 renderer->DestroyTexture = GDI_DestroyTexture; 207 renderer->DestroyTexture = GDI_DestroyTexture;
685 return -1; 688 return -1;
686 } 689 }
687 } 690 }
688 691
689 static int 692 static int
690 GDI_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, int count) 693 GDI_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
694 int count)
691 { 695 {
692 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; 696 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
693 int i; 697 int i;
694 COLORREF color; 698 COLORREF color;
695 699
717 721
718 return 0; 722 return 0;
719 } 723 }
720 724
721 static int 725 static int
722 GDI_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, int count) 726 GDI_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
727 int count)
723 { 728 {
724 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; 729 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
725 HPEN pen; 730 HPEN pen;
726 BOOL status; 731 BOOL status;
727 732
771 } 776 }
772 return 0; 777 return 0;
773 } 778 }
774 779
775 static int 780 static int
776 GDI_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) 781 GDI_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
782 int count)
783 {
784 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
785 HPEN pen;
786 POINT vertices[5];
787 int i, status = 1;
788
789 if (data->makedirty) {
790 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
791 SDL_Rect clip, rect;
792
793 clip.x = 0;
794 clip.y = 0;
795 clip.w = window->w;
796 clip.h = window->h;
797
798 for (i = 0; i < count; ++i) {
799 if (SDL_IntersectRect(rects[i], &clip, &rect)) {
800 SDL_AddDirtyRect(&data->dirty, &rect);
801 }
802 }
803 }
804
805 /* Should we cache the pen? .. it looks like GDI does for us. :) */
806 pen = CreatePen(PS_SOLID, 1, RGB(renderer->r, renderer->g, renderer->b));
807 SelectObject(data->current_hdc, pen);
808 for (i = 0; i < count; ++i) {
809 const SDL_Rect *rect = rects[i];
810
811 vertices[0].x = rect->x;
812 vertices[0].y = rect->y;
813
814 vertices[1].x = rect->x+rect->w-1;
815 vertices[1].y = rect->y;
816
817 vertices[2].x = rect->x+rect->w-1;
818 vertices[2].y = rect->y+rect->h-1;
819
820 vertices[3].x = rect->x;
821 vertices[3].y = rect->y+rect->h-1;
822
823 vertices[4].x = rect->x;
824 vertices[4].y = rect->y;
825
826 status &= Polyline(data->current_hdc, vertices, 5);
827 }
828 DeleteObject(pen);
829
830 if (!status) {
831 WIN_SetError("Polyline()");
832 return -1;
833 }
834 return 0;
835 }
836
837 static int
838 GDI_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
839 int count)
777 { 840 {
778 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; 841 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
779 RECT rc; 842 RECT rc;
780 HBRUSH brush; 843 HBRUSH brush;
781 int i, status = 1; 844 int i, status = 1;