VedaMachineOGL/OGLMachine.h

Go to the documentation of this file.
00001 /*! \file 
00002     \author victorien ferry & www.m4nkind.com
00003     \brief This file applies the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 , read file COPYING.
00004 */
00005 #ifndef COM_M4NKIND_OGLMachine_H
00006 #define COM_M4NKIND_OGLMachine_H
00007 
00008 #include "VirtualMachine.h"
00009 
00010 // cuno la muerte !!! Needed for gl.h under windows
00011 #ifdef WIN32
00012 #include <windows.h>
00013 #endif
00014 #ifdef MACOSX
00015 // macos special
00016 #include <OpenGL/gl.h>
00017 #else
00018 //classic unix/windows/...
00019 #include <GL/gl.h>
00020 #endif
00021 // to avoid include troubles, we don't include any glext.h, as a lots
00022 // of version can be found, with shader missing, or multitexture missing, or
00023 // framebuffer missing. so, we define them here, if not done in gl.h
00024 // and it should be OK for any configuration.
00025 
00026 #ifndef APIENTRY
00027 #define APIENTRY
00028 #endif
00029 #ifndef APIENTRYP
00030 #define APIENTRYP APIENTRY *
00031 #endif
00032 #ifndef GLAPI
00033 #define GLAPI extern
00034 #endif
00035 // multitexturing:
00036 #ifndef PFNGLACTIVETEXTUREARBPROC
00037 typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
00038 #endif
00039 #ifndef PFNGLCLIENTACTIVETEXTUREARBPROC
00040 typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
00041 #endif
00042 #ifndef GL_TEXTURE0_ARB
00043 #define GL_TEXTURE0_ARB                   0x84C0
00044 #define GL_TEXTURE1_ARB                   0x84C1
00045 #endif
00046 // framebuffer objects:
00047 #ifndef PFNGLGENRENDERBUFFERSEXTPROC
00048 typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers);
00049 #endif
00050 #ifndef PFNGLGENFRAMEBUFFERSEXTPROC
00051 typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers);
00052 #endif
00053 #ifndef PFNGLBINDRENDERBUFFEREXTPROC
00054 typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer);
00055 #endif
00056 #ifndef PFNGLRENDERBUFFERSTORAGEEXTPROC
00057 typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
00058 #endif
00059 #ifndef PFNGLDELETEFRAMEBUFFERSEXTPROC
00060 typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers);
00061 #endif
00062 #ifndef PFNGLDELETERENDERBUFFERSEXTPROC
00063 typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers);
00064 #endif
00065 #ifndef PFNGLBINDFRAMEBUFFEREXTPROC
00066 typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer);
00067 #endif
00068 #ifndef PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC
00069 typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
00070 #endif
00071 #ifndef PFNGLFRAMEBUFFERTEXTURE2DEXTPROC
00072 typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
00073 #endif
00074 #ifndef GL_FRAMEBUFFER_EXT
00075 #define GL_FRAMEBUFFER_EXT                0x8D40
00076 #endif
00077 #ifndef GL_RENDERBUFFER_EXT
00078 #define GL_RENDERBUFFER_EXT               0x8D41
00079 #endif
00080 #ifndef GL_DEPTH_COMPONENT16
00081 #define GL_DEPTH_COMPONENT16              0x81A5
00082 #define GL_DEPTH_COMPONENT24              0x81A6
00083 #define GL_DEPTH_COMPONENT32              0x81A7
00084 #endif
00085 #ifndef GL_COLOR_ATTACHMENT0_EXT
00086 #define GL_COLOR_ATTACHMENT0_EXT          0x8CE0
00087 #endif
00088 #ifndef GL_DEPTH_ATTACHMENT_EXT
00089 #define GL_DEPTH_ATTACHMENT_EXT           0x8D00
00090 #endif
00091 /*
00092 typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer);
00093 typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers);
00094 typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers);
00095 typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
00096 typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
00097 typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer);
00098 typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer);
00099 typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers);
00100 typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers);
00101 typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target);
00102 typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
00103 typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
00104 typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
00105 typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
00106 typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
00107 typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target);
00108 */
00109 //test #include "glext.h"
00110 //#include <GL/glext.h>
00111 
00112 /*!
00113     \class  OGLMachine
00114     \ingroup    VirtualMachineDocGroup
00115     \brief   Defines a \mainprojectname platform independant OpenGL Machine. 
00116             Still, this class 
00117             is virtual, doesn't manage screen opening, doesn't manage sounds,
00118             But unify all OpenGL code, for any machine willing to use OpenGL.
00119 */
00120 
00121 class OGLMachine : public VirtualMachine
00122 {
00123 /*==================================================================
00124                                 PUBLIC
00125 ==================================================================*/
00126 public:
00127     /*!
00128         \brief  Constructor. 
00129     */
00130     OGLMachine(void);
00131     /*!
00132         \brief  Destructor.
00133     */
00134     virtual ~OGLMachine(void);
00135     class OGLInternalTexture;
00136     /*!
00137         \class  InternalViewPort
00138         \brief Nested class that defines a viewport where to draw (screen, sub-screen,texture rendering screens.)
00139             It must be extented to other classes.
00140     */
00141     class   OGLInternalViewPort : public InternalViewPort
00142     {   public:
00143         /*!
00144             \brief  Constructor. 
00145             \param  _pFather the father, or NULL if new root.
00146             \param  _pCreator the machine upon that manage the VP.
00147         */
00148         OGLInternalViewPort(OGLInternalViewPort *_pFather, OGLMachine *_pCreator);
00149 #ifdef _ENGINE_EDITABLE_
00150         /*!
00151             \brief  Destructor. See DeleteViewport() 
00152         */
00153         virtual ~OGLInternalViewPort();
00154 #endif
00155         /*!
00156             \brief  Reset color to black (or given color),and depth buffer, of this ViewPort.
00157             \param  _red [0.0,1.0]
00158             \param  _green [0.0,1.0]
00159             \param  _blue [0.0,1.0]
00160         */
00161         virtual void    Clear( float _red=0.0f,float _green=0.0f,float _blue=0.0f);
00162         /*!
00163             \brief  Render a 3D Object. The vertexes are transformed with matrix _pMatrix,
00164                     the object shape is defined by _pMeshBuffer, the texture of the object is
00165                     defined by _pTexture, the ViewPort that define the rectangle where to draw,
00166                     and the camera parameters is _pViewPort, or the default viewport if not specified.  
00167                     Note drawings on the main screen needs a SwapScreenBuffer() to be shown at each frames.
00168             \param  _pMatrix Internal3DMatrixStack
00169             \param  _pMeshBuffer InternalObject3DBuffer
00170             \param  _pTexture InternalTexture or nothing, will draw shades.
00171         */
00172         virtual void    RenderMesh( InternalObject3DBuffer *_pMeshBuffer,
00173                                     InternalTexture *_pTexture=0L
00174                                     ) ;
00175         /*!
00176             \brief  Render directly a 32bit pixel bitmap image from memory on a viewport.
00177                     Note drawings on the main screen needs a SwapScreenBuffer() to be shown at each frames.
00178             \param  _prgbaTable pointer to the beginning of a 32bit RGBA table.
00179             \param  _PixelWidth number of pixel of a line
00180             \param  _PixelHeight number of pixel lines.
00181         */
00182         virtual void    DrawRGBARectangle( 
00183                                             unsigned char   *_prgbaTable,
00184                                             unsigned int    _PixelWidth,
00185                                             unsigned int    _PixelHeight
00186                                             ) ;
00187         /*!
00188             \brief  Swap buffer so that what was drawn on the viewport is shown.
00189                     this is needed to active all Clear(), RenderMesh() ,...
00190                     It has to be done with main screen viewport like texture-rendering
00191                     viewports.
00192         */
00193         virtual void    SwapBuffer();
00194         /*
00195             \brief  Change the coodinates of the clipping borders of a ViewPort,
00196                     in the origin of its father.default is 0.0,0.0,1.0,1.0
00197                     If the ViewPort is a Root ViewPort, like the main screen,
00198                     or a texture rendering, it is inactive.
00199             \param  _ClippingX1 upperleft corner in [0,1] scale for visible bounds.
00200             \param  _ClippingY1 upperleft corner in [0,1] scale for visible bounds.
00201             \param  _ClippingX2 downright corner in [0,1] scale for visible bounds.
00202             \param  _ClippingY2 downright corner in [0,1] scale for visible bounds.
00203         */
00204         virtual void SetClippingCoordinates(float _ClippingX1,float _ClippingY1,float _ClippingX2,float _ClippingY2 );
00205         /*
00206             \brief  Change the coodinates of the draw scale of a ViewPort, in the origin 
00207                     of its father. default is 0.0,0.0,1.0,1.0
00208                     If the ViewPort is a Root ViewPort, like the main screen,
00209                     or a texture rendering, it is inactive.
00210             \param  _ScaleX1 upperleft corner in [0,1] scale for aspect ratio .
00211             \param  _ScaleY1 upperleft corner in [0,1] scale for aspect ratio .
00212             \param  _ScaleX2 downright corner in [0,1] scale for aspect ratio .
00213             \param  _ScaleY2 downright corner in [0,1] scale for aspect ratio .
00214         */
00215         virtual void SetScaleCoordinates(float _ScaleX1,float _ScaleY1,float _ScaleX2,float _ScaleY2 );
00216 
00217         /*!
00218             \brief  Change the root viewport pixel resolution.This is a low level call in case of resize or screen init.        
00219             \param  _pixelWidth 
00220             \param  _pixelHeight
00221         */  
00222         void    ResetRootPixelSize( unsigned int _pixelWidth,unsigned int _pixelHeight );
00223         /*!
00224             \brief  get the rectangle pixel coordinates in the root viewport bitmap.
00225             \return pixel
00226         */  
00227         inline  int GetPixelX1(){ return m_pixel_x1; };
00228         /*!
00229             \brief  get the rectangle pixel coordinates in the root viewport bitmap.
00230             \return pixel
00231         */  
00232         inline  int GetPixelY1(){ return m_pixel_y1; };
00233         /*!
00234             \brief  get the rectangle pixel coordinates in the root viewport bitmap.
00235             \return pixel
00236         */  
00237         inline  int GetPixelX2(){ return m_pixel_x2; };
00238         /*!
00239             \brief  get the rectangle pixel coordinates in the root viewport bitmap.
00240             \return pixel
00241         */  
00242         inline  int GetPixelY2(){ return m_pixel_y2; };
00243 
00244         //! 2d Scale coordinates of the rectangle recomputed in the Root ViewPort scale.
00245         float m_ScaleRootX1;    
00246         float m_ScaleRootY1;
00247         float m_ScaleRootX2;
00248         float m_ScaleRootY2;
00249 
00250         //! 2d coordinates of the rectangle recomputed in the Root ViewPort scale.
00251         float m_ClippingRootX1; 
00252         float m_ClippingRootY1;
00253         float m_ClippingRootX2;
00254         float m_ClippingRootY2;
00255 
00256         //! real clipped frustrum
00257         float   m_FinalClipFrustrumX1;
00258         float   m_FinalClipFrustrumY1;
00259         float   m_FinalClipFrustrumX2;
00260         float   m_FinalClipFrustrumY2;
00261 
00262         //! in case of texture rendering, otherwise 0L:
00263         OGLInternalTexture  *m_pRenderTexture;
00264         //! layer index affected on texture: m_pRenderTexture.
00265         int     m_RenderTextureLayer;
00266 
00267         /*!
00268             \brief  Tool for other methods: Set the current GL viewport matrix to an InternalViewPort.
00269         */
00270         virtual void    SetGLToViewPort();
00271 
00272         virtual void    Matrix_LoadID(eLoadId _enum=eLoadId_All);
00273         virtual void    Matrix_Translate(float _x,float _y,float _z);
00274         virtual void    Matrix_Rotate( float _angle,float _x,float _y,float _z);
00275         virtual void    Matrix_Scale(float _sx,float _sy,float _sz);
00276         virtual void    Matrix_Push();
00277         virtual void    Matrix_Pop();
00278     protected:
00279         //! machine that created us:
00280         OGLMachine  *m_pOGLMachine;
00281         //! if false, can't be drawn, because invalid coordinates.
00282         bool    m_Valid;
00283         //! the rectangle coordinates in term of screen pixel. 
00284         int     m_pixel_x1; 
00285         //! the rectangle coordinates in term of screen pixel. 
00286         int     m_pixel_y1;
00287         //! the rectangle coordinates in term of screen pixel. 
00288         int     m_pixel_x2;
00289         //! the rectangle coordinates in term of screen pixel. 
00290         int     m_pixel_y2;     
00291         /*
00292             \brief  Change the coodinates of the ViewPort pixels, in its root origin.
00293                     Used by SetCoordinates(). Non-Virtual. Reset the hierarchy down.
00294         */
00295         void    ResetPixelCoordinates();
00296 
00297         //! the pointer where this viewport was attached in the clipping hierarchy, father or brother. 
00298         //! Used to destroy the object. Use ClippingHierarchy_AttachTo to change it.
00299         InternalViewPort    **m_ppClippingHierarchyAttached;
00300 #ifdef _ENGINE_EDITABLE_
00301         /*
00302             \brief  tool: invalidate down the viewport hierachy when a viewport is destroyed.
00303         */
00304         void    ClippingDetach();
00305 #endif
00306     };
00307 
00308     /*!
00309         \class  OGLInternalObject3DBuffer
00310         \brief  Nested class that implements a 3D object as a vertex and a polygon list.
00311                 You ask the creation of it with VirtualMachine::NewObject3DBuffer(),
00312                 then defines its shape by filling the list you get with GetFirstVertex()
00313                 and GetFirstTriangle(), then it can be rendered with VirtualMachine::RenderMesh().
00314                 In order to optimize a static shape, use VirtualMachine::CompileAsStatic()
00315                 In edition mode, it can be destroyed with VirtualMachine::DeleteObject3DBuffer().
00316     */
00317     class   OGLInternalObject3DBuffer : public InternalObject3DBuffer
00318     { public:
00319         /*!
00320             \brief  A call to CompileAsStatic() will fix the current geometry of an object.
00321                     It will try to use the 3D buffer compilation of a given machine, which can fasten the drawing.
00322                     From that moment on, further modification to its shape will be useless.
00323         */
00324         virtual void    CompileAsStatic( );
00325         /*!
00326             \brief  return true is CompileAsStatic() were used.
00327             \return  true is CompileAsStatic() were used, false if still dynamic.
00328         */
00329         virtual bool    IsCompiledAsStatic();
00330         /*!
00331             \brief  Get the beginning of the vertex list. Assume the maximum number of vertex 
00332                     was given by NewObject3DBuffer() and can be read with GetMaximumNumberOfVertexes().
00333             \return a pointer to the first Vertex.
00334         */
00335         virtual InternalVertex   *GetFirstVertex();
00336         /*!
00337             \brief  Get the beginning of the Triangle list. Assume the maximum number of Triangle 
00338                     was given by NewObject3DBuffer() and can be read with GetMaximumNumberOfTriangles().
00339                     last Note: the first triangle returned  already use the offset given with SetNumberOfActiveTriangle(): _FirstActiveTriangleIndex.
00340             \return a pointer to the first Vertex.
00341         */
00342         virtual InternalTriangle *GetFirstTriangle();
00343         /*!
00344             \brief  Set the number of active triangle defined in the triangle list.
00345                     note the active number of vertex is actually given by the highest vertex
00346                     number used by one of the active triangle. If _CurrentNumberOfTriangle is
00347                     greater than GetMaximumNumberOfTriangles(), it is set to zero.
00348                     _FirstActiveTriangleIndex is an optional offset in the triangle list.
00349                     it allows the rendering of a mesh with multiple textures, by 
00350                     setting a windowing in the triangle list and using
00351                     multiple calls to RenderMesh(). Default is zero, start of the list.
00352             \param _CurrentNumberOfTriangle the new number of triangle in the object.
00353             \param _FirstActiveTriangleIndex optional active triangle offset in list.
00354         */
00355         virtual void    SetNumberOfActiveTriangle( unsigned int _CurrentNumberOfTriangle,unsigned int _FirstActiveTriangleIndex=0 );
00356         /*!
00357             \brief  Get the number of active triangle defined by SetNumberOfActiveTriangle().
00358             \return the number of triangle in the object.
00359         */
00360         virtual unsigned int GetNumberOfActiveTriangle();
00361         /*!
00362             \brief  the maximum number of elements in table GetFirstVertex()
00363             \return  the maximum number of elements in table GetFirstVertex() 
00364         */
00365         virtual unsigned int    GetMaximumNumberOfVertexes();
00366         /*!
00367             \brief  the maximum number of elements in table GetFirstTriangle()
00368             \return  the maximum number of elements in table GetFirstTriangle() 
00369         */
00370         virtual unsigned int    GetMaximumNumberOfTriangles();
00371         /*!
00372             \brief   Set the color for the whole object. Active if object was not created with bOb3D_EnableRGB or bOb3D_EnableAlpha.
00373             \param  _red    color component
00374             \param  _green  color component
00375             \param  _blue   color component
00376             \param  _alpha  color component
00377         */
00378         virtual void    SetColor(float _red,float _green,float _blue,float _alpha=1.0f);
00379 
00380 
00381         //! real implementation of the vertex base.
00382         InternalVertex      *m_pVertexBase;
00383         //! real implementation of the triangle base.
00384         InternalTriangle    *m_pTriangleBase;
00385         //! If !=0, It is an OpenGL compiled process: 
00386         unsigned int        m_CompiledObjectHandler;
00387         //! First Active Triangle Index
00388         unsigned int    m_FirstActiveTriangleIndex;
00389         //! current number of active triangle set by SetNumberOfActiveTriangle()
00390         unsigned int    m_NumberOfActiveTriangles;
00391         //! the maximum number of vertex, and the size of the vertex list returned by GetFirstVertex().
00392         unsigned int    m_MaximumNumberOfVertexes;
00393         //! the maximum number of Triangles, and the size of the triangle list returned by GetFirstTriangle().
00394         unsigned int    m_MaximumNumberOfTriangles;
00395         //! tells which vertex members are enabled; use VirtualMachine::bOB3d_xxx
00396         unsigned int    m_ExtraMemberFlags;
00397         //! main color of the object(RGBA, [0.0,1.0]): (note:there is also vertex colors) 
00398         float           m_Color[4];
00399     };
00400     /*!
00401         \class  OGLInternalTexture
00402                 Nested class that defines a texture to render an object with VirtualMachine::RenderMesh().
00403     */
00404     class   OGLInternalTexture : public InternalTexture
00405     { public:
00406         /*!
00407             \brief  Constructor
00408         */
00409         OGLInternalTexture(void);
00410         /*!
00411             \brief  Set or change the render flags for a texture.
00412             \param  _flags or'ed bit flags ( itf_... flags)
00413         */
00414         virtual void    SetRenderFlags( unsigned int _flags );
00415         /*!
00416             \brief  Set base color, default to 1.0f,1.0f,1.0f,1.0f
00417             \param  _rgba Red Green Blue and Alpha transparency components. 
00418         */
00419         virtual void    SetBaseColor( float _rgba[4] );
00420         /*!
00421             \brief  Get the render flags for a texture.
00422             \return  or'ed bit flags (InternalTextureFlagBitsEnum)
00423         */
00424         virtual unsigned int GetRenderFlags( );
00425         /*!
00426             \brief  set an image layer for a texture. see layers with itile_... enums.
00427             \param  _layerToSet the enum that define which layer to change.
00428             \param  _pByteChunk     pointer to a byte chunk 
00429             \param  _pixelByteDepth number of bytes per pixel in _pByteChunk.
00430             \param  _pixelWidth     the number of pixel in a row
00431             \param  _pixelHeight
00432         */
00433         virtual void    SetImageBitmap( TextureImageLayerEnum _layerToSet,
00434                                 const unsigned char *_pByteChunk,
00435                                 unsigned int _pixelByteDepth,
00436                                 unsigned int _pixelWidth,
00437                                 unsigned int _pixelHeight
00438                                 );
00439         static const int    m_MaxNumberOfLayer=2;
00440         //! \class Layer
00441         //! `\brief nested class for private use.
00442         class Layer { public:
00443             unsigned int    m_OGLTextureHandler;
00444             unsigned int    m_BitmapPixelWidth;
00445             unsigned int    m_BitmapPixelHeight;
00446         };
00447         //! OGL texture handlers: simple map+env.
00448         Layer       m_Layer[m_MaxNumberOfLayer];
00449         //! current flags set
00450         unsigned int    m_flags;
00451         //! the base color, which is modulated on mapping layer.
00452         float       m_BaseColorRGBA[4];
00453         //! tell which layer is active:
00454         unsigned int    m_ActiveLayerFlag;
00455         //! in case of render to texture with render extension:
00456         GLuint m_frameBuffer;
00457         //! in case of render to texture with render extension:
00458         GLuint m_depthRenderBuffer;
00459     };
00460     
00461     /*!
00462         \brief  Init the machine. It would open a screen and do the init for each theme (3D,sound,...)
00463                 the machine closing should be done at deletion.
00464         \return vmr_OK or vmr_FAILED
00465     */
00466     virtual eVMResult   InitMachine();
00467     /*!
00468         \brief  Swap default VP buffer: so that what was drawn is shown.
00469     */
00470     virtual void    SwapMainScreenBuffer()=0;
00471 
00472     /*!
00473         \brief  Ask the Creation of a new InternalObject3DBuffer you can then fill with 
00474                     InternalObject3DBuffer::GetFirstVertex() , InternalObject3DBuffer::GetFirstTriangle()
00475                     and InternalObject3DBuffer::SetNumberOfActiveTriangle() .
00476                     Then the object can be positionned with the matrix methods, and drawn with RenderMesh()
00477                     The object shape can be dynamic and rebuilt, until a call to CompileAsStatic().
00478                     In edition mode, object has to be destroyed with DeleteObject3DBuffer().
00479         \param  _ppVertexAndPolygonBufferOut    the object returned, or 0L if failed.(no mem ?)
00480         \param  _maxNbVertex                    maximum number of vertex to fill.
00481         \param  _maxNbTriangle                  maximum number of Triangle to fill.
00482         \param  _extraMemberFlags               or'ed bits (bOb3D_...) to activate extra vertex members.
00483     */
00484     virtual void    NewObject3DBuffer(  InternalObject3DBuffer **_ppVertexAndPolygonBufferOut, 
00485                             unsigned int _maxNbVertex,
00486                             unsigned int _maxNbTriangle, 
00487                             unsigned int _extraMemberFlags );
00488 
00489     /*
00490         \brief      Destroy objects previously created with NewObject3DBuffer()
00491         \param      _ppBufferToDestroy object to destroy, and set to 0L.
00492     */
00493     virtual void    DeleteObject3DBuffer(  InternalObject3DBuffer **_ppBufferToDestroy );
00494 
00495     /*!
00496         \brief  Ask the Creation of a new InternalTexture, then used to render 3D objects with RenderMesh().
00497                 In edition mode, InternalTexture has to be destroyed with DeleteTexture().
00498         \param  _ppTextureOut   the object returned, or 0L if failed.(no mem ?)
00499     */
00500     virtual void    NewTexture(  InternalTexture **_ppTextureOut  );
00501 #ifdef _ENGINE_EDITABLE_
00502     /*!
00503         \brief  Destroy objects previously created with NewTexture()
00504         \param  _ppTextureToDestroy  object to destroy, and set to 0L.
00505     */
00506     virtual void    DeleteTexture(  InternalTexture **_ppTextureToDestroy );
00507 #endif
00508 
00509     /*!
00510         \brief  Ask the Creation of a new InternalViewPort, that must be the child of another ViewPort,
00511                 specified by _pFatherViewPort.if no father is specified, the new ViewPort will be
00512                 the child of the default root ViewPort. To create another Root ViewPort, create a texture
00513                 and use VirtualMedia::NewViewPortOnTexture().
00514                 In edition mode, each InternalViewPort has to be destroyed with DeleteViewPort().
00515         \param  _ppViewPortOut  the object returned, or 0L if failed.(no mem ?)
00516         \param  _pFatherViewPort the father viewport. If 0L, it uses the default root.
00517     */
00518     virtual void    NewViewPortChild(  InternalViewPort **_ppViewPortOut,InternalViewPort *_pFatherViewPort=0L);
00519     /*!
00520         \brief  Ask the Creation of a new Root InternalViewPort, that will render on a texture image.
00521                 specified by _pRootTexture. You got to create a texture first for parameter _pRootTexture.
00522                 In edition mode, each InternalViewPort has to be destroyed with DeleteViewPort().
00523         \param  _ppViewPortOut  the object returned, or 0L if failed.(no mem ?)
00524         \param  _pRootTexture an InternalTexture. Can't be null.
00525         \param  _np2PixelWidth  integer which can be 1,2,4,8,16,32,64,128,256,512 that stand for the square of the pixel width.
00526         \param  _np2PixelHeight integer which can be 1,2,4,8,16,32,64,128,256,512 that stand for the square of the pixel height.
00527         \param  _layerToAffect  the texture layer (simple mapping, environment) where  to render.
00528     */
00529     virtual void    NewViewPortOnTexture(  InternalViewPort **_ppViewPortOut,
00530                                             InternalTexture *_pRootTexture,
00531                                             unsigned int _np2PixelWidth,
00532                                             unsigned int _np2PixelHeight,
00533                                             InternalTexture::TextureImageLayerEnum _layerToAffect);
00534 
00535 
00536     /*!
00537         \brief  Destroy any objects previously created with NewViewPortChild() or NewViewPortOnTexture().
00538         \param  _ppViewPortToDestroy     pointer to object to destroy, and set to 0L.
00539     */
00540     virtual void    DeleteViewPort(  InternalViewPort **_ppViewPortToDestroy );
00541 
00542 
00543     // extension for multiple texture units:
00544     static  PFNGLACTIVETEXTUREARBPROC       glActiveTextureARB;
00545     static  PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB;
00546     
00547     // GL_EXT_framebuffer_object related extension, (render-to-texture)
00548     static  bool    m_RenderObjectExtension;
00549     // in order of appearance:
00550     static PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT; // init
00551     static PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT; // init
00552     static PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT ; // init
00553     static PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT; // init
00554     static PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT; // end
00555     static PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT; //end
00556     static PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT; // draw
00557     static PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT; //draw
00558     static PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT ; //draw
00559 
00560 
00561     //static PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT;
00562 /*  static PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT = NULL;
00563     static PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT = NULL;
00564 
00565     static PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT = NULL;
00566     static PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glGetRenderbufferParameterivEXT = NULL;
00567     static PFNGLISFRAMEBUFFEREXTPROC glIsFramebufferEXT = NULL;
00568     static PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT = NULL;
00569     static PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT = NULL;
00570 
00571     static PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT = NULL;
00572     static PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glFramebufferTexture1DEXT = NULL;
00573     static PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT = NULL;
00574     static PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT = NULL;
00575     static PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT = NULL;
00576     static PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT = NULL;
00577     static PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT = NULL;
00578 */
00579         /*
00580         glIsRenderbufferEXT = (glIsRenderbufferEXTPROC) getGLExtensionProcAddress("glIsRenderbufferEXT");
00581         glBindRenderbufferEXT = (glBindRenderbufferEXTPROC) getGLExtensionProcAddress("glBindRenderbufferEXT");
00582         glDeleteRenderbuffersEXT = (glDeleteRenderbuffersEXTPROC) getGLExtensionProcAddress("glDeleteRenderbuffersEXT");
00583         glGenRenderbuffersEXT = (glGenRenderbuffersEXTPROC) getGLExtensionProcAddress("glGenRenderbuffersEXT");
00584         glRenderbufferStorageEXT = (glRenderbufferStorageEXTPROC) getGLExtensionProcAddress("glRenderbufferStorageEXT");
00585         glGetRenderbufferParameterivEXT = (glGetRenderbufferParameterivEXTPROC) getGLExtensionProcAddress("glGetRenderbufferParameterivEXT");
00586         glIsFramebufferEXT = (glIsFramebufferEXTPROC) getGLExtensionProcAddress("glIsFramebufferEXT");
00587         glBindFramebufferEXT = (glBindFramebufferEXTPROC) getGLExtensionProcAddress("glBindFramebufferEXT");
00588         glDeleteFramebuffersEXT = (glDeleteFramebuffersEXTPROC) getGLExtensionProcAddress("glDeleteFramebuffersEXT");
00589         glGenFramebuffersEXT = (glGenFramebuffersEXTPROC) getGLExtensionProcAddress("glGenFramebuffersEXT");
00590         glCheckFramebufferStatusEXT = (glCheckFramebufferStatusEXTPROC) getGLExtensionProcAddress("glCheckFramebufferStatusEXT");
00591         glFramebufferTexture1DEXT = (glFramebufferTexture1DEXTPROC) getGLExtensionProcAddress("glFramebufferTexture1DEXT");
00592         glFramebufferTexture2DEXT = (glFramebufferTexture2DEXTPROC) getGLExtensionProcAddress("glFramebufferTexture2DEXT");
00593         glFramebufferTexture3DEXT = (glFramebufferTexture3DEXTPROC) getGLExtensionProcAddress("glFramebufferTexture3DEXT");
00594         glFramebufferRenderbufferEXT = (glFramebufferRenderbufferEXTPROC) getGLExtensionProcAddress("glFramebufferRenderbufferEXT");
00595         glGetFramebufferAttachmentParameterivEXT = (glGetFramebufferAttachmentParameterivEXTPROC) getGLExtensionProcAddress("glGetFramebufferAttachmentParameterivEXT");
00596         glGenerateMipmapEXT = (glGenerateMipmapEXTPROC) getGLExtensionProcAddress("glGenerateMipmapEXT");
00597 */
00598 
00599 /*==================================================================
00600                                 PROTECTED
00601 ==================================================================*/
00602 protected:
00603 
00604 };
00605 
00606 
00607 #endif

      /\/\        4         N         k         !         N         D
                      _______  _ __ ___  _____            ___ _ _  ____
     ___________  __//___   /________  |/    / ___________\_______/    \
    /   _   _   \/   _     /    _   /      _/_/____/    _       __     /
   /    /   /       /     /    /    \      \/     /    /    \   \     /
  \\___/___/___/    ¯    _____/_____/       ______\___/_____/\________\\
               \________/_ ___ __ l____\      /elD!  
                 http://www.m4nkind.com \____/