00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #pragma once
00024
00025 #include <OgreGPGPUPrerequisites.h>
00026
00027 #include <OgreMaterial.h>
00028 #include <OgreHardwarePixelBuffer.h>
00029 #include <OgreCamera.h>
00030 #include <OgreRectangle2D.h>
00031
00032 namespace Ogre
00033 {
00034 namespace GPGPU
00035 {
00036 class Operation;
00037 class Result;
00038
00039 class _OgreGPGPUExport Root
00040 {
00041 public:
00042 Root();
00043 virtual ~Root();
00044
00045 void compute(Result* result, Operation* operation);
00046 virtual void waitForCompletion();
00047
00048 Operation* createOperation(Ogre::Pass* pass);
00049 Operation* createOperation(const std::string& pixelShaderName);
00050 Result* createResult(Ogre::HardwarePixelBufferSharedPtr pixelBuffer);
00051 void destroyOperation(Operation* operation);
00052 void destroyResult(Result* result);
00053
00054 static Root* createRoot(Ogre::RenderWindow* renderWindow, Ogre::RenderSystem* renderSystem);
00055 static void destroyRoot(Root* root);
00056
00057 protected:
00058 int mMaterialCounter;
00059 Ogre::Camera* mCamera;
00060 Ogre::SceneManager* mSceneManager;
00061 Ogre::Rectangle2D* mQuad;
00062 Ogre::RenderOperation mRenderOperation;
00063 };
00064
00065 class _OgreGPGPUExport Operation
00066 {
00067 friend class Root;
00068 public:
00069 Operation(Ogre::Pass* pass);
00070 void setInput(Ogre::Texture* texture);
00071 void setParameter(const std::string& name, Ogre::Real value);
00072
00073 protected:
00074 Ogre::Pass* mPass;
00075 };
00076
00077 class _OgreGPGPUExport Result
00078 {
00079 friend class Root;
00080 public:
00081 Result(Ogre::HardwarePixelBufferSharedPtr pixelBuffer, Ogre::Camera* cam);
00082 void save(const std::string& filename);
00083
00084 protected:
00085 Ogre::HardwarePixelBufferSharedPtr mPixelBuffer;
00086 Ogre::RenderTexture* mRenderTexture;
00087 Ogre::Viewport* mViewport;
00088 };
00089 }
00090 }