1
0
Fork 0

Initial commit

This commit is contained in:
Henrik Hautakoski 2015-12-22 17:43:51 +01:00
commit edfc5298e1
252 changed files with 93965 additions and 0 deletions

View file

@ -0,0 +1,76 @@
#ifndef SPECTRE_DISPLAY_DISPLAY_H
#define SPECTRE_DISPLAY_DISPLAY_H
#include "DisplayMode.h"
#include "DisplayDescription.h"
#include <Spectre/Display/GLContext.h>
#include <Spectre/System/SystemEvent.h>
#include <string>
class PlatformDisplay;
class GLContext;
class Display
{
friend class PlatformDisplay;
public :
enum Mode {
WINDOWED = 0,
FULLSCREEN = 1,
WINDOWEDFULLSCREEN = 2,
};
public :
Display();
virtual ~Display();
bool create(DisplayDescription decription);
void destroy();
void setSize(unsigned int width, unsigned int height);
void setCaption(const std::string& title);
const std::string& getCaption() const;
void setIcon(const std::string& filename);
void setDisplayMode(const DisplayMode& mode);
const DisplayMode& getDisplayMode() const;
void setVideoMode(Mode mode);
enum Mode getVideoMode() const;
void showCursor(bool value);
bool activate(bool value);
// Enable/Disable Vertical Sync.
bool enableVSync(bool value);
void swapBuffers();
protected :
void init();
void onReshape(int width, int height);
protected :
enum Mode m_fmode;
DisplayDescription m_description;
DisplayDescription m_cacheDesc;
std::string m_caption;
PlatformDisplay* m_impl;
GLContext* m_context;
};
#endif /* SPECTRE_DISPLAY_DISPLAY_H */

View file

@ -0,0 +1,30 @@
#ifndef SPECTRE_DISPLAY_DISPLAYDESCRIPTION_H
#define SPECTRE_DISPLAY_DISPLAYDESCRIPTION_H
#include "DisplayMode.h"
namespace DisplayDecorate {
enum Type {
None = 0,
Menu = 1 << 0,
Resize = 1 << 1,
Close = 1 << 2,
Default = Menu | Resize | Close,
};
};
struct DisplayDescription
{
public :
DisplayDescription();
DisplayDescription(DisplayMode mode, unsigned decoration = DisplayDecorate::Default);
public :
DisplayMode mode;
unsigned int decoration;
};
#endif /* SPECTRE_DISPLAY_DISPLAYDESCRIPTION_H */

View file

@ -0,0 +1,35 @@
#ifndef SPECTRE_DISPLAY_DISPLAYMODE_H
#define SPECTRE_DISPLAY_DISPLAYMODE_H
#include <vector>
class DisplayMode
{
public :
DisplayMode();
DisplayMode(unsigned int width, unsigned int height, unsigned int bpp = 32);
static std::vector<DisplayMode> getFullscreenModes();
static DisplayMode getDesktopMode();
inline bool operator==(const DisplayMode& other)
{
return width == other.width
&& height == other.height
&& bpp == other.bpp;
}
inline bool operator!=(const DisplayMode& other)
{
return !(*this == other);
}
public :
unsigned int width;
unsigned int height;
unsigned int bpp; /* Bits per pixel. */
};
#endif /* SPECTRE_DISPLAY_DISPLAYMODE_H */

View file

@ -0,0 +1,46 @@
#ifndef DISPLAY_GLCONTEXT_H
#define DISPLAY_GLCONTEXT_H
#include <Spectre/Math/Vector2.h>
class PlatformDisplay;
// Platform independant interface for OpenGL Contexts.
class GLContext
{
public :
static GLContext* create();
virtual ~GLContext();
// Create a GLContext for this perticular display.
virtual bool create(const PlatformDisplay* display, unsigned int bpp) = 0;
virtual void destroy() = 0;
// Activate this context.
virtual bool activate() = 0;
// Deactivate this context.
virtual bool deactivate() = 0;
// Returns true if this context is the active one. false otherwise.
// There can only be one GL context active per thread.
virtual bool isActive() const = 0;
// Set the interval for when the front and back framebuffers should be swapped.
// The interval is the number of v-blanks that the gpu must wait before swapping buffers.
// 0 means that the gpu never waits, 1 means after exactly 1 v-blank and so on.
// This is usually refered to as enabling/disabling vertical synchronization.
virtual bool setSwapInterval(int interval) = 0;
// Set the size of the pixel buffer.
virtual void setSize(unsigned int width, unsigned int height) = 0;
// Swap front with back buffer and vice versa.
virtual void swapBuffers() = 0;
};
#endif /* DISPLAY_GLCONTEXT_H */