Page 1 of 1
Render directly on image output ?
Posted: Sat Nov 16, 2013 4:29 pm
by marc_256
Is it possible to render directly on image output ?
I made some stuff and use 3D OGRE engine to render on WindowedScreen in real time.
But I like to make an 3D animation movie.
And need all my renders on image bmp format.
To build an movie from these images.
Marc,
Re: Render directly on image output ?
Posted: Sat Nov 16, 2013 4:49 pm
by IdeasVacuum
Why not capture the screen? You would need to save each screen capture, then assemble the .bmp files into an AVI.
Windows OS Screen Capture code, ready to be butched to suit:
Code: Select all
#Image = 0
Structure MONINFO
iW.i ;Desktop Width
iH.i ;Desktop Height
EndStructure
;#Desktop Values
;Check to see if there is more than one monitor
Global igTotalDesktops.i = ExamineDesktops()
;If multiple monitors, igDesktopNum is the number of the currently active monitor
;Get the currently active monitor from the location of your app window
Global igDesktopNum.i = 0
Global Dim gMon.MONINFO(igTotalDesktops - 1)
Global Dim igVirtDesktopW.i(igTotalDesktops - 1)
For i = 0 To (igTotalDesktops - 1)
gMon(i)\iW = DesktopWidth(i)
gMon(i)\iH = DesktopHeight(i)
Next i
For i = 0 To (igTotalDesktops - 1)
If(i = 0)
igVirtDesktopW(i) = gMon(i)\iW
Else
igVirtDesktopW(i) = igVirtDesktopW(i - 1) + gMon(i)\iW
EndIf
Next i
Procedure CaptureScreen()
;------------------------
Protected dm.DEVMODE ;structure for CreateDC()
Protected sDate.s = FormatDate("%yyyy%mm%dd%hh%ii%ss", Date())
Protected sImgFile.s = "C:\" + sDate + ".bmp"
Protected screenDC.i = CreateDC_("DISPLAY", "", "", dm) ;Initialise dm
Protected trgDC.i = CreateCompatibleDC_(screenDC)
Protected BMPHandle.i = CreateCompatibleBitmap_(screenDC, gMon(igDesktopNum)\iW, gMon(igDesktopNum)\iH)
Protected iLeft.i = 0
RedrawWindow_(#Null,#Null,#Null,#RDW_INVALIDATE)
If(igDesktopNum > 0) : iLeft = igVirtDesktopW(igDesktopNum - 1) : EndIf
SelectObject_(trgDC, BMPHandle)
BitBlt_(trgDC, 0, 0, gMon(igDesktopNum)\iW, gMon(igDesktopNum)\iH, screenDC, iLeft, 0, #SRCCOPY)
If Not (BMPHandle = 0)
If(IsImage(#Image)) : FreeImage(#Image) : EndIf
If CreateImage(#Image, gMon(igDesktopNum)\iW, gMon(igDesktopNum)\iH, 24)
If StartDrawing(ImageOutput(#Image))
DrawImage(BMPHandle, 0, 0)
StopDrawing()
SaveImage(#Image, sImgFile)
EndIf
EndIf
EndIf
;Clean up
DeleteDC_(trgDC)
ReleaseDC_(BMPHandle, screenDC)
FreeImage(#PB_All)
EndProcedure
CaptureScreen()
End
Re: Render directly on image output ?
Posted: Sat Nov 16, 2013 5:11 pm
by marc_256
IdeasVacuum wrote:Why not capture the screen? You would need to save each screen capture, then assemble the .bmp files into an AVI.
Well, 20 minutes * 60 sec/min * 25 images/sec = 30000 images
So, thanks for the hint, but I like it more automated than manual screen captions
marc,
Re: Render directly on image output ?
Posted: Sat Nov 16, 2013 5:19 pm
by IdeasVacuum
...there is no reason why you can't automate the screen capture code
Re: Render directly on image output ?
Posted: Sat Nov 16, 2013 5:25 pm
by marc_256
thanks, i did not understand your idea ...
but with your example,
I understands it, thats nice, so I can automated it.
marc,
Re: Render directly on image output ?
Posted: Sat Nov 16, 2013 5:28 pm
by marc_256
I also would need to render specific entities on background buffers, but we can't, just limited Render Textures.
My idea was to render the OGRE created 3D world on the background, and superpose an other real world image above it.
marc,
Re: Render directly on image output ?
Posted: Sat Nov 16, 2013 5:47 pm
by IdeasVacuum
You can build the AVI file using source code from dige, it's very easy to use too:
http://www.purebasic.fr/english/viewtop ... 4&start=15
Re: Render directly on image output ?
Posted: Sat Nov 16, 2013 5:48 pm
by marc_256
Hi IdeasVacuum,
This works very well,
I just changed
Code: Select all
BitBlt_(trgDC, 0, 0, gMon(igDesktopNum)\iW, gMon(igDesktopNum)\iH, screenDC, iLeft, 0, #SRCCOPY)
to
Code: Select all
BitBlt_(trgDC, 100, 100, 800, 600, screenDC, iLeft, 0, #SRCCOPY)
to select my screen zone,
BUT
My cursor is not drawn on the screen caption,
can this be done ?
marc,
Re: Render directly on image output ?
Posted: Sat Nov 16, 2013 5:54 pm
by IdeasVacuum
Ah - not sure when it comes to screen display rather than window display. If anything, I expected you to want to hide the cursor lol.
A hack would be to get the cursor position and superimpose a cursor image. Although that sounds wacky, you could then for example have the cursor highlighted with a semi-transparent circle, and the cursor itself need not be an arrow.
Re: Render directly on image output ?
Posted: Sat Nov 16, 2013 5:58 pm
by marc_256
Thanks, I go to see this WE to solve this.
Thanks for the help here.
Marc,