Jump to content
  • Advertisement
Sign in to follow this  
Huzaifa Gain

OpenGL how save screen shots

This topic is 4853 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 trying to save screen shots of the opengl window.i am using C# and CsGL
 
variable:
public long width,i,j;
		 public long bitsize; 
		 public int[] viewport= new int[4];

public uint []  pixel= new uint[115200];
Code 
GL.glGetIntegerv(GL.GL_VIEWPORT, viewport);
				 width=this.viewport[2]*3;
				 width=(this.width + 3) & ~3;
				 bitsize=width*viewport[3];
				  GL.glPixelStorei(GL.GL_PACK_ALIGNMENT, 4); /* Force 4-byte alignment */
				 GL.glPixelStorei(GL.GL_PACK_ROW_LENGTH, 0);
				 GL.glPixelStorei(GL.GL_PACK_SKIP_ROWS, 0);
				 GL.glPixelStorei(GL.GL_PACK_SKIP_PIXELS, 0);
        		 GL.glReadBuffer(CsGL.OpenGL.GL.GL_BACK);
				 GL.glReadPixels(0,0,viewport[2],viewport[3],GL.GL_RGB,GL.GL_UNSIGNED_BYTE,pixel);

NOW THE PROBLEM IS NOTHING IS GETTING IS SAVED IN PIXEL VARIABLE EXCEPT OF ZERO PLEASE IDENTIFY THE ERROR [Edited by - phantom on September 1, 2005 5:23:29 PM]

Share this post


Link to post
Share on other sites
Advertisement
I dont like this line

glPixelStorei(GL_PACK_ROW_LENGTH, 0);

You should pass the actual length of your row (width)

I dont like this line too

glPixelStorei(GL_PACK_ALIGNMENT, 4);

if you are using RGB/BYTE every pixel is 8*3 = 24 bit so I would use 1 or 3.

PS: have you wrapped the entire API?

Share this post


Link to post
Share on other sites
Using the Tao Framework might be a better idea then using CSGL. Tao.OpenGl uses P/Invoke to call the OpenGL functions directly as opposed to reinventing the wheel. I made up some compilations of some of the libraries they provide and uploaded them to my server here. Just link to Tao.OpenGl.dll and you'll be good to go. The Tao Framework is also updated more often [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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!