~ubuntu-branches/ubuntu/trusty/libsdl2/trusty

« back to all changes in this revision

Viewing changes to test/testgles.c

  • Committer: Package Import Robot
  • Author(s): Manuel A. Fernandez Montecelo, Felix Geyer
  • Date: 2013-12-28 12:31:19 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20131228123119-e0k27gckmnzskfgb
Tags: 2.0.1+dfsg1-1
* New upstream release (Closes: #728974)
  - Remove patch applied upstream:
    bug-723797-false_positives_in_mouse_wheel_code.patch
* Bump Standards-Version to 3.9.5, no changes needed.

[ Felix Geyer ]
* Import upstream gpg key for uscan to verify the orig tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
110
110
    Uint32 then, now, frames;
111
111
    int status;
112
112
 
 
113
    /* Enable standard application logging */
 
114
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
115
 
113
116
    /* Initialize parameters */
114
117
    fsaa = 0;
115
118
    accel = 0;
143
146
            }
144
147
        }
145
148
        if (consumed < 0) {
146
 
            fprintf(stderr, "Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
 
149
            SDL_Log("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
147
150
                    SDLTest_CommonUsage(state));
148
151
            quit(1);
149
152
        }
156
159
    state->gl_green_size = 5;
157
160
    state->gl_blue_size = 5;
158
161
    state->gl_depth_size = depth;
 
162
    state->gl_major_version = 1;
 
163
    state->gl_minor_version = 1;
 
164
    state->gl_profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
159
165
    if (fsaa) {
160
166
        state->gl_multisamplebuffers=1;
161
167
        state->gl_multisamplesamples=fsaa;
169
175
 
170
176
    context = SDL_calloc(state->num_windows, sizeof(context));
171
177
    if (context == NULL) {
172
 
        fprintf(stderr, "Out of memory!\n");
 
178
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
173
179
        quit(2);
174
180
    }
175
181
 
177
183
    for (i = 0; i < state->num_windows; i++) {
178
184
        context[i] = SDL_GL_CreateContext(state->windows[i]);
179
185
        if (!context[i]) {
180
 
            fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
 
186
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
181
187
            quit(2);
182
188
        }
183
189
    }
189
195
    }
190
196
 
191
197
    SDL_GetCurrentDisplayMode(0, &mode);
192
 
    printf("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
193
 
    printf("\n");
194
 
    printf("Vendor     : %s\n", glGetString(GL_VENDOR));
195
 
    printf("Renderer   : %s\n", glGetString(GL_RENDERER));
196
 
    printf("Version    : %s\n", glGetString(GL_VERSION));
197
 
    printf("Extensions : %s\n", glGetString(GL_EXTENSIONS));
198
 
    printf("\n");
 
198
    SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
 
199
    SDL_Log("\n");
 
200
    SDL_Log("Vendor     : %s\n", glGetString(GL_VENDOR));
 
201
    SDL_Log("Renderer   : %s\n", glGetString(GL_RENDERER));
 
202
    SDL_Log("Version    : %s\n", glGetString(GL_VERSION));
 
203
    SDL_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS));
 
204
    SDL_Log("\n");
199
205
 
200
206
    status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
201
207
    if (!status) {
202
 
        printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
 
208
        SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
203
209
    } else {
204
 
        fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n",
 
210
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n",
205
211
                SDL_GetError());
206
212
    }
207
213
    status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
208
214
    if (!status) {
209
 
        printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
 
215
        SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
210
216
    } else {
211
 
        fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
 
217
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
212
218
                SDL_GetError());
213
219
    }
214
220
    status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
215
221
    if (!status) {
216
 
        printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
 
222
        SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
217
223
    } else {
218
 
        fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
 
224
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
219
225
                SDL_GetError());
220
226
    }
221
227
    status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
222
228
    if (!status) {
223
 
        printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
 
229
        SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
224
230
    } else {
225
 
        fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
 
231
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
226
232
                SDL_GetError());
227
233
    }
228
234
    if (fsaa) {
229
235
        status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
230
236
        if (!status) {
231
 
            printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
 
237
            SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
232
238
        } else {
233
 
            fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
 
239
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
234
240
                    SDL_GetError());
235
241
        }
236
242
        status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
237
243
        if (!status) {
238
 
            printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
 
244
            SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
239
245
                   value);
240
246
        } else {
241
 
            fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
 
247
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
242
248
                    SDL_GetError());
243
249
        }
244
250
    }
245
251
    if (accel) {
246
252
        status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
247
253
        if (!status) {
248
 
            printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
 
254
            SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
249
255
        } else {
250
 
            fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
 
256
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
251
257
                    SDL_GetError());
252
258
        }
253
259
    }
258
264
 
259
265
        status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
260
266
        if (status) {
261
 
            printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
 
267
            SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
262
268
 
263
269
            /* Continue for next window */
264
270
            continue;
292
298
                            if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
293
299
                                status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
294
300
                                if (status) {
295
 
                                    printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
 
301
                                    SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
296
302
                                    break;
297
303
                                }
298
304
                                /* Change view port to the new window dimensions */
309
315
            SDLTest_CommonEvent(state, &event, &done);
310
316
        }
311
317
        for (i = 0; i < state->num_windows; ++i) {
 
318
            if (state->windows[i] == NULL)
 
319
                continue;
312
320
            status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
313
321
            if (status) {
314
 
                printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
 
322
                SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
315
323
 
316
324
                /* Continue for next window */
317
325
                continue;
324
332
    /* Print out some timing information */
325
333
    now = SDL_GetTicks();
326
334
    if (now > then) {
327
 
        printf("%2.2f frames per second\n",
 
335
        SDL_Log("%2.2f frames per second\n",
328
336
               ((double) frames * 1000) / (now - then));
329
337
    }
330
338
    quit(0);
336
344
int
337
345
main(int argc, char *argv[])
338
346
{
339
 
    printf("No OpenGL ES support on this system\n");
 
347
    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL ES support on this system\n");
340
348
    return 1;
341
349
}
342
350