comparison src/video/photon/SDL_photon_render.c @ 3386:fff074de9675

Photon SDL renderer almost finished, the double/tripple buffering is left only.
author Mike Gorchak <lestat@i.com.ua>
date Mon, 12 Oct 2009 11:45:01 +0000
parents 04af265172f9
children 05499ec8c022
comparison
equal deleted inserted replaced
3385:45d7f0f70b27 3386:fff074de9675
90 "photon", 90 "photon",
91 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | 91 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
92 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | 92 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
93 SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD | 93 SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD |
94 SDL_RENDERER_ACCELERATED), 94 SDL_RENDERER_ACCELERATED),
95 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | 95 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_ALPHA),
96 SDL_TEXTUREMODULATE_ALPHA), 96 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND |
97 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND), 97 SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
98 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_SLOW | 98 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_SLOW |
99 SDL_TEXTURESCALEMODE_FAST), 99 SDL_TEXTURESCALEMODE_FAST),
100 10, 100 10,
101 {SDL_PIXELFORMAT_INDEX8, 101 {SDL_PIXELFORMAT_INDEX8,
102 SDL_PIXELFORMAT_RGB555, 102 SDL_PIXELFORMAT_RGB555,
230 230
231 /* Set current scale blitting capabilities */ 231 /* Set current scale blitting capabilities */
232 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_OFFSCREEN) 232 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_OFFSCREEN)
233 { 233 {
234 renderer->info.scale_modes=SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_SLOW; 234 renderer->info.scale_modes=SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_SLOW;
235 if ((didata->mode_2dcaps & SDL_VIDEO_CAP_SCALED_BLIT)==SDL_VIDEO_CAP_SCALED_BLIT) 235 if ((didata->mode_2dcaps & SDL_VIDEO_PHOTON_CAP_SCALED_BLIT)==SDL_VIDEO_PHOTON_CAP_SCALED_BLIT)
236 { 236 {
237 /* This video mode supports hardware scaling */ 237 /* This video mode supports hardware scaling */
238 renderer->info.scale_modes|=SDL_TEXTURESCALEMODE_FAST; 238 renderer->info.scale_modes|=SDL_TEXTURESCALEMODE_FAST;
239 } 239 }
240 } 240 }
761 { 761 {
762 SDL_SetError("Photon: can't set palette for non-paletted texture"); 762 SDL_SetError("Photon: can't set palette for non-paletted texture");
763 return -1; 763 return -1;
764 } 764 }
765 765
766 SDL_Unsupported();
766 return -1; 767 return -1;
767 } 768 }
768 769
769 static int 770 static int
770 photon_gettexturepalette(SDL_Renderer * renderer, SDL_Texture * texture, 771 photon_gettexturepalette(SDL_Renderer * renderer, SDL_Texture * texture,
784 { 785 {
785 SDL_SetError("Photon: can't return palette for non-paletted texture"); 786 SDL_SetError("Photon: can't return palette for non-paletted texture");
786 return -1; 787 return -1;
787 } 788 }
788 789
790 SDL_Unsupported();
789 return -1; 791 return -1;
790 } 792 }
791 793
792 static int 794 static int
793 photon_settexturecolormod(SDL_Renderer * renderer, SDL_Texture * texture) 795 photon_settexturecolormod(SDL_Renderer * renderer, SDL_Texture * texture)
794 { 796 {
795 /* TODO */ 797 SDL_Unsupported();
796 return -1; 798 return -1;
797 } 799 }
798 800
799 static int 801 static int
800 photon_settexturealphamod(SDL_Renderer * renderer, SDL_Texture * texture) 802 photon_settexturealphamod(SDL_Renderer * renderer, SDL_Texture * texture)
801 { 803 {
802 /* TODO */ 804 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
803 return -1; 805
806 /* Check, if it is not initialized */
807 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
808 {
809 SDL_SetError("Photon: can't set texture blend mode for OpenGL ES window");
810 return -1;
811 }
812
813 /* Check if current renderer instance supports alpha modulation */
814 if ((renderer->info.mod_modes & SDL_TEXTUREMODULATE_ALPHA)!=SDL_TEXTUREMODULATE_ALPHA)
815 {
816 SDL_Unsupported();
817 return -1;
818 }
819
820 return 0;
804 } 821 }
805 822
806 static int 823 static int
807 photon_settextureblendmode(SDL_Renderer * renderer, SDL_Texture * texture) 824 photon_settextureblendmode(SDL_Renderer * renderer, SDL_Texture * texture)
808 { 825 {
818 switch (texture->blendMode) 835 switch (texture->blendMode)
819 { 836 {
820 case SDL_BLENDMODE_NONE: 837 case SDL_BLENDMODE_NONE:
821 case SDL_BLENDMODE_MASK: 838 case SDL_BLENDMODE_MASK:
822 case SDL_BLENDMODE_BLEND: 839 case SDL_BLENDMODE_BLEND:
823 return 0;
824 case SDL_BLENDMODE_ADD: 840 case SDL_BLENDMODE_ADD:
825 case SDL_BLENDMODE_MOD: 841 case SDL_BLENDMODE_MOD:
842 return 0;
826 default: 843 default:
827 SDL_Unsupported(); 844 SDL_Unsupported();
828 texture->blendMode = SDL_BLENDMODE_NONE; 845 texture->blendMode = SDL_BLENDMODE_NONE;
829 return -1; 846 return -1;
830 } 847 }
871 SDL_Unsupported(); 888 SDL_Unsupported();
872 texture->scaleMode = SDL_TEXTURESCALEMODE_NONE; 889 texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
873 return -1; 890 return -1;
874 } 891 }
875 892
893 SDL_Unsupported();
876 return -1; 894 return -1;
877 } 895 }
878 896
879 static int 897 static int
880 photon_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture, 898 photon_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture,
988 1006
989 static void 1007 static void
990 photon_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture, 1008 photon_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture,
991 int numrects, const SDL_Rect * rects) 1009 int numrects, const SDL_Rect * rects)
992 { 1010 {
1011 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
1012
993 /* Check, if it is not initialized */ 1013 /* Check, if it is not initialized */
994 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) 1014 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
995 { 1015 {
996 SDL_SetError("Photon: can't update dirty texture for OpenGL ES window"); 1016 SDL_SetError("Photon: can't update dirty texture for OpenGL ES window");
997 return; 1017 return;
1027 1047
1028 static int 1048 static int
1029 photon_setdrawblendmode(SDL_Renderer * renderer) 1049 photon_setdrawblendmode(SDL_Renderer * renderer)
1030 { 1050 {
1031 /* TODO */ 1051 /* TODO */
1052 SDL_Unsupported();
1032 return -1; 1053 return -1;
1033 } 1054 }
1034 1055
1035 static int 1056 static int
1036 photon_renderpoint(SDL_Renderer * renderer, int x, int y) 1057 photon_renderpoint(SDL_Renderer * renderer, int x, int y)
1135 /* Switch on requested graphics context modifiers */ 1156 /* Switch on requested graphics context modifiers */
1136 switch(texture->blendMode) 1157 switch(texture->blendMode)
1137 { 1158 {
1138 case SDL_BLENDMODE_MASK: 1159 case SDL_BLENDMODE_MASK:
1139 /* Enable and set chroma key */ 1160 /* Enable and set chroma key */
1161 PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW);
1140 PgChromaOnCx(rdata->gc); 1162 PgChromaOnCx(rdata->gc);
1163 break;
1164 case SDL_BLENDMODE_BLEND:
1165 /* Enable and set chroma key and alpha blending */
1141 PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW); 1166 PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW);
1142 break; 1167 PgChromaOnCx(rdata->gc);
1143 case SDL_BLENDMODE_BLEND: 1168 PgSetAlphaCx(rdata->gc, Pg_ALPHA_OP_SRC_GLOBAL | Pg_BLEND_SRC_As | Pg_BLEND_DST_1mAs, NULL, NULL, texture->a, 0);
1144 /* TODO */ 1169 PgAlphaOnCx(rdata->gc);
1170 break;
1171 case SDL_BLENDMODE_ADD:
1172 /* Enable and set chroma key and alpha blending */
1173 PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW);
1174 PgChromaOnCx(rdata->gc);
1175 PgSetAlphaCx(rdata->gc, Pg_ALPHA_OP_SRC_GLOBAL | Pg_BLEND_SRC_As | Pg_BLEND_DST_1, NULL, NULL, texture->a, 0);
1176 PgAlphaOnCx(rdata->gc);
1177 break;
1178 case SDL_BLENDMODE_MOD:
1179 /* Enable and set alpha blending */
1180 PgSetAlphaCx(rdata->gc, Pg_BLEND_SRC_0 | Pg_BLEND_DST_S, NULL, NULL, 0, 0);
1181 PgAlphaOnCx(rdata->gc);
1145 break; 1182 break;
1146 case SDL_BLENDMODE_NONE: 1183 case SDL_BLENDMODE_NONE:
1147 default: 1184 default:
1148 /* Do nothing */ 1185 /* Do nothing */
1149 break; 1186 break;
1211 case SDL_BLENDMODE_MASK: 1248 case SDL_BLENDMODE_MASK:
1212 /* Disable chroma key */ 1249 /* Disable chroma key */
1213 PgChromaOffCx(rdata->gc); 1250 PgChromaOffCx(rdata->gc);
1214 break; 1251 break;
1215 case SDL_BLENDMODE_BLEND: 1252 case SDL_BLENDMODE_BLEND:
1216 /* TODO */ 1253 /* Disable chroma key and alpha blending */
1254 PgChromaOffCx(rdata->gc);
1255 PgAlphaOffCx(rdata->gc);
1256 break;
1257 case SDL_BLENDMODE_ADD:
1258 /* Disable chroma key and alpha blending */
1259 PgChromaOffCx(rdata->gc);
1260 PgAlphaOffCx(rdata->gc);
1261 break;
1262 case SDL_BLENDMODE_MOD:
1263 /* Disable chroma key and alpha blending */
1264 PgAlphaOffCx(rdata->gc);
1217 break; 1265 break;
1218 case SDL_BLENDMODE_NONE: 1266 case SDL_BLENDMODE_NONE:
1219 default: 1267 default:
1220 /* Do nothing */ 1268 /* Do nothing */
1221 break; 1269 break;