mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-25 23:57:53 +03:00
Fixed FBOs.
Minor fixes for Emscripten and Android. --HG-- branch : dev
This commit is contained in:
+2
-2
@@ -441,8 +441,8 @@ function build_link_configuration( package_name, use_ee_icon )
|
||||
add_cross_config_links()
|
||||
|
||||
configuration "emscripten"
|
||||
linkoptions{ "-O1 -s TOTAL_MEMORY=67108864 -s ASM_JS=1 -s VERBOSE=1 -s DISABLE_EXCEPTION_CATCHING=0 -s USE_SDL=2" }
|
||||
buildoptions { "-fno-strict-aliasing -O2 -ffast-math -s USE_SDL=2" }
|
||||
linkoptions{ "-O2 -s TOTAL_MEMORY=67108864 -s ASM_JS=1 -s VERBOSE=1 -s DISABLE_EXCEPTION_CATCHING=0 -s USE_SDL=2" }
|
||||
buildoptions { "-fno-strict-aliasing -O2 -s USE_SDL=2 -s PRECISE_F32=1" }
|
||||
|
||||
if _OPTIONS["with-gles1"] and ( not _OPTIONS["with-gles2"] or _OPTIONS["force-gles1"] ) then
|
||||
linkoptions{ "-s LEGACY_GL_EMULATION=1" }
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace EE { namespace Graphics {
|
||||
FrameBuffer * FrameBuffer::New( const Uint32& Width, const Uint32& Height, bool StencilBuffer, bool DepthBuffer, EE::Window::Window * window ) {
|
||||
if ( FrameBufferFBO::isSupported() )
|
||||
return eeNew( FrameBufferFBO, ( Width, Height, StencilBuffer, DepthBuffer, window ) );
|
||||
|
||||
eePRINTL( "FBO not supported" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,23 +82,24 @@ bool FrameBufferFBO::create(const Uint32& Width, const Uint32& Height, bool Sten
|
||||
|
||||
mFrameBuffer = static_cast<Int32>( frameBuffer );
|
||||
|
||||
if ( !mFrameBuffer) {
|
||||
if ( !mFrameBuffer ) {
|
||||
eePRINT("FrameBufferFBO::create: Failed to created FrameBuffer Object");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bindFrameBuffer();
|
||||
|
||||
if ( DepthBuffer ) {
|
||||
if ( mHasDepthBuffer ) {
|
||||
unsigned int depth = 0;
|
||||
|
||||
GLi->genRenderbuffers( 1, &depth );
|
||||
|
||||
mDepthBuffer = static_cast<unsigned int>(depth);
|
||||
|
||||
if ( !mDepthBuffer )
|
||||
if ( !mDepthBuffer ) {
|
||||
eePRINT("FrameBufferFBO::create: Failed to created Depth Buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
bindDepthBuffer();
|
||||
|
||||
@@ -106,10 +107,10 @@ bool FrameBufferFBO::create(const Uint32& Width, const Uint32& Height, bool Sten
|
||||
|
||||
GLi->framebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mDepthBuffer );
|
||||
|
||||
GLi->bindFramebuffer( GL_RENDERBUFFER, mLastDB );
|
||||
GLi->bindRenderbuffer( GL_RENDERBUFFER, mLastDB );
|
||||
}
|
||||
|
||||
if ( StencilBuffer ) {
|
||||
if ( mHasStencilBuffer ) {
|
||||
GLuint stencil = 0;
|
||||
GLi->genRenderbuffers( 1, &stencil );
|
||||
|
||||
@@ -117,17 +118,16 @@ bool FrameBufferFBO::create(const Uint32& Width, const Uint32& Height, bool Sten
|
||||
|
||||
if (!mStencilBuffer) {
|
||||
eePRINT("FrameBufferFBO::create: Failed to created Stencil Buffer");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bindStencilBuffer();
|
||||
|
||||
GLi->renderbufferStorage( GL_RENDERBUFFER, GL_STENCIL_INDEX, Width, Height );
|
||||
GLi->renderbufferStorage( GL_RENDERBUFFER, GL_STENCIL_INDEX8, Width, Height );
|
||||
|
||||
GLi->framebufferRenderbuffer( GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER_EXT, mStencilBuffer );
|
||||
|
||||
GLi->bindFramebuffer( GL_RENDERBUFFER, mLastSB );
|
||||
GLi->bindRenderbuffer( GL_RENDERBUFFER, mLastSB );
|
||||
}
|
||||
|
||||
if ( NULL == mTexture ) {
|
||||
@@ -136,15 +136,17 @@ bool FrameBufferFBO::create(const Uint32& Width, const Uint32& Height, bool Sten
|
||||
if ( TextureFactory::instance()->existsId( TexId ) ) {
|
||||
mTexture = TextureFactory::instance()->getTexture( TexId );
|
||||
} else {
|
||||
eePRINTL( "FrameBufferFBO::create: failed to create texture" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
GLi->framebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexture->getHandle(), 0 );
|
||||
|
||||
if ( GLi->checkFramebufferStatus( GL_FRAMEBUFFER ) != GL_FRAMEBUFFER_COMPLETE ) {
|
||||
Uint32 status = GLi->checkFramebufferStatus( GL_FRAMEBUFFER );
|
||||
if ( status != GL_FRAMEBUFFER_COMPLETE ) {
|
||||
eePRINTL("FrameBufferFBO::create: Failed to attach Frame Buffer. Status: %04X", status );
|
||||
GLi->bindFramebuffer( GL_FRAMEBUFFER, mLastFB );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -177,6 +179,7 @@ void FrameBufferFBO::reload() {
|
||||
|
||||
void FrameBufferFBO::bindFrameBuffer() {
|
||||
int curFB;
|
||||
|
||||
glGetIntegerv( GL_FRAMEBUFFER_BINDING, &curFB );
|
||||
|
||||
mLastFB = (Int32)curFB;
|
||||
|
||||
@@ -161,7 +161,7 @@ void Primitives::drawArc( const Vector2f& p, const Float& radius, Uint32 segment
|
||||
if(segmentsCount < 6) segmentsCount = 6;
|
||||
segmentsCount = segmentsCount > 360 ? 360 : segmentsCount;
|
||||
|
||||
Float angle_shift = 360 / static_cast<Float>(segmentsCount);
|
||||
Float angleShift = 360 / static_cast<Float>(segmentsCount);
|
||||
Float arcAngleA = arcAngle > 360 ? arcAngle - 360 * std::floor( arcAngle / 360 ) : arcAngle;
|
||||
|
||||
sBR->setTexture( NULL );
|
||||
@@ -202,12 +202,12 @@ void Primitives::drawArc( const Vector2f& p, const Float& radius, Uint32 segment
|
||||
sBR->triangleFanBegin();
|
||||
sBR->triangleFanSetColor( mColor );
|
||||
|
||||
for( Float i = 0; i < arcAngleA; i+= angle_shift ) {
|
||||
for( Float i = 0; i < arcAngleA; i+= angleShift ) {
|
||||
Float startAngle = arcStartAngle + i;
|
||||
|
||||
sBR->batchTriangleFan( p.x , p.y,
|
||||
p.x + radius * Math::sinAng( startAngle ), p.y + radius * Math::cosAng( startAngle ),
|
||||
p.x + radius * Math::sinAng( startAngle + angle_shift ), p.y + radius * Math::cosAng( startAngle + angle_shift ) );
|
||||
p.x + radius * Math::sinAng( startAngle + angleShift ), p.y + radius * Math::cosAng( startAngle + angleShift ) );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -244,6 +244,8 @@ void Renderer::init() {
|
||||
isExtension( "WEBKIT_WEBGL_compressed_texture_s3tc" ) ||
|
||||
isExtension( "MOZ_WEBGL_compressed_texture_s3tc" ) );
|
||||
}
|
||||
|
||||
writeExtension( EEGL_ARB_texture_non_power_of_two , 1 );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ void mainLoop()
|
||||
}
|
||||
|
||||
// Draw a circle
|
||||
p.drawCircle( Vector2f( win->getWidth() * 0.5f, win->getHeight() * 0.5f ), 200, 50 );
|
||||
p.drawCircle( Vector2f( win->getWidth() * 0.5f, win->getHeight() * 0.5f ), 200, 60 );
|
||||
|
||||
// Draw frame
|
||||
win->display();
|
||||
|
||||
+6
-1
@@ -65,7 +65,7 @@ void EETest::init() {
|
||||
ContextSettings ConSettings = EE->createContextSettings( &Ini );
|
||||
|
||||
if ( !( WinSettings.Style & WindowStyle::Fullscreen ) && !( WinSettings.Style & WindowStyle::UseDesktopResolution ) ) {
|
||||
#if EE_PLATFORM != EE_PLATFORM_MACOSX
|
||||
#if EE_PLATFORM != EE_PLATFORM_MACOSX && EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN
|
||||
WinSettings.Width *= WinSettings.PixelDensity;
|
||||
WinSettings.Height *= WinSettings.PixelDensity;
|
||||
#endif
|
||||
@@ -74,6 +74,8 @@ void EETest::init() {
|
||||
mWindow = EE->createWindow( WinSettings, ConSettings );
|
||||
|
||||
if ( NULL != mWindow && mWindow->isOpen() ) {
|
||||
MyPath = Sys::getProcessPath() + "assets/"; // Android needs to get the real process path AFTER the window creation
|
||||
|
||||
setScreen( StartScreen );
|
||||
|
||||
mWindow->setCaption( "eepp - Test Application" );
|
||||
@@ -196,6 +198,9 @@ void EETest::onFontLoaded( ResourceLoader * ObjLoaded ) {
|
||||
eeASSERT( DBSM != NULL );
|
||||
|
||||
Con.create( DBSM, true );
|
||||
// RR GG BB AA
|
||||
// EE 1F 1F 20
|
||||
// 20 1F 1F EE
|
||||
Con.setBackgroundColor( 0x201F1FEE );
|
||||
Con.setBackgroundLineColor( 0x666666EE );
|
||||
Con.setFontColor( 0xCFCFCFFF );
|
||||
|
||||
Reference in New Issue
Block a user