Skip to main content
gamedev.net
🔒 Locked

method performance advice please...

Started by Damocles 2 replies 300+ views
Original Post
Damocles
Damocles
I came across a bug in my current 2D engine regarding scaling to different resolutions. Although the bug isn''t serious it did get me wondering about other ways to handle scaling. I see two main options: 1) Pass all translation/rendering calls through wrapper functions that multiply the coordinates according to the base supported screen resolution. 2) Render to a texture of a given size and and draw that texture onto the screen using the gpu to scale it up/down as needed. I''m wondering which would likely provide the fastest results. Method one requires an average of 2 floating point calculations per vertex. When you consider the thousands of vertices that can make up a complex display then it could get quite processor intensive. Method two requires no such calculations on the cpu, but does require a complete redraw of the screen every frame on top of normal drawing operations. Also, some older cards don''t have very good support for rendering to textures. At the moment I''m using method 1, but would you guys recommend 2 as the better option or not?
------------------------------------------[New Delta Games] | [Sliders]
_the_phantom_
_the_phantom_
if you are just doing everything in 2d and dont require an overlay then you could probably get away with option 2, just render to a setsize p-buffer and then use that as a texture and bang it to the screen
lonesock
lonesock
since this on an OpenGL forum I assume you are using OGL? If so you can just glScale your way to happiness (even in 2D, except for DrawPixel stuff). That is already in the pipeline so it doesn''t cost you anything.

Render to texture is very expensive in OpenGL on my hardware.


lonesock

Piranha are people too.
Damocles
Damocles
The glSclae idea is a good one, but alas the same bug appears using glScale as when doing the screen position transformations manually. The problem is that I have an interface made up of several parts that need to line up to each other perfectly. In the base resolution (800x600) they do line up perfectly because there are no additional transformations to the screen coords. However, as soon as they are scaled down to fit 640x480 small gaps start to appear between the interface sections. This is probably due to the floating point precision of OGL''s drawing routines, so there are tiny sections less than 1.0f in size that are being drawn or not drawn to because of this precision.

Anyone have a good way to combat this? I don''t want to go around adding a few pixels here and there because then the 800x600 version won''t line up correctly
------------------------------------------[New Delta Games] | [Sliders]

Topic Locked

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

Sign in to reply to this topic.