Quote Originally Posted by PJP Dev
For PJPlib's graphics core I need to be able to get various data from the surfaces. But PSDL_Surface can't give me stuff like width, height and format. I need to use TSDL_Surface instead, but then I can't load images into it because the loading routines of JEDI-SDL return pointers.
After you've called a loading routine and assuming that the image has been loaded correctly, you can get the width of the surface with MySDL_Surface^.w and the height with MySDL_Surface^.h. (var MySDL_Surface: PSDL_Surface should be declared somewhere in your code.) As far as I know w and h are read-only, so don't try to change the values.

Quote Originally Posted by PJP Dev
For PJPlib I've decided to use OpenGL for graphics rendering, so I need to be able to convert the PSDL_Surface data to OpenGL textures.
Basically you just need to write your own texture loader or use an existing one.

For example to convert a SDL_Surface into a texture to be used with OpenGL, you can use this little function (it also scales the surfaces that are not power of 2):

[pascal]
function CreateTexture(SDL_Surface: PSDL_Surface): Integer;
var Texture: TGLuInt;
Begin
Result := -1;
if Assigned(SDL_Surface) then
begin
glGenTextures(1, @Texture);
glBindTexture(GL_TEXTURE_2D, Texture);
if SDL_Surface.format.BytesPerPixel > 3 then glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SDL_Surface^.w, SDL_Surface^.h,0, GL_RGBA, GL_UNSIGNED_BYTE, SDL_Surface^.pixels)
else glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, SDL_Surface^.w, SDL_Surface^.h,0, GL_RGB, GL_UNSIGNED_BYTE, SDL_Surface^.pixels);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if SDL_Surface.format.BytesPerPixel > 3 then gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, SDL_Surface^.w, SDL_Surface^.h, GL_RGBA, GL_UNSIGNED_BYTE, SDL_Surface^.pixels)
else gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, SDL_Surface^.w, SDL_Surface^.h, GL_RGB, GL_UNSIGNED_BYTE, SDL_Surface^.pixels);
SDL_FreeSurface(SDL_Surface);
Result := Texture;
end;
End;

...

var
MyTexture: GLuInt;
MySDL_Surface: PSDL_Surface;

begin
// SDL init and OpenGL init

glEnable(GL_TEXTURE_2D);

MySDL_Surface := IMG_Load(...);
MyTexture := CreateTexture(MySDL_Surface);

// Game Loop
while ... do
begin
glBindTexture(GL_TEXTURE_2D, Texture);
// Draw quad here

end;

end.
[/pascal]
Alternatively, you can the easySDL texture loader from DelphiGL:
http://svn.delphigl.com/websvn/filed...es.pas&rev=174