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_VedaMachineDreamcast_H 00006 #define COM_M4NKIND_VedaMachineDreamcast_H 00007 00008 #include "VirtualMachine.h" 00009 #include "kos.h" 00010 #include "MatrixModel.h" 00011 00012 //#define PRINTDEBUG 1 00013 00014 /*! 00015 \class VedaMachineDreamcast 00016 \ingroup VirtualMachineDocGroup 00017 \brief Defines a \mainprojectname Machine targeted for the Sega 00018 Dreamcast hardware, using the free Developpement kit Kallistios, 00019 and other things. For the moment, the renderer is partly based on KGL. 00020 */ 00021 00022 class VedaMachineDreamcast : public VirtualMachine 00023 { 00024 /*================================================================== 00025 PUBLIC 00026 ==================================================================*/ 00027 public: 00028 /*! 00029 \brief Constructor. 00030 */ 00031 VedaMachineDreamcast(void); 00032 /*! 00033 \brief Destructor. 00034 */ 00035 virtual ~VedaMachineDreamcast(void); 00036 class DCInternalTexture; 00037 class DCInternalObject3DBuffer; 00038 00039 static void RenderMesh_SetglCullFaceDepthTestAndMask(unsigned int _renderflag); 00040 static void RenderMesh_Setgl2DBilinearAndClamp(unsigned int _renderflag); 00041 static void RenderMesh_SetGlColorToObjectAndTexture(float rgba[4], 00042 DCInternalObject3DBuffer *_pMeshBuffer,DCInternalTexture *_pOGLTexture); 00043 //! tool method used by pass1(opque) and 2(transp.). drawn after flags&matrix are set. 00044 static void RenderMesh_Draw3D_Flat( DCInternalObject3DBuffer *pbuffer); 00045 static void RenderMesh_Draw3D_FlatColor4( DCInternalObject3DBuffer *pbuffer); 00046 static void RenderMesh_Draw3D_Bitmap( DCInternalObject3DBuffer *pbuffer); 00047 static void RenderMesh_Draw3D_BitmapColor4( DCInternalObject3DBuffer *pbuffer); 00048 static void RenderMesh_Draw3D_Environment( DCInternalObject3DBuffer *pbuffer, matrix_t *pMatrix); 00049 static void RenderMesh_Draw3D_EnvironmentColor4( DCInternalObject3DBuffer *pbuffer, matrix_t *pMatrix); 00050 00051 /*! 00052 \class InternalViewPort 00053 \brief nested class that defines a viewport where to draw (screen, sub-screen,texture rendering screens.) 00054 It must be extented to other classes. 00055 */ 00056 class DCInternalViewPort : public InternalViewPort 00057 { public: 00058 /*! 00059 \brief Constructor. 00060 \param _pFather the father, or NULL if new root. 00061 */ 00062 DCInternalViewPort(DCInternalViewPort *_pFather); 00063 #ifdef _ENGINE_EDITABLE_ 00064 /*! 00065 \brief Destructor. See DeleteViewport() 00066 */ 00067 virtual ~DCInternalViewPort(); 00068 #endif 00069 /*! 00070 \brief Reset color to black (or given color),and depth buffer, of this ViewPort. 00071 \param _red [0.0,1.0] 00072 \param _green [0.0,1.0] 00073 \param _blue [0.0,1.0] 00074 */ 00075 virtual void Clear( float _red=0.0f,float _green=0.0f,float _blue=0.0f); 00076 /*! 00077 \brief Render a 3D Object. The vertexes are transformed with matrix _pMatrix, 00078 the object shape is defined by _pMeshBuffer, the texture of the object is 00079 defined by _pTexture, the ViewPort that define the rectangle where to draw, 00080 and the camera parameters is _pViewPort, or the default viewport if not specified. 00081 Note drawings on the main screen needs a SwapScreenBuffer() to be shown at each frames. 00082 \param _pMatrix Internal3DMatrixStack 00083 \param _pMeshBuffer InternalObject3DBuffer 00084 \param _pTexture InternalTexture or nothing, will draw shades. 00085 */ 00086 virtual void RenderMesh( InternalObject3DBuffer *_pMeshBuffer, 00087 InternalTexture *_pTexture=0L 00088 ) ; 00089 /*! 00090 \brief Render directly a 32bit pixel bitmap image from memory on a viewport. 00091 Note drawings on the main screen needs a SwapScreenBuffer() to be shown at each frames. 00092 \param _prgbaTable pointer to the beginning of a 32bit RGBA table. 00093 \param _PixelWidth number of pixel of a line 00094 \param _PixelHeight number of pixel lines. 00095 */ 00096 virtual void DrawRGBARectangle( 00097 unsigned char *_prgbaTable, 00098 unsigned int _PixelWidth, 00099 unsigned int _PixelHeight 00100 ) ; 00101 /*! 00102 \brief Swap buffer so that what was drawn on the viewport is shown. 00103 this is needed to active all Clear(), RenderMesh() ,... 00104 It has to be done with main screen viewport like texture-rendering 00105 viewports. 00106 */ 00107 virtual void SwapBuffer(); 00108 /* 00109 \brief Change the coodinates of the clipping borders of a ViewPort, 00110 in the origin of its father.default is 0.0,0.0,1.0,1.0 00111 If the ViewPort is a Root ViewPort, like the main screen, 00112 or a texture rendering, it is inactive. 00113 \param _ClippingX1 upperleft corner in [0,1] scale for visible bounds. 00114 \param _ClippingY1 upperleft corner in [0,1] scale for visible bounds. 00115 \param _ClippingX2 downright corner in [0,1] scale for visible bounds. 00116 \param _ClippingY2 downright corner in [0,1] scale for visible bounds. 00117 */ 00118 virtual void SetClippingCoordinates(float _ClippingX1,float _ClippingY1,float _ClippingX2,float _ClippingY2 ); 00119 /* 00120 \brief Change the coodinates of the draw scale of a ViewPort, in the origin 00121 of its father. default is 0.0,0.0,1.0,1.0 00122 If the ViewPort is a Root ViewPort, like the main screen, 00123 or a texture rendering, it is inactive. 00124 \param _ScaleX1 upperleft corner in [0,1] scale for aspect ratio . 00125 \param _ScaleY1 upperleft corner in [0,1] scale for aspect ratio . 00126 \param _ScaleX2 downright corner in [0,1] scale for aspect ratio . 00127 \param _ScaleY2 downright corner in [0,1] scale for aspect ratio . 00128 */ 00129 virtual void SetScaleCoordinates(float _ScaleX1,float _ScaleY1,float _ScaleX2,float _ScaleY2 ); 00130 00131 /*! 00132 \brief Change the root viewport pixel resolution.This is a low level call in case of resize or screen init. 00133 \param _pixelWidth 00134 \param _pixelHeight 00135 */ 00136 void ResetRootPixelSize( unsigned int _pixelWidth,unsigned int _pixelHeight ); 00137 /*! 00138 \brief get the rectangle pixel coordinates in the root viewport bitmap. 00139 \return pixel 00140 */ 00141 inline int GetPixelX1(){ return m_pixel_x1; }; 00142 /*! 00143 \brief get the rectangle pixel coordinates in the root viewport bitmap. 00144 \return pixel 00145 */ 00146 inline int GetPixelY1(){ return m_pixel_y1; }; 00147 /*! 00148 \brief get the rectangle pixel coordinates in the root viewport bitmap. 00149 \return pixel 00150 */ 00151 inline int GetPixelX2(){ return m_pixel_x2; }; 00152 /*! 00153 \brief get the rectangle pixel coordinates in the root viewport bitmap. 00154 \return pixel 00155 */ 00156 inline int GetPixelY2(){ return m_pixel_y2; }; 00157 //! for 3D rendering, Distance between the projected plane and the center. must be >0.001 00158 inline float GetFov() { return m_fov; }; 00159 //! 00160 inline float GetNearCutPlane() { return m_NearCutPlane; }; 00161 //! 00162 inline float GetFarCutPlane() { return m_FarCutPlane; }; 00163 00164 //! 2d Scale coordinates of the rectangle recomputed in the Root ViewPort scale. 00165 float m_ScaleRootX1; 00166 float m_ScaleRootY1; 00167 float m_ScaleRootX2; 00168 float m_ScaleRootY2; 00169 00170 //! 2d coordinates of the rectangle recomputed in the Root ViewPort scale. 00171 float m_ClippingRootX1; 00172 float m_ClippingRootY1; 00173 float m_ClippingRootX2; 00174 float m_ClippingRootY2; 00175 00176 //! real clipped frustrum 00177 float m_FinalClipFrustrumX1; 00178 float m_FinalClipFrustrumY1; 00179 float m_FinalClipFrustrumX2; 00180 float m_FinalClipFrustrumY2; 00181 00182 //! in case of texture rendering, otherwise 0L: 00183 DCInternalTexture *m_pRenderTexture; 00184 //! for texture rendering, we manage the PVR mem: 00185 pvr_ptr_t m_pvrmem; 00186 //! OGL texture: 00187 int m_RenderTextureOGLHandle; 00188 00189 /*! 00190 \brief Tool for other methods: Set the current GL viewport matrix to an InternalViewPort. 00191 */ 00192 //virtual void SetGLToViewPort(); 00193 /* 00194 \brief Matrix_ 00195 */ 00196 virtual void Matrix_LoadID(eLoadId _enum=eLoadId_All); 00197 virtual void Matrix_Translate(float _x,float _y,float _z); 00198 virtual void Matrix_Rotate( float _angle,float _x,float _y,float _z); 00199 virtual void Matrix_Scale(float _sx,float _sy,float _sz); 00200 virtual void Matrix_Push(); 00201 virtual void Matrix_Pop(); 00202 VedaMachineDreamcast *m_pMachine; 00203 00204 00205 protected: 00206 //! if false, can't be drawn, because invalid coordinates. 00207 bool m_Valid; 00208 //! the rectangle coordinates in term of screen pixel. 00209 int m_pixel_x1; 00210 //! the rectangle coordinates in term of screen pixel. 00211 int m_pixel_y1; 00212 //! the rectangle coordinates in term of screen pixel. 00213 int m_pixel_x2; 00214 //! the rectangle coordinates in term of screen pixel. 00215 int m_pixel_y2; 00216 //! we manage a 3D transformation matrix 00217 MatrixModel m_Matrix; 00218 00219 /* 00220 \brief Change the coodinates of the ViewPort pixels, in its root origin. 00221 Used by SetCoordinates(). Non-Virtual. Reset the hierarchy down. 00222 */ 00223 void ResetPixelCoordinates(); 00224 00225 //! the pointer where this viewport was attached in the clipping hierarchy, father or brother. 00226 //! Used to destroy the object. Use ClippingHierarchy_AttachTo to change it. 00227 InternalViewPort **m_ppClippingHierarchyAttached; 00228 #ifdef _ENGINE_EDITABLE_ 00229 /* 00230 \brief tool: invalidate down the viewport hierachy when a viewport is destroyed. 00231 */ 00232 void ClippingDetach(); 00233 #endif 00234 00235 }; 00236 00237 /*! 00238 \class DCInternalObject3DBuffer 00239 \brief Nested class that implements a 3D object as a vertex and a polygon list. 00240 You ask the creation of it with VirtualMachine::NewObject3DBuffer(), 00241 then defines its shape by filling the list you get with GetFirstVertex() 00242 and GetFirstTriangle(), then it can be rendered with VirtualMachine::RenderMesh(). 00243 In order to optimize a static shape, use VirtualMachine::CompileObject3DBufferAsStatic() 00244 In edition mode, it can be destroyed with VirtualMachine::DeleteObject3DBuffer(). 00245 */ 00246 class DCInternalObject3DBuffer : public InternalObject3DBuffer 00247 { public: 00248 /*! 00249 \brief A call to CompileObject3DBufferAsStatic() will fix the current geometry of an object. 00250 It will try to use the 3D buffer compilation of a given machine, which can fasten the drawing. 00251 From that moment on, further modification to its shape will be useless. 00252 */ 00253 virtual void CompileAsStatic( ); 00254 /*! 00255 \brief return true is CompileAsStatic() were used. 00256 \return true is CompileAsStatic() were used, false if still dynamic. 00257 */ 00258 virtual bool IsCompiledAsStatic(); 00259 /*! 00260 \brief Get the beginning of the vertex list. Assume the maximum number of vertex 00261 was given by NewObject3DBuffer() and can be read with GetMaximumNumberOfVertexes(). 00262 \return a pointer to the first Vertex. 00263 */ 00264 virtual InternalVertex *GetFirstVertex(); 00265 /*! 00266 \brief Get the beginning of the Triangle list. Assume the maximum number of Triangle 00267 was given by NewObject3DBuffer() and can be read with GetMaximumNumberOfTriangles(). 00268 last Note: the first triangle returned already use the offset given with SetNumberOfActiveTriangle(): _FirstActiveTriangleIndex. 00269 \return a pointer to the first Vertex. 00270 */ 00271 virtual InternalTriangle *GetFirstTriangle(); 00272 /*! 00273 \brief Set the number of active triangle defined in the triangle list. 00274 note the active number of vertex is actually given by the highest vertex 00275 number used by one of the active triangle. If _CurrentNumberOfTriangle is 00276 greater than GetMaximumNumberOfTriangles(), it is set to zero. 00277 _FirstActiveTriangleIndex is an optional offset in the triangle list. 00278 it allows the rendering of a mesh with multiple textures, by 00279 setting a windowing in the triangle list and using 00280 multiple calls to RenderMesh(). Default is zero, start of the list. 00281 \param _CurrentNumberOfTriangle the new number of triangle in the object. 00282 \param _FirstActiveTriangleIndex optional active triangle offset in list. 00283 */ 00284 virtual void SetNumberOfActiveTriangle( unsigned int _CurrentNumberOfTriangle,unsigned int _FirstActiveTriangleIndex=0 ); 00285 00286 /*! 00287 \brief Get the number of active triangle defined by SetNumberOfActiveTriangle(). 00288 \return the number of triangle in the object. 00289 */ 00290 virtual unsigned int GetNumberOfActiveTriangle(); 00291 /*! 00292 \brief the maximum number of elements in table GetFirstVertex() 00293 \return the maximum number of elements in table GetFirstVertex() 00294 */ 00295 virtual unsigned int GetMaximumNumberOfVertexes(); 00296 /*! 00297 \brief the maximum number of elements in table GetFirstTriangle() 00298 \return the maximum number of elements in table GetFirstTriangle() 00299 */ 00300 virtual unsigned int GetMaximumNumberOfTriangles(); 00301 /*! 00302 \brief Set the color for the whole object. Active if object was not created with bOb3D_EnableRGB or bOb3D_EnableAlpha. 00303 \param _red color component 00304 \param _green color component 00305 \param _blue color component 00306 \param _alpha color component 00307 */ 00308 virtual void SetColor(float _red,float _green,float _blue,float _alpha=1.0f); 00309 00310 //! real implementation of the vertex base. 00311 InternalVertex *m_pVertexBase; 00312 //! real implementation of the triangle base. 00313 InternalTriangle *m_pTriangleBase; 00314 //! First Active Triangle Index 00315 unsigned int m_FirstActiveTriangleIndex; 00316 //! current number of active triangle set by SetNumberOfActiveTriangle() 00317 unsigned int m_NumberOfActiveTriangles; 00318 //! If !=0, It is an OpenGL compiled process: 00319 unsigned int m_CompiledObjectHandler; 00320 //! the maximum number of vertex, and the size of the vertex list returned by GetFirstVertex(). 00321 unsigned int m_MaximumNumberOfVertexes; 00322 //! the maximum number of Triangles, and the size of the triangle list returned by GetFirstTriangle(). 00323 unsigned int m_MaximumNumberOfTriangles; 00324 //! tells which vertex members are enabled; use VirtualMachine::bOB3d_xxx 00325 unsigned int m_ExtraMemberFlags; 00326 //! main color of the object(RGBA, [0.0,1.0]): (note:there is also vertex colors) 00327 float m_Color[4]; 00328 //! DC special: environment mapping computation. nb=m_MaximumNumberOfVertexes*2 00329 float *m_pVertexEnvironmentUV; 00330 }; 00331 /*! 00332 \class DCInternalTexture 00333 Nested Class that defines a texture to render an object with VirtualMachine::RenderMesh(). 00334 */ 00335 class DCInternalTexture : public InternalTexture 00336 { public: 00337 /*! 00338 \brief Constructor 00339 */ 00340 DCInternalTexture(void); 00341 /*! 00342 \brief Set or change the render flags for a texture. 00343 \param _flags or'ed bit flags ( itf_... flags) 00344 */ 00345 virtual void SetRenderFlags( unsigned int _flags ); 00346 /*! 00347 \brief Set base color, default to 1.0f,1.0f,1.0f,1.0f 00348 \param _rgba Red Green Blue and Alpha transparency components. 00349 */ 00350 virtual void SetBaseColor( float _rgba[4] ); 00351 /*! 00352 \brief Get the render flags for a texture. 00353 \return or'ed bit flags (InternalTextureFlagBitsEnum) 00354 */ 00355 virtual unsigned int GetRenderFlags( ); 00356 /*! 00357 \brief set an image layer for a texture. see layers with itile_... enums. 00358 \param _layerToSet the enum that define which layer to change. 00359 \param _pByteChunk pointer to a byte chunk 00360 \param _pixelByteDepth number of bytes per pixel in _pByteChunk. 00361 \param _pixelWidth the number of pixel in a row 00362 \param _pixelHeight 00363 */ 00364 virtual void SetImageBitmap( TextureImageLayerEnum _layerToSet, 00365 const unsigned char *_pByteChunk, 00366 unsigned int _pixelByteDepth, 00367 unsigned int _pixelWidth, 00368 unsigned int _pixelHeight 00369 ); 00370 static const int m_MaxNumberOfLayer=2; 00371 //! \class Layer 00372 //! `\brief nested class for private use. 00373 class Layer { public: 00374 unsigned int m_OGLTextureHandler; 00375 unsigned int m_BitmapPixelWidth; 00376 unsigned int m_BitmapPixelHeight; 00377 //! video mem: 00378 pvr_ptr_t m_txaddr; 00379 }; 00380 //! OGL texture handlers: simple map+env. 00381 Layer m_Layer[m_MaxNumberOfLayer]; 00382 //! OGL texture handlers: simple map+env. 00383 //unsigned int m_OGLTextureHandler[2]; 00384 //! current flags set 00385 unsigned int m_flags; 00386 //! the base color, which is modulated on mapping layer. 00387 float m_BaseColorRGBA[4]; 00388 //! tell which layer is active: 00389 unsigned int m_ActiveLayerFlag; 00390 //! true if ARGBA were used as pixel format (then the mesh will be declared translucent) 00391 bool m_BitmapImageUseAlpha; 00392 //! in case of render to texture with render extension: 00393 //int m_frameBuffer; 00394 //! in case of render to texture with render extension: 00395 //int m_depthRenderBuffer; 00396 }; 00397 00398 /*! 00399 \brief Init the machine. It would open a screen and do the init for each theme (3D,sound,...) 00400 the machine closing should be done at deletion. 00401 \return vmr_OK or vmr_FAILED 00402 */ 00403 virtual eVMResult InitMachine(); 00404 /*! 00405 \brief Ask the Creation of a new InternalObject3DBuffer you can then fill with 00406 InternalObject3DBuffer::GetFirstVertex() , InternalObject3DBuffer::GetFirstTriangle() 00407 and InternalObject3DBuffer::SetNumberOfActiveTriangle() . 00408 Then the object can be positionned with the matrix methods, and drawn with RenderMesh() 00409 The object shape can be dynamic and rebuilt, until a call to CompileObject3DBufferAsStatic(). 00410 In edition mode, object has to be destroyed with DeleteObject3DBuffer(). 00411 \param _ppVertexAndPolygonBufferOut the object returned, or 0L if failed.(no mem ?) 00412 \param _maxNbVertex maximum number of vertex to fill. 00413 \param _maxNbTriangle maximum number of Triangle to fill. 00414 \param _extraMemberFlags or'ed bits (bOb3D_...) to activate extra vertex members. 00415 */ 00416 virtual void NewObject3DBuffer( InternalObject3DBuffer **_ppVertexAndPolygonBufferOut, 00417 unsigned int _maxNbVertex, 00418 unsigned int _maxNbTriangle, 00419 unsigned int _extraMemberFlags ); 00420 00421 /* 00422 \brief Destroy objects previously created with NewObject3DBuffer() 00423 \param _ppBufferToDestroy object to destroy, and set to 0L. 00424 */ 00425 virtual void DeleteObject3DBuffer( InternalObject3DBuffer **_ppBufferToDestroy ); 00426 00427 /*! 00428 \brief Ask the Creation of a new InternalTexture, then used to render 3D objects with RenderMesh(). 00429 In edition mode, InternalTexture has to be destroyed with DeleteTexture(). 00430 \param _ppTextureOut the object returned, or 0L if failed.(no mem ?) 00431 */ 00432 virtual void NewTexture( InternalTexture **_ppTextureOut ); 00433 #ifdef _ENGINE_EDITABLE_ 00434 /*! 00435 \brief Destroy objects previously created with NewTexture() 00436 \param _ppTextureToDestroy object to destroy, and set to 0L. 00437 */ 00438 virtual void DeleteTexture( InternalTexture **_ppTextureToDestroy ); 00439 #endif 00440 00441 /*! 00442 \brief Ask the Creation of a new InternalViewPort, that must be the child of another ViewPort, 00443 specified by _pFatherViewPort.if no father is specified, the new ViewPort will be 00444 the child of the default root ViewPort. To create another Root ViewPort, create a texture 00445 and use VirtualMedia::NewViewPortOnTexture(). 00446 In edition mode, each InternalViewPort has to be destroyed with DeleteViewPort(). 00447 \param _ppViewPortOut the object returned, or 0L if failed.(no mem ?) 00448 \param _pFatherViewPort the father viewport. If 0L, it uses the default root. 00449 */ 00450 virtual void NewViewPortChild( InternalViewPort **_ppViewPortOut,InternalViewPort *_pFatherViewPort=0L); 00451 /*! 00452 \brief Ask the Creation of a new Root InternalViewPort, that will render on a texture image. 00453 specified by _pRootTexture. You got to create a texture first for parameter _pRootTexture. 00454 In edition mode, each InternalViewPort has to be destroyed with DeleteViewPort(). 00455 \param _ppViewPortOut the object returned, or 0L if failed.(no mem ?) 00456 \param _pRootTexture an InternalTexture. Can't be null. 00457 \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. 00458 \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. 00459 \param _layerToAffect the texture layer (simple mapping, environment) where to render. 00460 */ 00461 virtual void NewViewPortOnTexture( InternalViewPort **_ppViewPortOut, 00462 InternalTexture *_pRootTexture, 00463 unsigned int _np2PixelWidth, 00464 unsigned int _np2PixelHeight, 00465 InternalTexture::TextureImageLayerEnum _layerToAffect); 00466 00467 00468 /*! 00469 \brief Destroy any objects previously created with NewViewPortChild() or NewViewPortOnTexture(). 00470 \param _ppViewPortToDestroy pointer to object to destroy, and set to 0L. 00471 */ 00472 virtual void DeleteViewPort( InternalViewPort **_ppViewPortToDestroy ); 00473 00474 /*! 00475 \brief Swap buffer so that what was drawn on the main screen is shown. 00476 */ 00477 virtual void SwapScreenBuffer(); 00478 /*! 00479 \brief Return the machine main play frequency, in herz, (tick per sec). 00480 \return freq (44100.0,22050.0,...) 00481 */ 00482 virtual float GetPlayFrequency(); 00483 /*! 00484 \brief force a date to the clock passed to the sound objects. 00485 \param _seconds in second units. 00486 \param _fraction the following after-the-point-units of _seconds, like if the whole were a 64 bits integer. 00487 */ 00488 virtual void SetSoundCurrentTime(int _seconds,unsigned int _fraction ); 00489 /*! 00490 \brief tool: change main volume [0,1]. 00491 Yes, you can saturate when >1. 00492 \param _newVolumeValue [0,1] 00493 */ 00494 virtual void SetSoundVolume(float _newVolumeValue); 00495 /*! 00496 \brief tool: get main volume value [0,1]. 00497 \return VolumeValue [0,1] 00498 */ 00499 virtual float GetSoundVolume(); 00500 /*! 00501 \brief For Information, an image of the current sound buffer. 00502 This is always a 2 float(left,right) table: 00503 The buffer size may vary. It can be used by preview methods or 00504 live effects. 00505 \param _ppSoundBuffer pointer on pointer on the buffer to return. 00506 \param _pLength pointer on a unsigned int that return the length. 00507 */ 00508 virtual void GetCurrentSoundBufferImage(float ** const _ppSoundBuffer,unsigned int *_pLength) const ; 00509 /*! 00510 \brief Return the language of the machine, as a simple enum. It can be used 00511 to display one or the other langage. 00512 \return an enum integer. 00513 */ 00514 virtual eMachineLocalization GetCurrentWorldLocalizationEnum(); 00515 00516 /*! 00517 \brief Process the Machine's interface messages (mouse,keyboard,...), in the real time. 00518 Then methods like VirtualMachine::GetQuitMessage() are updated. 00519 */ 00520 virtual void ProcessInterface(); 00521 00522 00523 00524 float GetCurrentTime( ); 00525 00526 void SetCurrentTime( float _timeSec ); 00527 00528 /*! 00529 \brief Process the Machine's interface messages (mouse,keyboard,...), in the real time. 00530 Then methods like VirtualMachine::GetQuitMessage() are updated. 00531 */ 00532 inline void SetRate( float _rate){ m_timerate = _rate ; }; 00533 00534 /* 00535 void printtest(){ 00536 printf("nbtranslu:%d\n",m_NumberOfTranslucentObjects);}; 00537 */ 00538 /*================================================================== 00539 PROTECTED 00540 ==================================================================*/ 00541 protected: 00542 00543 00544 //! link the machine to a static machine list, because sound mixing is static for more than one machine: 00545 static VedaMachineDreamcast *m_pFirstMachine; 00546 VedaMachineDreamcast *m_pNextMachine; 00547 // ----------------------------------- 00548 //! 1st pad: 00549 unsigned int m_FirstController; 00550 //! 00551 unsigned int m_MachineLocalization; 00552 //! 00553 unsigned int m_PixelWidth; 00554 //! 00555 unsigned int m_PixelHeight; 00556 //! 00557 VedaMachineDreamcast::DCInternalViewPort *m_pCurrentActiveViewport; 00558 //! 00559 void SetCurrentActiveViewport(DCInternalViewPort *_pViewport); 00560 // ------------------------------------------- 00561 //! sound mix rate: 22050,44100 , ... 00562 static unsigned int m_MixRate; 00563 //! float version: 00564 static float m_fPlayFrequency; 00565 //! 1/m_fPlayFrequency 00566 //float m_1OverMixRate; 00567 //! sound stuff 00568 unsigned int m_TotalPlaySize; 00569 //! 00570 int m_LastStartPlayTime_SecondUnit; 00571 //! 00572 unsigned int m_LastStartPlayTime_SecondFrac; 00573 //! synchronize more. 00574 //unsigned int m_TimeShift; 00575 //! 00576 bool InitSound(); 00577 //! 00578 void ExitSound(); 00579 //! 00580 static void *StreamCallBack(int _p1, int *_pp2); 00581 00582 static void SoundServer_thread(void *p); 00583 //! 32768 00584 static const unsigned int m_SoundBufferLength=4096; 00585 static const unsigned int m_NumberOfBuf=16; // 2^n 00586 static short *m_pShortSoundBuffer; 00587 // we alloc a larger sound buffer to 00588 static float *m_pFloatSoundBufferAlloc; 00589 static unsigned int m_SoundBufferIndex; 00590 00591 //static float *m_pFloatSoundBuffer2; 00592 static unsigned int m_LastSoundBufferLength[m_NumberOfBuf]; 00593 00594 static volatile bool m_SoundThreadGotToQuit; 00595 static volatile bool m_SoundThreadIsOn; 00596 unsigned int m_CurrentPolyListIndex; // KOS poly list system current index. 00597 00598 //! translucent mesh list, for pass 2 rendering for kgl. cf SwapScreenBuffer() 00599 static const unsigned int m_TranslucentListMaximumDepth=240; 00600 //! the real alloc for m_pTranslucentMatrixList, because it must be 32b aligned. 00601 unsigned char *m_pAllocChunkForTranslucentList; 00602 00603 //! \struct _translucentMeshToRender MUST BE 32b aligned !!! 00604 typedef struct _translucentMeshToRender 00605 { public: 00606 // sizeof:64 00607 matrix_t m_matrix; 00608 // sizeof 4 00609 DCInternalObject3DBuffer *m_pObject; 00610 // 4 00611 unsigned int m_GLTextureHandler; 00612 //! 4 00613 unsigned int m_renderFlags; 00614 //! 4 00615 unsigned int m_IsEnvironment; 00616 //! 16b. color and alpha, may be transparent: 00617 float m_rgba[4]; 00618 float m_fov; 00619 float m_near; 00620 float m_far; 00621 float m_dummy[5]; 00622 } translucentMeshToRender ; // sizeof: 32+64=96 00623 //! 00624 translucentMeshToRender *m_pTranslucentMeshList; 00625 //! 00626 unsigned int m_NumberOfTranslucentObjects; 00627 00628 unsigned int m_LastProcessInterfaceClock; 00629 //! last 00630 unsigned int m_lastButtonCondition; 00631 //! 00632 unsigned int m_interfaceStateBits; 00633 unsigned int m_ChoicePannelIndex; 00634 float m_QuitChoicePanelAlpha; 00635 float m_TimePanelAlpha; 00636 float m_timerate; 00637 //! 00638 float m_StartTime; 00639 //! 00640 float m_TimeSpeed; 00641 int m_ClockStart; 00642 00643 static const unsigned int m_bs_QuitChoicePanelIsOn=1; 00644 }; 00645 00646 00647 #endif
/\/\ 4 N k ! N D _______ _ __ ___ _____ ___ _ _ ____ ___________ __//___ /________ |/ / ___________\_______/ \ / _ _ \/ _ / _ / _/_/____/ _ __ / / / / / / / \ \/ / / \ \ / \\___/___/___/ ¯ _____/_____/ ______\___/_____/\________\\ \________/_ ___ __ l____\ /elD! http://www.m4nkind.com \____/