}
}
+static void
+write_ppm(const char *filename, const GLubyte *buffer, int width, int height)
+{
+ const int binary = 0;
+ FILE *f = fopen( filename, "w" );
+ if (f) {
+ int i, x, y;
+ const GLubyte *ptr = buffer;
+ if (binary) {
+ fprintf(f,"P6\n");
+ fprintf(f,"# ppm-file created by osdemo.c\n");
+ fprintf(f,"%i %i\n", width,height);
+ fprintf(f,"255\n");
+ fclose(f);
+ f = fopen( filename, "ab" ); /* reopen in binary append mode */
+ for (y=height-1; y>=0; y--) {
+ for (x=0; x<width; x++) {
+ i = (y*width + x) * 4;
+ fputc(ptr[i], f); /* write red */
+ fputc(ptr[i+1], f); /* write green */
+ fputc(ptr[i+2], f); /* write blue */
+ }
+ }
+ }
+ else {
+ /*ASCII*/
+ int counter = 0;
+ fprintf(f,"P3\n");
+ fprintf(f,"# ascii ppm file created by osdemo.c\n");
+ fprintf(f,"%i %i\n", width, height);
+ fprintf(f,"255\n");
+ for (y=height-1; y>=0; y--) {
+ for (x=0; x<width; x++) {
+ i = (y*width + x) * 4;
+ fprintf(f, " %3d %3d %3d", ptr[i], ptr[i+1], ptr[i+2]);
+ counter++;
+ if (counter % 5 == 0)
+ fprintf(f, "\n");
+ }
+ }
+ }
+ fclose(f);
+ }
+}
+
+#include "../src/egl/main/egldisplay.h"
+
+typedef struct fb_display
+{
+ _EGLDisplay Base; /* base class/object */
+ void *pFB;
+} fbDisplay;
int
Reshape(1024, 768);
glDrawBuffer( GL_FRONT );
+ glClearColor( 0,
+ 1.0,
+ 0,
+ 1);
- Draw(d, screen_surf);
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ doubleBuffer = 1;
+ glDrawBuffer( GL_BACK );
+ Draw(d, screen_surf);
+
+ write_ppm("dump.ppm", ((struct fb_display *)_eglLookupDisplay(d))->pFB, 1024, 768);
+
eglDestroySurface(d, screen_surf);
eglDestroyContext(d, ctx);
eglTerminate(d);
strerror(errno));
return EGL_FALSE;
}
+
+ if (fixedInfo.visual == FB_VISUAL_DIRECTCOLOR) {
+ struct fb_cmap cmap;
+ unsigned short red[256], green[256], blue[256];
+ int rcols = 1 << varInfo.red.length;
+ int gcols = 1 << varInfo.green.length;
+ int bcols = 1 << varInfo.blue.length;
+ int i;
+
+ cmap.start = 0;
+ cmap.len = gcols;
+ cmap.red = red;
+ cmap.green = green;
+ cmap.blue = blue;
+ cmap.transp = NULL;
+
+ for (i = 0; i < rcols ; i++)
+ red[i] = (65536/(rcols-1)) * i;
+
+ for (i = 0; i < gcols ; i++)
+ green[i] = (65536/(gcols-1)) * i;
+
+ for (i = 0; i < bcols ; i++)
+ blue[i] = (65536/(bcols-1)) * i;
+
+ if (ioctl(fd, FBIOPUTCMAP, (void *) &cmap) < 0) {
+ fprintf(stderr, "ioctl(FBIOPUTCMAP) failed [%d]\n", i);
+ exit(1);
+ }
+ }
/* mmap the framebuffer into our address space */
- disp->pFB = (caddr_t)mmap(0, /* start */
+ if (!disp->pFB)
+ disp->pFB = (caddr_t)mmap(0, /* start */
fixedInfo.smem_len, /* bytes */
PROT_READ | PROT_WRITE, /* prot */
MAP_SHARED, /* flags */
fbShowSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
EGLSurface surface, EGLModeMESA m)
{
- FILE *file;
- char buffer[NAME_MAX];
+ fbDisplay *display = Lookup_fbDisplay(dpy);
fbScreen *scrn = Lookup_fbScreen(dpy, screen);
fbSurface *surf = Lookup_fbSurface(surface);
+ FILE *file;
+ char buffer[NAME_MAX];
_EGLMode *mode = _eglLookupMode(dpy, m);
int bits;
fputs(buffer, file);
fclose(file);
+ fbSetupFramebuffer(display, scrn->fb);
+
snprintf(buffer, sizeof(buffer), "%s/%s/blank", sysfs, scrn->fb);
file = fopen(buffer, "r+");