Re: [Plib-users] Wanted--bitmap
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2001-04-22 15:56:29
|
Marlin Mixon wrote: > > Working with viewer.cxx--great program BTW. Trying to figure out how it > works. I was trying to figure out where it generated the bitmap, when it > dawned on me: duh, it's handled by the video card. So, ssgLoadAndCull() + > GLUT basically sends the handle of the 3-d object to the card and the card > renders the image right? Well, there's a *bit* more to it than that - there are 30,000 lines of code between "ssgCullAndDraw" and the graphics card(!) - but essentially, yes. > Question: is there a way to get a handle to a bitmap of, say, frame 7? No. You can read the contents of the frame buffer do to a 'screen dump' if that's what you need - but if you were thinking of doing some direct writing to the screen by simply addressing it as an array - forget it. 3D chipsets are very posessive when it comes to the frame buffer and *ALL* rendering must go via OpenGL (which is what PLIB uses of course). "bitmap" is the wrong term BTW since it implies a one bit-per-pixel image. So, if you want to add a screen dump feature, you could use something like this: void do_screen_grab ( int width, int height ) { unsigned char pixels [ width * height * 3 ] ; glReadPixels ( 0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels ) ; FILE *fd = fopen ( "tmp.ppm", "wa" ) ; assert ( fd != NULL ) ; fprintf ( fd, "P3\n# Screen Dump\n%d %d\n255\n", width, height ) ; for ( int i = height-1 ; i >= 0 ; i-- ) for ( int j = 0 ; j < width*3 ; j++ ) { fprintf ( fd, "%d ", pixels[i*width*3+j] ) ; if ( (j+1)%4 == 0 ) fprintf ( fd, "\n" ) ; } fclose ( fd ) ; } ...this writes a file in "ppm" format - which is probably the easiest format to write out. glReadPixels does the job of transferring the screen image into main memory. > One reason why I'm enthusiastic about viewer.cxx is I've got some great > aircraft models that I downloaded from www.flightsim.com . One in > particular is outstanding: a Kawasaki Ki-61 Hien. File: st-hien2.zip. The > airplane is generally similar to a Messershmidt Bf-109, however the paint > scheme is particularly colorful with some mean looking spotty camo. The > original author, Shigeru Tanaka of Kobe Japan does really nice work. I > emailed him a few years ago and he said that he was modeling plastic models, > but most of his collection was destroyed during the Kobe earthquake. More > recently he's been shifting his energies to virtual modelling that can be > shared over the internet. Anyone who's interested in a copy, just send me > an email and I'll be happy to pass it on. I believe Wolfram Kuss is collecting aircraft models for the FlightGear list - if he doesn't already have this one, I'm *sure* he'd be interested. (He's a regular on this list BTW). -- Steve Baker HomeEmail: <sjb...@ai...> WorkEmail: <sj...@li...> HomePage : http://web2.airmail.net/sjbaker1 Projects : http://plib.sourceforge.net http://tuxaqfh.sourceforge.net http://tuxkart.sourceforge.net http://prettypoly.sourceforge.net http://freeglut.sourceforge.net |