Advertisement

Is it possible to do an SDL_BlitSurface on an OpenGL

Started by December 10, 2004 11:20 PM
18 comments, last by teamonkey 19 years, 9 months ago
Screen defined By SDL? Thanks!!!
Hi.
directly, no.

what you can do is map the surface out as a texture and then render it as a quad.
Check out my homepage. I am working on a library that is just for this.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
Advertisement
Thanks!!
Hi.
Yes.

Look at the SetVideoMode flags

One of them is something like SDL_OPENGLBLIT or something. Then you can BlitSurface on an OpenGL window. (They claim it'd deprecated, but meh)
Quote: Original post by C-Junkie
Yes.

Look at the SetVideoMode flags

One of them is something like GLBLIT or something. Then you can BlitSurface on an OpenGL window.


From what I understand, that flag has been deprecicated.

Quote: SDL_OPENGLBLIT:
Create an OpenGL rendering context, like above, but allow normal blitting operations. The screen (2D) surface may have an alpha channel, and SDL_UpdateRects must be used for updating changes to the screen surface. NOTE: This option is kept for compatibility only, and is not recommended for new code.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
That's one of the flags I use GL_BLIT and SDL_OPENGL

Won't let me do a blitSurface
Hi.
Advertisement
relsoft - The final and correct answer is YES. BUT, you have to do some special steps so it will work. Go to NeHe's Site and download, from the main page on the left, "NeHeGL SDL". In that tutorial it shows how to correctly set up OpenGL blitting with SDL, so you can make a OpenGL screen and blit SDL to it. To actually do the blitting, here's the function that I use:

void SDL_DrawSurface(SDL_Surface* surface, SDL_Surface* dest_surface, int x, int y){	SDL_Rect destrect;	destrect.x = x;	destrect.y = y;	SDL_FillRect(dest_surface, &destrect, SDL_MapRGBA(dest_surface->format,0,0,0,0));	SDL_BlitSurface(surface, NULL, dest_surface, &destrect);	SDL_UpdateRects(dest_surface, 1, &destrect);}


If you need more help just ask. It's tricky at first, but once you get it, it is the neatest thing ever [WINK].

[Edited by - Drew_Benton on December 12, 2004 6:24:30 AM]
out of curiosity.. whats the point? why not just draw a quad? and is SDL under the hood drawing a quad? or is SDL doing some software rendering with it?
FTA, my 2D futuristic action MMORPG
Thanks guys. In case you're wondering why I need ro blit a 2d surface on a an openGL surface. I was making a game in DOS using ASM and QB.

http://rel.betterwebber.com/junk.php?id=23

Space to fire and Arrows to move.

So I had to make my own rasters(including the triangle fillers and the blitters in sofware using ASM), for it to be able to run well on a lowend machine. But after discovering both SL and OpenGL, I wouldn't wan't to pull my hairs trying to do what the hardware can do for me.

I also made a pure sofware render using Tinyptc + ASM + FreeBasic that although it runs faster than my GL/SDL render in software on a 233, GL+SDL beats the crap out of it in a 400 with a decent vid card.

Here are the samples:(remember it's like a week since I started in GL and I can't code everyday due to my work)

GL+SDL
http://rel.betterwebber.com/junk.php?id=35

TinyPTC
http://rel.betterwebber.com/junk.php?id=29

Don't worry, I can also code in C/C++ but I was a beta tester of this new BASIC compiler.

Again Thanks!


Hi.
NP! All I have to say is that game looks sooooo beautiful! *jealous* [lol]. However, I would give the option not to disable vsync, simply b/c I was at over 300fps and it was crazy [WINK]. I'd love to see this game as it progresses!

This topic is closed to new replies.

Advertisement