source file REDIWindow.h

Go to the documentation of this file.

#ifndef RED_IWINDOW_H
#define RED_IWINDOW_H

//******************************************************************************
// Copyright (c) 2005 Redway. All rights reserved.
//
// Redway3d is a registered trademark. Any reproduction and / or utilization
// of any material from this document without Redway?s express authorization
// are prohibited.
//******************************************************************************

#include "REDIImage.h"
#include "REDIResourceManager.h"
#include "REDWindowRenderInfo.h"
#include "REDShapePath.h"
#include "REDRenderLayer.h"


//******************************************************************************
//*** VRL FBO parameters *******************************************************
//******************************************************************************

#define RED_MAX_FBO_COLORS     8


//******************************************************************************
//*** RED::IWindow interface ***************************************************
//******************************************************************************

namespace RED
{
  class LayerSet;
  class FrameStatistics;
  
  
  // FrameTracing feedback:
  // ----------------------

  enum FRAME_TRACING_FEEDBACK { FTF_BY_BLOCKS           = -1,
                                FTF_BY_SURFACE_LEVEL_0  = 0,
                                FTF_BY_SURFACE_LEVEL_1  = 1,
                                FTF_BY_SURFACE_LEVEL_2  = 2,
                                FTF_BY_SURFACE_LEVEL_3  = 3,
                                FTF_BY_SURFACE_LEVEL_4  = 4,
                                FTF_BY_SURFACE_LEVEL_5  = 5,
                                FTF_BY_BLOCKS_LEVEL_0   = 6,
                                FTF_BY_BLOCKS_LEVEL_1   = 7,
                                FTF_BY_BLOCKS_LEVEL_2   = 8,
                                FTF_BY_BLOCKS_LEVEL_3   = 9,
                                FTF_BY_BLOCKS_LEVEL_4   = 10,
                                FTF_BY_BLOCKS_LEVEL_5   = 11,
                                FTF_PATH_TRACING        = 12 };
  
  
  // FrameTracingGICache modes:
  // --------------------------

  enum GI_CACHE_MODE { GICM_CAMERA_VIEW       = 0,
                       GICM_CAMERA_SPHERICAL  = 1,
                       GICM_WORLD             = 2 };
  
  
  // IWindow types:
  // --------------
  
  typedef RED_RC (*RENDERING_PROGRESS_CALLBACK)( const RED::FrameStatistics& iFrameStatistics,
                                                 void*                       iUserData );
  
  
  // IWindow interface:
  // ------------------
  
  class REDFullExp IWindow : public IREDObject
  {
    public:

    // Typing information:
    // -------------------
    
    SET_CID( CID_class_REDIWindow );
    
    
    // Window contents:
    // ----------------
    
    virtual RED_RC InsertViewpoint( RED::Object*      iViewpoint,
                                    const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetViewpoint( RED::Object*& oViewpoint,
                                 int           iViewpointNumber,
                                 int           iStateNumber = -1 ) = 0;
    
    
    virtual RED_RC GetViewpointsCount( int& oCount,
                                       int  iStateNumber = -1 ) = 0;
    
    
    virtual RED_RC RemoveViewpoint( RED::Object*      iViewpoint,
                                    const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetDefaultVRL( RED::Object*& oVRL,
                                  int           iStateNumber = -1 ) = 0;
    
    
    virtual RED_RC CreateVRL( RED::Object*&     oVRL,
                              int               iWidth,
                              int               iHeight,
                              RED::FORMAT       iFormat,
                              bool              iZBuffered,
                              const RED::State& iState ) = 0;
    
    
    virtual RED_RC CreateMultiRenderTargetVRL( RED::Object*&     oVRL,
                                               int               iWidth,
                                               int               iHeight,
                                               RED::FORMAT       iFormat[ RED_MAX_FBO_COLORS ],
                                               int               iColorBufferCount,
                                               bool              iZBuffered,
                                               const RED::State& iState ) = 0;
    
    
    virtual RED_RC DeleteVRL( RED::Object*      iVRL,
                              const RED::State& iState ) = 0;
    
    
    virtual const RED::Vector< RED::Object* >& GetVRLList( int iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetVRL( RED::Object*& oVRL,
                           int           iNumber,
                           int           iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetVRLCount( int& oCount,
                                int  iStateNumber = -1 ) const = 0;
    
    
    // Window resizing:
    // ----------------
    
    virtual RED_RC GetSize( int& oWidth,
                            int& oHeight,
                            int  iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC Resize( int               iWidth,
                           int               iHeight,
                           const RED::State& iState ) = 0;
    
        
    // Frame rendering interface:
    // --------------------------
    
    virtual RED_RC FrameDrawing() = 0;
    
    
    virtual RED_RC FrameTracing( bool&                       oComplete,
                                 RED::FRAME_TRACING_FEEDBACK iMinFeedback      = RED::FTF_BY_SURFACE_LEVEL_0,
                                 float                       iFeedbackInterval = 500.0f ) = 0;
    

    virtual RED_RC FrameTracingStop( bool iGlobalStop = true ) = 0;
    
    
    virtual RED_RC FrameTracingGICache( bool&                              oComplete,
                                        RED::Object*&                      oGICache,
                                        RED::Object*                       iCamera,
                                        RED::GI_CACHE_MODE                 iMode,
                                        const RED::Vector< RED::Vector3 >& iFilteringPositions,
                                        const RED::Vector< RED::Object* >& iExcludedObjects,
                                        const RED::Vector< RED::Object* >& iSampleBlockingObjects,
                                        float                              iFeedbackInterval = 500.0f ) = 0;
    
    
    virtual RED_RC FrameTracingImages( bool&                              oComplete,
                                       const RED::Vector< RED::Object* >& iImages,
                                       const RED::Vector< RED::Object* >& iViewpoints,
                                       RED::FRAME_TRACING_FEEDBACK        iMinFeedback      = RED::FTF_BY_SURFACE_LEVEL_0,
                                       float                              iFeedbackInterval = 500.0f ) = 0;
    
    
    virtual RED_RC FrameTracingImageLayers( bool&                            oComplete,
                                            RED::Vector< RED::RenderLayer >& ioLayers,
                                            RED::FRAME_TRACING_FEEDBACK      iMinFeedback = RED::FTF_BY_SURFACE_LEVEL_0,
                                            float                            iFeedbackInterval = 500.0f ) = 0;
    
    
    // Frame picking interface:
    // ------------------------
    
    virtual RED_RC FramePicking( RED::Vector< RED::ShapePath >& oPickList,
                                 const RED::Object*             iVRL,
                                 int                            iX,
                                 int                            iY,
                                 const RED::LayerSet*           iLayerSet,
                                 int                            iStateNumber = -1 ) = 0;
    
    
    virtual RED_RC FramePickingRectangle( RED::Vector< RED::ShapePath >& oPickList,
                                          const RED::Object*             iVRL,
                                          int                            iXMin,
                                          int                            iXMax,
                                          int                            iYMin,
                                          int                            iYMax,
                                          const RED::LayerSet*           iLayerSet,
                                          bool                           iPickOnlyInside = false,
                                          bool                           iPickAllElements = false,
                                          int                            iStateNumber = -1 ) = 0;
    
    
    virtual RED_RC GetPickLine( RED::Vector3&      oP1,
                                RED::Vector3&      oP2,
                                const RED::Object* iVRL,
                                const RED::Object* iCamera,
                                int                iX,
                                int                iY,
                                int                iStateNumber = -1 ) const = 0;
    
    
    // OS & Graphic driver specific rendering:
    // ---------------------------------------
    
    virtual void* GetOSHandler() const = 0;
    
    
    virtual RED_RC SetOSHandler( void* iNewOSHandle ) = 0;
    
    
    virtual const RED::WindowRenderInfo& GetRenderInfo() const = 0;
    
    
    // GPU identification queries:
    // ---------------------------
    
    virtual RED_RC GetHardwareVendor( const char*& oVendor ) = 0;
    
    
    virtual RED_RC GetOpenGLExtensions( const char*& oExtensions ) = 0;
    
    
    virtual RED_RC GetRenderer( const char*& oRenderer ) = 0;
    
    
    virtual RED_RC GetOpenGLVersion( const char*& oVersion ) = 0;
    
    
    virtual RED_RC IsNVidia( bool& oNVidia ) = 0;
    
    
    virtual RED_RC IsATI( bool& oATI ) = 0;
    
    
    virtual RED_RC IsINTEL( bool& oINTEL ) = 0;
    
    
    virtual RED_RC IsNoRayTrace( bool& oNoRayTrace ) = 0;
    
    
    virtual RED_RC IsLimitedRayTrace( bool& oLimitedRayTrace ) = 0;
    
    
    virtual RED_RC IsLimitedAreaLighting( bool& oLimitedAreaLighting ) = 0;
    
    
    virtual RED_RC IsNativeHDR( bool& oNativeHDR ) = 0;
    
    
    virtual RED_RC GetGPUChipset( RED::HARDWARE_PLATFORM& oChipset ) = 0;
    
    
    virtual RED_RC GetMaxTextureSize( int& oMaxTexSize ) const = 0;
    
    
    virtual RED_RC GetMax3DTextureSize( int& oMax3DTexSize ) const = 0;
    
    
    // Progress indicator callbacks:
    // -----------------------------

    virtual void SetRenderingProgressCallback( RED::RENDERING_PROGRESS_CALLBACK iCallback,
                                               void*                            iUserData ) = 0;
    
    
    virtual void GetRenderingProgressCallback( RED::RENDERING_PROGRESS_CALLBACK& oCallback,
                                               void*&                            oUserData ) const = 0;
    
    
    virtual const RED::FrameStatistics& GetFrameStatistics() const = 0;
    
    
    // Miscellaneous methods:
    // ----------------------
    
#if defined( _WIN32 )
    
    virtual RED_RC RestoreHostState( HDC   iHDC,
                                     HGLRC iHGLRC ) = 0;
    
    
    virtual RED_RC RestoreREDState( HDC   iHDC,
                                    HGLRC iHGLRC ) = 0;
    
#elif defined( _LIN32 )
    
    virtual RED_RC RestoreHostState( Drawable   iDrawable,
                                     GLXContext iGLXContext ) = 0;
    
    
    virtual RED_RC RestoreREDState( Drawable   iDrawable,
                                    GLXContext iGLXContext ) = 0;
    
#elif defined( _MAC32 )
    
    virtual RED_RC RestoreHostState( REDNSOpenGLContext* iContext ) = 0;
    
    
    virtual RED_RC RestoreREDState ( REDNSOpenGLContext* iContext ) = 0;
    
#endif
    
    virtual void ReleaseOpenGLContext() = 0;
    
    
    virtual RED_RC DisplayFPSCounter( bool              iOnOff,
                                      const RED::State& iState ) = 0;
    
    
    virtual RED_RC IsFPSCounterDisplay( bool& oOnOff,
                                        int   iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetFPSCounter( float& oApplicationTime,
                                  float& oREDEngineTime ) const = 0;
    
    
    virtual RED_RC ExtractGICache( RED::Object*& oGICache ) = 0;
  };
};


#endif