glDrawPixels .... HELP!!!

Trying to blit an image to the screen aas a background… using the following code I see no image. I know that the image is valid because I can texture map it onto a plate. Any ideas?

	gluOrtho2D(left,right,bottom,top);
	glPixelStorei(GL_UNPACK_ALIGNMENT,1);
	glRasterPos3i(0,0,-1);
	glPushAttrib(GL_ENABLE_BIT);
	glDisable(GL_DEPTH_TEST);
	glDisable(GL_LINE_SMOOTH);
	glDisable(GL_BLEND);
	width = m_BkgImage->width();
	height = m_BkgImage->height();
	glDrawPixels(
		width,
		height,
		m_BkgImage->dataFormat(),
		m_BkgImage->dataType(),
		m_BkgImage->imageData()
	);
	glPopAttrib();

Hello pleopard!

If you can use the image as a texturemap then you can use a texturemapped quad as a background.

Osku

Thanks, I have done that. For performance reasons I would prefer to simply blit the image to the screen though. The glDrawPixels() function is supposed to let me do this … guess I am missing some simple little nuance somewhere…

Thanks again,
Paul Leopard

GLubyte *rasterImage;

void makeImage(void)
{

    glRasterPos2i(0, 0);
    glDrawPixels(rh.ras_width, rh.ras_height, GL_RGB, GL_UNSIGNED_BYTE, rasterImage);

=========================
test_back.c: rasterImage[a_number] = red[(GLubyte) c];
test_back.c: rasterImage[a_number] = green[(GLubyte) c];
test_back.c: rasterImage[a_number] = blue[(GLubyte) c];

==========
hope this is of some use.

gav :slight_smile:

Thanks guys… I did find a solution …

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,m_ViewPort->width(),0,m_ViewPort->height(),-1,1);

glPixelZoom(
	float(m_ViewPort->width())/float(m_BkgImage->width()),
	float(m_ViewPort->height())/float(m_BkgImage->height())
);

// Draw the image
glRasterPos2i(0,0);
glDrawPixels(
	m_BkgImage->width(),
	m_BkgImage->height(),
	m_BkgImage->dataFormat(),
	m_BkgImage->dataType(),
	m_BkgImage->imageData()
);

glPopMatrix();

Osku’s suggestion will likely yield better preformace that using glDrawPixels. Texturing a quad allows the graphics card to do all the work and the texture comes from video memory.

glDrawPixels, on the other hand, takes a pointer to the image. Of course, this means that it’s transferring the image from system ram over the AGP bus and down to the graphics card every time it’s called.

Do a little benchmarking, and you’ll see that glDrawPixels is not a good solution. (Quick disclaimer though: if you have extremely limited texture space on the graphics card, and your texture is stored in system ram, then both techniques will be roughly equivelant.)

Thanks for the tip. I have a GeForce w/32Mb of texture ram so that might be a good idea. I will try it both ways and see.

Also, I am experiencing a severe performance problem using glDrawPixels on Windows NT 4.0. On Win98 the glDrawPixels method works incredibly fast but on WinNT4 each blit takes roughly 4 seconds. Your suggestion will probable make this problem moot.

Thanks again,
Paul Leopard