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).N64vSNES wrote: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.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?
OpenGL Texture to SDL_Surface
Moderator: Coders of Rage
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: OpenGL Texture to SDL_Surface
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
Re: OpenGL Texture to SDL_Surface
OK I think we're on the same page nowdandymcgee wrote: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).N64vSNES wrote: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.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?
-
- Chaos Rift Regular
- Posts: 198
- Joined: Thu Mar 26, 2009 8:42 pm
- Current Project: My Engine
- Programming Language of Choice: C++
Re: OpenGL Texture to SDL_Surface
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?
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?
My first game: http://donsvoice.com/randomdever/Duck%2 ... 01.0.0.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
-
- Chaos Rift Regular
- Posts: 198
- Joined: Thu Mar 26, 2009 8:42 pm
- Current Project: My Engine
- Programming Language of Choice: C++
Re: OpenGL Texture to SDL_Surface
I still need someone to help me fix the texture ID problem because it's a HUGE speed bump.
My first game: http://donsvoice.com/randomdever/Duck%2 ... 01.0.0.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
-
- Respected Programmer
- Posts: 387
- Joined: Fri Dec 19, 2008 3:33 pm
- Location: Dallas
- Contact:
Re: OpenGL Texture to SDL_Surface
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.
It would be difficult to say why the load fails without code, there's a couple reasons it would.
- Zer0XoL
- ES Beta Backer
- Posts: 54
- Joined: Fri Apr 24, 2009 1:18 pm
- Current Project: Zelda untitled multiplayer game
- Favorite Gaming Platforms: PC, GBA, N64
- Programming Language of Choice: C++, Lua
- Location: Sweden
- Contact:
Re: OpenGL Texture to SDL_Surface
i found a function here that works awesomely
in "krumm"s post:
http://www.gamedev.net/community/forums ... _id=184477
might be of interest
in "krumm"s post:
http://www.gamedev.net/community/forums ... _id=184477
might be of interest
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: OpenGL Texture to SDL_Surface
that's the other way aroundZer0XoL wrote:i found a function here that works awesomely
in "krumm"s post:
http://www.gamedev.net/community/forums ... _id=184477
might be of interest
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
- Zer0XoL
- ES Beta Backer
- Posts: 54
- Joined: Fri Apr 24, 2009 1:18 pm
- Current Project: Zelda untitled multiplayer game
- Favorite Gaming Platforms: PC, GBA, N64
- Programming Language of Choice: C++, Lua
- Location: Sweden
- Contact:
Re: OpenGL Texture to SDL_Surface
oh :P, well i hope someone of interest sees itGinto8 wrote:that's the other way aroundZer0XoL wrote:i found a function here that works awesomely
in "krumm"s post:
http://www.gamedev.net/community/forums ... _id=184477
might be of interest
-
- Chaos Rift Regular
- Posts: 198
- Joined: Thu Mar 26, 2009 8:42 pm
- Current Project: My Engine
- Programming Language of Choice: C++
Re: OpenGL Texture to SDL_Surface
Here's my draw function:
The texture will not draw on the quad.
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 );
My first game: http://donsvoice.com/randomdever/Duck%2 ... 01.0.0.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
-
- Respected Programmer
- Posts: 387
- Joined: Fri Dec 19, 2008 3:33 pm
- Location: Dallas
- Contact:
Re: OpenGL Texture to SDL_Surface
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.
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.