#include "ortoolgrabview3d_view.h"
#if defined( KARCH_ENV_WIN )
#include <windows.h>
#endif
#pragma comment(lib,"user32.lib") // This is to avoid changing the template for the .dsp files.
ORView3D::ORView3D() :
mFontDisplayList(0)
{
mRender = mSystem.Renderer;
mFileName = "output.avi";
mFilePath = "C:";
FBViewingOptions* lVO = mRender->GetViewingOptions();
lVO->ShowTimeCode() = true;
lVO->ShowSafeArea() = true;
lVO->ShowCameraLabel() = true;
}
void ORView3D::FBDestroy()
{
if( mFontDisplayList )
{
glDeleteLists(mFontDisplayList,256);
mFontDisplayList = 0;
}
}
void ORView3D::Refresh(bool pNow)
{
FBView::Refresh(pNow);
}
void ORView3D::ViewExpose()
{
int Width = Region.Position.X[1] - Region.Position.X[0];
int Height = Region.Position.Y[1] - Region.Position.Y[0];
if( mRender->RenderBegin(0, 0, Width, Height) )
{
mRender->PreRender();
mRender->Render();
mRender->RenderEnd(this);
}
CustomGLDrawString(5, 15, "Custom Title!");
}
void ORView3D::ViewInput(
int pMouseX,
int pMouseY,
FBInputType pAction,
int pButtonKey,
int pModifier)
{
{
FBVideoGrabber VideoGrabber;
FBVideoGrabOptions GrabOptions = VideoGrabber.GetOptions();
FBTime lStart, lStop, lStep;
lStart.SetTime(0, 0, 0, 0, 0);
lStop.SetTime(0, 0, 0, 150, 0);
lStep.SetTime(0, 0, 0, 1, 0);
GrabOptions.mTimeSpan.Set(lStart, lStop);
GrabOptions.mTimeSteps.SetTime(0, 0, 0, 1, 0);
GrabOptions.mOutputFileName = mFilePath + FBString( "\\" ) + mFileName;
GrabOptions.mAntiAliasing = false;
GrabOptions.mRenderAudio = false;
VideoGrabber.SetOptions(&GrabOptions);
VideoGrabber.SetRefreshViewFunc(this, RefreshViewCallback);
if( VideoGrabber.BeginGrab() )
{
VideoGrabber.Grab();
VideoGrabber.EndGrab();
}
}
}
void ORView3D::RefreshViewCallback(void* pThis)
{
ORView3D* lThis = (ORView3D*)pThis;
lThis->Refresh(true);
}
FBString ORView3D::GetFileName()
{
return mFileName;
}
void ORView3D::SetFileName( const char* pFileName )
{
mFileName = pFileName;
}
FBString ORView3D::GetFilePath()
{
return mFilePath;
}
void ORView3D::SetFilePath( const char* pFilePath )
{
mFilePath = pFilePath;
}
void ORView3D::CustomGLDrawString(int pX, int pY, const char* pText)
{
#if defined( KARCH_ENV_WIN )
if( mFontDisplayList == 0 )
{
mFontDisplayList = glGenLists(256);
if( !wglUseFontBitmaps(GetDC(
NULL), 0, 256, mFontDisplayList) )
{
glDeleteLists(mFontDisplayList, 256);
mFontDisplayList = 0;
}
}
if( mFontDisplayList )
{
int Width = Region.Position.X[1] - Region.Position.X[0];
int Height = Region.Position.Y[1] - Region.Position.Y[0];
glViewport(0, 0, Width, Height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, Width, Height, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRasterPos2i(pX, pY);
glListBase(mFontDisplayList);
glCallLists((GLsizei)strlen(pText), GL_UNSIGNED_BYTE, pText);
}
#endif
}