Panda3D
|
00001 // Filename: rocketRenderInterface.h 00002 // Created by: rdb (04Nov11) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef ROCKET_RENDER_INTERFACE_H 00016 #define ROCKET_RENDER_INTERFACE_H 00017 00018 #include "config_rocket.h" 00019 #include "cullTraverser.h" 00020 #include "cullTraverserData.h" 00021 #include "geom.h" 00022 #include "renderState.h" 00023 #include "transformState.h" 00024 00025 #include <Rocket/Core/RenderInterface.h> 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : RocketRenderInterface 00029 // Description : Class that provides the main render interface for 00030 // libRocket integration. 00031 //////////////////////////////////////////////////////////////////// 00032 class RocketRenderInterface : public Rocket::Core::RenderInterface { 00033 public: 00034 void render(Rocket::Core::Context* context, CullTraverser *trav); 00035 00036 protected: 00037 struct CompiledGeometry { 00038 CPT(Geom) _geom; 00039 CPT(RenderState) _state; 00040 }; 00041 00042 PT(Geom) make_geom(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, GeomEnums::UsageHint uh); 00043 void render_geom(const Geom* geom, const RenderState* state, const Rocket::Core::Vector2f& translation); 00044 00045 void RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation); 00046 Rocket::Core::CompiledGeometryHandle CompileGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture); 00047 void RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry, const Rocket::Core::Vector2f& translation); 00048 void ReleaseCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry); 00049 00050 bool LoadTexture(Rocket::Core::TextureHandle& texture_handle, 00051 Rocket::Core::Vector2i& texture_dimensions, 00052 const Rocket::Core::String& source); 00053 bool GenerateTexture(Rocket::Core::TextureHandle& texture_handle, 00054 const Rocket::Core::byte* source, 00055 const Rocket::Core::Vector2i& source_dimensions); 00056 void ReleaseTexture(Rocket::Core::TextureHandle texture_handle); 00057 00058 void EnableScissorRegion(bool enable); 00059 void SetScissorRegion(int x, int y, int width, int height); 00060 00061 private: 00062 Mutex _lock; 00063 00064 // Hold the scissor settings and whether or not to enable scissoring. 00065 bool _enable_scissor; 00066 LVecBase4f _scissor; 00067 00068 // These are temporarily filled in by render(). 00069 CullTraverser *_trav; 00070 CPT(TransformState) _net_transform; 00071 CPT(RenderState) _net_state; 00072 Rocket::Core::Vector2i _dimensions; 00073 }; 00074 00075 #endif