expand GraphicsContextResource to self-register itself with GraphicsDevice
This commit is contained in:
parent
b0db10f77a
commit
183631c5e6
26
src/framework/graphics/graphicscontextresource.cpp
Normal file
26
src/framework/graphics/graphicscontextresource.cpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#include "../debug.h"
|
||||||
|
|
||||||
|
#include "graphicscontextresource.h"
|
||||||
|
#include "graphicsdevice.h"
|
||||||
|
|
||||||
|
GraphicsContextResource::GraphicsContextResource()
|
||||||
|
{
|
||||||
|
STACK_TRACE;
|
||||||
|
m_graphicsDevice = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GraphicsContextResource::GraphicsContextResource(GraphicsDevice *graphicsDevice)
|
||||||
|
{
|
||||||
|
STACK_TRACE;
|
||||||
|
ASSERT(graphicsDevice != NULL);
|
||||||
|
|
||||||
|
m_graphicsDevice = graphicsDevice;
|
||||||
|
m_graphicsDevice->RegisterManagedResource(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
GraphicsContextResource::~GraphicsContextResource()
|
||||||
|
{
|
||||||
|
STACK_TRACE;
|
||||||
|
if (m_graphicsDevice != NULL)
|
||||||
|
m_graphicsDevice->UnregisterManagedResource(this);
|
||||||
|
}
|
|
@ -1,23 +1,37 @@
|
||||||
#ifndef __FRAMEWORK_GRAPHICS_GRAPHICSCONTEXTRESOURCE_H_INCLUDED__
|
#ifndef __FRAMEWORK_GRAPHICS_GRAPHICSCONTEXTRESOURCE_H_INCLUDED__
|
||||||
#define __FRAMEWORK_GRAPHICS_GRAPHICSCONTEXTRESOURCE_H_INCLUDED__
|
#define __FRAMEWORK_GRAPHICS_GRAPHICSCONTEXTRESOURCE_H_INCLUDED__
|
||||||
|
|
||||||
|
#include "../common.h"
|
||||||
|
|
||||||
|
class GraphicsDevice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for objects whose lifecycle is tied to the current graphics
|
* Base class for objects whose lifecycle is tied to the current graphics
|
||||||
* context and should be made aware when the context is lost and/or
|
* context and should be made aware when the context is lost and/or
|
||||||
* recreated.
|
* recreated.
|
||||||
*/
|
*/
|
||||||
class GraphicsContextResource
|
class GraphicsContextResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
GraphicsContextResource();
|
||||||
|
GraphicsContextResource(GraphicsDevice *graphicsDevice);
|
||||||
|
|
||||||
|
virtual ~GraphicsContextResource();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New OpenGL graphics context creation callback.
|
* New OpenGL graphics context creation callback.
|
||||||
*/
|
*/
|
||||||
virtual void OnNewContext() = 0;
|
virtual void OnNewContext() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lost OpenGL graphics context callback.
|
* Lost OpenGL graphics context callback.
|
||||||
*/
|
*/
|
||||||
virtual void OnLostContext() = 0;
|
virtual void OnLostContext() {}
|
||||||
|
|
||||||
|
GraphicsDevice* GetGraphicsDevice() const { return m_graphicsDevice; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
GraphicsDevice *m_graphicsDevice;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Reference in a new issue