Mercurial > sdl-ios-xcode
comparison src/video/SDL_renderer_gles.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 | 066384910f50 |
comparison
equal
deleted
inserted
replaced
2883:11626a53e7bc | 2884:9dde605c7540 |
---|---|
83 "opengl_es", | 83 "opengl_es", |
84 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD | | 84 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD | |
85 SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED), | 85 SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED), |
86 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | | 86 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | |
87 SDL_TEXTUREMODULATE_ALPHA), | 87 SDL_TEXTUREMODULATE_ALPHA), |
88 (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK | | 88 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | |
89 SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | | 89 SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), |
90 SDL_TEXTUREBLENDMODE_MOD), | |
91 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST | | 90 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST | |
92 SDL_TEXTURESCALEMODE_SLOW), 2, | 91 SDL_TEXTURESCALEMODE_SLOW), 2, |
93 { | 92 { |
94 SDL_PIXELFORMAT_RGB24, | 93 SDL_PIXELFORMAT_RGB24, |
95 SDL_PIXELFORMAT_ABGR8888, | 94 SDL_PIXELFORMAT_ABGR8888, |
497 | 496 |
498 static int | 497 static int |
499 GLES_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) | 498 GLES_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) |
500 { | 499 { |
501 switch (texture->blendMode) { | 500 switch (texture->blendMode) { |
502 case SDL_TEXTUREBLENDMODE_NONE: | 501 case SDL_BLENDMODE_NONE: |
503 case SDL_TEXTUREBLENDMODE_MASK: | 502 case SDL_BLENDMODE_MASK: |
504 case SDL_TEXTUREBLENDMODE_BLEND: | 503 case SDL_BLENDMODE_BLEND: |
505 case SDL_TEXTUREBLENDMODE_ADD: | 504 case SDL_BLENDMODE_ADD: |
506 case SDL_TEXTUREBLENDMODE_MOD: | 505 case SDL_BLENDMODE_MOD: |
507 return 0; | 506 return 0; |
508 default: | 507 default: |
509 SDL_Unsupported(); | 508 SDL_Unsupported(); |
510 texture->blendMode = SDL_TEXTUREBLENDMODE_NONE; | 509 texture->blendMode = SDL_BLENDMODE_NONE; |
511 return -1; | 510 return -1; |
512 } | 511 } |
513 } | 512 } |
514 | 513 |
515 static int | 514 static int |
678 data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | 677 data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); |
679 } | 678 } |
680 | 679 |
681 if (texture->blendMode != data->blendMode) { | 680 if (texture->blendMode != data->blendMode) { |
682 switch (texture->blendMode) { | 681 switch (texture->blendMode) { |
683 case SDL_TEXTUREBLENDMODE_NONE: | 682 case SDL_BLENDMODE_NONE: |
684 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); | 683 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); |
685 data->glDisable(GL_BLEND); | 684 data->glDisable(GL_BLEND); |
686 break; | 685 break; |
687 case SDL_TEXTUREBLENDMODE_MASK: | 686 case SDL_BLENDMODE_MASK: |
688 case SDL_TEXTUREBLENDMODE_BLEND: | 687 case SDL_BLENDMODE_BLEND: |
689 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | 688 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
690 data->glEnable(GL_BLEND); | 689 data->glEnable(GL_BLEND); |
691 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 690 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
692 break; | 691 break; |
693 case SDL_TEXTUREBLENDMODE_ADD: | 692 case SDL_BLENDMODE_ADD: |
694 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | 693 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
695 data->glEnable(GL_BLEND); | 694 data->glEnable(GL_BLEND); |
696 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE); | 695 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE); |
697 break; | 696 break; |
698 case SDL_TEXTUREBLENDMODE_MOD: | 697 case SDL_BLENDMODE_MOD: |
699 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | 698 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
700 data->glEnable(GL_BLEND); | 699 data->glEnable(GL_BLEND); |
701 data->glBlendFunc(GL_ZERO, GL_SRC_COLOR); | 700 data->glBlendFunc(GL_ZERO, GL_SRC_COLOR); |
702 break; | 701 break; |
703 } | 702 } |