Help with ortho projection!

Started by
5 comments, last by freddoh 22 years, 1 month ago
Hi, I''m using under directX 8 an orthogonal projection to display a let''s say 200x200 bitmap into a 200x200 window and it works fine. Now if I change the size of my window to 400x200 the bitmap get twice larger to fit all the window. How can I avoid that? I''d like my bitmap to always be the same size regardless of the window''s size, Thanks, fred.
Advertisement
send us some code snips, and we''ll see what the problem is... =)

During projection, you''re probably using the window size as a basis of scale instea of the bitmap.

Bound to be simple...

-Spiral
-- Give me a hard copy right there ---
solution 1: call Present() with the correct rectangle for the window. if you pass NULL for it, d3d8 will take the whole window-client-area.

solution 2: reset the device and re-create everything when window-size changes.

d3d will always use a framebuffer the size you passed with the last create-device or reset call - it doesnt change "dynamically" when resizing the window.

bye,

--- foobar
We push more polygons before breakfast than most people do in a day
--- foobarWe push more polygons before breakfast than most people do in a day
Did you change your orthogonal projection when you changed the window size? Your orthogonal projection is going to have a width and height, and these will be mapped to your window width and height respectively.

So if your orthogonal has a width of 200, and a height of 200, and you display your bitmap it works fine... but then when you make your window twice as wide that orthogonal width of 200 now gets mapped to a window width of 400 pixels. Result being your bitmap is going to double in size. To keep it the size you want it you''ld have to change your orthogonal projection to have a width and height matching the new window (in this case width of 400 and height of 200).


Thanks guys for you replies, I''ve checked what you said but for now my problem is still there:

SpiralGuru3d: sorry I can''t send code the lines are in the middle of hundred of others and not all at the same place (the miracle of object oriented!)

foobar: I always need to render the whole client area (other things have to be displayed) and my bitmap is not always at the same position within the window. I''m afraid I can''t use any RECT into Present() to help me.

Sorrow: my window size doesn''t change dynamically, it''s fixed at startup, but can be of any size. However the bitmap size is always constant. So yes the orthogonal projection is based on the bitmap dimensions and not the window size.

I''ve checked my code and in fact the only places where I use the window size instead of the bitmap size are:
- when creating the device for the backbuffer sizes but I guess it''s normal since the backbuffers only represent the display isn''t it? Well I''ve tried anyway to change their size to the bitmap size but it didn''t change anything.
- the rendering is made into a window so is somewhere related to an HWND and it related size, maybe directX is using that internally to do I don''t know what mapping.

So I still have my scene distorted by the window size, even though the ortho projection is using the bitmap size as parameters.

Would anyone see what the problem is?

thanks,

Fred.

if you use the same projection everytime, but a bigger viewport (window-size), then clearly your image will stretch.

if you want 1:1 vertex-to-pixel mapping, you have to setup your projection/view matrices from then viewport (window) size.

everything should work fine then.

you say you use 200x200 window -> fine.
and 400x200 window -> same image stretched to 400x200 := bad.

so you need to change your projection OR your coordinates to get another image in your bigger window, and not just the one you had before stretched.

i hope i could make clear what i mean - i find no better words to describe it...

if you havent got me, post again...

bye


--- foobar
We push more polygons before breakfast than most people do in a day
--- foobarWe push more polygons before breakfast than most people do in a day
it works! That was the problem, I was using the bitmap size in my ortho projection instead of the window size.

Thanks a lot!

Fred.

This topic is closed to new replies.

Advertisement