I had a look in the FreeFrame sample codes…
Background of the example, it loads an avi-file and shows the video clip with two effect filters (plug-in 1/2). I can see some OpenGL stuff, but I’m zero in OpenGL I’m looking for something where I can make its output to SDL_Surface. Then I can use it in my SDL program.
Below is the piece of codes for looping the frames. I also attached the (main) file and include-files. Here is also the link for FreeFrame functions.
Thanks
Phuoc
http://freeframe.svn.sourceforge.net/viewvc/freeframe/trunk/docs/specification.html
while (keepRunning)
{
if (g_hwnd!=NULL && g_glrc!=NULL)
{
//get the window's display context
HDC hdc = GetDC(g_hwnd);
//activate gl rendering to the window
wglMakeCurrent(hdc, g_glrc);
//whats the current time on the timer?
double curFrameTime = time->GetElapsedTime();
//get the next frame from the avi
int curFrame = (int)(curFrameTime * aviFile.GetFramerate());
void *bitmapData = aviFile.GetFrameData(curFrame);
//bind the gl texture so we can upload the next video frame
glBindTexture(GL_TEXTURE_2D, aviTexture.Handle);
//upload it to the gl texture. use subimage because
//the video frame size is probably smaller than the
//size of the texture on the gpu hardware
glTexSubImage2D(GL_TEXTURE_2D, 0,
0, 0,
aviFile.GetWidth(),
aviFile.GetHeight(),
GL_BGR_EXT,
GL_UNSIGNED_BYTE,
bitmapData);
//unbind the gl texture
glBindTexture(GL_TEXTURE_2D, 0);
//activate the fbo as our render target
if (!fbo.BindAsRenderTarget(glExtensions))
{
FFDebugMessage("FBO Bind As Render Target Failed");
return 0;
}
//set the gl viewport to equal the size of the FBO
glViewport(
fboViewport.x,
fboViewport.y,
fboViewport.width,
fboViewport.height);
//prepare gl state for rendering the first plugin (brightness)
//make sure all the matrices are reset
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//clear the depth and color buffers
glClearColor(0,0,0,0);
glClearDepth(1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//tell plugin 1 what time it is
plugin1->SetTime(curFrameTime);
//plugin 1 parameter #0 is mouse X
plugin1->SetFloatParameter(0, mouseX);
//prepare the structure used to call
//the plugin's ProcessOpenGL method
ProcessOpenGLStructTag processStruct;
//create the array of OpenGLTextureStruct * to be passed
//to the plugin
FFGLTextureStruct *inputTextures[1];
inputTextures[0] = &aviTexture;
//provide our 1 input texture
processStruct.numInputTextures = 1;
processStruct.inputTextures = inputTextures;
//we must let the plugin know that it is rendering into a FBO
//by sharing with it the handle to the currently bound FBO
processStruct.HostFBO = fbo.GetFBOHandle();
//call the plugin's ProcessOpenGL
if (plugin1->CallProcessOpenGL(processStruct)==FF_SUCCESS)
{
//if the plugin call succeeds, the drawning is complete
}
else
{
//the plugin call failed, exit
FFDebugMessage("Plugin 1's ProcessOpenGL failed");
return 0;
}
//deactivate rendering to the fbo
//(this re-activates rendering to the window)
fbo.UnbindAsRenderTarget(glExtensions);
//set the gl viewport to equal the size of our output window
glViewport(
windowViewport.x,
windowViewport.y,
windowViewport.width,
windowViewport.height);
//prepare to render the 2nd plugin (the mirror effect or the custom plugin)
//reset all matrices
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//clear the color and depth buffers
glClearColor(0,0,0,0);
glClearDepth(1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//now pass the contents of the FBO as a texture to the mirror plugin
FFGLTextureStruct fboTexture = fbo.GetTextureInfo();
//change our processStruct so that the input texture refers to
//the FBO texture
inputTextures[0] = &fboTexture;
//change the processOpenGLStruct so that the HostFBO is 0
//(we are rendering the plugin into the output window)
processStruct.HostFBO = 0;
//tell plugin 2 what time it is
plugin2->SetTime(curFrameTime);
//set plugin 2 parameter #0 to the last mouse Y position
plugin2->SetFloatParameter(0, mouseY);
//call plugin #2's ProcessOpenGL
if (plugin2->CallProcessOpenGL(processStruct)==FF_SUCCESS)
{
//if the plugin call succeeds, the drawning is complete
}
else
{
//the plugin call failed, exit
FFDebugMessage("Plugin 2's ProcessOpenGL failed");
return 0;
}
//swapbuffers tells opengl to finish all of the pending
//drawing instructions (which are to the "back" buffer)
//and copy/swap them to the front buffer
SwapBuffers(hdc);
/_/_/_/_/_/_
www.huaonline.com
My Homepage is my Castle— On Wed, 15/7/09, Phuoc Can Hua <@Phuoc_Can_Hua> wrote:
From: Phuoc Can Hua <@Phuoc_Can_Hua>
Subject: Re: [SDL] How to write FreeFrame Host with SDL?
To: sdl at lists.libsdl.org
Received: Wednesday, 15 July, 2009, 5:21 PMI’m writing a slideshow program (with SDL) where I want to
use FreeFrame plug-in (video effects). I’m not even sure
whether FreeFrame would do the job because I’m absolutly
FreeFrame newbie (since yesterday)?I know, my question sounds more FreeFrame related. But I
only hope that someone from the SDL group has already done
that before. Otherwise I’ve to get FreeFrame working and
then port it in my SDL environment.What I need is to blit the contents of FreeFrame to SDL
surface (frame by frame). I’m not sure whether that’s the
right way. But I’ve done similar with Avisynth./_/_/_/_/_/_
www.huaonline.com
My Homepage is my Castle— On Wed, 15/7/09, peter wrote:
From: peter
Subject: Re: [SDL] How to write FreeFrame Host with
SDL?
To: “home” ,
“A list for developers using the SDL library.
(includesSDL-announce)”
Received: Wednesday, 15 July, 2009, 1:32 PM?
?
? _filtered #yiv74585160 {
font-family:??;
}
? _filtered #yiv74585160 {
font-family:Verdana;
}
? _filtered #yiv74585160 {}
? _filtered #yiv74585160 {margin:72.0pt 90.0pt
72.0pt
90.0pt;}
#yiv74585160 P.MsoNormal {TEXT-JUSTIFY:inter-ideograph;TEXT-ALIGN:justify;MARGIN:0cm
0cm 0pt;FONT-FAMILY:“Times New
Roman”;FONT-SIZE:10.5pt;}
#yiv74585160 LI.MsoNormal {TEXT-JUSTIFY:inter-ideograph;TEXT-ALIGN:justify;MARGIN:0cm
0cm 0pt;FONT-FAMILY:“Times New
Roman”;FONT-SIZE:10.5pt;}
#yiv74585160 DIV.MsoNormal {TEXT-JUSTIFY:inter-ideograph;TEXT-ALIGN:justify;MARGIN:0cm
0cm 0pt;FONT-FAMILY:“Times New
Roman”;FONT-SIZE:10.5pt;}
#yiv74585160 A:link {
COLOR:blue;TEXT-DECORATION:underline;}
#yiv74585160 SPAN.MsoHyperlink {
COLOR:blue;TEXT-DECORATION:underline;}
#yiv74585160 A:visited {
COLOR:purple;TEXT-DECORATION:underline;}
#yiv74585160 SPAN.MsoHyperlinkFollowed {
COLOR:purple;TEXT-DECORATION:underline;}
#yiv74585160 SPAN.EmailStyle17 {FONT-STYLE:normal;FONT-FAMILY:Verdana;COLOR:windowtext;FONT-WEIGHT:normal;TEXT-DECORATION:none;}
#yiv74585160 DIV.Section1 {
}
#yiv74585160 UNKNOWN {
FONT-SIZE:10pt;}
#yiv74585160 BLOCKQUOTE {
MARGIN-TOP:0px;MARGIN-BOTTOM:0px;MARGIN-LEFT:2em;}
#yiv74585160 OL {
MARGIN-TOP:0px;MARGIN-BOTTOM:0px;}
#yiv74585160 UL {
MARGIN-TOP:0px;MARGIN-BOTTOM:0px;}?
i hope i
can do,can you give me
some SRS ?
?
?
2009-07-15peter
??? Phuoc Can Hua
???
2009-07-15? 10:52:10??? sdl
???
??? [SDL] How to write
FreeFrame
Host with SDL?
?I’m?thinking?of?writing?a?FreeFrame?host?with?SDL.?Can?anyone?point?me?to?some?documentations?or?sample?codes?
Thanks
Phuoc/_/_/_/_/_/_
www.huaonline.com
My?Homepage?is?my?Castle???____________________________________________________________________________________
Access?Yahoo!7?Mail?on?your?mobile.?Anytime.?Anywhere.
Show?me?how:?http://au.mobile.yahoo.com/mail
SDL?mailing?list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
?? ? ?
Access Yahoo!7 Mail on your mobile. Anytime. Anywhere.
Show me how: http://au.mobile.yahoo.com/mail
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
____________________________________________________________________________________
Access Yahoo!7 Mail on your mobile. Anytime. Anywhere.
Show me how: http://au.mobile.yahoo.com/mail
-------------- next part --------------
A non-text attachment was scrubbed…
Name: somefiles.zip
Type: application/x-zip-compressed
Size: 18463 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090715/23c32aeb/attachment.bin