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