Répondre à la discussion
Affichage des résultats 1 à 12 sur 12

[C/C++] accéder à la mémoire vidéo



  1. #1
    Tix

    [C/C++] accéder à la mémoire vidéo


    ------

    Lut

    voyez vous, je bidouillait pas mal en Qbasic fut un temps pas trop éloigné. J'avais bienentendu lu beaucoup de cours sur le graphisme avancé.

    j'aurai aimé savoir si il était possible d'acceder a la memoire vidéo, bidouiller avec les tableaux pour faire des images ect...

    auriez vous des solutions ?

    merci, ++ Tix.

    -----

  2. Publicité
  3. #2
    skydancer

    Re : [C/C++] acceder a la mémoire vidéo

    oui si tu veux commencer à acceder à ce qui se passe sur l'écran, tu peux utiliser l'api OPENGL. Ca ressemble à du C et c'est plutot facile à apprendre. Tu peux aussi utiliser DirectX si tu utilise Windows mais ça je ne connais pas.

  4. #3
    Tix

    Re : [C/C++] acceder a la mémoire vidéo

    hmm... je t'avoue que plus de détail m'auraient bien rassurer. n'y a til pas un équivalent a peek, poke, ect ... ?

  5. #4
    skydancer

    Re : [C/C++] acceder a la mémoire vidéo

    Ben je connais pas QBasic par contre je sais ce qui se fait en C/C++ et Java pour manipuler des images :
    en C++: CImg, The Insight Toolkit (ITK) (traitement d'image avancée), The Visualization Toolkit VTK (Visu 3D et 2D), DirectX (3D)

    en C: OpenGl (visu 3D)

    en java, il y a Java Advanced Imaging, ImageJ, les deux font que du 2D.

    Les libs que je cite sont gratuites.

    Apres si tu veux plus de détails, sur comment ça marche, je te conseille d'aller voir d'abord par toi-même et on pourra alors entrer dans les détails. Mais en fait, qu'est ce que tu veux faire exactement ? Juste afficher des images, mes modifier en les filtrant ou bien des animamtions 3D...

  6. A voir en vidéo sur Futura
  7. #5
    Tix

    Re : [C/C++] acceder a la mémoire vidéo

    Les libs que je cite sont gratuites.
    encor heureux

    merci pour les infos, j'y jette un coup d'oeuil des cet aprem.

    ++ Tix.

  8. #6
    snakemetalgear

    Re : [C/C++] acceder a la mémoire vidéo

    slt ts je cherche de laide avec un code opengl,tt ce que je veu faire c'est un carré blanc et quand on met le curseur de la souris sur lune de ces 4 sommets et en tape au clavier b le sommet indiqué par le curseur sallume en bleu et si on tape v c'est en vert et r en rouge pourtant sa marche pas quan je le teste sa change de couleur pour une seconde et puis sa devien tout bleu bon voila le code que j'ai ecris:
    /*je sais que c'est un code plutot stupide est trop long mais comme jai dis je suis juste un debutant si quelqun peut le corriger tan mieux mais nhesitez pas a me donner des codes nouveau pour apprendre la faute que jai fais plzzzzz go*\

  9. Publicité
  10. #7
    snakemetalgear

    Re : [C/C++] acceder a la mémoire vidéo

    #include<gl/glut.h>
    int nope,nop,no,n,rouge,vert,bleu;
    int z1=n,z2=no,z3=nop,z4=nope;
    void rectangle(int s,float r1,float r2,float r3,float r4)
    {
    if(s==1){
    glBegin(GL_TRIANGLES);
    glColor4f(r1,r2,r3,r4);
    glVertex3f(0.0,0.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.5,0.5,0.0);
    if (z2==no){
    glColor4f(1.0,1.0,1.0,1.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z2==rouge){
    glColor4f(1.0,0.0,0.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z2==vert){
    glColor4f(0.0,1.0,0.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z2==bleu){
    glColor4f(0.0,0.0,1.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z3==nop){
    glColor4f(1.0,1.0,1.0,1.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z3==rouge){
    glColor4f(1.0,0.0,0.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z3==vert){
    glColor4f(0.0,1.0,0.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z3==bleu){
    glColor4f(0.0,0.0,1.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z4==nope){
    glColor4f(1.0,1.0,1.0,1.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z4==rouge){
    glColor4f(1.0,0.0,0.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z4==vert){
    glColor4f(0.0,1.0,0.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z4==bleu){
    glColor4f(0.0,0.0,1.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);
    glVertex3f(0.5,0.0,0.0);}
    }
    else
    if (s==2){
    glBegin(GL_TRIANGLES);
    glColor4f(r1,r2,r3,r4);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);
    if (z3==nop){
    glColor4f(1.0,1.0,1.0,1.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z3==rouge){
    glColor4f(1.0,0.0,0.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z3==vert){
    glColor4f(0.0,1.0,0.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z3==bleu){
    glColor4f(0.0,0.0,1.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z4==nope){
    glColor4f(1.0,1.0,1.0,1.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z4==rouge){
    glColor4f(1.0,0.0,0.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z4==vert){
    glColor4f(0.0,1.0,0.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z4==bleu){
    glColor4f(0.0,0.0,1.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z1==n){
    glColor4f(1.0,1.0,1.0,1.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z1==rouge){
    glColor4f(1.0,0.0,0.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z1==vert){
    glColor4f(0.0,1.0,0.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z1==bleu){
    glColor4f(0.0,0.0,1.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);}
    }
    else
    if (s==3){
    glBegin(GL_TRIANGLES);
    glColor4f(r1,r2,r3,r4);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);
    glVertex3f(0.0,0.0,0.0);
    if (z2==no){
    glColor4f(1.0,1.0,1.0,1.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z2==rouge){
    glColor4f(1.0,0.0,0.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z2==vert){
    glColor4f(0.0,1.0,0.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z2==bleu){
    glColor4f(0.0,0.0,1.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z1==n){
    glColor4f(1.0,1.0,1.0,1.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z1==rouge){
    glColor4f(1.0,0.0,0.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z1==vert){
    glColor4f(0.0,1.0,0.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z1==bleu){
    glColor4f(0.0,0.0,1.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z4==nope){
    glColor4f(1.0,1.0,1.0,1.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z4==rouge){
    glColor4f(1.0,0.0,0.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z4==vert){
    glColor4f(0.0,1.0,0.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z4==bleu){
    glColor4f(0.0,0.0,1.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);
    glVertex3f(0.5,0.0,0.0);}
    }
    else
    if (s==4){
    glBegin(GL_TRIANGLES);
    glColor4f(r1,r2,r3,r4);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);
    glVertex3f(0.5,0.0,0.0);
    if (z3==nop){
    glColor4f(1.0,1.0,1.0,1.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z3==rouge){
    glColor4f(1.0,0.0,0.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z3==vert){
    glColor4f(0.0,1.0,0.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z3==bleu){
    glColor4f(0.0,0.0,1.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z2==no){
    glColor4f(1.0,1.0,1.0,1.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z2==rouge){
    glColor4f(1.0,0.0,0.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z2==vert){
    glColor4f(0.0,1.0,0.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z2==bleu){
    glColor4f(0.0,0.0,1.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.5,0.0,0.0);}
    if (z1==n){
    glColor4f(1.0,1.0,1.0,1.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z1==rouge){
    glColor4f(1.0,0.0,0.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z1==vert){
    glColor4f(0.0,1.0,0.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);}
    if (z1==rouge){
    glColor4f(0.0,0.0,1.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.0,0.5,0.0);
    glVertex3f(0.0,0.0,0.0);}
    glEnd();
    glFlush();
    }
    }
    void scene()
    {
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_QUADS);
    glVertex3f(0.0,0.0,0.0);
    glVertex3f(0.5,0.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.0,0.5,0.0);
    glEnd();
    glFlush();
    }
    void keyboard(unsigned char key,int x,int y)
    {
    if(x>160&&x<160,25&&y<159,5&&y >159,75)
    {
    switch (key)
    {
    case 'b':
    case 'B':
    rectangle(1,0.0,0.0,1.0,0.0);
    z1==bleu;
    glutPostRedisplay();break;
    case 'r':
    case 'R':
    rectangle(1,1.0,0.0,0.0,0.0);
    z1==rouge;
    glutPostRedisplay();break;
    case 'v':
    case 'V':
    rectangle(1,0.0,1.0,0.0,0.0);
    z1==vert;
    glutPostRedisplay();break;
    }
    }
    if (x>160,25&&x<160,5&&y<159,5&&y >159,75)
    {
    switch(key)
    {
    case'b':
    case'B':
    rectangle(2,0.0,0.0,1.0,0.0);
    z2==bleu;
    glutPostRedisplay();break;
    case 'r':
    case 'R':
    rectangle(2,1.0,0.0,0.0,0.0);
    z2==rouge;
    glutPostRedisplay();break;
    case 'v':
    case 'V':
    rectangle(2,0.0,1.0,0.0,0.0);
    z2==vert;
    glutPostRedisplay();break;
    }
    }
    if (x>160,25&&x<160,5&&y>159,75&& y<160)
    {
    switch(key)
    {
    case 'b':
    case 'B':
    rectangle(3,0.0,0.0,1.0,0.0);
    z3==bleu;
    glutPostRedisplay();break;
    case 'r':
    case 'R':
    rectangle(3,1.0,0.0,0.0,0.0);
    z3==rouge;
    glutPostRedisplay();break;
    case 'v':
    case 'V':
    rectangle(3,0.0,1.0,0.0,0.0);
    z3==vert;
    glutPostRedisplay();break;
    }
    }
    if (x>160&&x<160,25&&y>159,75&&y< 160)
    {
    switch(key)
    {
    case 'b':
    case 'B':
    rectangle(4,0.0,0.0,1.0,0.0);
    z4==bleu;
    glutPostRedisplay();break;
    case 'r':
    case 'R':
    rectangle(4,1.0,0.0,0.0,0.0);
    z4==rouge;
    glutPostRedisplay();break;
    case 'v':
    case 'V':
    rectangle(4,0.0,1.0,0.0,0.0);
    z4==vert;
    glutPostRedisplay();break;
    }
    }
    }
    int main(int argc,char **argv)
    {
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DEPTH |GLUT_SINGLE|GLUT_RGBA);
    glutInitWindowSize(320,320);
    glutInitWindowPosition(100,100 );
    glutCreateWindow("still test");
    glutDisplayFunc(scene);
    glutKeyboardFunc(keyboard);
    glutMainLoop();
    }

  11. #8
    BrainMan

    Re : [C/C++] acceder a la mémoire vidéo

    Bonsoir,

    je suis plus delphi, pas trop C (je sais C un tord )
    par contre je pense que ton erreur est la

    void scene()
    {
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_QUADS);
    glcolor3f(1.0,1.0,1.0);
    glVertex3f(0.0,0.0,0.0);
    glVertex3f(0.5,0.0,0.0);
    glVertex3f(0.5,0.5,0.0);
    glVertex3f(0.0,0.5,0.0);
    glEnd();
    glFlush();
    En rouge a mon avis la correction.
    il te faut definir la couleur de ton fond en blanc,
    c'est la dernier couleur utilisée qui est reprise je pense.
    Si c'est pas élastique, c'est cassé.

  12. #9
    Philder

    Re : [C/C++] acceder a la mémoire vidéo

    Salut,
    Un autre problème dans ton code c'est que tu utilises le == au lieu du = pour les affectations dans tes switchs.

    Le == c'est uniquement pour les comparaisons if (a==b) {}
    Par contre les affectations c'est un = simple:
    a=5;

    Sinon pour l'histoire de l'accès à la mémoire vidéo, on ne le fait plus directement depuis que l'on a quitté le DOS. Mais a l'époque, selon le mode vidéo que tu activais sur la carte, la mémoire vidéo était structurée d'une certaine manière pouvant être parfois très étrange. Enfin bref c'était un joyeux bordel, mais ce temps là est terminé.

    Bon courage.

  13. #10
    snakemetalgear

    Re : [C/C++] acceder a la mémoire vidéo

    slt a tous,merci pour les solutions mais sa marche pas tjs, la premiere solution sa a juste changer le couleur du carré et a propos des == dans le switch cetais ma faute mais tjs sa change rien,jexplique la strategie du code:
    premierment sa dessine un carré blanc et quand une frappe du clavier se tape on appele a la fonction keyboard et alors le job de celle ci et premierement de indiquer le placement de la souris (if(x>160&&x<160,25&&y<159,5&& y >159,75))
    et puis par exemple si elle est dans le premier sommet du carré on switch le key par exemple si il est b alors on fé appele la fonction rectangle passant les arguments suivant:rectangle(1,0.0,0.0,1. 0,0.0) et on affecte z1 a bleu donc rectangle analyse le premier argument (s) si il est 1 sa veut dire quon dessine sur le premier sommet du carré et les autres argument c la couler avec la quelle on va dessiner le bleu dont notre exemple puisqon a tapé b;et puis on analyse les variables des 3 autres cotés du carré (2 3 et 4 dans notre example)
    si ils sont a nope nop no ou n on les dessine avec du blanc si au rouge on les dessine au rouge etc....
    et comme sa on allume juste la coté sur laquel on met le curseeur et avec la couleur choisi en gardans les couleurs des autres trois coté(on les dessinons une autre fois en analysent leurs variables z1 z2 z3 z4 puisquon les change a chaque modification) .
    et sa marche pas meme si cest bien pensé
    bon jespere que sa eclairsisse les choses et si vous avez une autre ideé meme sil est differente de la mienne plzzz informez moi juste pour que je minspire d'elle et pour corriger mes fautes.merci d'avance.juste de penser a cet algorithme et a cette facon sa me fé plaisir meme di sa marche pas

  14. #11
    Philder

    Re : [C/C++] acceder a la mémoire vidéo

    Salut,
    un autre souci dans ton code c'est que tu n'initialises pas les valeurs nope nop no n rouge vert bleu..., elles sont toutes en valeur par defaut (0 probablement) et donc tu ne peux pas les distinguer.

    int nope,nop,no,n,rouge,vert,bleu;

    donne leur des valeurs differentes des l'initialisation genre 0 1 2 3 4 ... ou fait une enum

  15. #12
    snakemetalgear

    Re : [C/C++] accéder à la mémoire vidéo

    oué c'est vrai c'est une autre faute je l'ai corrigé jai fé une enum maintenant sa allume juste le coin inferieure gauche dans tous les cas,je pense que c'est a cause de mes calculs de la position de la souris,px etre,les coordonnés que jai donner a x et y ne correspont pas.en tous cas merci a tous.

  16. Publicité

Discussions similaires

  1. [Physiologie] Mémoire de la femme, mémoire de l'homme ??,
    Par marimar dans le forum Biologie
    Réponses: 37
    Dernier message: 08/10/2007, 10h44
  2. optimiser mémoire vidéo
    Par dragoneti85 dans le forum Logiciel - Software - Open Source
    Réponses: 1
    Dernier message: 02/10/2007, 16h39
  3. mémoire volontaire/mémoire involontaire
    Par llevela squall dans le forum Psychologies (archives)
    Réponses: 12
    Dernier message: 21/06/2007, 22h59
  4. probleme mémoire sur ampli audio-vidéo thomson 300 ht
    Par Jehan-luc dans le forum Dépannage
    Réponses: 2
    Dernier message: 09/10/2006, 19h47
  5. Mémoire, conscience et vidéo...
    Par uruk dans le forum Psychologies (archives)
    Réponses: 8
    Dernier message: 21/06/2006, 14h06
Découvrez nos comparatifs produits sur l'informatique et les technologies.