Drawing to video framebuffer in Rotated mode
Jacob Zachariah
jacob_z at yahoo.com
Fri Oct 20 10:07:21 PDT 2006
Hi ,
I'm working with a legacy 2D application that gets the
address of the video framebuffer (/proc/pci -
Prefetchable memory of gfx card) & draws 2d graphics
to it.
When i rotate the display using XrandR or the Nvidia
driver's 'Rotate' methods; drawing to the framebuffer
doesn't work as in normal mode.
The example code below draws rgb bands to the
framebuffer in normal mode.
In rotated mode, when the program is run, I don't see
the colors. But when i move the terminal i see the
colors on the edges of the terminal. Tells me that
maybe the area needs to be marked 'dirty' & the X
server needs to copy it to the rotated buffer or
something to that effect.
What would be fast ways to accomplish this? I'm using
Xorg6.9 on RH 7.3(2.4-18) but am curious about kdrive
so am trying to build Xorg7.1.
Tips would be much appreciated.
best regards
------------------------
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <assert.h>
int main()
{
int val = 4096;
// Prefetchable memory
char ptr[16]="0xf0000000";
unsigned long pVal = strtoul(ptr, NULL, 0);
void * videoBuffer = (void *) pVal;
int fd = open("/dev/mem", O_RDWR);
if (fd == -1)
{
printf("Failed to open server memory access:
%s\n", strerror(errno));
exit(1);
}
void * addr = mmap(0, 0x1000000, PROT_READ |
PROT_WRITE, MAP_SHARED, fd, (long)videoBuffer);
if (addr == (void *) -1)
{
printf("Failed to mmap physical server memory:
%s\n", strerror(errno));
close(fd);
exit(1);
}
unsigned char* pCol = (unsigned char*)addr;
for(int i=0; i<100000; i++)
{
*pCol ++ = 255;
*pCol ++ = 0;
*pCol ++ = 0;
*pCol ++ = 255;
}
for(int i=0; i<100000; i++)
{
*pCol ++ = 0;
*pCol ++ = 255;
*pCol ++ = 0;
*pCol ++ = 255;
}
for(int i=0; i<100000; i++)
{
*pCol ++ = 0;
*pCol ++ = 0;
*pCol ++ = 255;
*pCol ++ = 255;
}
}
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the xorg
mailing list