glBitmap vs glDrawPixels

Started by
5 comments, last by HappySnapper 22 years, 9 months ago
after a long time looking around for something that should be obviously covered by game developers, I''ve stumbled across two related functions. If you were to draw somewhere on the screen and indication of your health or ammo or some 2-dimensional related thing while displaying 3-dimensional objects, how would you do this? I looked at glDrawPixels but the 2 dimensional data suffers shrinking depending on the current rastor depth(however a depth of zero shows nothing). On the other side, glBitmap draws pixel to pixel on the screen without suffering shrinking by any depth setting. The only problem is that glBitmap doesn''t offer the format and type parameters that glDrawPixel does. I don''t understand why this topic isn''t covered in NeHe lessons for games(his bitmaps with colour blending for textures, lesson 9 i think, comes close). Stretching a bitmap with arbitrary dimensions to suit a texture for a square polygon is an ugly and painful way to this.... but trying to figure this out is worse I suppose. Does anybody know how to control the pixel pipeline with OpenGL?
Advertisement
Why don''t you just use a textured quad? It is so much easier than worrying about glDrawPixels and glBitmap.

[Resist Windows XP''s Invasive Production Activation Technology!]
but what about for bitmaps larger than 256x256. for example, I''m trying to port my 3d modeller to openGL and my GUI relies on 2-dimensional windows that have all the tools in them. They need to be resizeable and to be pixel perfect visually so buttons can be clicked etc.
A lot of video cards support textures larger than 256x256 now. My (old) TNT2 supports up to 4096x4096. The GUI ruitines that my engine uses are "pixel perfect," and they use lots of textured quads (9+ per complex control, only one or two on simple ones).

[Resist Windows XP''s Invasive Production Activation Technology!]
I read some of your opinions on Windows XP. I have no idea what it is cause I don''t think we have it for end user sale here in Australia. I believe what you say about "renting" the software. The future of Microsoft operating systems is very shaky if it''s come down to compulsory online registration. I think I''ll stick to Windows 98. BTW, could you please explain to me how you managed to get it so your textured quads were at just the right depth and stretched in a way that you can do pixel perfect checking for things like buttons and other GUI components?.... it''s been a hard transition from Glide to openGL..... just as everything was perfect.... 3DFX had to die.
I pretty much do this (once, at startup), and then I can use vertices just like pixels:
    glViewport(0,0,Width,Height);  glMatrixMode(GL_PROJECTION);  glLoadIdentity();  glOrtho(0.0f,Width,Height,0.0f,-1.0f,1.0f);  glMatrixMode(GL_MODELVIEW);  glLoadIdentity();  

Width and Height are the size of your Window/Screen.

[Resist Windows XP''s Invasive Production Activation Technology!]
Yeah you can switch between normall 3D and ortho or whatever... so that it goes back to the oh-so-loveable (0,0) is the top left corner of the screen, and (max_x, max_y) is exactly the same as width/height of the resolution :-)

The last nehe tutorial (in the OpenGL section) where he goes through the creation of an entire game has it in it... ya know, the one where you shoot stuff flying across the screen...

This topic is closed to new replies.

Advertisement