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 "nomlib/config.hpp"
38
39#if defined(NOM_PLATFORM_WINDOWS)
40 #define NOM_API_EXPORT __stdcall
41#else
42 #define NOM_API_EXPORT
43#endif
44
45namespace nom {
46
47namespace priv {
48
49typedef void (NOM_API_EXPORT* glUseProgramObjectARB_func) (unsigned int);
50
51} // namespace priv
52
53// Forward declarations
54class RenderWindow;
55
62class RocketSDL2RenderInterface: public Rocket::Core::RenderInterface
63{
64 public:
80 static bool gl_init( int width, int height );
81
82 RocketSDL2RenderInterface( RenderWindow* window );
83
84 virtual ~RocketSDL2RenderInterface();
85
89 virtual void Release();
90
92 virtual void
93 RenderGeometry( Rocket::Core::Vertex* vertices, int num_vertices,
94 int* indices, int num_indices,
95 Rocket::Core::TextureHandle texture_handle,
96 const Rocket::Core::Vector2f& translation);
97
99 virtual void EnableScissorRegion(bool enable);
100
106 virtual void SetScissorRegion(int x, int y, int width, int height);
107
109 virtual bool LoadTexture(Rocket::Core::TextureHandle& texture_handle, Rocket::Core::Vector2i& texture_dimensions, const Rocket::Core::String& source);
111 virtual bool GenerateTexture(Rocket::Core::TextureHandle& texture_handle, const Rocket::Core::byte* source, const Rocket::Core::Vector2i& source_dimensions);
112
114 virtual void
115 ReleaseTexture(Rocket::Core::TextureHandle texture_handle);
116
121
122 private:
127 static priv::glUseProgramObjectARB_func ctx_;
128};
129
130} // namespace nom
131
132#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.