提供的哈,都在技术文档那块
http://www.synwit.cn/Download/DownloadHome/downList/cate_id/9/nav/4/m/Download/p/2.html
是这个吗?都是 pdf, 不能修改。
@华芯微特 请问官网那些开发板 http://www.synwit.cn/productList1/21.html 都能提供 sch & pcb 吗?
这样方便客户快速上手哦。
offscreen.c
/* http://stackoverflow.com/questions/3191978/how-to-use-glut-opengl-to-render-to-a-file/14324292#14324292 */
/* Turn output methods on and off. */
#ifndef PPM
#define PPM 1
#endif
#ifndef LIBPNG
#define LIBPNG 1
#endif
#ifndef FFMPEG
#define FFMPEG 1
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define GL_GLEXT_PROTOTYPES 1
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <GL/glext.h>
#if LIBPNG
#include <png.h>
#endif
#if FFMPEG
#include <libavcodec/avcodec.h>
#include <libavutil/imgutils.h>
#include <libavutil/opt.h>
#include <libswscale/swscale.h>
#endif
enum Constants { SCREENSHOT_MAX_FILENAME = 256 };
static GLubyte *pixels = NULL;
static GLuint fbo;
static GLuint rbo_color;
static GLuint rbo_depth;
static int offscreen = 1;
static unsigned int max_nframes = 128;
static unsigned int nframes = 0;
static unsigned int time0;
static unsigned int height = 128;
static unsigned int width = 128;
#define PPM_BIT (1 << 0)
#define LIBPNG_BIT (1 << 1)
#define FFMPEG_BIT (1 << 2)
static unsigned int output_formats = PPM_BIT | LIBPNG_BIT | FFMPEG_BIT;
/* Model. */
static double angle;
static double delta_angle;
#if PPM
/* Take screenshot with glReadPixels and save to a file in PPM format.
*
* - filename: file path to save to, without extension
* - width: screen width in pixels
* - height: screen height in pixels
* - pixels: intermediate buffer to avoid repeated mallocs across multiple calls.
* Contents of this buffer do not matter. May be NULL, in which case it is initialized.
* You must `free` it when you won't be calling this function anymore.
*/
static void screenshot_ppm(const char *filename, unsigned int width,
unsigned int height, GLubyte **pixels) {
size_t i, j, cur;
const size_t format_nchannels = 3;
FILE *f = fopen(filename, "w");
fprintf(f, "P3\n%d %d\n%d\n", width, height, 255);
*pixels = realloc(*pixels, format_nchannels * sizeof(GLubyte) * width * height);
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, *pixels);
for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) {
cur = format_nchannels * ((height - i - 1) * width + j);
fprintf(f, "%3d %3d %3d ", (*pixels)[cur], (*pixels)[cur + 1], (*pixels)[cur + 2]);
}
fprintf(f, "\n");
}
fclose(f);
}
#endif
#if LIBPNG
/* Adapted from https://github.com/cirosantilli/cpp-cheat/blob/19044698f91fefa9cb75328c44f7a487d336b541/png/open_manipulate_write.c */
static png_byte *png_bytes = NULL;
static png_byte **png_rows = NULL;
static void screenshot_png(const char *filename, unsigned int width, unsigned int height,
GLubyte **pixels, png_byte **png_bytes, png_byte ***png_rows) {
size_t i, nvals;
const size_t format_nchannels = 4;
FILE *f = fopen(filename, "wb");
nvals = format_nchannels * width * height;
*pixels = realloc(*pixels, nvals * sizeof(GLubyte));
*png_bytes = realloc(*png_bytes, nvals * sizeof(png_byte));
*png_rows = realloc(*png_rows, height * sizeof(png_byte*));
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, *pixels);
for (i = 0; i < nvals; i++)
(*png_bytes)[i] = (*pixels)[i];
for (i = 0; i < height; i++)
(*png_rows)[height - i - 1] = &(*png_bytes)[i * width * format_nchannels];
png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png) abort();
png_infop info = png_create_info_struct(png);
if (!info) abort();
if (setjmp(png_jmpbuf(png))) abort();
png_init_io(png, f);
png_set_IHDR(
png,
info,
width,
height,
8,
PNG_COLOR_TYPE_RGBA,
PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT
);
png_write_info(png, info);
png_write_image(png, *png_rows);
png_write_end(png, NULL);
png_destroy_write_struct(&png, &info);
fclose(f);
}
#endif
#if FFMPEG
/* Adapted from: https://github.com/cirosantilli/cpp-cheat/blob/19044698f91fefa9cb75328c44f7a487d336b541/ffmpeg/encode.c */
static AVCodecContext *c = NULL;
static AVFrame *frame;
static AVPacket pkt;
static FILE *file;
static struct SwsContext *sws_context = NULL;
static uint8_t *rgb = NULL;
static void ffmpeg_encoder_set_frame_yuv_from_rgb(uint8_t *rgb) {
const int in_linesize[1] = { 4 * c->width };
sws_context = sws_getCachedContext(sws_context,
c->width, c->height, AV_PIX_FMT_RGB32,
c->width, c->height, AV_PIX_FMT_YUV420P,
0, NULL, NULL, NULL);
sws_scale(sws_context, (const uint8_t * const *)&rgb, in_linesize, 0,
c->height, frame->data, frame->linesize);
}
void ffmpeg_encoder_start(const char *filename, int codec_id, int fps, int width, int height) {
AVCodec *codec;
int ret;
avcodec_register_all();
codec = avcodec_find_encoder(codec_id);
if (!codec) {
fprintf(stderr, "Codec not found\n");
exit(1);
}
c = avcodec_alloc_context3(codec);
if (!c) {
fprintf(stderr, "Could not allocate video codec context\n");
exit(1);
}
c->bit_rate = 400000;
c->width = width;
c->height = height;
c->time_base.num = 1;
c->time_base.den = fps;
c->gop_size = 10;
c->max_b_frames = 1;
c->pix_fmt = AV_PIX_FMT_YUV420P;
if (codec_id == AV_CODEC_ID_H264)
av_opt_set(c->priv_data, "preset", "slow", 0);
if (avcodec_open2(c, codec, NULL) < 0) {
fprintf(stderr, "Could not open codec\n");
exit(1);
}
file = fopen(filename, "wb");
if (!file) {
fprintf(stderr, "Could not open %s\n", filename);
exit(1);
}
frame = av_frame_alloc();
if (!frame) {
fprintf(stderr, "Could not allocate video frame\n");
exit(1);
}
frame->format = c->pix_fmt;
frame->width = c->width;
frame->height = c->height;
ret = av_image_alloc(frame->data, frame->linesize, c->width, c->height, c->pix_fmt, 32);
if (ret < 0) {
fprintf(stderr, "Could not allocate raw picture buffer\n");
exit(1);
}
}
void ffmpeg_encoder_finish(void) {
uint8_t endcode[] = { 0, 0, 1, 0xb7 };
int got_output, ret;
do {
fflush(stdout);
ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
if (ret < 0) {
fprintf(stderr, "Error encoding frame\n");
exit(1);
}
if (got_output) {
fwrite(pkt.data, 1, pkt.size, file);
av_packet_unref(&pkt);
}
} while (got_output);
fwrite(endcode, 1, sizeof(endcode), file);
fclose(file);
avcodec_close(c);
av_free(c);
av_freep(&frame->data[0]);
av_frame_free(&frame);
}
void ffmpeg_encoder_encode_frame(uint8_t *rgb) {
int ret, got_output;
ffmpeg_encoder_set_frame_yuv_from_rgb(rgb);
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
if (ret < 0) {
fprintf(stderr, "Error encoding frame\n");
exit(1);
}
if (got_output) {
fwrite(pkt.data, 1, pkt.size, file);
av_packet_unref(&pkt);
}
}
void ffmpeg_encoder_glread_rgb(uint8_t **rgb, GLubyte **pixels, unsigned int width, unsigned int height) {
size_t i, j, k, cur_gl, cur_rgb, nvals;
const size_t format_nchannels = 4;
nvals = format_nchannels * width * height;
*pixels = realloc(*pixels, nvals * sizeof(GLubyte));
*rgb = realloc(*rgb, nvals * sizeof(uint8_t));
/* Get RGBA to align to 32 bits instead of just 24 for RGB. May be faster for FFmpeg. */
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, *pixels);
for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) {
cur_gl = format_nchannels * (width * (height - i - 1) + j);
cur_rgb = format_nchannels * (width * i + j);
for (k = 0; k < format_nchannels; k++)
(*rgb)[cur_rgb + k] = (*pixels)[cur_gl + k];
}
}
}
#endif
static void model_init(void) {
angle = 0;
delta_angle = 1;
}
static int model_update(void) {
angle += delta_angle;
return 0;
}
static int model_finished(void) {
return nframes >= max_nframes;
}
static void init(void) {
int glget;
if (offscreen) {
/* Framebuffer */
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
/* Color renderbuffer. */
glGenRenderbuffers(1, &rbo_color);
glBindRenderbuffer(GL_RENDERBUFFER, rbo_color);
/* Storage must be one of: */
/* GL_RGBA4, GL_RGB565, GL_RGB5_A1, GL_DEPTH_COMPONENT16, GL_STENCIL_INDEX8. */
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB565, width, height);
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo_color);
/* Depth renderbuffer. */
glGenRenderbuffers(1, &rbo_depth);
glBindRenderbuffer(GL_RENDERBUFFER, rbo_depth);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rbo_depth);
glReadBuffer(GL_COLOR_ATTACHMENT0);
/* Sanity check. */
assert(glCheckFramebufferStatus(GL_FRAMEBUFFER));
glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &glget);
assert(width < (unsigned int)glget);
assert(height < (unsigned int)glget);
} else {
glReadBuffer(GL_BACK);
}
glClearColor(0.0, 0.0, 0.0, 0.0);
glEnable(GL_DEPTH_TEST);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
time0 = glutGet(GLUT_ELAPSED_TIME);
model_init();
#if FFMPEG
ffmpeg_encoder_start("tmp.mpg", AV_CODEC_ID_MPEG1VIDEO, 25, width, height);
#endif
}
static void deinit(void) {
printf("FPS = %f\n", 1000.0 * nframes / (double)(glutGet(GLUT_ELAPSED_TIME) - time0));
free(pixels);
#if LIBPNG
if (output_formats & LIBPNG_BIT) {
free(png_bytes);
free(png_rows);
}
#endif
#if FFMPEG
if (output_formats & FFMPEG_BIT) {
ffmpeg_encoder_finish();
free(rgb);
}
#endif
if (offscreen) {
glDeleteFramebuffers(1, &fbo);
glDeleteRenderbuffers(1, &rbo_color);
glDeleteRenderbuffers(1, &rbo_depth);
}
}
static void draw_scene(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glRotatef(angle, 0.0f, 0.0f, -1.0f);
glBegin(GL_TRIANGLES);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f( 0.0f, 0.5f, 0.0f);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f(-0.5f, -0.5f, 0.0f);
glColor3f(0.0f, 0.0f, 1.0f);
glVertex3f( 0.5f, -0.5f, 0.0f);
glEnd();
}
static void display(void) {
char filename[SCREENSHOT_MAX_FILENAME];
draw_scene();
if (offscreen) {
glFlush();
} else {
glutSwapBuffers();
}
#if PPM
if (output_formats & PPM_BIT) {
snprintf(filename, SCREENSHOT_MAX_FILENAME, "tmp.%d.ppm", nframes);
screenshot_ppm(filename, width, height, &pixels);
}
#endif
#if LIBPNG
if (output_formats & LIBPNG_BIT) {
snprintf(filename, SCREENSHOT_MAX_FILENAME, "tmp.%d.png", nframes);
screenshot_png(filename, width, height, &pixels, &png_bytes, &png_rows);
}
#endif
# if FFMPEG
if (output_formats & FFMPEG_BIT) {
frame->pts = nframes;
ffmpeg_encoder_glread_rgb(&rgb, &pixels, width, height);
ffmpeg_encoder_encode_frame(rgb);
}
#endif
nframes++;
if (model_finished())
exit(EXIT_SUCCESS);
}
static void idle(void) {
while (model_update());
glutPostRedisplay();
}
int main(int argc, char **argv) {
int arg;
GLint glut_display;
/* CLI args. */
glutInit(&argc, argv);
arg = 1;
if (argc > arg) {
offscreen = (argv[arg][0] == '1');
} else {
offscreen = 1;
}
arg++;
if (argc > arg) {
max_nframes = strtoumax(argv[arg], NULL, 10);
}
arg++;
if (argc > arg) {
width = strtoumax(argv[arg], NULL, 10);
}
arg++;
if (argc > arg) {
height = strtoumax(argv[arg], NULL, 10);
}
arg++;
if (argc > arg) {
output_formats = strtoumax(argv[arg], NULL, 10);
}
/* Work. */
if (offscreen) {
/* TODO: if we use anything smaller than the window, it only renders a smaller version of things. */
/*glutInitWindowSize(50, 50);*/
glutInitWindowSize(width, height);
glut_display = GLUT_SINGLE;
} else {
glutInitWindowSize(width, height);
glutInitWindowPosition(100, 100);
glut_display = GLUT_DOUBLE;
}
glutInitDisplayMode(glut_display | GLUT_RGBA | GLUT_DEPTH);
glutCreateWindow(argv[0]);
if (offscreen) {
/* TODO: if we hide the window the program blocks. */
/*glutHideWindow();*/
}
init();
glutDisplayFunc(display);
glutIdleFunc(idle);
atexit(deinit);
glutMainLoop();
return EXIT_SUCCESS;
}
安装sdk:
sudo apt-get install libpng-dev libavcodec-dev libavutil-dev
编译:
gcc -DPPM=1 -DLIBPNG=1 -DFFMPEG=1 -ggdb3 -std=c99 -O0 -Wall -Wextra \
-o offscreen offscreen.c -lGL -lGLU -lglut -lpng -lavcodec -lswscale -lavutil
运行:
./offscreen
然后就生成了一堆你需要的 ppm, png, mpg文件
参考1: https://stackoverflow.com/questions/3191978/how-to-use-glut-opengl-to-render-to-a-file
参考2: https://github.com/cirosantilli/cpp-cheat/blob/master/opengl/offscreen.c
我的意思是如何通过telnet或者ssh访问设备?
本站搜一下 dropbear:
https://whycan.cn/t_2035.html
https://whycan.cn/t_639.html
https://whycan.cn/t_710.html
https://whycan.cn/t_547.html
还有很多, 你自己搜索一下。
晕哥的VIP百度云
呀!你也用立创EDA呀,他们新出了个开源硬件平台 https://oshwhub.com/(立创EDA开源硬件平台),这些资料可以顺带上传到他们那啊。
这个可以有, 下次用 lceda 画板可以传上去玩玩。
液晶屏是 天马TM101JDHP01 LVDS 接口, 哪位有靠谱的供应商推荐吗?
找到一个原理图:
https://whycan.cn/t_323.html#p31729
https://whycan.cn/files/members/1613/lvds.pdf
对, 隐隐约约看到 SN75LVDS83, 看到 AM335x 也没有LVDS接口了.
这位大神推荐的 GM8285C 便宜多了
这些二进制Blob非常有用,因为它们现在允许在Allwinner平台上具有完全正常的OpenGL加速:
作为稳定性测试,我们最近在Allwinner A33平台上运行了一个Qt5应用程序,
在Allwinner A33平台上进行OpenGL渲染24/7,持续了1.5个月。当然,从长远来看,
我们将跟踪Lima项目的进度,该项目将提供一个完全免费的开源解决方案,
以在Allwinner平台上提供OpenGL加速。
看来稳定性不错嘛.
还有一个问题, https://github.com/bootlin/mali-blobs/tree/master/r6p2/arm/wayland
这些文件是谁发布的呢?
全志?arm?
root@test5:/opt/virtualgl/build# make
[ 2%] Built target vglutil
[ 2%] Built target vglsocket
[ 2%] Built target nettest
[ 3%] Built target fbx-faker
[ 4%] Built target pftest
[ 4%] Built target fbx
[ 5%] Built target bmptest
[ 5%] Built target fbxtest
[ 5%] Built target threadtest
[ 6%] Built target fbxv
[ 7%] Built target fbxvtest
[ 8%] Built target glreadtest
[ 8%] Built target glframe
[ 9%] Built target vglcommon
[ 9%] Built target frameut
[ 10%] Built target gefaker
[ 11%] Built target x11transut
[ 12%] Built target dlfaker
[ 13%] Built target vgltrans_test
[ 13%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/ConfigHash.cpp.o
[ 13%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/ContextHash.cpp.o
[ 14%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/DisplayHash.cpp.o
[ 14%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/faker.cpp.o
[ 14%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/faker-gl.cpp.o
[ 14%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/faker-glx.cpp.o
[ 15%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/faker-sym.cpp.o
[ 15%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/faker-x11.cpp.o
[ 15%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/faker-xcb.cpp.o
[ 16%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/XCBConnHash.cpp.o
[ 16%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/fakerconfig.cpp.o
[ 16%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/GlobalCriticalSection.cpp.o
[ 16%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/GLXDrawableHash.cpp.o
[ 17%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/glxvisual.cpp.o
[ 17%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/PixmapHash.cpp.o
[ 17%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/ReverseConfigHash.cpp.o
[ 18%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/TransPlugin.cpp.o
[ 18%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/VirtualDrawable.cpp.o
[ 18%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/VirtualPixmap.cpp.o
[ 18%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/VirtualWin.cpp.o
[ 19%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/VisualHash.cpp.o
[ 19%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/WindowHash.cpp.o
[ 19%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/X11Trans.cpp.o
[ 20%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/vglconfigLauncher.cpp.o
[ 20%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/VGLTrans.cpp.o
[ 20%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/XVTrans.cpp.o
[ 20%] Building CXX object server/CMakeFiles/vglfaker-opencl.dir/faker-ocl.cpp.o
[ 21%] Linking CXX shared library ../lib/libvglfaker-opencl.so
[ 22%] Built target vglfaker-opencl
[ 59%] Built target fltk_static
[ 60%] Built target vglconfig
Scanning dependencies of target vglfaker
[ 61%] Building CXX object server/CMakeFiles/vglfaker.dir/ConfigHash.cpp.o
[ 61%] Building CXX object server/CMakeFiles/vglfaker.dir/ContextHash.cpp.o
[ 61%] Building CXX object server/CMakeFiles/vglfaker.dir/DisplayHash.cpp.o
[ 62%] Building CXX object server/CMakeFiles/vglfaker.dir/faker.cpp.o
[ 62%] Building CXX object server/CMakeFiles/vglfaker.dir/faker-gl.cpp.o
[ 62%] Building CXX object server/CMakeFiles/vglfaker.dir/faker-glx.cpp.o
[ 62%] Building CXX object server/CMakeFiles/vglfaker.dir/faker-sym.cpp.o
[ 63%] Building CXX object server/CMakeFiles/vglfaker.dir/faker-x11.cpp.o
[ 63%] Building CXX object server/CMakeFiles/vglfaker.dir/faker-xcb.cpp.o
[ 63%] Building CXX object server/CMakeFiles/vglfaker.dir/XCBConnHash.cpp.o
[ 64%] Building CXX object server/CMakeFiles/vglfaker.dir/fakerconfig.cpp.o
[ 64%] Building CXX object server/CMakeFiles/vglfaker.dir/GlobalCriticalSection.cpp.o
[ 64%] Building CXX object server/CMakeFiles/vglfaker.dir/GLXDrawableHash.cpp.o
[ 64%] Building CXX object server/CMakeFiles/vglfaker.dir/glxvisual.cpp.o
[ 65%] Building CXX object server/CMakeFiles/vglfaker.dir/PixmapHash.cpp.o
[ 65%] Building CXX object server/CMakeFiles/vglfaker.dir/ReverseConfigHash.cpp.o
[ 65%] Building CXX object server/CMakeFiles/vglfaker.dir/TransPlugin.cpp.o
[ 66%] Building CXX object server/CMakeFiles/vglfaker.dir/VirtualDrawable.cpp.o
[ 66%] Building CXX object server/CMakeFiles/vglfaker.dir/VirtualPixmap.cpp.o
[ 66%] Building CXX object server/CMakeFiles/vglfaker.dir/VirtualWin.cpp.o
[ 66%] Building CXX object server/CMakeFiles/vglfaker.dir/VisualHash.cpp.o
[ 67%] Building CXX object server/CMakeFiles/vglfaker.dir/WindowHash.cpp.o
[ 67%] Building CXX object server/CMakeFiles/vglfaker.dir/X11Trans.cpp.o
[ 67%] Building CXX object server/CMakeFiles/vglfaker.dir/vglconfigLauncher.cpp.o
[ 68%] Building CXX object server/CMakeFiles/vglfaker.dir/VGLTrans.cpp.o
[ 68%] Building CXX object server/CMakeFiles/vglfaker.dir/XVTrans.cpp.o
[ 68%] Linking CXX shared library ../lib/libvglfaker.so
[ 68%] Built target vglfaker
Scanning dependencies of target vglfaker-nodl
[ 68%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/ConfigHash.cpp.o
[ 68%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/ContextHash.cpp.o
[ 68%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/DisplayHash.cpp.o
[ 69%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/faker.cpp.o
[ 69%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/faker-gl.cpp.o
[ 69%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/faker-glx.cpp.o
[ 70%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/faker-sym.cpp.o
[ 70%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/faker-x11.cpp.o
[ 70%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/faker-xcb.cpp.o
[ 70%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/XCBConnHash.cpp.o
[ 71%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/fakerconfig.cpp.o
[ 71%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/GlobalCriticalSec tion.cpp.o
[ 71%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/GLXDrawableHash.c pp.o
[ 72%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/glxvisual.cpp.o
[ 72%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/PixmapHash.cpp.o
[ 72%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/ReverseConfigHash .cpp.o
[ 72%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/TransPlugin.cpp.o
[ 73%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/VirtualDrawable.c pp.o
[ 73%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/VirtualPixmap.cpp .o
[ 73%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/VirtualWin.cpp.o
[ 74%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/VisualHash.cpp.o
[ 74%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/WindowHash.cpp.o
[ 74%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/X11Trans.cpp.o
[ 74%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/vglconfigLauncher .cpp.o
[ 75%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/VGLTrans.cpp.o
[ 75%] Building CXX object server/CMakeFiles/vglfaker-nodl.dir/XVTrans.cpp.o
[ 75%] Linking CXX shared library ../lib/libvglfaker-nodl.so
[ 76%] Built target vglfaker-nodl
Scanning dependencies of target vgltransut
[ 76%] Building CXX object server/CMakeFiles/vgltransut.dir/vgltransut.cpp.o
[ 77%] Building CXX object server/CMakeFiles/vgltransut.dir/VGLTrans.cpp.o
[ 77%] Building CXX object server/CMakeFiles/vgltransut.dir/fakerconfig.cpp.o
[ 77%] Linking CXX executable ../bin/vgltransut
[ 77%] Built target vgltransut
[ 78%] Built target dlfakerut
[ 78%] Built target deepbindtest
[ 78%] Built target GLdlfakerut
Scanning dependencies of target vgltrans_test2
[ 79%] Building CXX object server/CMakeFiles/vgltrans_test2.dir/testplugin2.cpp. o
[ 79%] Building CXX object server/CMakeFiles/vgltrans_test2.dir/X11Trans.cpp.o
[ 79%] Linking CXX shared library ../lib/libvgltrans_test2.so
[ 79%] Built target vgltrans_test2
[ 80%] Built target fakerut
Scanning dependencies of target vglclient
[ 80%] Building CXX object client/CMakeFiles/vglclient.dir/vglclient.cpp.o
[ 81%] Building CXX object client/CMakeFiles/vglclient.dir/ClientWin.cpp.o
[ 81%] Building CXX object client/CMakeFiles/vglclient.dir/VGLTransReceiver.cpp. o
[ 81%] Linking CXX executable ../bin/vglclient
[ 81%] Built target vglclient
[ 82%] Built target xrotfontdemo
[ 83%] Built target pbdemo
[ 84%] Built target glxspheres64
[ 85%] Built target glxinfo
[ 86%] Built target wincopy
[ 87%] Built target texture_from_pixmap
[ 88%] Built target glxcontexts
[ 89%] Built target glxgears
[ 90%] Built target glthreadsint
[ 91%] Built target xfont
[ 92%] Built target sharedtex
[ 92%] Built target glthreads
[ 92%] Built target shape
[ 92%] Built target glxdemo
[ 93%] Built target testgl5
[ 93%] Built target glxgears_pixmap
[ 94%] Built target glxheads
[ 95%] Built target offset
[ 95%] Built target glxpbdemo
[ 96%] Built target pbinfo
[ 97%] Built target glxpixmap
[ 98%] Built target sharedtex_mt
[ 99%] Built target manywin
[ 99%] Built target overlay
[ 99%] Built target imgdiff
[100%] Built target cpustat
[100%] Built target tcbench
root@test5:/opt/virtualgl/build# ls
bin CMakeCache.txt cmake_install.cmake common doc include Makefile server util
client CMakeFiles cmake_uninstall.cmake diags glxdemos lib pkgscripts staticlib
root@test5:/opt/virtualgl/build# cd bin/
root@test5:/opt/virtualgl/build/bin# ls
bmptest fbxvtest glxcontexts glxinfo manywin pbinfo sharedtex_mt utiltest vgltransut
cpustat frameut glxdemo glxpbdemo nettest pftest tcbench vglclient wincopy
dlfakerut glreadtest glxgears glxpixmap offset servertest testgl5 vglconfig x11transut
fakerut glthreads glxgears_pixmap glxspheres64 overlay shape texture_from_pixmap vglconnect xfont
fbxtest glthreadsint glxheads imgdiff pbdemo sharedtex threadtest vglrun xrotfontdemo
root@test5:/opt/virtualgl/build/bin# cd ..
root@test5:/opt/virtualgl/build# make install
[ 2%] Built target vglutil
[ 2%] Built target vglsocket
[ 2%] Built target nettest
[ 3%] Built target fbx-faker
[ 4%] Built target pftest
[ 4%] Built target fbx
[ 5%] Built target bmptest
[ 5%] Built target fbxtest
[ 5%] Built target threadtest
[ 6%] Built target fbxv
[ 7%] Built target fbxvtest
[ 8%] Built target glreadtest
[ 8%] Built target glframe
[ 9%] Built target vglcommon
[ 9%] Built target frameut
[ 10%] Built target gefaker
[ 11%] Built target x11transut
[ 12%] Built target dlfaker
[ 13%] Built target vgltrans_test
[ 22%] Built target vglfaker-opencl
[ 59%] Built target fltk_static
[ 60%] Built target vglconfig
[ 68%] Built target vglfaker
[ 76%] Built target vglfaker-nodl
[ 77%] Built target vgltransut
[ 78%] Built target dlfakerut
[ 78%] Built target deepbindtest
[ 78%] Built target GLdlfakerut
[ 79%] Built target vgltrans_test2
[ 80%] Built target fakerut
[ 81%] Built target vglclient
[ 82%] Built target xrotfontdemo
[ 83%] Built target pbdemo
[ 84%] Built target glxspheres64
[ 85%] Built target glxinfo
[ 86%] Built target wincopy
[ 87%] Built target texture_from_pixmap
[ 88%] Built target glxcontexts
[ 89%] Built target glxgears
[ 90%] Built target glthreadsint
[ 91%] Built target xfont
[ 92%] Built target sharedtex
[ 92%] Built target glthreads
[ 92%] Built target shape
[ 92%] Built target glxdemo
[ 93%] Built target testgl5
[ 93%] Built target glxgears_pixmap
[ 94%] Built target glxheads
[ 95%] Built target offset
[ 95%] Built target glxpbdemo
[ 96%] Built target pbinfo
[ 97%] Built target glxpixmap
[ 98%] Built target sharedtex_mt
[ 99%] Built target manywin
[ 99%] Built target overlay
[ 99%] Built target imgdiff
[100%] Built target cpustat
[100%] Built target tcbench
Install the project...
-- Install configuration: "Release"
-- Installing: /opt/VirtualGL/bin/nettest
-- Installing: /opt/VirtualGL/bin/glreadtest
-- Installing: /opt/VirtualGL/lib64/libvglfaker.so
-- Installing: /opt/VirtualGL/lib64/libvglfaker-nodl.so
-- Installing: /opt/VirtualGL/lib64/libvglfaker-opencl.so
-- Installing: /opt/VirtualGL/lib64/libdlfaker.so
-- Installing: /opt/VirtualGL/lib64/libgefaker.so
-- Installing: /opt/VirtualGL/include/rr.h
-- Installing: /opt/VirtualGL/include/rrtransport.h
-- Installing: /opt/VirtualGL/bin/vglconfig
-- Installing: /opt/VirtualGL/bin/vglgenkey
-- Installing: /opt/VirtualGL/bin/vgllogin
-- Installing: /opt/VirtualGL/bin/vglserver_config
-- Installing: /opt/VirtualGL/bin/vglrun
-- Installing: /opt/VirtualGL/bin/.vglrun.vars64
-- Installing: /opt/VirtualGL/bin/vglclient
-- Installing: /opt/VirtualGL/bin/vglconnect
-- Installing: /opt/VirtualGL/bin/glxinfo
-- Installing: /opt/VirtualGL/bin/glxspheres64
-- Installing: /opt/VirtualGL/bin/cpustat
-- Installing: /opt/VirtualGL/bin/tcbench
-- Installing: /opt/VirtualGL/doc/configdialog.gif
-- Installing: /opt/VirtualGL/doc/subsampling.gif
-- Installing: /opt/VirtualGL/doc/somerights20.png
-- Installing: /opt/VirtualGL/doc/sshtunnel.png
-- Installing: /opt/VirtualGL/doc/vgltransport.png
-- Installing: /opt/VirtualGL/doc/vgltransportservernetwork.png
-- Installing: /opt/VirtualGL/doc/x11transport.png
-- Installing: /opt/VirtualGL/doc/LICENSE-FLTK.txt
-- Installing: /opt/VirtualGL/doc/LICENSE.txt
-- Installing: /opt/VirtualGL/doc/LGPL.txt
-- Installing: /opt/VirtualGL/doc/index.html
-- Installing: /opt/VirtualGL/doc/virtualgl.css
-- Installing: /opt/VirtualGL/doc/ChangeLog.md
root@test5:/opt/virtualgl/build#
搞定, 接着跑一下试一试。
1. 准备
sudo apt-get install libturbojpeg-dev libopencl-dev libxtst-dev libxcb*-dev -y
2. 克隆
git clone https://github.com/VirtualGL/virtualgl.git
3. 编译
cd virtualgl
mkdir build
cd build
cmake ..
https://whycan.cn/t_2940.html#p24311
https://whycan.cn/t_1672.html#p22720
试一试 @checkout 大神这个修改: https://whycan.cn/t_1672.html#p22720
直接按照上面各位大佬的步骤patch到4.14内核是没问题的,但荔枝派官方4.14-exp版本内核有个bug,就是105楼@Peter所遇到的
填坑:修改drivers/usb/musb/sunxi.c:742行- of_device_is_compatible(np, "allwinner,suniv-musb")) { + of_device_is_compatible(np, "allwinner,suniv-f1c100s-musb")) {
移植到单片机没有?
awtk 已经用上了nanovg:
https://github.com/zlgopen/awtk/tree/master/3rd/nanovg
后端软件渲染引擎:
https://github.com/zlgopen/awtk/tree/master/3rd/agg
源码: https://github.com/wjakob/nanogui
1. 准备工作:
sudo apt-get install libglfw3-dev -y
2. 克隆源码:
git clone https://github.com/wjakob/nanogui
cd nanogui
git submodule update --init --recursive
3. 编译:
cmake .
make
4. 运行:
./example1
./example2
./example3
./example4
//画图区域限制在 圆心(128,128) 半径36.8 的圆内
cairo_arc(cr, 128.0, 128.0, 36.8, 0, 2 * M_PI);
cairo_clip(cr);
//填充一个矩形区域
cairo_new_path(cr);
cairo_rectangle(cr, 0, 0, 256, 256);
cairo_set_source_rgba(cr, 0.3, 0.3, 0.3, 0.1);
cairo_fill(cr);
//画 x
cairo_set_source_rgba(cr, 0, 1, 0, 0.5);
cairo_move_to(cr, 0, 0);
cairo_line_to(cr, 256, 256);
cairo_move_to(cr, 256, 0);
cairo_line_to(cr, 0, 256);
cairo_set_line_width(cr, 10.0);
cairo_stroke(cr);
参考1 https://www.cairographics.org/samples/
参考2 https://www.cairographics.org/tutorial/
参考3 https://github.com/apachecn/zetcode-zh/
参考4 https://github.com/apachecn/zetcode-zh/blob/master/docs/graph/30.md
double xc = 20.0;
double yc = 20.0;
double radius = 200.0;
double angle1 = 0.0 * (M_PI / 180.0); /* angles are specified */
double angle2 = 45.0 * (M_PI / 180.0); /* in radians */
cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
cairo_set_line_width(cr, 1.0);
cairo_arc(cr, xc, yc, radius, angle1, angle2);
cairo_stroke(cr);
/* draw helping lines */
cairo_set_source_rgba(cr, 1, 0.2, 0.2, 0.6);
cairo_set_line_width(cr, 1.0);
cairo_arc(cr, xc, yc, 3.0, 0, 2 * M_PI);
cairo_fill(cr);
cairo_arc(cr, xc, yc, radius, angle1, angle1);
cairo_line_to(cr, xc, yc);
cairo_arc(cr, xc, yc, radius, angle2, angle2);
cairo_line_to(cr, xc, yc);
//cairo_fill(cr);
cairo_stroke(cr);
cairo_fill(cr);
参考1 https://www.cairographics.org/samples/
参考2 https://www.cairographics.org/tutorial/
改了几行代码, 把点都标出来 bspline.c
/*! \file bspline.c
* This file contains the functions to calculate control points from a list of
* points for drawing bezier curves.
*
* License: This is free software. Take it, use it, modify it!
*
* @author Bernhard R. Fischer
* @version 2015/11/30
*
*/
#include <stdio.h>
#include <cairo.h>
#include <math.h>
#include "bspline.h"
void draw_dot(cairo_t *ctx, int x, int y)
{
//int x=50.0;
//int y=400.0;
cairo_move_to (ctx, x,y);
/* draw helping lines */
cairo_set_source_rgba (ctx, 1, 0.2, 0.2, 0.6);
cairo_set_line_width (ctx, 6.0);
cairo_arc (ctx, x, y, 10.0, 0, 2*M_PI);
cairo_fill (ctx);
}
int main(int argc, char **argv)
{
// Cairo surface and context.
cairo_surface_t *dst;
cairo_t *ctx;
// Loop variable and variable for number of Points.
int cnt;
// Array of points.
point_t pt[] = {{50, 400}, {500, 400}, {650, 220}, {480,90}, {430, 100}, {400, 110}, {300, 190}, };
// Alternative array of points.
//point_t pt[] = {{160, 190}, {100, 400}, {470, 600}, {300, 200}, {400, 150},
// {470, 250}, {575, 400}, {630, 390}, {650, 300}, {670, 210}};
/* This parameter defines if the points shall be connected in a loop (start
* = 0) or as open line (start = 1). */
int start = 1;
// Number of points in array.
cnt = sizeof(pt) / sizeof(*pt);
//#define WITH_RAND
#ifdef WITH_RAND
srand(time(NULL));
for (int i = 0; i < cnt; i++)
pt[i].x = rand() % 800, pt[i].y = rand() % 800;
#endif
// Create and init Cairo drawing context.
dst = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 800, 800);
ctx = cairo_create(dst);
COL_BG(ctx);
cairo_paint(ctx);
for(int i=0;i<sizeof(pt)/sizeof(pt[0]);i++)
{
draw_dot(ctx, pt[i].x, pt[i].y);
}
#if 0
draw_dot(ctx, pt[0].x, pt[0].y);
draw_dot(ctx, pt[1].x, pt[1].y);
draw_dot(ctx, pt[2].x, pt[2].y);
draw_dot(ctx, pt[3].x, pt[3].y);
#endif
// Draw curve between the points pt.
draw_curve(ctx, pt, cnt, start);
// Save image and destroy Cairo context.
cairo_destroy(ctx);
cairo_surface_write_to_png(dst, "bspline.png");
cairo_surface_destroy(dst);
return 0;
}
bspline.c
/*! \file bspline.c
* This file contains the functions to calculate control points from a list of
* points for drawing bezier curves.
*
* License: This is free software. Take it, use it, modify it!
*
* @author Bernhard R. Fischer
* @version 2015/11/30
*
*/
#include <stdio.h>
#include <cairo.h>
#include <math.h>
#include "bspline.h"
int main(int argc, char **argv)
{
// Cairo surface and context.
cairo_surface_t *dst;
cairo_t *ctx;
// Loop variable and variable for number of Points.
int cnt;
// Array of points.
point_t pt[] = {{50, 400}, {500, 400}, {650, 220}, {480,90}};
// Alternative array of points.
//point_t pt[] = {{160, 190}, {100, 400}, {470, 600}, {300, 200}, {400, 150},
// {470, 250}, {575, 400}, {630, 390}, {650, 300}, {670, 210}};
/* This parameter defines if the points shall be connected in a loop (start
* = 0) or as open line (start = 1). */
int start = 1;
// Number of points in array.
cnt = sizeof(pt) / sizeof(*pt);
//#define WITH_RAND
#ifdef WITH_RAND
srand(time(NULL));
for (int i = 0; i < cnt; i++)
pt[i].x = rand() % 800, pt[i].y = rand() % 800;
#endif
// Create and init Cairo drawing context.
dst = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 800, 800);
ctx = cairo_create(dst);
COL_BG(ctx);
cairo_paint(ctx);
// Draw curve between the points pt.
draw_curve(ctx, pt, cnt, start);
// Save image and destroy Cairo context.
cairo_destroy(ctx);
cairo_surface_write_to_png(dst, "bspline.png");
cairo_surface_destroy(dst);
return 0;
}
bspline_constr.c
#ifdef CONSTRUCTION
#include <stdio.h>
#include <cairo.h>
#include <math.h>
#include "bspline.h"
static void dp(cairo_t *ctx, double x, double y)
{
cairo_rectangle(ctx, x - R, y - R, R * 2, R * 2);
cairo_fill(ctx);
}
static void show_angle(cairo_t *ctx, const line_t *l)
{
char buf[20];
double a;
a = angle(l);
snprintf(buf, sizeof(buf), "%.1f°", a * 180 / M_PI);
cairo_save(ctx);
cairo_move_to(ctx, (l->A.x + l->B.x) / 2, (l->A.y + l->B.y) / 2 - 5);
if (a < -M_PI_2 || a > M_PI_2)
a += M_PI;
cairo_rotate(ctx, a);
cairo_show_text(ctx, buf);
cairo_restore(ctx);
}
void draw_lines(cairo_t *ctx, const point_t *pt, int cnt)
{
char buf[20];
int i;
cairo_save(ctx);
cairo_set_line_width(ctx, W_LINE);
COL_LINE(ctx);
cairo_new_path(ctx);
for (i = 0; i < cnt; i++)
cairo_line_to(ctx, pt[i].x, pt[i].y);
cairo_stroke(ctx);
cairo_select_font_face(ctx, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size(ctx, F_SIZE);
for (i = 0; i < cnt; i++)
{
snprintf(buf, sizeof(buf), "P%d", i);
cairo_move_to(ctx, pt[i].x - 5, pt[i].y + 14);
cairo_show_text(ctx, buf);
if (i < cnt - 1)
show_angle(ctx, &((line_t) {pt[i], pt[(i + 1) % cnt]}));
}
cairo_restore(ctx);
}
void draw_construction(cairo_t *ctx, const point_t *pt, int cnt, int start)
{
point_t c1, c2, prev_p;
line_t g, l;
double dash[] = {10, 5};
char buf[20];
int i;
cairo_save(ctx);
cairo_select_font_face(ctx, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size(ctx, F_SIZE);
for (i = start; i < cnt; i++)
{
g.A = pt[(i + cnt - 2) % cnt];
g.B = pt[(i + cnt - 1) % cnt];
l.A = pt[(i + cnt + 0) % cnt];
l.B = pt[(i + cnt + 1) % cnt];
control_points(&g, &l, &c1, &c2);
if (start && i == 1) c1 = g.B;
if (start && i == cnt - 1) c2 = l.A;
COL_C1(ctx);
dp(ctx, c1.x, c1.y);
snprintf(buf, sizeof(buf), "C1[%d] (%d/%d)", i, (int) c1.x, (int) c1.y);
cairo_move_to(ctx, c1.x + 5, c1.y);
cairo_show_text(ctx, buf);
COL_C2(ctx);
dp(ctx, c2.x, c2.y);
snprintf(buf, sizeof(buf), "C2[%d] (%d/%d)", i, (int) c2.x, (int) c2.y);
cairo_move_to(ctx, c2.x + 5, c2.y);
cairo_show_text(ctx, buf);
if (i > start)
{
cairo_save(ctx);
COL_TLINE(ctx);
cairo_set_line_width(ctx, 1);
cairo_set_dash(ctx, dash, 2, 0);
cairo_move_to(ctx, prev_p.x, prev_p.y);
cairo_line_to(ctx, c1.x, c1.y);
cairo_stroke(ctx);
cairo_restore(ctx);
}
prev_p = c2;
}
cairo_restore(ctx);
}
#endif
bspline_ctrl.c
/*! \file bspline_ctrl.c
* This file contains the functions to calculate control points from a list of
* points for drawing bezier curves.
*
* License: This is free software. Take it, use it, modify it!
*
* @author Bernhard R. Fischer
* @version 2015/11/30
*
*/
#include <cairo.h>
#include <math.h>
#include "bspline.h"
// This factor defines the "curviness". Play with it!
#define CURVE_F 0.25
// This defines the method of using isosceles triangles. Undefine it to see the
// method of equal distances.
#define ISOSCELES_TRIANGLE
/*! This function calculates the angle of line in respect to the coordinate
* system.
* @param g Pointer to a line.
* @return Returns the angle in radians.
*/
double angle(const line_t *g)
{
return atan2(g->B.y - g->A.y, g->B.x - g->A.x);
}
/*! This function calculates the control points. It takes two lines g and l as
* arguments but it takes three lines into account for calculation. This is
* line g (P0/P1), line h (P1/P2), and line l (P2/P3). The control points being
* calculated are actually those for the middle line h, this is from P1 to P2.
* Line g is the predecessor and line l the successor of line h.
* @param g Pointer to first line.
* @param l Pointer to third line (the second line is connecting g and l).
* @param p1 Pointer to memory of first control point. This will receive the
* coordinates.
* @param p2 Pointer to memory of second control point.
*/
void control_points(const line_t *g, const line_t *l, point_t *p1, point_t *p2)
{
line_t h;
double f = CURVE_F;
double lgt, a;
// calculate length of line (P1/P2)
lgt = sqrt(pow(g->B.x - l->A.x, 2) + pow(g->B.y - l->A.y, 2));
#ifdef ISOSCELES_TRIANGLE
// end point of 1st tangent
h.B = l->A;
// start point of tangent at same distance as end point along 'g'
h.A.x = g->B.x - lgt * cos(angle(g));
h.A.y = g->B.y - lgt * sin(angle(g));
#else
h.A = g->A;
h.B = l->A;
#endif
// angle of tangent
a = angle(&h);
// 1st control point on tangent at distance 'lgt * f'
p1->x = g->B.x + lgt * cos(a) * f;
p1->y = g->B.y + lgt * sin(a) * f;
#ifdef ISOSCELES_TRIANGLE
// start point of 2nd tangent
h.A = g->B;
// end point of tangent at same distance as start point along 'l'
h.B.x = l->A.x + lgt * cos(angle(l));
h.B.y = l->A.y + lgt * sin(angle(l));
#else
h.A = g->B;
h.B = l->B;
#endif
// angle of tangent
a = angle(&h);
// 2nd control point on tangent at distance 'lgt * f'
p2->x = l->A.x - lgt * cos(a) * f;
p2->y = l->A.y - lgt * sin(a) * f;
}
void draw_curve(cairo_t *ctx, const point_t *pt, int cnt, int start)
{
// Helping variables for lines.
line_t g, l;
// Variables for control points.
point_t c1, c2;
#ifdef CONSTRUCTION
// Draw direct lines between points.
draw_lines(ctx, pt, cnt);
#endif
// Draw bezier curve through all points.
COL_CURVE(ctx);
cairo_set_line_width(ctx, W_CURVE);
cairo_move_to(ctx, pt[(start - 1 + cnt) % cnt].x, pt[(start - 1 + cnt) % cnt].y);
for (int i = start; i < cnt; i++)
{
g.A = pt[(i + cnt - 2) % cnt];
g.B = pt[(i + cnt - 1) % cnt];
l.A = pt[(i + cnt + 0) % cnt];
l.B = pt[(i + cnt + 1) % cnt];
// Calculate controls points for points pt[i-1] and pt[i].
control_points(&g, &l, &c1, &c2);
// Handle special case if points are not connected in a loop.
if (start && i == 1) c1 = g.B;
if (start && i == cnt - 1) c2 = l.A;
// Create Cairo curve path.
cairo_curve_to(ctx, c1.x, c1.y, c2.x, c2.y, pt[i].x, pt[i].y);
}
// Actually draw curve.
cairo_stroke(ctx);
#ifdef CONSTRUCTION
// Draw construction lines.
draw_construction(ctx, pt, cnt, start);
#endif
}
bspline.h
#ifndef BSPLINE_H
#define BSPLINE_H
#include <cairo.h>
#define COL_BG(x) cairo_set_source_rgb(x, 1, 1, 1)
#define COL_CURVE(x) cairo_set_source_rgb(x, 0, 0, 1)
#define COL_LINE(x) cairo_set_source_rgb(ctx, 0, 0, 0)
#define COL_C1(x) cairo_set_source_rgb(ctx, 1, 0.2, 0.2)
#define COL_C2(x) cairo_set_source_rgb(ctx, 0.2, 0.8, 0.2)
#define COL_TLINE(x) cairo_set_source_rgb(ctx, 1, 0.2, 0.2)
#define COL_HLINE(x) cairo_set_source_rgb(ctx, 0, 0, 0)
#define W_CURVE 5
#define W_LINE 2
#define F_SIZE 10
#define R 3
typedef struct point
{
double x, y;
} point_t;
typedef struct line
{
point_t A, B;
} line_t;
#ifdef CONSTRUCTION
void draw_lines(cairo_t *, const point_t *, int );
void draw_construction(cairo_t *, const point_t *, int , int );
#endif
double angle(const line_t *);
void control_points(const line_t *, const line_t *, point_t *, point_t *);
void draw_curve(cairo_t *, const point_t *, int , int );
#endif
根文件系统用 debian 替换, 就可以为所欲为了: https://whycan.cn/t_3287.html
***保留的内存区域***
预留内存被指定为/ reserved-memory节点下的一个节点。
操作系统应从正常使用中排除保留的内存
一个人可以创建描述特定保留的子节点(不包括在
正常使用)存储区域。通常将此类存储区设计用于
各种设备驱动程序的特殊用法。可以将每个存储区的参数编码到设备树中
应该是在设备书中修改这个值, 这些内存可能是编解码器用的吧?
Linux Reserved Memory: https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18841683/Linux+Reserved+Memory
M9 直接写屏红绿蓝
编译指令: arm-none-linux-gnueabi-gcc main.c -o test -static
#include <stdio.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
#define screen_height 960
#define screen_width 640
int main(void)
{
int devfb0;
unsigned char * fb0;
unsigned char * framebuff;
int i, j;
printf("starting... ... !n");
devfb0 = open("/dev/fb0", O_RDWR);
fb0 = (char *) mmap(0, 960*640*4, PROT_READ | PROT_WRITE, MAP_SHARED, devfb0, 0);
if ( (int) fb0 == -1)
{
printf ("Error: failed to map framebuffer device to memory.\n");
exit (2);
}
else
{
printf ("The framebuffer device was mapped to memory successfully.\n");
}
while(1)
{
framebuff = fb0;
//printf("AAAAAA........3333..............\n");
for (i = 0; i < screen_height; ++i)
{
for (j = 0; j < screen_width; ++j)
{
/* magic transformation: color index to RGB24 */
*framebuff ++ = 0x00; /* blue */
*framebuff ++ = 0x00; /* green */
*framebuff ++ = 0xFF; /* red */
*framebuff ++ = 0xFF; /* alpha */
}
}
}
}