ios - OpenGL ES 3.0 Transform Feedback glDrawArrays with GL_LINE_STRIP output is all zeros -
recently confused opengl es 3.0 transform feedback using gldrawarrays gl_line_strip output zeros,  meanwhile, adapting coordinates of points gl_lines called gldrawarrays , works. what want using transform feedback gpgpu off-screen calculation such image process through gldrawarrays called 1 time parameter gl_line_strip , gl_trangle_fan etc. speed performance , compare benchmarks of these draw modes. code used gl_lines works correctly lists below:
typedef struct {     glfloat x, y; } gpupoint;  - (gpupoint *)generatepointsfromimagesize:(cgsize)imagesize {     pointssize = sizeof(gpupoint) * imagesize.width * imagesize.height;     pointscount = imagesize.width * imagesize.height;     gpupoint *points = calloc(1, pointssize);     gpupoint *currentpointer = points;     (int line = 0; line < imagesize.height; ++line) {         (int col = 0; col < imagesize.width; ++col) {             currentpointer->x = col;             currentpointer->y = line;             ++currentpointer;         }     }     return points; } here use previous code create 1920x1080 points.
pointsforimage = [self generatepointsfromimagesize:     (cgsize){.width = 1920, .height = 1080}]; now call transform feedback these code:
glbegintransformfeedback(gl_points); gldrawarrays(gl_points, 0, pointscount); glendtransformfeedback(); alright, work fine on iphone 6. however want speed replacing gl_points gl_lines, gl_line_strip, gl_triangle_fan or that. when changing gl_lines, works correctly points generated before. changing gl_line_strip, zeros. through glmapbufferrange gl_map_writer, conform points upload gpu successfully. code has been used this:
- (gpupoint *)generatepointsforlinestripsfromimagesize:(cgsize)imagesize {     pointscount = (1920 - 1) * 1080 + (1080 - 1);     pointssize = sizeof(gpupoint) * pointscount;     gpupoint *points = calloc(1, pointssize);     if (!points) {         exit(-1);     }     int finalcreatedlinecount = 0;     gpupoint *currentpointer = points;     (int line = 0; line < imagesize.height; ++line) {         (int col = 0; col < imagesize.width; ++col) {         // row         if (line % 2 == 0) {                 currentpointer->x = col;                 currentpointer->y = line;                 ++currentpointer;         } else {             currentpointer->x = ((int)imagesize.width - 1) - col;             currentpointer->y = line;             ++currentpointer;         }         ++finalcreatedlinecount;         }     }     return points; } i call these lines. the var addr not null zeros.
glbegintransformfeedback(gl_line_strip); gldrawarrays(gl_line_strip, 0, (1920 - 1) * 1080 + (1080 - 1)); glendtransformfeedback(); glfinish(); gluint *addr = glmapbufferrange(gl_transform_feedback_buffer, 0, 1920 * 1080 * sizeof(gluint), gl_map_read_bit); i think points line strip correct , samples of points listed below. (0,    0)
 (1,    0)
 (2,    0)
 // ... lots of points ignored, following line odd line
 (1917,    0)
 (1918,    0)
 (1919,    0)
 (1919,    1)
 (1918,    1)
 (1917,    1)
 // ... lots of points ignored, following odd line line
 (   2,    1)
 (   1,    1)
 (   0,    1)
 (   0,    2)
 (   1,    2)
 (   2,    2)
 // ... lots of points ignored, following last few lines
 (   2, 1077)
 (   1, 1077)
 (   0, 1077)
 (   0, 1078)
 (   1, 1078)
 (   2, 1078)
 // ... lots of points ignored
 (   3, 1079)
 (   2, 1079)
 (   1, 1079)
 (   0, 1079)   
any appreciated.
not sure problem is, why not use gldrawelements , indexed gl_lines calls? it'll remove load of redundant vertices gldrawarrays, , you'll redundancy in index stream fact gl_line_strip doesn't work shouldn't matter much.
Comments
Post a Comment