quote:Original post by davepermen i guess mac has 0,0 at left-top, while windows has it at left-bottom
Nope - SDL behaves the same on all platforms. (Otherwise it wouldn''t be very cross-platform, now would it?)
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
quote:Original post by davepermen i guess mac has 0,0 at left-top, while windows has it at left-bottom
Nope - SDL behaves the same on all platforms. (Otherwise it wouldn''t be very cross-platform, now would it?)
sure, but what if sdl defines the origin at a common place, but the mac-os itself has it different? the original tutorial doesn''t state its sdl if i remember correctly. or has it changed recently?
If that''s not the help you''re after then you''re going to have to explain the problem better than what you have. - joanusdmentia
davepermen.net
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia
I''ve used the same web page when making my own ray tracer. As others have said windows takes the top-left pixel to be the origin. With the positive X axis moving right, and the positive Y axis moving down. However, the coordinate system that the raytracer uses has its origin in the center of the picture, and importantly a positive Y axis moving up as other posters have mentioned. (Left or right handedness isn''t an issue here since both have positive Y as up.) To see this take a look at your ray direction code and have a think about where the ray for the central pixel goes:-
currDirection.mX = x - width/2; currDirection.mY = y - height/2;
Substitue width/2, height/2 for the central pixel:-
So we''ve placed this ray in the negative quadrent of the image, below and left of the images origin. Not what we expected. Hence, as you''ve found, the Y axis needs to be reversed between the image coordinates and the screen coordinates:-
currDirection.mX = x - width/2; currDirection.mY = height/2 - y;
Which explains that you do need to reverse the Y axis, but not why the original website does not. Maybe its a bug with his code, or a difference with mac screen coordinates?