Advertisement

Problems with using opengl 2D style

Started by January 31, 2004 04:16 AM
6 comments, last by Ruudje 21 years, 1 month ago
Hey all, I am trying to create a 2D engine using opengl, but ran into a problem I cant figure out I have tried 2 different approaches to draw on the screen. Basically I have a buffer (array of bytes) that represent the rgb-data. The problem is that copying those pixels to the screen takes way to long! Either by using drawpixels or by making a texture and applying it to a quad. How can I draw e.g. a surface of 800x600 FAST on screen??? [edited by - Ruudje on January 31, 2004 5:33:53 AM]
I think you will have to load the seperate sprites into the videocards memory, and then draw everything together using OpenGL.
However, what framerate do you get? I used per frame texture loading in one of my programs, and it ran at about 15 fps (not that high, but i was doing a lot of other calculations).
Advertisement
I think what you are looking for is glOrtho(...), which lets you draw everything in 2D with coordiantes on the pixel level.

Check out Nehe''s Font tutorial it shows you how to use orthographic projection.
quote:
Original Post by snisarenko
I think what you are looking for is glOrtho(...), which lets you draw everything in 2D with coordiantes on the pixel level.



The problem is the texture transfer speed, not that it's displayed incorrectly.

[edited by - Tree Penguin on January 31, 2004 7:59:40 AM]
I am using glOrtho, and I got 3 fps (the counter works, has been verified)

Using textures on a quad isnt working for me as they have to be square etc. (and its too slow)

using the 2D functions is too slow as well?? :S

I also wrote a basic 2D DirectDraw "engine" today, but its glitchy. It kindof blinks occasionally, which might be because of the framerate and my refreshrate? the ddraw framerate is limited to 60 fps, but variable (because of the display/cooperative mode) and my refreshrate is 120

But ddraw wouldnt let me do what I wanted either. The reason I tried it with opengl first is because opengl can convert a buffer of bytes into an image. Kindof like programming old vga-games (wich is fast) with modern graphics (24bit)
Are you having problems with this still?

I''ve made a set of classes for handling 2D sprites with opengl. They will handle irregular sizes, rotation, blending fading scaling text etc.

You can see them working on my pong demo at http://www.cls-productions.net

There is even a simple particle effect class in there. If you want the code email me at sharktraiger@hotmail.com and I''ll send it to you.
Advertisement
Hi www.cls-productions.net, I wonder if you could post me the code you use to manage Open GL in 2D.

That would be lovely, I'm playing around with various attempts at 2D effects, and would love to see how others are managing it.

Thanks,


Rob

My email address is:
trinitychaos50@hotmail.com

[edited by - serenity on February 3, 2004 7:27:44 PM]
quote:
Original post by Ruudje
I am using glOrtho, and I got 3 fps (the counter works, has been verified)

Using textures on a quad isnt working for me as they have to be square etc. (and its too slow)

using the 2D functions is too slow as well?? :S




glDrawPixels is going to be slow so you wouldn''t want to use it often. To make an image power of 2 why not just add 0 or whichever color you use for transparency to the rest of the image so that you can then use it as a texture ?
The more applications I write, more I find out how less I know

This topic is closed to new replies.

Advertisement