Skip to main content
gamedev.net
🔒 Locked

glDrawPixels help

Started by fil_gamedev Jun 1, 2003 at 5:30 PM 2 replies 350+ views
Original Post
fil_gamedev
fil_gamedev
what im trying to do is render a bmp file onto the framebuffer with glDrawPixels, (dont want to use textures cuz of size limitations, actualy i heard there is a work around, and would appreciate if anyone gave me a hint, also would that be faster then building display lists for glDrawPixels?) anyhoo the problem is that i want to mix this method with normal 3d rendering, but im not so familiar with opengl workings. Specificaly when i write to the buffer by: glRasterPos2i(x,y); glDrawPixels(m_Singleton->m_images[index].width, m_Singleton->m_images[index].height, m_Singleton->m_images[index].bpp, GL_UNSIGNED_BYTE, m_Singleton->m_images[index].data); i get my 3d scene with no effect shown by the above (ps when i debug this, all the data seems to be there just fine). The obvious thing is that my lack of knowledge of buffers is screwing things up. basicaly this is what i have: // in init function glViewport(0,0,width,height); glViewport takes (x, y, width, height) glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,(GLfloat)width/(GLfloat)height, 1.0f, view); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // the main drawing function glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glPushAttrib(GL_CURRENT_BIT); glMatrixMode(GL_MODELVIEW); glPushMatrix(); Draw3DSGrid(); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopAttrib(); SwapBuffers(sEngine.hDC); where exactly am i supposed to put the call, and how do i combine the two techniques. Thanks in advance for ur help
blizzard999
blizzard999
I found glDrawPixels() very very slow so I never used it again...perphaps now it''s different...?

I suggest you to load the big texture and map a quad on the screen...is not the texture big enough (or you want to prevent HW limitations) ?
Consider that recent video cards support 1024x1024...

If you need small textures split your image is smaller images and ''map'' them separately! (for example 4 images 256x256)
Of course you have to play with texcoordinates but it''s not so difficult...



fil_gamedev
fil_gamedev
that was my first idea which i got working but the limitation of textures sizes is that they have to be multiples of 2. therefore something like 800X600 cant be loaded without distorting it. Im not sure how to work around this...
what i realy want to do is have a 2d engine, and wanted to experiment with what is faster 3d textured quads or direct buffer manipulation.
Brother Bob
Brother Bob
Does your image really have to fit exactly in the texture? Can''t you just fill up the lower left 800x600 part of a 1024x1024 texture and adjust the texture coordinates?

And if you resize your image up to nearest power of two using a nearest filter and then draw it using a nearest filter, you can get away with no distorion at all even though you resized the image. This assumes you draw the texture with a one to one mapping between texels and pixels, and not as a texture on a moving object.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.