back to normal blit, for this you need to use the funkey SDL library which has the corect alpha per-pixel alpha blending

Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
This commit is contained in:
Vincent-FK 2019-10-22 19:10:08 +02:00
parent 6eb1a04901
commit ea42f62418
6 changed files with 78 additions and 32 deletions

2
.gitignore vendored
View File

@ -1,6 +1,7 @@
syntax: glob
*.orig
*.suo
*~
.git
Build/
Documentation/Documentation/*
@ -9,4 +10,3 @@ Documentation/Manual/_build/*
Configuration/Configuration/bin/**
Configuration/Configuration/obj/**
Artifacts/**

11
.project Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>funkey_retrofe</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

View File

@ -50,6 +50,8 @@ if(WIN32)
find_package(SDL_ttf REQUIRED )
find_package(SDL_gfx REQUIRED )
find_package(ZLIB REQUIRED)
find_package(X11)
else()
include(FindPkgConfig)
#pkg_search_module(SDL2 REQUIRED sdl2)
@ -70,6 +72,8 @@ if(APPLE)
#find_package(SDL2 REQUIRED)
find_package(SDL REQUIRED )
endif()
find_package(X11)
endif()
set(RETROFE_INCLUDE_DIRS
@ -88,6 +92,7 @@ set(RETROFE_INCLUDE_DIRS
"${ZLIB_INCLUDE_DIRS}"
"${SQLITE3_ROOT}"
"${RAPIDXML_ROOT}"
"${X11_INCLUDE_DIR}"
)
if(MSVC)
@ -107,6 +112,7 @@ set(RETROFE_LIBRARIES
${SDL_TTF_LIBRARIES}
${SDL_GFX_LIBRARIES}
${ZLIB_LIBRARIES}
${X11_LIBRARIES}
)
if(NOT WIN32)
@ -224,7 +230,6 @@ set(RETROFE_SOURCES
set(EXECUTABLE_OUTPUT_PATH "${RETROFE_DIR}/Build" CACHE PATH "Build directory" FORCE)
set(LIBRARY_OUTPUT_PATH "${RETROFE_DIR}/Build" CACHE PATH "Build directory" FORCE)
include_directories(${RETROFE_INCLUDE_DIRS})
add_executable(retrofe ${RETROFE_SOURCES} ${RETROFE_HEADERS})
target_link_libraries(retrofe ${RETROFE_LIBRARIES})

View File

@ -18,7 +18,7 @@
#include "../Utility/Log.h"
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>
#include <SDL/SDL_gfxBlitFunc.h>
//#include <SDL/SDL_gfxBlitFunc.h>
#include <cstdio>
#include <cstring>

View File

@ -95,10 +95,25 @@ void RetroFE::render( )
//SDL_RenderClear( SDL::getRenderer( ) );
SDL_FillRect(SDL::getWindow( ), NULL, SDL_MapRGB(SDL::getWindow( )->format, 0, 0, 0));
uint32_t draw_ticks = SDL_GetTicks();
if ( currentPage_ )
{
currentPage_->draw( );
}
int draw_time = SDL_GetTicks()-draw_ticks;
//printf("draw time: %dms\n", draw_time);
// DEBUG: Average draw time over FPS*5 frames
static int avg_draw_time = 0;
static int avg_draw_time_nb_vals = 0;
avg_draw_time += draw_time;
avg_draw_time_nb_vals++;
if(avg_draw_time_nb_vals >= FPS*5){
printf("Average draw time: %dms\n", avg_draw_time/avg_draw_time_nb_vals);
avg_draw_time=0;
avg_draw_time_nb_vals=0;
}
//SDL_RenderPresent( SDL::getRenderer( ) );
//SDL_Flip(SDL::getWindow( ));

View File

@ -182,15 +182,16 @@ bool SDL::initialize( Configuration &config )
}
SDL_FillRect(window_virtual_, NULL, SDL_MapRGBA(window_virtual_->format, 0, 0, 0, 0));
texture_copy_alpha_ = SDL_CreateRGBSurface(0, windowWidth_, windowHeight_, 32, rmask, gmask, bmask, amask);
/*texture_copy_alpha_ = SDL_CreateRGBSurface(0, windowWidth_, windowHeight_, 32, rmask, gmask, bmask, amask);
if ( texture_copy_alpha_ == NULL )
{
std::string error = SDL_GetError( );
Logger::write( Logger::ZONE_ERROR, "SDL", "SDL_CreateRGBSurface texture_copy_alpha_ failed: " + error );
retVal = false;
}
SDL_FillRect(texture_copy_alpha_, NULL, SDL_MapRGBA(texture_copy_alpha_->format, 0, 0, 0, 0));
SDL_FillRect(texture_copy_alpha_, NULL, SDL_MapRGBA(texture_copy_alpha_->format, 0, 0, 0, 0));*/
}
/*if ( retVal )
{
renderer_ = SDL_CreateRenderer( window_, -1, SDL_RENDERER_ACCELERATED );
@ -271,11 +272,11 @@ bool SDL::deInitialize( )
window_virtual_ = NULL;
}
if ( texture_copy_alpha_ )
/*if ( texture_copy_alpha_ )
{
SDL_FreeSurface(texture_copy_alpha_);
texture_copy_alpha_ = NULL;
}
}*/
SDL_ShowCursor( SDL_TRUE );
@ -569,7 +570,7 @@ bool SDL::renderCopy( SDL_Surface *texture, float alpha, SDL_Rect *src, SDL_Rect
/*SDL_SetAlpha(texture, SDL_SRCALPHA, static_cast<char>( alpha * 255 ));
SDL_BlitSurface (texture, &srcRect, getWindow(), &dstRect);*/
/*if(alpha){
unsigned int rmask;
unsigned int gmask;
unsigned int bmask;
@ -593,6 +594,20 @@ bool SDL::renderCopy( SDL_Surface *texture, float alpha, SDL_Rect *src, SDL_Rect
//SDL_gfxBlitRGBA(texture_tmp, &srcRect, getWindow(), &dstRect);
SDL_BlitSurface(texture_tmp, &srcRect, getWindow(), &dstRect);
SDL_FreeSurface(texture_tmp);
}*/
if(alpha){
SDL_SetAlpha(texture, SDL_SRCALPHA, static_cast<uint8_t>( alpha * 255 ));
//printf("\n-----------\n");
//printf("Alpha = %f = %u\n", alpha, texture->format->alpha);
SDL_BlitSurface(texture, &srcRect, getWindow(), &dstRect);
}
//texture = rotozoomSurfaceXY(texture, viewInfo.Angle, scaleX, scaleY, SMOOTHING_OFF);