Debian Codegraph @

patches/blobandconquer_accumbuffer.diff

raw
1 --- blobandconquer-1.05.orig/data/widgets/additional
2 +++ blobandconquer-1.05/data/widgets/additional
3 @@ -133,6 +133,40 @@
4
5 Widget {
6
7 + widgetType = LABEL;
8 + grid = AdditionalGrid;
9 + name = label;
10 + groupName = additional;
11 +
12 + x = 1;
13 + y = 11;
14 +
15 + text = Limit Frames per Second;
16 +
17 +};
18 +
19 +Widget {
20 +
21 + widgetType = SLIDER;
22 + grid = AdditionalGrid;
23 + name = FPSlimit;
24 + groupName = additional;
25 + enabled = 1;
26 + visible = 1;
27 +
28 + x = 14;
29 + y = 11;
30 +
31 + colSpan = 12;
32 + rowSpan = 1;
33 +
34 + min = 5;
35 + max = 100;
36 +
37 +};
38 +
39 +Widget {
40 +
41 grid = ConfigurationGrid;
42 widgetType = BUTTON;
43 name = Done;
44 --- blobandconquer-1.05.orig/src/init.cpp
45 +++ blobandconquer-1.05/src/init.cpp
46 @@ -413,6 +413,11 @@
47 }
48
49 SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
50 + SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
51 +
52 + SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, 1);
53 + SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 1);
54 + SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, 1);
55
56 loadConfig();
57
58 --- blobandconquer-1.05.orig/src/hud/options.cpp
59 +++ blobandconquer-1.05/src/hud/options.cpp
60 @@ -432,6 +432,7 @@
61
62 void doAdditionalOptions()
63 {
64 + extern int maxfps;
65 uiManager->onlyShowGroup("additional");
66
67 Grid *grid = uiManager->getGrid("AdditionalGrid");
68 @@ -442,6 +443,7 @@
69 ComboBox *shadows = (ComboBox*)uiManager->getWidget("Shadows", "additional");
70 ComboBox *decals = (ComboBox*)uiManager->getWidget("Decals", "additional");
71 CheckBox *swap = (CheckBox*)uiManager->getWidget("SwapAxis", "additional");
72 + Slider *fpslimit = (Slider*)uiManager->getWidget("FPSlimit", "additional");
73
74 Button *done = (Button*)uiManager->getWidget("Done", "additional");
75
76 @@ -472,6 +474,8 @@
77
78 swap->checked = engine->swapSecondStickAxis;
79
80 + fpslimit->value = maxfps;
81 +
82 engine->resetTimeDifference();
83
84 while (!finished)
85 @@ -508,6 +512,7 @@
86 game->decalPolicy = decals->selectedItem;
87 game->shadowPolicy = shadows->selectedItem;
88 engine->swapSecondStickAxis = swap->checked;
89 + maxfps = fpslimit->value;
90
91 blood->clear();
92 decals->clear();
93 --- blobandconquer-1.05.orig/src/cplusplus/CGraphics.cpp
94 +++ blobandconquer-1.05/src/cplusplus/CGraphics.cpp
95 @@ -24,6 +24,9 @@
96 #include <SDL/SDL_syswm.h>
97 #endif
98
99 +int acc = 0;
100 +int maxfps = 60;
101 +
102 Graphics::Graphics()
103 {
104 fontIndex = 0;
105 @@ -58,8 +61,8 @@
106 screenMode[3].w = 1280;
107 screenMode[3].h = 1024;
108
109 - screenMode[4].w = 1900;
110 - screenMode[4].h = 1200;
111 + screenMode[4].w = 1680;
112 + screenMode[4].h = 1050;
113
114 animTimer = 0;
115
116 @@ -133,6 +136,24 @@
117 glLoadIdentity();
118
119 gluPerspective(45.0f, (GLfloat) screen->w / (GLfloat) screen->h, 0.1f, 9000.0f);
120 +
121 + // AA using the accumulation buffer
122 +
123 + static GLfloat dx[100] = {-0.5, 0.5, -0.5, 0.5, 0, -0.5, 0.5, 0, 0, 0};
124 + static GLfloat dy[100] = {-0.5, 0.5, 0.5, -0.5, 0, 0, 0, -0.5, 0.5, 0};
125 +
126 + if(!dx[9]) {
127 + for(int i = 9; i < 100; i++) {
128 + dx[i] = drand48() - 1.0;
129 + dy[i] = drand48() - 1.0;
130 + }
131 + }
132 +
133 + GLfloat m[16];
134 + glGetFloatv(GL_PROJECTION_MATRIX, m);
135 + m[8] = dx[acc % 100]/(GLfloat)screen->w;
136 + m[9] = dy[acc % 100]/(GLfloat)screen->h;
137 + glLoadMatrixf(m);
138
139 glMatrixMode(GL_MODELVIEW);
140 glLoadIdentity();
141 @@ -247,9 +268,12 @@
142 debug(("Graphics::setResolution() - Done\n"));
143 }
144
145 +static int swapframes = 0;
146 +
147 void Graphics::resetFPSCount()
148 {
149 frames = 0;
150 + swapframes = 0;
151 time = 0.0;
152 fps = "N/A";
153 }
154 @@ -267,12 +291,13 @@
155
156 if (time <= 0)
157 {
158 - fps.setText("%d fps", frames);
159 + fps.setText("%d * %3.1f fps", swapframes, (float)frames / swapframes);
160 time = 100;
161 frames = 0;
162 + swapframes = 0;
163 }
164
165 - drawString(screen->w - 5, y, TXT_RIGHT, GLColor::white, true, "%s", fps.getText());
166 + drawString(screen->w - 11, y, TXT_RIGHT, GLColor::white, true, "%s", fps.getText());
167 }
168
169 void Graphics::showLoadingProgress(const char *status)
170 @@ -333,8 +358,30 @@
171
172 void Graphics::updateScreen()
173 {
174 - SDL_GL_SwapBuffers();
175 - SDL_Delay(1);
176 + static const int maxacc = 256;
177 + bool flush = false;
178 + static uint32_t lastflush = 0;
179 + uint32_t now = SDL_GetTicks();
180 +
181 + acc++;
182 +
183 + // Decide to flush accumulation buffer if another frame would make us miss the next vblank.
184 + if(now - lastflush >= 1000 / maxfps || acc >= maxacc)
185 + flush = true;
186 +
187 + // Accumulate this frame unless it's the first frame and we're flushing.
188 + if(!flush || acc > 1)
189 + glAccum(acc > 1 ? GL_ACCUM : GL_LOAD, 1.0f / maxacc);
190 +
191 + if(flush) {
192 + if(acc > 1)
193 + glAccum(GL_RETURN, (float)maxacc / (float)acc);
194 + acc = 0;
195 + lastflush = now;
196 + swapframes++;
197 + SDL_GL_SwapBuffers();
198 + }
199 + //SDL_Delay(1);
200
201 if ((engine->keyState[SDLK_F10]) || ((engine->keyState[SDLK_RETURN]) && (engine->keyState[SDLK_LALT])))
202 {
203 @@ -587,7 +634,7 @@
204 glBindTexture(GL_TEXTURE_2D, glTexture);
205
206 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, tmp->pixels);
207 - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
208 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
209 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
210 gluBuild2DMipmaps(GL_TEXTURE_2D, 3, tmp->w, tmp->h, GL_RGBA, GL_UNSIGNED_BYTE, tmp->pixels);
211
212 @@ -611,7 +658,7 @@
213
214 glGenTextures(1, &glTexture);
215 glBindTexture(GL_TEXTURE_2D, glTexture);
216 - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
217 + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
218 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
219
220 Texture *texture = new Texture();
221 --- blobandconquer-1.05.orig/src/cplusplus/CEngine.cpp
222 +++ blobandconquer-1.05/src/cplusplus/CEngine.cpp
223 @@ -45,7 +45,7 @@
224
225 joystickIndex = 0;
226
227 - showFPS = false;
228 + showFPS = true;
229 showPosition = false;
230
231 memset(lastKeyEvents, 0, 35);