OpenGL fastest 2D bitmaps drawing

Started by
7 comments, last by Brandon N 19 years, 1 month ago
Hey guys! I want to develop a 2D game with OpenGL. I tried to use DrawPixel() to draw to the front- and backbuffer but it is way too slow. So whats the fastest way please for a simple 2D game to draw a bitmap? I dont want any kind of effects like shadows, lightning, antialising or whatever there exists. All I want to do is drawing a bitmap into one of the buffers. Thats all I need. And I dont want to use SDL! Thank you!!
Advertisement
you need set up the ortho mode, build a quad and texture it.

go to nehe in the articles section there is plenty of examples for many platforms on how to do this.

good luck!
[size="2"]I like the Walrus best.
Put the bitmap in a texture and put the texture on a quad. Render the quad.
This method is also quite slow, especially on laptops. Your best bet is to use DirectDraw. Any version will do. It is fast, and supported on all Windows machines above 3.1 I believe. And it is easy to use than the OpenGL method just described. I uses the blt method that you tried, but DirectDraw makes it fast!!
While it will require a 3D accelerator, I've found glOrtho() and quads to run plenty fast on any system I've worked on. Not to mention that it leaves the door open on the entire 3D pipeline should you ever want to experiment later on.
Oh, maybe it's me.

See StickyBricks to see what I did. Click demos. I blt to the whole screen with 3d models in the same scene. It runs well on PCs, but dirt slow on laptops.
There are several options - the main one is to use textured quads.

Of course using textured quads means you'll be able to use transparency, partial transparency, blending, lighting etc. While these things aren't "free" (as some opengl users claim), they do come at a significantly reduced cost over trying to do them in software.

Plus Directdraw is thoroughly deprecated and can't do most of these things anyway (I believe Microsoft would have you use similar techniques with Direct3d, which IS the modern DirectX graphics API).

There is also an opengl extension for point sprites, which basically have a similar effect to using billboarding but involve throwing less geometry at the card - it's effectively an optimisation.

Mark
What I did with my tile engine, was using ortho mode and render an optimised vertex buffer every frame. This results on high framerates here.

Crafter 2D: the open source 2D game framework

?Github: https://github.com/crafter2d/crafter2d
Twitter: [twitter]crafter_2d[/twitter]

Quote:Original post by rpg_code_master
Oh, maybe it's me.

See StickyBricks to see what I did. Click demos. I blt to the whole screen with 3d models in the same scene. It runs well on PCs, but dirt slow on laptops.
Laptops are PCs. :p

Anyway, there is no blitting with textured quads. Maybe that was your problem; glDrawPixels is slooooow.

This topic is closed to new replies.

Advertisement