flopoloco's picture

Image loading and flipping?

After long experimenting and searching around the internet, I found out that OpenGL needs the texture flipped in order to UVs behave nice.

var bitmap = new Bitmap(Optimus.FileBasePath(file));
var data = bitmap.LockBits(new Rectangle(Point.Empty, bitmap.Size), Imaging.ImageLockMode.ReadOnly,	Imaging.PixelFormat.Format32bppArgb);

Any ideas why this happen?

(I use Assimp.NET and loading a Collada .dae model exported from Blender)


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

System.Drawing.Bitmap uses a coordinate system where the origin (0, 0) lies at the top-left, with +x going right and +y going down.

OpenGL textures use a Cartesian coordinate system, where the origin (0, 0) lies at the bottom-left, with +x going right and +y going up.

There is no right or wrong way, you just need to keep this difference in mind when you are mixing different APIs.