~ubuntu-branches/ubuntu/vivid/libsdl2/vivid

« back to all changes in this revision

Viewing changes to src/render/opengles/SDL_render_gles.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:
96
96
    GLES_CreateRenderer,
97
97
    {
98
98
     "opengles",
99
 
     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
 
99
     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC ),
100
100
     1,
101
101
     {SDL_PIXELFORMAT_ABGR8888},
102
102
     0,
113
113
    } current;
114
114
 
115
115
#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
 
116
#define SDL_PROC_OES SDL_PROC
116
117
#include "SDL_glesfuncs.h"
117
118
#undef SDL_PROC
 
119
#undef SDL_PROC_OES
118
120
    SDL_bool GL_OES_framebuffer_object_supported;
119
121
    GLES_FBOList *framebuffers;
120
122
    GLuint window_framebuffer;
183
185
 
184
186
#ifdef __SDL_NOGETPROCADDR__
185
187
#define SDL_PROC(ret,func,params) data->func=func;
 
188
#define SDL_PROC_OES(ret,func,params) data->func=func;
186
189
#else
187
190
#define SDL_PROC(ret,func,params) \
188
191
    do { \
191
194
            return SDL_SetError("Couldn't load GLES function %s: %s\n", #func, SDL_GetError()); \
192
195
        } \
193
196
    } while ( 0 );
 
197
#define SDL_PROC_OES(ret,func,params) \
 
198
    do { \
 
199
        data->func = SDL_GL_GetProcAddress(#func); \
 
200
    } while ( 0 );    
194
201
#endif /* _SDL_NOGETPROCADDR_ */
195
202
 
196
203
#include "SDL_glesfuncs.h"
197
204
#undef SDL_PROC
 
205
#undef SDL_PROC_OES
198
206
    return 0;
199
207
}
200
208
 
272
280
    GLint value;
273
281
    Uint32 windowFlags;
274
282
 
275
 
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 1);
 
283
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
276
284
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
277
285
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
278
286
 
367
375
    data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
368
376
    renderer->info.max_texture_height = value;
369
377
 
370
 
    if (SDL_GL_ExtensionSupported("GL_OES_framebuffer_object")) {
 
378
    /* Android does not report GL_OES_framebuffer_object but the functionality seems to be there anyway */
 
379
    if (SDL_GL_ExtensionSupported("GL_OES_framebuffer_object") || data->glGenFramebuffersOES) {
371
380
        data->GL_OES_framebuffer_object_supported = SDL_TRUE;
372
381
        renderer->info.flags |= SDL_RENDERER_TARGETTEXTURE;
373
382
 
405
414
    }
406
415
}
407
416
 
408
 
static __inline__ int
 
417
static SDL_INLINE int
409
418
power_of_2(int input)
410
419
{
411
420
    int value = 1;
465
474
        }
466
475
    }
467
476
 
468
 
    texture->driverdata = data;
 
477
    
469
478
    if (texture->access == SDL_TEXTUREACCESS_TARGET) {
470
 
       data->fbo = GLES_GetFBO(renderer->driverdata, texture->w, texture->h);
 
479
        if (!renderdata->GL_OES_framebuffer_object_supported) {
 
480
            SDL_free(data);
 
481
            return SDL_SetError("GL_OES_framebuffer_object not supported");
 
482
        }
 
483
        data->fbo = GLES_GetFBO(renderer->driverdata, texture->w, texture->h);
471
484
    } else {
472
 
       data->fbo = NULL;
 
485
        data->fbo = NULL;
473
486
    }
 
487
    
474
488
 
475
489
    renderdata->glGetError();
476
490
    renderdata->glEnable(GL_TEXTURE_2D);
503
517
 
504
518
    result = renderdata->glGetError();
505
519
    if (result != GL_NO_ERROR) {
 
520
        SDL_free(data);
506
521
        return GLES_SetError("glTexImage2D()", result);
507
522
    }
 
523
    
 
524
    texture->driverdata = data;
508
525
    return 0;
509
526
}
510
527
 
556
573
                    data->format,
557
574
                    data->formattype,
558
575
                    src);
559
 
    if (blob) {
560
 
        SDL_free(blob);
561
 
    }
 
576
    SDL_free(blob);
562
577
 
563
578
    if (renderdata->glGetError() != GL_NO_ERROR)
564
579
    {
602
617
    GLenum status;
603
618
 
604
619
    GLES_ActivateRenderer(renderer);
 
620
    
 
621
    if (!data->GL_OES_framebuffer_object_supported) {
 
622
        return SDL_SetError("Can't enable render target support in this renderer");
 
623
    }
605
624
 
606
625
    if (texture == NULL) {
607
626
        data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, data->window_framebuffer);
843
862
    GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
844
863
    GLfloat minx, miny, maxx, maxy;
845
864
    GLfloat minu, maxu, minv, maxv;
 
865
    GLfloat vertices[8];
 
866
    GLfloat texCoords[8];
846
867
 
847
868
    GLES_ActivateRenderer(renderer);
848
869
 
903
924
        maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
904
925
        maxv *= texturedata->texh;
905
926
 
906
 
        GLfloat vertices[8];
907
 
        GLfloat texCoords[8];
908
 
 
909
927
        vertices[0] = minx;
910
928
        vertices[1] = miny;
911
929
        vertices[2] = maxx;
944
962
    GLfloat minx, miny, maxx, maxy;
945
963
    GLfloat minu, maxu, minv, maxv;
946
964
    GLfloat centerx, centery;
 
965
    GLfloat vertices[8];
 
966
    GLfloat texCoords[8];
 
967
 
947
968
 
948
969
    GLES_ActivateRenderer(renderer);
949
970
 
994
1015
    maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
995
1016
    maxv *= texturedata->texh;
996
1017
 
997
 
    GLfloat vertices[8];
998
 
    GLfloat texCoords[8];
999
 
 
1000
1018
    vertices[0] = minx;
1001
1019
    vertices[1] = miny;
1002
1020
    vertices[2] = maxx;
1096
1114
    if (data->texture) {
1097
1115
        renderdata->glDeleteTextures(1, &data->texture);
1098
1116
    }
1099
 
    if (data->pixels) {
1100
 
        SDL_free(data->pixels);
1101
 
    }
 
1117
    SDL_free(data->pixels);
1102
1118
    SDL_free(data);
1103
1119
    texture->driverdata = NULL;
1104
1120
}