Click to See Complete Forum and Search --> : glReadPixels and vectors


gareth19
May 5th, 2004, 03:33 PM
Im trying to use this call like so:

// .h
std::vector<BYTE> m_pix;

// .cpp (onrender)
m_pix.resize( m_nWidth * m_nHeight );
glReadPixels( 0, 0, m_nWidth, m_nHeight, GL_RGB, GL_UNSIGNED_BYTE, reinterpret_cast<LPVOID>( &m_pix ) );


This crashes...memory issue?
How can i use vectors with this call?

TIA

Philip Nicoletti
May 5th, 2004, 05:28 PM
You need to send the address of the first element :


.... &m_pix[0] ..) // &m_pix[0] instead of &m_pix

cvogt61457
May 6th, 2004, 11:18 AM
Can you post the prototype found in the header file for glReadPixels?

wien
May 6th, 2004, 01:44 PM
http://www.mevis.de/~uwe/opengl/glReadPixels.html

wien
May 6th, 2004, 01:48 PM
You should possibly also change the cast to GLvoid* instead of LPVOID. It doesn't matter much, as they're the same thing, but you might as well use the OpenGL types to be on the safe side.