Panda3D
rocketRenderInterface.h
1 // Filename: rocketRenderInterface.h
2 // Created by: rdb (04Nov11)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef ROCKET_RENDER_INTERFACE_H
16 #define ROCKET_RENDER_INTERFACE_H
17 
18 #include "config_rocket.h"
19 #include "cullTraverser.h"
20 #include "cullTraverserData.h"
21 #include "geom.h"
22 #include "renderState.h"
23 #include "transformState.h"
24 
25 #include <Rocket/Core/RenderInterface.h>
26 
27 ////////////////////////////////////////////////////////////////////
28 // Class : RocketRenderInterface
29 // Description : Class that provides the main render interface for
30 // libRocket integration.
31 ////////////////////////////////////////////////////////////////////
32 class RocketRenderInterface : public Rocket::Core::RenderInterface {
33 public:
34  void render(Rocket::Core::Context* context, CullTraverser *trav);
35 
36 protected:
37  struct CompiledGeometry {
38  CPT(Geom) _geom;
39  CPT(RenderState) _state;
40  };
41 
42  PT(Geom) make_geom(Rocket::Core::Vertex* vertices,
43  int num_vertices, int* indices, int num_indices,
44  GeomEnums::UsageHint uh, const LVecBase2 &tex_scale);
45  void render_geom(const Geom* geom, const RenderState* state, const Rocket::Core::Vector2f& translation);
46 
47  void RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation);
48  Rocket::Core::CompiledGeometryHandle CompileGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture);
49  void RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry, const Rocket::Core::Vector2f& translation);
50  void ReleaseCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry);
51 
52  bool LoadTexture(Rocket::Core::TextureHandle& texture_handle,
53  Rocket::Core::Vector2i& texture_dimensions,
54  const Rocket::Core::String& source);
55  bool GenerateTexture(Rocket::Core::TextureHandle& texture_handle,
56  const Rocket::Core::byte* source,
57  const Rocket::Core::Vector2i& source_dimensions);
58  void ReleaseTexture(Rocket::Core::TextureHandle texture_handle);
59 
60  void EnableScissorRegion(bool enable);
61  void SetScissorRegion(int x, int y, int width, int height);
62 
63 private:
64  Mutex _lock;
65 
66  // Hold the scissor settings and whether or not to enable scissoring.
67  bool _enable_scissor;
68  LVecBase4 _scissor;
69 
70  // These are temporarily filled in by render().
71  CullTraverser *_trav;
72  CPT(TransformState) _net_transform;
73  CPT(RenderState) _net_state;
74  Rocket::Core::Vector2i _dimensions;
75 
76 };
77 
78 #endif
A standard mutex, or mutual exclusion lock.
Definition: pmutex.h:44
void render(Rocket::Core::Context *context, CullTraverser *trav)
Called by RocketNode in cull_callback.
A container for geometry primitives.
Definition: geom.h:58
This is the base class for all two-component vectors and points.
Definition: lvecBase2.h:105
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
Class that provides the main render interface for libRocket integration.
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
Definition: cullTraverser.h:48