Image Rotation by using Opengl ES -
i'm working on opengl es 2.0 using omap3530 development board on windows ce 7.
my task load 24-bit image file & rotate angle in z-axis & export image file(buffer).
for task i've created fbo off-screen rendering & loaded image file texture using glteximage2d() & i've applied texture quad & rotate quad using pvrtmat4::rotationz() api & read-back using readpixels() api. since single frame process made 1 loop.
here problems i'm facing now. 1) api's taking distinct processing time on every run.ie when run application different processing time api's.
2) gldrawarrays() taking time (~50 ms - 80 ms)
3) glreadpixels() taking time ~95 ms image(800x600)
4) loading 32-bit image faster 24-bit image conversion needed.
i'd ask if facing/solved similar problem kindly suggest me any
here code snippet of application.
[code] [i] void bindtexture(){ glgentextures(1, &m_uitexture); glbindtexture(gl_texture_2d, m_uitexture); glteximage2d(gl_texture_2d, 0, gl_rgba, imagewidth, imageheight, 0, gl_rgba, gl_unsigned_byte, ptexdata); gltexparameterf(gl_texture_2d, gl_texture_min_filter,gl_linear ); gltexparameterf(gl_texture_2d, gl_texture_mag_filter, gl_linear ); } int winapi winmain(hinstance hinstance, hinstance hprevinstance, tchar *lpcmdline, int ncmdshow) { // fragment , vertex shaders code char* pszfragshader = "same in rendertotexture sample; char* pszvertshader = "same in rendertotexture sample; createwindow(imagewidth, imageheight);//for i've referred ogles2hellotriangle_windows.cpp example loadimagebuffers(); bindtexture(); generate& bindframe,render buffer(); glframebuffertexture2d(gl_framebuffer, gl_color_attachment0, gl_texture_2d, m_auifbo, 0); glrenderbufferstorage(gl_renderbuffer, gl_depth_component16, imagewidth, imageheight); glframebufferrenderbuffer(gl_framebuffer, gl_depth_attachment, gl_renderbuffer, m_auidepthbuffer); bindtexture(); glfloat angle = 0.02f; glfloat afvertices[] = {vertices draw quad}; glgenbuffers(1, &ui32vbo); loadvbo's();//aps's load vbo's refer // draws triangle 1 frames while(g_bdemodone==false) { glbindframebuffer(gl_framebuffer, m_auifbo); glclear(gl_color_buffer_bit|gl_depth_buffer_bit); pvrtmat4 mrot,mtrans, mmvp; mtrans = pvrtmat4::translation(0,0,0); mrot = pvrtmat4::rotationz(angle); glbindbuffer(gl_array_buffer, ui32vbo); gldisable(gl_cull_face); int i32location = glgetuniformlocation(uiprogramobject, "mypmvmatrix"); mmvp = mtrans * mrot ; gluniformmatrix4fv(i32location, 1, gl_false, mmvp.ptr()); // pass vertex data glenablevertexattribarray(vertex_array); glvertexattribpointer(vertex_array, 3, gl_float, gl_false, m_ui32vertexstride, 0); // pass texture coordinates data glenablevertexattribarray(texcoord_array); glvertexattribpointer(texcoord_array, 2, gl_float, gl_false, m_ui32vertexstride, (void*) (3 * sizeof(glfloat))); gldrawarrays(gl_triangle_strip, 0, 4);// glreadpixels(0,0,imagewidth ,imageheight,gl_rgba,gl_unsigned_byte,pouttexdata) ; glbindbuffer(gl_array_buffer, 0); glbindframebuffer(gl_framebuffer, 0); eglswapbuffers(egldisplay, eglsurface); } deinitall();[/i][/code]
the powervr architecture can not render single frame , allow arm read quickly. not designed work way fast - deferred rendering tile-based architecture. execution times seeing expected , using fbo not going make faster either. also, beware opengl es drivers on omap windows ce poor quality. consider lucky if work @ all.
a better design display opengl es rendering directly dss , avoid using glreadpixels() , fbo completely.
Comments
Post a Comment