Page 2 of 2
Re: OpenGL Texture to SDL_Surface
Posted: Tue Dec 07, 2010 10:40 pm
by dandymcgee
N64vSNES wrote:
dandymcgee wrote:
If it's loaded in as an OpenGL tex where do you expect to magically find all of that information to construct an SDL_Surface?
I have no idea what your even talking about here, what I meant to say was you would be getting rid of information that can be usefull such as the dimensions of the image you've loaded and its color dept.
I believe he was implying he never had access to an SDL_Surface in the first place. If he does then there shouldn't have ever been any problem storing it somewhere (other than the extra memory).
Re: OpenGL Texture to SDL_Surface
Posted: Wed Dec 08, 2010 2:03 pm
by N64vSNES
dandymcgee wrote:N64vSNES wrote:
dandymcgee wrote:
If it's loaded in as an OpenGL tex where do you expect to magically find all of that information to construct an SDL_Surface?
I have no idea what your even talking about here, what I meant to say was you would be getting rid of information that can be usefull such as the dimensions of the image you've loaded and its color dept.
I believe he was implying he never had access to an SDL_Surface in the first place. If he does then there shouldn't have ever been any problem storing it somewhere (other than the extra memory).
OK I think we're on the same page now
Re: OpenGL Texture to SDL_Surface
Posted: Fri Dec 10, 2010 1:23 pm
by RandomDever
Alright first of all let me say the problem is solved I'm just going to include an SDL_Surface in my texture struct.
As for the mentioning of using SDL and OpenGL rendering at the same time, that was not my intention at all.
I just wanted to be able to modify the texture like applying a clip ( which is easier in SDL ).
And BTW I use SDL_image to load the textures so all I have to do is copy the SDL_Surface pointer.
However even though the problem which was listed in this topic is still valid and I would like to have a conversion rather than having an SDL_Surface in every texture there is a new problem.
OpenGL is returning 0 as the texture ID for a 128 by 128 .png and is refusing to draw it.
Does anyone have any idea why?
Re: OpenGL Texture to SDL_Surface
Posted: Sun Dec 12, 2010 7:27 am
by RandomDever
I still need someone to help me fix the texture ID problem because it's a HUGE speed bump.
Re: OpenGL Texture to SDL_Surface
Posted: Sun Dec 12, 2010 9:42 am
by qpHalcy0n
You should contact me on that. I posted a solution for ya. OpenGL will facilitate for you all of the information you need to retrieve the texture, load it into an SDL_Surface or what have you.
It would be difficult to say why the load fails without code, there's a couple reasons it would.
Re: OpenGL Texture to SDL_Surface
Posted: Mon Dec 13, 2010 1:12 pm
by Zer0XoL
i found a function here that works awesomely
in "krumm"s post:
http://www.gamedev.net/community/forums ... _id=184477
might be of interest
Re: OpenGL Texture to SDL_Surface
Posted: Mon Dec 13, 2010 1:24 pm
by Ginto8
that's the other way around
Re: OpenGL Texture to SDL_Surface
Posted: Mon Dec 13, 2010 2:32 pm
by Zer0XoL
Ginto8 wrote:
that's the other way around
oh :P, well i hope someone of interest sees it
Re: OpenGL Texture to SDL_Surface
Posted: Tue Dec 14, 2010 8:47 pm
by RandomDever
Here's my draw function:
Code: Select all
glEnable( GL_TEXTURE_2D );
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glTranslatef( x + ( w / 2 ), y + ( h / 2 ), 0 );
glColor4f( 1, 1, 1, alpha );
glScalef( scale, scale, scale );
glRotatef( rotation, 0, 0, 1.0 );
glBindTexture( GL_TEXTURE_2D, id );
glBegin( GL_QUADS );
glTexCoord2i( 0, 0 );
glVertex3f( -w / 2, -h / 2, 0 );
glTexCoord2i( 1, 0 );
glVertex3f( w / 2, -h / 2, 0 );
glTexCoord2i( 1, 1 );
glVertex3f( w / 2, h / 2, 0 );
glTexCoord2i( 0, 1 );
glVertex3f( -w / 2, h / 2, 0 );
glEnd();
glDisable( GL_TEXTURE_2D );
glDisable( GL_BLEND );
The texture will not draw on the quad.
Re: OpenGL Texture to SDL_Surface
Posted: Tue Dec 14, 2010 10:58 pm
by qpHalcy0n
If indeed your handle is zero, then you have not generated a texture handle or the img load (glTexImagexxxx) was passed an invalid parameter. This will result in a failure to apply the texture.
It's also possible that your blend mode does not agree with your pixel format. You need to have a valid format with some form of packed alpha in that.