mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-12 09:48:51 +01:00
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:
parent
6eb1a04901
commit
ea42f62418
2
.gitignore
vendored
2
.gitignore
vendored
@ -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
11
.project
Normal 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>
|
||||
@ -31,8 +31,8 @@ endif()
|
||||
|
||||
set(GSTREAMER_ROOT "C:/gstreamer/1.0/x86" CACHE STRING "location of where your gstreamer include and lib folders reside")
|
||||
set(GLIB2_ROOT "${GSTREAMER_ROOT}")
|
||||
|
||||
if(MSVC)
|
||||
|
||||
if(MSVC)
|
||||
set(DIRENT_INCLUDE_DIR "${RETROFE_THIRD_PARTY_DIR}/dirent-1.20.1/include")
|
||||
endif()
|
||||
endif()
|
||||
@ -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})
|
||||
|
||||
@ -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>
|
||||
|
||||
|
||||
@ -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( ));
|
||||
|
||||
@ -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,30 +570,44 @@ 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;
|
||||
unsigned int amask;
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
rmask = 0xff000000;
|
||||
gmask = 0x00ff0000;
|
||||
bmask = 0x0000ff00;
|
||||
amask = 0x000000ff;
|
||||
#else
|
||||
rmask = 0x000000ff;
|
||||
gmask = 0x0000ff00;
|
||||
bmask = 0x00ff0000;
|
||||
amask = 0xff000000;
|
||||
#endif
|
||||
SDL_Surface * texture_tmp = SDL_CreateRGBSurface(0, texture->w, texture->h, 32, rmask, gmask, bmask, amask);
|
||||
//SDL_FillRect(texture_tmp, NULL, SDL_MapRGBA(texture_tmp->format, 0, 0, 0, 0));
|
||||
SDL_SetAlpha( texture, 0, SDL_ALPHA_OPAQUE );
|
||||
SDL_BlitSurface (texture, NULL, texture_tmp, NULL);
|
||||
SDL_gfxMultiplyAlpha (texture_tmp, static_cast<char>( alpha * 255 ));
|
||||
//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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned int rmask;
|
||||
unsigned int gmask;
|
||||
unsigned int bmask;
|
||||
unsigned int amask;
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
rmask = 0xff000000;
|
||||
gmask = 0x00ff0000;
|
||||
bmask = 0x0000ff00;
|
||||
amask = 0x000000ff;
|
||||
#else
|
||||
rmask = 0x000000ff;
|
||||
gmask = 0x0000ff00;
|
||||
bmask = 0x00ff0000;
|
||||
amask = 0xff000000;
|
||||
#endif
|
||||
SDL_Surface * texture_tmp = SDL_CreateRGBSurface(0, texture->w, texture->h, 32, rmask, gmask, bmask, amask);
|
||||
//SDL_FillRect(texture_tmp, NULL, SDL_MapRGBA(texture_tmp->format, 0, 0, 0, 0));
|
||||
SDL_SetAlpha( texture, 0, SDL_ALPHA_OPAQUE );
|
||||
SDL_BlitSurface (texture, NULL, texture_tmp, NULL);
|
||||
SDL_gfxMultiplyAlpha (texture_tmp, static_cast<char>( alpha * 255 ));
|
||||
//SDL_gfxBlitRGBA(texture_tmp, &srcRect, getWindow(), &dstRect);
|
||||
SDL_BlitSurface(texture_tmp, &srcRect, getWindow(), &dstRect);
|
||||
SDL_FreeSurface(texture_tmp);
|
||||
|
||||
|
||||
//texture = rotozoomSurfaceXY(texture, viewInfo.Angle, scaleX, scaleY, SMOOTHING_OFF);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user