In the Mandelbrot interactive viewer that I did in real time, I did in R and Rcpp + OpenMP and Shiny. I'm in search of a powerful way to display 1920x1080 matrices as bitmaps in the hope that you can achieve approx. 5-10 fps (the calculation of the Mandelbrot images themselves reaches 20-30 frames per second at moderate scales , and, of course, scrolling should go quickly). Using image() with the option useRaster=TRUE , plot.raster or even grid.raster() still doesn't quite shorten it, so I'm looking for a more efficient option, ideally using OpenGL acceleration.
I noticed that there are qt packages of the qtutils and qtpaint http://finzi.psych.upenn.edu/R/library/qtutils/html/sceneDevice.html where you can set the argument opengl=TRUE and http: //finzi.psych .upenn.edu / R / library / qtpaint / html / qplotView.html again with the argument opengl=TRUE and http://finzi.psych.upenn.edu/R/library/qtpaint/html/painting.html .
And I also noticed that you need to be able to call the SDL and GL / OpenGL functions using the rdyncall package (install from https://cran.r-project.org/src/contrib/Archive/rdyncall/ and SDL from https: // www.libsdl.org/download-1.2.php ) `, demos are available at http://hg.dyncall.org/pub/dyncall/bindings/file/87fd9f34eaa0/R/rdyncall/demo/00Index , e.g. http: // hg.dyncall.org/pub/dyncall/bindings/file/87fd9f34eaa0/R/rdyncall/demo/randomfield.R ).
I am correcting that with these packages you should be able to display a 2D raster image using opengl acceleration? If so, does anyone have thoughts on how to do this (I ask because I'm not an expert in qt or SDL / OpenGL )?
Some timings of parameters other than OpenGL that are too slow for my application:
# some example data & desired colour mapping of [0-1] ranged data matrix library(RColorBrewer) ncol=1080 cols=colorRampPalette(RColorBrewer::brewer.pal(11, "RdYlBu"))(ncol) colfun=colorRamp(RColorBrewer::brewer.pal(11, "RdYlBu")) col = rgb(colfun(seq(0,1, length.out = ncol)), max = 255) mat=matrix(seq(1:1080)/1080,nrow=1920,ncol=1080,byrow=TRUE) mat2rast = function(mat, col) { idx = findInterval(mat, seq(0, 1, length.out = length(col))) colors = col[idx] rastmat = t(matrix(colors, ncol = ncol(mat), nrow = nrow(mat), byrow = TRUE)) class(rastmat) = "raster" return(rastmat) } system.time(mat2rast(mat, col))
r qt graphics sdl opengl
Tom wenseleers
source share