mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-07-20 01:32:51 +03:00
Added support for Frame Buffers, FBO and PBuffer (win and linux ftm), better known as render to texture.
Added loading from memory of texture groups. Fixed minor things.
This commit is contained in:
61
src/graphics/cframebuffer.cpp
Normal file
61
src/graphics/cframebuffer.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
#include "cframebuffer.hpp"
|
||||
#include "ctexturefactory.hpp"
|
||||
#include "../window/cengine.hpp"
|
||||
#include "cframebufferfbo.hpp"
|
||||
#include "cframebufferpbuffer.hpp"
|
||||
|
||||
namespace EE { namespace Graphics {
|
||||
|
||||
cFrameBuffer * cFrameBuffer::CreateNew( const Uint32& Width, const Uint32& Height, bool DepthBuffer ) {
|
||||
if ( cFrameBufferFBO::IsSupported() )
|
||||
return new cFrameBufferFBO( Width, Height, DepthBuffer );
|
||||
|
||||
if ( cFrameBufferPBuffer::IsSupported() )
|
||||
return new cFrameBufferPBuffer( Width, Height, DepthBuffer );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cFrameBuffer::cFrameBuffer() :
|
||||
mWidth(0),
|
||||
mHeight(0),
|
||||
mTexture(NULL),
|
||||
mClearColor(0,0,0,0)
|
||||
{}
|
||||
|
||||
cFrameBuffer::~cFrameBuffer() {
|
||||
if ( NULL != mTexture )
|
||||
cTextureFactory::instance()->Remove( mTexture->TexId() );
|
||||
}
|
||||
|
||||
cTexture * cFrameBuffer::GetTexture() const {
|
||||
return mTexture;
|
||||
}
|
||||
|
||||
void cFrameBuffer::ClearColor( eeColorAf Color ) {
|
||||
mClearColor = Color;
|
||||
}
|
||||
|
||||
eeColorAf cFrameBuffer::ClearColor() const {
|
||||
return mClearColor;
|
||||
}
|
||||
|
||||
void cFrameBuffer::SetBufferView() {
|
||||
glClearColor( mClearColor.R(), mClearColor.G(), mClearColor.B(), mClearColor.A() );
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
|
||||
mPrevView = Window::cEngine::instance()->GetView();
|
||||
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glLoadIdentity();
|
||||
glViewport( 0, 0, mWidth, mHeight );
|
||||
glOrtho( 0.0f, mWidth, 0.f, mHeight, -1000.0f, 1000.0f );
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
void cFrameBuffer::RecoverView() {
|
||||
cEngine::instance()->SetView( mPrevView );
|
||||
}
|
||||
|
||||
}}
|
||||
Reference in New Issue
Block a user