Check-in [74c9a7d15a]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixes in glBitmap and friends
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 74c9a7d15a9761ea43039fc715007b4d24242089
User & Date: chw 2014-12-07 08:20:38
Context
2014-12-07
08:21
fixes for Android glshim and threading check-in: 877c4b7b02 user: chw tags: trunk
08:20
fixes in glBitmap and friends check-in: 74c9a7d15a user: chw tags: trunk
08:18
added upstream changes to jni/sdl2tk plus improvements in GLX like interfaces check-in: 01162beffe user: chw tags: trunk
Changes

Changes to jni/glshim/include/GL/gl.h.

64
65
66
67
68
69
70

71


72

73
74
75
76
77
78
79
#  else
#    define GLAPIENTRY __stdcall
#  endif
#elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */
#  define GLAPI extern
#  define GLAPIENTRY __stdcall
#elif defined(__GNUC__)	|| (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))

#  define GLAPI __attribute__((visibility("default")))


#  define GLAPIENTRY

#endif /* WIN32 && !CYGWIN */

#if (defined(__BEOS__) && defined(__POWERPC__)) || defined(__QUICKDRAW__)
#  define PRAGMA_EXPORT_SUPPORTED		1
#endif

/*







>
|
>
>
|
>







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#  else
#    define GLAPIENTRY __stdcall
#  endif
#elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */
#  define GLAPI extern
#  define GLAPIENTRY __stdcall
#elif defined(__GNUC__)	|| (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
#  ifndef GLAPI
#    define GLAPI __attribute__((visibility("default")))
#  endif
#  ifndef GLAPIENTRY
#    define GLAPIENTRY
#  endif
#endif /* WIN32 && !CYGWIN */

#if (defined(__BEOS__) && defined(__POWERPC__)) || defined(__QUICKDRAW__)
#  define PRAGMA_EXPORT_SUPPORTED		1
#endif

/*

Changes to jni/glshim/src/gl/raster.c.

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
..
81
82
83
84
85
86
87
88
89
90
91


92
93
94
95
96
97
98
99
100
101



102
103
104
105
106
107
108
        }
        raster->pixel = 0xFFFFFFFF;
    }
}

void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
    PUSH_IF_COMPILING(glViewport);
    PROXY_GLES(glViewport);
    if (state.raster.buf) {
        render_raster();
    }
    gles_glViewport(x, y, width, height);
    viewport_state_t *viewport = &state.viewport;
    viewport->x = x;
    viewport->y = y;
    viewport->width = width;
    viewport->height = height;
    viewport->nwidth = npot(width);
    viewport->nheight = npot(height);

}

void init_raster() {
    if (!state.viewport.width || !state.viewport.height) {
        glGetIntegerv(GL_VIEWPORT, (GLint *)&state.viewport);
        state.viewport.nwidth = npot(state.viewport.width);
        state.viewport.nheight = npot(state.viewport.height);
    }
    if (! state.raster.buf) {
        state.raster.buf = (GLubyte *)malloc(4 * state.viewport.nwidth * state.viewport.nheight * sizeof(GLubyte));
    }
}

void glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig,
              GLfloat xmove, GLfloat ymove, const GLubyte *bitmap) {
    PROXY_GLES(glBitmap);
    raster_state_t *raster = &state.raster;
................................................................................
        raster->pos.y -= ymove;
        return;
    }
    init_raster();

    const GLubyte *from;
    GLuint *to;
    int x, y;

    // copy to pixel data
    // TODO: strip blank lines and mirror vertically?


    for (y = 0; y < height; y++) {
        to = (GLuint *)raster->buf + (GLuint)(raster->pos.x + ((raster->pos.y - y) * state.viewport.nwidth));
        from = bitmap + (y * 2);
        for (x = 0; x < width; x += 8) {
            if (raster->pos.x + x > state.viewport.width || raster->pos.y - y > state.viewport.height)
                continue;

            GLubyte b = *from++;
            for (int j = 8; j--; ) {
                *to++ = (b & (1 << j)) ? raster->pixel : 0;



            }
        }
    }

    raster->pos.x += xmove;
    raster->pos.y += ymove;
}







<



<







>









|







 







|



>
>


|






|
>
>
>







39
40
41
42
43
44
45

46
47
48

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
..
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
        }
        raster->pixel = 0xFFFFFFFF;
    }
}

void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
    PUSH_IF_COMPILING(glViewport);

    if (state.raster.buf) {
        render_raster();
    }

    viewport_state_t *viewport = &state.viewport;
    viewport->x = x;
    viewport->y = y;
    viewport->width = width;
    viewport->height = height;
    viewport->nwidth = npot(width);
    viewport->nheight = npot(height);
    PROXY_GLES(glViewport);
}

void init_raster() {
    if (!state.viewport.width || !state.viewport.height) {
        glGetIntegerv(GL_VIEWPORT, (GLint *)&state.viewport);
        state.viewport.nwidth = npot(state.viewport.width);
        state.viewport.nheight = npot(state.viewport.height);
    }
    if (! state.raster.buf) {
        state.raster.buf = (GLubyte *)calloc(4, state.viewport.nwidth * state.viewport.nheight * sizeof(GLubyte));
    }
}

void glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig,
              GLfloat xmove, GLfloat ymove, const GLubyte *bitmap) {
    PROXY_GLES(glBitmap);
    raster_state_t *raster = &state.raster;
................................................................................
        raster->pos.y -= ymove;
        return;
    }
    init_raster();

    const GLubyte *from;
    GLuint *to;
    int x, y, lwidth;

    // copy to pixel data
    // TODO: strip blank lines and mirror vertically?
    // assume GL_PACK_ALIGNMENT 4
    lwidth = 4 * ((((width + 7) / 8) + 3) / 4);
    for (y = 0; y < height; y++) {
        to = (GLuint *)raster->buf + (GLuint)(raster->pos.x + ((raster->pos.y - y) * state.viewport.nwidth));
        from = bitmap + y * lwidth;
        for (x = 0; x < width; x += 8) {
            if (raster->pos.x + x > state.viewport.width || raster->pos.y - y > state.viewport.height)
                continue;

            GLubyte b = *from++;
            for (int j = 8; j--; ) {
                if (b & (1 << j)) {
                    *to |= raster->pixel;
                }
                to++;
            }
        }
    }

    raster->pos.x += xmove;
    raster->pos.y += ymove;
}