Affichage avec le framebuffer Linux
amal89
Messages postés
1
Date d'inscription
Statut
Membre
Dernière intervention
-
Bogomips Messages postés 125 Date d'inscription Statut Membre Dernière intervention -
Bogomips Messages postés 125 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
j'utilise le code de synthèse 3D celui de shaune Daure s'executant sur une plateforme windows avec compilateur turboC3
j'ai voulu afficher la matrice virtuelle sur le système linux embarqué(carte devkit8000) en accédant directement au framebuffer(sans utilisation d'une biblio graphique)
j'ai utilisé le code suivant:
Mais pour le résultat j'ai eu une succession de forme 2D non 3D au lieu d'avoir un seul objet 3D
SVP il y a t'il quelqu'un qui peut m'aider
merciii
j'utilise le code de synthèse 3D celui de shaune Daure s'executant sur une plateforme windows avec compilateur turboC3
j'ai voulu afficher la matrice virtuelle sur le système linux embarqué(carte devkit8000) en accédant directement au framebuffer(sans utilisation d'une biblio graphique)
j'ai utilisé le code suivant:
#include <stdlib.h> #include <unistd.h> #include <stdio.h> #include <fcntl.h> #include <linux/fb.h> #include <sys/mman.h> #include <sys/ioctl.h> int main() { int fbfd = 0; struct fb_var_screeninfo vinfo; struct fb_fix_screeninfo finfo; long int screensize = 0; char *fbp = 0; int x = 0, y = 0; long int location = 0; // Open the file for reading and writing fbfd = open("/dev/fb0", O_RDWR); if (fbfd == -1) { perror("Error: cannot open framebuffer device"); exit(1); } printf("The framebuffer device was opened successfully.\n"); // Get fixed screen information if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo) == -1) { perror("Error reading fixed information"); exit(2); } // Get variable screen information if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo) == -1) { perror("Error reading variable information"); exit(3); } printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel); // Figure out the size of the screen in bytes screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; // Map the device to memory fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0); if ((int)fbp == -1) { perror("Error: failed to map framebuffer device to memory"); exit(4); } printf("The framebuffer device was mapped to memory successfully.\n"); x = 0; y = 0; // Where we are going to put the pixel int k=0; // Figure out where in memory to put the pixel for (y = 0; y < 480; y++) for (x = 0; x < 800; x++) { location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) + (y+vinfo.yoffset) * finfo.line_length; // if (vinfo.bits_per_pixel == 32) { // *(fbp + location) = virtuel[k+2]; // Some blue // *(fbp + location + 1) = virtuel[k+1]; // A little green // *(fbp + location + 2) = virtuel[k]; // A lot of red // *(fbp + location + 3) = 0; // No transparency *(fbp + location) = 250; *(fbp + location + 1) =250; *(fbp + location + 2) = 250; *(fbp + location + 3) = 0; // No transparency k+=3; location += 4; } munmap(fbp, screensize); close(fbfd); return 0; }
Mais pour le résultat j'ai eu une succession de forme 2D non 3D au lieu d'avoir un seul objet 3D
SVP il y a t'il quelqu'un qui peut m'aider
merciii
A voir également:
- Affichage avec le framebuffer Linux
- Linux reader - Télécharger - Stockage
- Affichage double ecran - Guide
- Windows 11 affichage classique - Guide
- Toutou linux - Télécharger - Systèmes d'exploitation
- Backtrack linux - Télécharger - Sécurité
2 réponses
Petite erreur ici :
... devrait s'écrire :
Bon à part ça je n'ai pas pu tester le programme (et je ne peux pas changer ma configuration pour activer le framebuffer) :(
Bonne chance
if ((int)fbp == -1)
... devrait s'écrire :
if (fbp == (void *) -1)
Bon à part ça je n'ai pas pu tester le programme (et je ne peux pas changer ma configuration pour activer le framebuffer) :(
(mando@aldur) (~) $ ./a.out Error: cannot open framebuffer device: No such file or directory
Bonne chance