|
Author Topic:   F***ING bitmaps in OpenGL are pissing me off!
TheGecko
New Member
posted April 09, 2000 01:30 AM            
If there is one thing I have to complain about in OpenGL,it's the way it hadles bitmaps! It's REALLY pissing me off! If I want to drop a background image as a bitmap instead of pasting it on a polygon then I should be able to do that with no problems.

Sorry if I seem aggressive.Maybe I'm doing something wrong.

Ok here's the problem.I want to do something very simple here.I have a bitmap file "sea.bmp" which is an 800x600 image. I want to place this as a backdrop to my OpenGL application where I draw fishes and stuff as OpenGL models and render them.
Suppose I already loaded the bitmap. What should I put in my DrawBackground() function to actually render the bitmap to the screen?

void DrawBitmap(void)
{

//<---what goes here!?

}

Please help.

IP:

Klaus Hartmann
Member
posted April 09, 2000 02:53 AM            
Split your 800x600 image into textures with a maximum size of 256x256 pixels (because of Voodoo).
Then use textured polygons to display the background image.

I know that you wanted to hear of a different solution, but there's a problem. Even if OpenGL provided a Blit function (maybe it even does -- I don't know), this wouldn't be the way to go. The reason is, that switching between 2D and 3D hardware accelerated functions can become really slow. This mode switch requires the hardware to flush its internal pipeline, which is not exactly a good thing. So the general rule is: Don't mix 2D with 3D.

IP:

TheGecko
New Member
posted April 09, 2000 01:17 PM            
Well then...if OpenGL can't do something that simple then it's just pure garbage isn't it? Now I know why poeple preferred DirectX instead.

I mean seriously,if DirectX can do it then why can't OpenGL?

IP:

Klaus Hartmann
Member
posted April 10, 2000 12:51 AM            
No, it would be unfair to say that OpenGL is garbage. I used both DirectX, and OpenGL. Even though I prefer DirectX, I cannot say that OpenGL is much worse. I'd say they are about equally good.
True, DirectX offers Blit functions through DirectDraw, but it's still not recommended to mix 2D/3D like this. This really has nothing to do with the API... The problem is the hardware, and it doesn't matter what API you are using... it won't change the way the hardware works.
For example, Microsoft wanted to support alpha-blitting in DirectDraw 7. The plan was to use the 3D hardware to provide this feature. Then, however, they had to drop this idea, because IHVs told them, that this feature means a flush of the hardware's internal pipeline.
In other words: It's perfectly okay to use OpenGL. There are still lots of professionals who prefer OpenGL over Direct3D. It's a matter of taste, and you should use the API you like the most.
If you feel that OpenGL is garbage, then you might want to switch APIs. But I warn you: DirectX isn't perfect either, and there will be times when you say "That's garbage". None of the two APIs will solve all your problems.

IP:

MarkBatten
Member
posted April 10, 2000 08:52 AM            
Take a look at glDrawPixels(). You may have to swizzle the data a bit, but it avoids having to render polygons if you don't want to do that.

IP:

CheshireCat
Member
posted April 10, 2000 01:22 PM            
Regardless of the API (and it is possible in OGL, see glDrawPixels), it's going to be dog slow on a lot of of hardware, since the 2D rendering path won't be optimized (and even if it is, drawing to the frame buffer would require flushing of all of the various hardware buffers before it would execute). It's actually faster to load the bmp into a texture and draw a textured poly.

[This message has been edited by CheshireCat (edited April 10, 2000).]

IP:

Bryan T
Member
posted April 10, 2000 03:41 PM            
There are several reasons to use polygons over blit functions for implementation purposes:

- Cool Effects
- 3D Accelerated
- Automatically scaled
- Simple (heck it's practicly built in)

I have always hated blit functions anyway, they are so specific to the hardware, screensize, color depth, etc. By making a few triangles you eliminate all those headaches and it works cross-platform.

If after all that, you still want to blit stuff, Mark's reference should do it for ya (glDrawPixels).

--Bryan

IP:

MarkBatten
Member
posted April 11, 2000 08:40 AM            
Just to be clear, I agree completely with those above who say that rendering is better than blitting, certainly with GL. You get a lot of bonuses, and it's not hard to do. I mention glDrawPixels because you'd said you didn't want to render in the traditional way.

IP:

mitchw
New Member
posted April 16, 2000 10:25 PM            
You need to draw 2 tris. Create a square texture, goto ortho view (glOrtho) and use 1.0 and 0.75 as your texture coord extents.

IP:

Siggen
New Member
posted April 17, 2000 11:40 AM            
I would just like to add, that even under Direct3D, most games uses textured polygons instead of a blit(). The reason is that a blit() draws right into the frame buffer, which stalls the entire 3D pipe-line, and drawing textured polygons is therefore a lot faster. This is probably also the reason why glDrawPixels() isn't optimized on many current drivers. If you use texture polygons you can also use HW bilinear filtering and other cool stuff

IP: