
Loading Textures
Posted Tuesday, 5 February, 2008 - 11:44 by Datriot inI'm pretty new to OpenGL, as I've been a DirectX use for the most part. I must say that texture loading and usage is quite different in OpenGL and I'm not sure how to go about loading and displaying one ( preferably on a quad ).
There's some tutorials out there, but one catered for OpenTK would be helpful so help would be appreciated. :)


Comments
Re: Loading Textures
A good place to start would be getting the data off of the hard drive and into memory. You can use the System.Drawing name space for this purpose:
Re: Loading Textures
Thanks Stevo, that's exactly what I needed, I got the texture to load, now I can just slap it onto a quad. I'll have to experiment a bit more and find out all the different settings and stuff you can have.
Thanks again!
Re: Loading Textures
Welcome Datriot :)
The OpenTK distribution also includes a couple of examples you can take a look at. They reside in the folder Source/Examples/Tutorial
Re: Loading Textures
Yea, experimenting will help you find out what is possible. If you don't need mipmaps, you can alternatively load the texture using "GL.TexImage2D(/*..params...*/);" and replace "TextureMinFilter.LinearMipmapLinear" with just "TextureMinFilter.Linear".
Re: Loading Textures
Ah, didn't notice the examples in the folder, sorry about that.
Thanks for all the help guys, it's going pretty well. :)
Re: Loading Textures
No problem, it's a bit hidden.
I should probably point at http://www.glprogramming.com/red/ too, which is a quality book to get started with OpenGL.
Re: Loading Textures
A couple of observations:
UnlockBitsmethod, to free the resources used byLockBits.Re: Loading Textures
Thanks Fiddler, I'll update it here and in my own code.
Re: Loading Textures
Thanks guys, I've been going over that tutorial that Inertia posted and I came across the glReadPixels() and glDrawPixels(). Are they are faster and more effective way of using image data to create a 2D game?
Re: Loading Textures
Actually, no, they are the slowest and least efficient way to do 2D graphics (unless you are rendering video frames, that is) :)
The way to go is to load everything into textures/texture sheets with glTex* and glSubTex* functions and apply the textures on quads. Same result, just way faster.