Jump to content

  • Log In with Google      Sign In   
  • Create Account


Alternative to glReadPixels?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 CommanderXXL   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 August 2001 - 01:00 AM

I have writtem a code which copies the actual screen (res 1024 * 768) to a texture by using glReadPixels() then a call to gluScaleImgage() for resizing the image to a power of 2 then a call to glteximage2d() but this seems to be very slow. Is there another way of creating a texture from a screen with a 4:3 aspect ratio at resolutions other then powers of 2 (800 * 600). i put my code i used for it here. void TEXTURE::CreateFromScreen(void) { GLubyte *SimageData; int P2ScreensizeX,P2ScreensizeY; P2ScreensizeX = 256; P2ScreensizeY = 256; tbpp = 24; glGenTextures(1, &ID); glBindTexture(GL_TEXTURE_2D, ID); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); imageData=(GLubyte *)malloc(Width * Height * 3); SimageData=(GLubyte *)malloc(P2ScreensizeX * P2ScreensizeY * 3); glReadPixels(0,0,Width,Height,GL_RGB,GL_UNSIGNED_BYTE,imageData); gluScaleImage(GL_RGB,Width,Height,GL_UNSIGNED_BYTE,imageData,P2ScreensizeX,P2ScreensizeY,GL_UNSIGNED_BYTE,SimageData); if(imageData!=NULL) free(imageData); glGenTextures(1, &ID); glBindTexture(GL_TEXTURE_2D, ID); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D,0,3,P2ScreensizeX,P2ScreensizeY,0,GL_RGB,GL_UNSIGNED_BYTE,SimageData); if(SimageData!=NULL) free(SimageData); }

Sponsor:

#2 zedzeek   Members   -  Reputation: 528

Like
Likes
Like

Posted 19 August 2001 - 09:25 AM

readpixels shouldnt be that slow but gluscaleimage is perhaps find a quicker algorithm that sacrifices quality for speed

>>I have writtem a code which copies the actual screen (res 1024 * 768) to a texture by using glReadPixels()<<

to copy a part from a screen (or all of it) to a texture use glCopyTexSubImage2D(..) fastest method out there




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS