Previous 199869 Revisions Next

r23972 Thursday 27th June, 2013 at 11:13:33 UTC by Miodrag Milanović
made guiengine and initialized librocket in it, lot of empty implementations for now (nw)
[/branches/micko/src/emu]emu.h emu.mak guiengine.c* guiengine.h* machine.c machine.h
[/branches/micko/src/tools]main.cpp

branches/micko/src/emu/guiengine.c
r0r23972
1/***************************************************************************
2
3    guiengine.c
4
5    GUI engine  of the core MAME system.
6
7****************************************************************************
8
9    Copyright Miodrag Milanovic
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY MIODRAG MILANOVIC ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL MIODRAG MILANOVIC BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
38***************************************************************************/
39#include <Rocket/Core.h>
40#include <Rocket/Debugger.h>
41#include <Rocket/Controls.h>
42
43#include "emu.h"
44#include "emuopts.h"
45#include "osdepend.h"
46
47
48class ShellSystemInterface : public Rocket::Core::SystemInterface
49{
50public:
51   /// Get the number of seconds elapsed since the start of the application
52   /// @returns Seconds elapsed
53   virtual float GetElapsedTime() { return 0; }
54};
55
56class ShellRenderInterfaceOpenGL : public Rocket::Core::RenderInterface
57{
58public:
59   ShellRenderInterfaceOpenGL()
60   {
61   }
62
63   /// Called by Rocket when it wants to render geometry that it does not wish to optimise.
64   virtual void RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation)
65   {
66   }
67
68   /// Called by Rocket when it wants to compile geometry it believes will be static for the forseeable future.
69   virtual Rocket::Core::CompiledGeometryHandle CompileGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture)
70   {
71      return (Rocket::Core::CompiledGeometryHandle) NULL;
72   }
73
74   /// Called by Rocket when it wants to render application-compiled geometry.
75   virtual void RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry, const Rocket::Core::Vector2f& translation)
76   {
77   }
78   
79   /// Called by Rocket when it wants to release application-compiled geometry.
80   virtual void ReleaseCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry)
81   {
82   }
83
84   /// Called by Rocket when it wants to enable or disable scissoring to clip content.
85   virtual void EnableScissorRegion(bool enable)
86   {
87   }
88   /// Called by Rocket when it wants to change the scissor region.
89   virtual void SetScissorRegion(int x, int y, int width, int height)
90   {
91   }
92
93   /// Called by Rocket when a texture is required by the library.
94   virtual bool LoadTexture(Rocket::Core::TextureHandle& texture_handle, Rocket::Core::Vector2i& texture_dimensions, const Rocket::Core::String& source)
95   {
96      return true;
97   }
98   /// Called by Rocket when a texture is required to be built from an internally-generated sequence of pixels.
99   virtual bool GenerateTexture(Rocket::Core::TextureHandle& texture_handle, const Rocket::Core::byte* source, const Rocket::Core::Vector2i& source_dimensions)
100   {
101      return true;
102   }
103   /// Called by Rocket when a loaded texture is no longer required.
104   virtual void ReleaseTexture(Rocket::Core::TextureHandle texture_handle)
105   {
106   }
107};
108
109ShellRenderInterfaceOpenGL opengl_renderer;
110ShellSystemInterface system_interface;
111Rocket::Core::Context* context = NULL;
112
113//**************************************************************************
114//  GUI ENGINE
115//**************************************************************************
116
117//-------------------------------------------------
118//  gui_engine - constructor
119//-------------------------------------------------
120
121gui_engine::gui_engine(running_machine &machine)
122   : m_machine(machine)
123{
124   context = NULL;   
125}
126
127//-------------------------------------------------
128//  ~gui_engine - destructor
129//-------------------------------------------------
130
131gui_engine::~gui_engine()
132{
133   shutdown();
134}
135
136//-------------------------------------------------
137//  initialize - initialize lua hookup to emu engine
138//-------------------------------------------------
139
140void gui_engine::initialize()
141{
142   // Rocket initialisation.
143   Rocket::Core::SetRenderInterface(&opengl_renderer);
144   
145   Rocket::Core::SetSystemInterface(&system_interface);
146   
147   Rocket::Core::Initialise();
148   // Initialise the Rocket Controls library.
149   Rocket::Controls::Initialise();
150   
151   // Create the main Rocket context and set it on the shell's input layer.
152   context = Rocket::Core::CreateContext("main", Rocket::Core::Vector2i(1920, 1080));
153   if (context == NULL)
154   {
155      Rocket::Core::Shutdown();
156      printf("Failed");
157      return;
158   }
159   Rocket::Debugger::Initialise(context);
160
161   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(gui_engine::shutdown), this));
162}
163
164//-------------------------------------------------
165//  shutdown - close and cleanup of gui engine
166//-------------------------------------------------
167
168void gui_engine::shutdown()
169{
170   // Shutdown Rocket.
171   if (context!=NULL)
172   {
173      context->RemoveReference();
174      Rocket::Core::Shutdown();   
175      context = NULL;
176   }
177}
178
179void gui_engine::update()
180{
181   context->Update();
182   context->Render();
183}
Property changes on: branches/micko/src/emu/guiengine.c
Added: svn:eol-style
   + native
Added: svn:mime-type
   + text/plain
branches/micko/src/emu/emu.mak
r23971r23972
7878   $(EMUOBJ)/emuopts.o \
7979   $(EMUOBJ)/emupal.o \
8080   $(EMUOBJ)/fileio.o \
81   $(EMUOBJ)/guiengine.o \
8182   $(EMUOBJ)/hash.o \
8283   $(EMUOBJ)/image.o \
8384   $(EMUOBJ)/info.o \
branches/micko/src/emu/guiengine.h
r0r23972
1/***************************************************************************
2
3    guiengine.h
4
5    GUI engine of the core MAME system.
6
7****************************************************************************
8
9    Copyright Miodrag Milanovic
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY MIODRAG MILANOVIC ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL MIODRAG MILANOVIC BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
38***************************************************************************/
39
40#pragma once
41
42#ifndef __EMU_H__
43#error Dont include this file directly; include emu.h instead.
44#endif
45
46#ifndef __GUI_ENGINE_H__
47#define __GUI_ENGINE_H__
48
49class gui_engine
50{
51public:
52   // construction/destruction
53   gui_engine(running_machine &machine);
54   ~gui_engine();
55
56   // getters
57   running_machine &machine() const { return m_machine; }
58
59   void initialize();
60   void shutdown();
61   void update();
62private:
63   // internal state
64   running_machine &   m_machine;                          // reference to our machine
65};
66
67#endif  /* __GUI_ENGINE_H__ */
Property changes on: branches/micko/src/emu/guiengine.h
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
branches/micko/src/emu/emu.h
r23971r23972
124124// lua engine
125125#include "luaengine.h"
126126
127// gui engine
128#include "guiengine.h"
129
127130// the running machine
128131#include "machine.h"
129132#include "driver.h"
branches/micko/src/emu/machine.c
r23971r23972
177177      m_memory(*this),
178178      m_ioport(*this),
179179      m_scheduler(*this),
180      m_lua_engine(*this)
180      m_lua_engine(*this),
181      m_gui_engine(*this)
181182{
182183   memset(gfx, 0, sizeof(gfx));
183184   memset(&m_base_time, 0, sizeof(m_base_time));
r23971r23972
341342   // initialize lua
342343   m_lua_engine.initialize();
343344
345   // initialize gui
346   m_gui_engine.initialize();
347
344348   // disallow save state registrations starting here
345349   m_save.allow_registration(false);
346350}
branches/micko/src/emu/machine.h
r23971r23972
424424   device_scheduler        m_scheduler;            // scheduler object
425425   emu_timer               *m_autoboot_timer;      // autoboot timer
426426   lua_engine              m_lua_engine;           // LUA engine
427   gui_engine              m_gui_engine;           // GUI engine
427428};
428429
429430
branches/micko/src/tools/main.cpp
r23971r23972
2727
2828#include <Rocket/Core.h>
2929#include <Rocket/Debugger.h>
30#include <Rocket/Controls.h>
3031#include <RocketInput.h>
3132#include <Shell.h>
3233
r23971r23972
6061   Rocket::Core::SetSystemInterface(&system_interface);
6162
6263   Rocket::Core::Initialise();
63
64   // Initialise the Rocket Controls library.
65   Rocket::Controls::Initialise();
66   
6467   // Create the main Rocket context and set it on the shell's input layer.
6568   context = Rocket::Core::CreateContext("main", Rocket::Core::Vector2i(1024, 768));
6669   if (context == NULL)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team