Mercurial > sdl-ios-xcode
annotate Xcode/TemplatesForXcodeSnowLeopard/SDL Cocoa Application/main.c @ 5053:b5b42be9333c
Fixed bug #1026
Vittorio Giovara 2010-07-16 19:09:28 PDT
i was reading SDL_renderer_gles and i noticed that every time we there
is some gl call the gl state is modified with a couple of
glEnableClientState()/glDisableClientState.
While this is completely fine for desktops systems, this is a major
performace kill on mobile devices, right where opengles is
implemented.
Normal practice in this case is to update the glstate once, keep it
always the same and disable/enable other states only in very special
occasions.
On the web there's plenty of documentation (on the top of my head
http://developer.apple.com/iphone/library/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/Performance/Performance.html#//apple_ref/doc/uid/TP40008793-CH105-SW5
) and i personally tried this.
I modified my code and got a 10 fps boost, then modified SDL_render_gles and
shifted from 40 fps to 50 fps alone -- considering that i started from ~30fps i
got an 80% performance increase with this technique.
I have attached a dif of my changes, hope that it will be included in
mainstream.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 19 Jan 2011 23:56:16 -0800 |
parents | d44a0a913aa2 |
children |
rev | line source |
---|---|
3331 | 1 |
2 /* Simple program: Create a blank window, wait for keypress, quit. | |
3 | |
4 Please see the SDL documentation for details on using the SDL API: | |
5 /Developer/Documentation/SDL/docs.html | |
6 */ | |
7 | |
8 #include <stdio.h> | |
9 #include <stdlib.h> | |
10 #include <string.h> | |
11 #include <math.h> | |
12 | |
13 #include "SDL.h" | |
14 | |
15 int main(int argc, char *argv[]) | |
16 { | |
17 Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */ | |
18 SDL_Surface *screen; | |
19 Uint8 video_bpp = 0; | |
20 Uint32 videoflags = SDL_SWSURFACE; | |
21 int done; | |
22 SDL_Event event; | |
23 | |
24 /* Initialize the SDL library */ | |
25 if ( SDL_Init(initflags) < 0 ) { | |
26 fprintf(stderr, "Couldn't initialize SDL: %s\n", | |
27 SDL_GetError()); | |
28 exit(1); | |
29 } | |
30 | |
31 /* Set 640x480 video mode */ | |
32 screen=SDL_SetVideoMode(640,480, video_bpp, videoflags); | |
33 if (screen == NULL) { | |
34 fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n", | |
35 video_bpp, SDL_GetError()); | |
36 SDL_Quit(); | |
37 exit(2); | |
38 } | |
39 | |
40 done = 0; | |
41 while ( !done ) { | |
42 | |
43 /* Check for events */ | |
44 while ( SDL_PollEvent(&event) ) { | |
45 switch (event.type) { | |
46 | |
47 case SDL_MOUSEMOTION: | |
48 break; | |
49 case SDL_MOUSEBUTTONDOWN: | |
50 break; | |
51 case SDL_KEYDOWN: | |
52 /* Any keypress quits the app... */ | |
53 case SDL_QUIT: | |
54 done = 1; | |
55 break; | |
56 default: | |
57 break; | |
58 } | |
59 } | |
60 } | |
61 | |
62 /* Clean up the SDL library */ | |
63 SDL_Quit(); | |
64 return(0); | |
65 } |