nomlib
Loading...
Searching...
No Matches
RocketSDL2RenderInterface.hpp
1/******************************************************************************
2
3 nomlib - C++11 cross-platform game engine
4
5Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6All rights reserved.
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions are met:
10
111. Redistributions of source code must retain the above copyright notice, this
12 list of conditions and the following disclaimer.
132. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28******************************************************************************/
29#ifndef NOMLIB_GUI_ROCKET_SDL2_RENDER_INTERFACE_HPP
30#define NOMLIB_GUI_ROCKET_SDL2_RENDER_INTERFACE_HPP
31
32// #include <memory>
33
34#include <Rocket/Core/Core.h>
35#include <Rocket/Core/RenderInterface.h>
36
37#include "export.hpp"
38#include "nomlib/config.hpp"
39
40#if defined(NOM_PLATFORM_WINDOWS)
41 #define NOM_API_EXPORT __stdcall
42#else
43 #define NOM_API_EXPORT
44#endif
45
46namespace nom {
47
48namespace priv {
49
50typedef void (NOM_API_EXPORT* glUseProgramObjectARB_func) (unsigned int);
51
52} // namespace priv
53
54// Forward declarations
55class RenderWindow;
56
63class NOM_EXPORT RocketSDL2RenderInterface: public Rocket::Core::RenderInterface
64{
65 public:
81 static bool gl_init( int width, int height );
82
83 RocketSDL2RenderInterface( RenderWindow* window );
84
85 virtual ~RocketSDL2RenderInterface();
86
90 virtual void Release();
91
93 virtual void
94 RenderGeometry( Rocket::Core::Vertex* vertices, int num_vertices,
95 int* indices, int num_indices,
96 Rocket::Core::TextureHandle texture_handle,
97 const Rocket::Core::Vector2f& translation);
98
100 virtual void EnableScissorRegion(bool enable);
101
107 virtual void SetScissorRegion(int x, int y, int width, int height);
108
110 virtual bool LoadTexture(Rocket::Core::TextureHandle& texture_handle, Rocket::Core::Vector2i& texture_dimensions, const Rocket::Core::String& source);
112 virtual bool GenerateTexture(Rocket::Core::TextureHandle& texture_handle, const Rocket::Core::byte* source, const Rocket::Core::Vector2i& source_dimensions);
113
115 virtual void
116 ReleaseTexture(Rocket::Core::TextureHandle texture_handle);
117
122
123 private:
128 static priv::glUseProgramObjectARB_func ctx_;
129};
130
131} // namespace nom
132
133#endif // include guard defined
static bool gl_init(int width, int height)
Initialize OpenGL with the necessary settings for libRocket and SDL2 to be all friendly.
virtual void RenderGeometry(Rocket::Core::Vertex *vertices, int num_vertices, int *indices, int num_indices, Rocket::Core::TextureHandle texture_handle, const Rocket::Core::Vector2f &translation)
Called by Rocket when it wants to render geometry that it does not wish to optimise.
virtual void SetScissorRegion(int x, int y, int width, int height)
Called by Rocket when it wants to change the scissor region.
static priv::glUseProgramObjectARB_func ctx_
Shader context function pointer.
virtual void Release()
Implements Rocket::Core::SystemInterface::Release.
virtual void ReleaseTexture(Rocket::Core::TextureHandle texture_handle)
Called by Rocket when a loaded texture is no longer required.
RenderWindow * window_
nomlib interface bridge between SDL2 and libRocket
virtual bool GenerateTexture(Rocket::Core::TextureHandle &texture_handle, const Rocket::Core::byte *source, const Rocket::Core::Vector2i &source_dimensions)
Called by Rocket when a texture is required to be built from an internally-generated sequence of pixe...
virtual bool LoadTexture(Rocket::Core::TextureHandle &texture_handle, Rocket::Core::Vector2i &texture_dimensions, const Rocket::Core::String &source)
Called by Rocket when a texture is required by the library.
virtual void EnableScissorRegion(bool enable)
Called by Rocket when it wants to enable or disable scissoring to clip content.