OpenGL Textures lazarus / 70-OpenGL ---------------------------------------------------------------------- SymbolicFrank · 2015-09-05 20:47 Can anyone tell me how I can load an image, like a jpeg, and make it into a texture that I can pass to glBindTexture? I tried a lot of things, like the Lazarus OpenGL example, that tells to use Vampyre for it, which doesn't compile. Like the NeHe Texture.pas unit. Etc. Everything else works. The shaders have the correct texture coordinates, just not the textures that go with them. I use the TOpenGLControl, the latest dglOpenGL.pas, TBRGABitmap for the 2D stuff, and even glslangValidator to check the shaders. ---------------------------------------------------------------------- derek.john.evans · 2015-09-05 20:59 I use a TPicture to load a picture, and then use this code on the TPicture.Bitmap. Code: [Select]  glGenTextures(1, @FTexture);   glBindTexture(GL_TEXTURE_2D, FTexture);   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);   gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, ABitmap.Width, ABitmap.Height,     lglGetPixelFormat(ABitmap.PixelFormat), GL_UNSIGNED_BYTE, ABitmap.RawImage.Data);    lglGetPixelFormat is this: Code: [Select]function lglGetPixelFormat(const APixelFormat: TPixelFormat): Integer; begin   case APixelFormat of     pf24bit: begin       Result := GL_BGR;     end;     pf32bit: begin       Result := GL_BGRA;     end;   end; end; ---------------------------------------------------------------------- User137 · 2015-09-05 22:37 gluBuild2DMipmaps() is not recommended, unless you are dealing with large 3D-world. Instead glTexImage2D() Code: [Select]glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ABitmap.Width, ABitmap.Height, 0,     lglGetPixelFormat(ABitmap.PixelFormat), GL_UNSIGNED_BYTE, ABitmap.RawImage.Data); ---------------------------------------------------------------------- SymbolicFrank · 2015-09-07 19:34 Thanks, it works. Well, I have 4 of them, which are upside-down, but I can fix that.