Render directly on image output ?

Everything related to 3D programming
marc_256
Addict
Addict
Posts: 859
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Render directly on image output ?

Post 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,
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Render directly on image output ?

Post 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
Last edited by IdeasVacuum on Sat Nov 16, 2013 5:18 pm, edited 2 times in total.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
marc_256
Addict
Addict
Posts: 859
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Re: Render directly on image output ?

Post 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 :wink:

marc,
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Render directly on image output ?

Post by IdeasVacuum »

...there is no reason why you can't automate the screen capture code
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
marc_256
Addict
Addict
Posts: 859
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Re: Render directly on image output ?

Post 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,
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
marc_256
Addict
Addict
Posts: 859
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Re: Render directly on image output ?

Post 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,
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Render directly on image output ?

Post 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
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
marc_256
Addict
Addict
Posts: 859
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Re: Render directly on image output ?

Post 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 :mrgreen:
My cursor is not drawn on the screen caption,
can this be done ? :oops:

marc,
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Render directly on image output ?

Post 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.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
marc_256
Addict
Addict
Posts: 859
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Re: Render directly on image output ?

Post by marc_256 »

Thanks, I go to see this WE to solve this.

Thanks for the help here.
Marc,
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
Post Reply