Jump to content
  • Advertisement
Sign in to follow this  
1stfrog

OpenGL Incredibble slow alpha blending

This topic is 3934 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I am writing an OpenGl program which runs on PC with Intel855 onboard graphics with 32M shared memory. I have function ( based on one from AlegroGl library) which do transparrent blit of bitmap to frame buffer. void blit_screen_masked(BITMAP *src, int s_x, int s_y,int d_x, int d_y,int w, int h, int flip) { void *data; GLfloat sav_zoom_x, sav_zoom_y; GLint sav_row; data = src->line[s_y]+s_x*BYTES_PER_PIXEL(bitmap_color_depth(src)); glGetFloatv(GL_ZOOM_X, &sav_zoom_x); glGetFloatv(GL_ZOOM_Y, &sav_zoom_y); glGetIntegerv(GL_UNPACK_ROW_LENGTH, &sav_row); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glRasterPos2i(d_x,FULLSCREEN_MAX_Y - d_y); glPixelZoom(1.0,-1.0); glPixelStorei(GL_UNPACK_ROW_LENGTH,(src->line[1] - src->line[0])/BYTES_PER_PIXEL(src->vtable->color_depth)); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); //ONLY IN MASKED VERSION glEnable(GL_BLEND); //ONLY IN MASKED VERSION glDrawPixels(w,h,__allegro_gl_get_bitmap_color_format(src,0),__allegro_gl_get_bitmap_type(src,0),data); glDisable(GL_BLEND); //ONLY IN MASKED VERSION glPixelZoom(sav_zoom_x, sav_zoom_y); glPixelStorei(GL_UNPACK_ROW_LENGTH, sav_row); if (flip) allegro_gl_flip(); } My problem is that non-blending version of this routine is 10 times faster than blending one. Fullscreen blitting takes ~18 ms on my system, but fullscreen blending blit takes ~186 ms!!!! Is it possible that pixel blending operation are so slow with this chipset? Maybe I do something wrong... I know that I can do texture from bitmap and then rendering it to frame buffer and it takes less time ( I' ve tried it), but I do a lot of manipulation with bitmaps in my program and must operate on bitmaps, not textures. If anyone could help me, I would be very thanksfull.

Share this post


Link to post
Share on other sites
Advertisement
Well, it's actually very common that glDrawPixels is one of the least optimized functions in a driver.
Usually you may expect this one to be usable for a simple pixel transfer without blending, and that's about it.
Just go with the textures & glTexSubImage2D.
You better off spending some time thinking how to move those bitmap manipulations to the 3D card. [wink]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!