Mercurial > sdl-ios-xcode
comparison src/video/win32/SDL_d3drender.c @ 2884:9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 20 Dec 2008 12:00:00 +0000 |
parents | 99210400e8b9 |
children | 2f91a3847ae8 |
comparison
equal
deleted
inserted
replaced
2883:11626a53e7bc | 2884:9dde605c7540 |
---|---|
80 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | | 80 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | |
81 SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC | | 81 SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC | |
82 SDL_RENDERER_ACCELERATED), | 82 SDL_RENDERER_ACCELERATED), |
83 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | | 83 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | |
84 SDL_TEXTUREMODULATE_ALPHA), | 84 SDL_TEXTUREMODULATE_ALPHA), |
85 (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK | | 85 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | |
86 SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | | 86 SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), |
87 SDL_TEXTUREBLENDMODE_MOD), | |
88 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST | | 87 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST | |
89 SDL_TEXTURESCALEMODE_SLOW | SDL_TEXTURESCALEMODE_BEST), | 88 SDL_TEXTURESCALEMODE_SLOW | SDL_TEXTURESCALEMODE_BEST), |
90 12, | 89 12, |
91 { | 90 { |
92 SDL_PIXELFORMAT_INDEX8, | 91 SDL_PIXELFORMAT_INDEX8, |
523 | 522 |
524 static int | 523 static int |
525 D3D_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) | 524 D3D_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) |
526 { | 525 { |
527 switch (texture->blendMode) { | 526 switch (texture->blendMode) { |
528 case SDL_TEXTUREBLENDMODE_NONE: | 527 case SDL_BLENDMODE_NONE: |
529 case SDL_TEXTUREBLENDMODE_MASK: | 528 case SDL_BLENDMODE_MASK: |
530 case SDL_TEXTUREBLENDMODE_BLEND: | 529 case SDL_BLENDMODE_BLEND: |
531 case SDL_TEXTUREBLENDMODE_ADD: | 530 case SDL_BLENDMODE_ADD: |
532 case SDL_TEXTUREBLENDMODE_MOD: | 531 case SDL_BLENDMODE_MOD: |
533 return 0; | 532 return 0; |
534 default: | 533 default: |
535 SDL_Unsupported(); | 534 SDL_Unsupported(); |
536 texture->blendMode = SDL_TEXTUREBLENDMODE_NONE; | 535 texture->blendMode = SDL_BLENDMODE_NONE; |
537 return -1; | 536 return -1; |
538 } | 537 } |
539 } | 538 } |
540 | 539 |
541 static int | 540 static int |
796 vertices[3].color = color; | 795 vertices[3].color = color; |
797 vertices[3].u = minu; | 796 vertices[3].u = minu; |
798 vertices[3].v = maxv; | 797 vertices[3].v = maxv; |
799 | 798 |
800 switch (texture->blendMode) { | 799 switch (texture->blendMode) { |
801 case SDL_TEXTUREBLENDMODE_NONE: | 800 case SDL_BLENDMODE_NONE: |
802 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, | 801 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
803 FALSE); | 802 FALSE); |
804 break; | 803 break; |
805 case SDL_TEXTUREBLENDMODE_MASK: | 804 case SDL_BLENDMODE_MASK: |
806 case SDL_TEXTUREBLENDMODE_BLEND: | 805 case SDL_BLENDMODE_BLEND: |
807 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, | 806 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
808 TRUE); | 807 TRUE); |
809 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, | 808 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, |
810 D3DBLEND_SRCALPHA); | 809 D3DBLEND_SRCALPHA); |
811 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, | 810 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, |
812 D3DBLEND_INVSRCALPHA); | 811 D3DBLEND_INVSRCALPHA); |
813 break; | 812 break; |
814 case SDL_TEXTUREBLENDMODE_ADD: | 813 case SDL_BLENDMODE_ADD: |
815 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, | 814 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
816 TRUE); | 815 TRUE); |
817 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, | 816 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, |
818 D3DBLEND_SRCALPHA); | 817 D3DBLEND_SRCALPHA); |
819 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, | 818 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, |
820 D3DBLEND_ONE); | 819 D3DBLEND_ONE); |
821 break; | 820 break; |
822 case SDL_TEXTUREBLENDMODE_MOD: | 821 case SDL_BLENDMODE_MOD: |
823 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, | 822 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
824 TRUE); | 823 TRUE); |
825 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, | 824 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, |
826 D3DBLEND_ZERO); | 825 D3DBLEND_ZERO); |
827 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, | 826 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, |