IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

OpenGL Discussion :

Frame buffer object


Sujet :

OpenGL

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    7
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 7
    Points : 2
    Points
    2
    Par défaut Frame buffer object
    Bonjour!

    voilà j'essaye d'utiliser les FBOs mais je n'y arrive pas,pour le moment j'essay juste de rendre un carré dans le fbo puis réutiliser cette texture pour la scene final.
    apres une fois ce cas passé ce seras pour faire du shadow mapping.

    j'ai cherché sous google ainsi que chez ati et nvidia sans rien trouver de bien expliqué,donc quelqu'un aurait-il des tuto sur les FBOs ou qui pourrait m'aider.

    Merci.

  2. #2
    Expert confirmé
    Avatar de shenron666
    Homme Profil pro
    avancé
    Inscrit en
    Avril 2005
    Messages
    2 535
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Seine et Marne (Île de France)

    Informations professionnelles :
    Activité : avancé

    Informations forums :
    Inscription : Avril 2005
    Messages : 2 535
    Points : 5 217
    Points
    5 217
    Par défaut
    Suffit de demander :

    http://www.codesampler.com/oglsrc/oglsrc_14.htm#ogl_frame_buffer_object

  3. #3
    2io
    2io est déconnecté
    Futur Membre du Club
    Inscrit en
    Octobre 2005
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 4
    Points : 5
    Points
    5
    Par défaut
    si j'ai bien compris ce que tu veux alors vas à cette page: http://www.codesampler.com/oglsrc/oglsrc_14.htm

    edit: lol message croisé

  4. #4
    Candidat au Club
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    7
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 7
    Points : 2
    Points
    2
    Par défaut
    Merci pour les réponses rapide

    J'ustement c'est de cette source que je me suis inspiré,d'ailleur j'ai beaucoup appris sur ce site,mais dans mon proramme la texture creé est toute noir

    voilà mon cheminement:

    en initialisation
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    glGenFramebuffersEXT( 1, &g_frameBuffer );
    glGenRenderbuffersEXT( 1, &g_depthRenderBuffer );
     
    glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, g_depthRenderBuffer );
    glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, RENDERBUFFER_WIDTH, RENDERBUFFER_HEIGHT );
     
    glGenTextures( 1, &g_dynamicTextureID );
    glBindTexture( GL_TEXTURE_2D, g_dynamicTextureID );
    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB,RENDERBUFFER_WIDTH, RENDERBUFFER_HEIGHT,0, GL_RGB, GL_UNSIGNED_BYTE, 0 );
    au rendu
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, g_frameBuffer );
    //glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, g_depthRenderBuffer );
    glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, g_dynamicTextureID, 0 );
    glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, g_depthRenderBuffer );
     
     
    glViewport( 0, 0, RENDERBUFFER_WIDTH, RENDERBUFFER_HEIGHT );
    glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
     
     
     
    faire le rendu
     
     
     
     
    glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
    //glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 );
    puis rendre normalement la scene avec la texture creé
    mais j'ai ma texture toute noir

    Merci.

  5. #5
    Candidat au Club
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    7
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 7
    Points : 2
    Points
    2
    Par défaut
    plus personne?

  6. #6
    Membre régulier
    Inscrit en
    Juillet 2005
    Messages
    80
    Détails du profil
    Informations forums :
    Inscription : Juillet 2005
    Messages : 80
    Points : 85
    Points
    85
    Par défaut
    Je n'ai pas de façon de vérifier si c'est ça, mais peut-être que tu devrais binder ton frame buffer object lorsque tu initialises ton depth buffer

  7. #7
    Futur Membre du Club
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    9
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2005
    Messages : 9
    Points : 7
    Points
    7
    Par défaut
    Si ça peut t'aider j'ai un de mes codes qui traine.
    J'affiche display2 dans la texture TexID et je l'applique à la teapot.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
     
    #include <gl/glew.h>
    #include <GL/glut.h>
    #include <GL/glext.h>
    #include <iostream>
    #include <fstream>
     
    using namespace std;
     
    GLuint fbID,texID;
     
    // Affiche une teapot avec texID comme texture
    void display()
    {
    	GLfloat positionProperties[] = {-2.0f, -2.0f, 2.0f, 0.0f};
    	glLightfv( GL_LIGHT0, GL_POSITION, positionProperties);
    	glEnable(GL_LIGHTING);
    	glEnable(GL_DEPTH_TEST);
    	glViewport(0,0,512,512);
    	glClearColor(0,0,0,1);
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();
    	gluPerspective(60.,512/(float)512,0.1,100.);
    	glTranslatef(0.,0.,-2.);
    	glMatrixMode(GL_MODELVIEW);
    	glLoadIdentity();
     
    	glEnable(GL_TEXTURE_2D);
    	glEnable(GL_LIGHT0);
    	glutSolidTeapot(0.5);
    	glDisable(GL_LIGHT0);
    	glDisable(GL_TEXTURE_2D);
    	glutSwapBuffers();
     
    }
     
    // display pour creer texID
    void display2()
    {
    	GLfloat positionProperties[] = {2.0f, 4.0f, -2.0f, 0.0f};
    	glLightfv( GL_LIGHT0, GL_POSITION, positionProperties);
    	glEnable(GL_LIGHTING);
    	glEnable(GL_DEPTH_TEST);
    	glViewport(0,0,512,512);
    	glClearColor(1,1,1,1);
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();
    	gluPerspective(60.,512/(float)512,0.1,100.);
    	glTranslatef(0.,0.,-2.);
    	glMatrixMode(GL_MODELVIEW);
    	glLoadIdentity();
     
    	glEnable(GL_LIGHT0);
    	glutSolidTeapot(0.5);
    	glDisable(GL_LIGHT0);
     
     
    }
     
    void InitGLExtentions(void)
    {
    	GLenum err = glewInit();
    	if (GLEW_OK != err)
    	{
    		char *s=(char*)glewGetErrorString(err);
    		cerr << s << endl;
    	}
    }
     
    void Init_FrameBufferObject()
    {
    	// creation texture
    	glGenTextures(1, &texID);
    	glBindTexture(GL_TEXTURE_2D, texID);
    	glTexImage2D(GL_TEXTURE_2D,0,4,512,512,0,GL_RGBA,GL_FLOAT,NULL);
    	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,	GL_LINEAR);  
    	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,	GL_LINEAR);	
    	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,		GL_REPEAT);	
    	glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T,		GL_REPEAT);
     
    	// creation frame buffer
    	glGenFramebuffersEXT(1, &fbID);
    	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbID);
    	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texID, 0);
    	display2();
     
    	GLenum status;
        status = (GLenum) glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
        switch(status) {
            case GL_FRAMEBUFFER_COMPLETE_EXT:
    			printf("Frame Buffer Object Supported and complete \n");
                break;
            case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
                printf("Unsupported framebuffer format\n");
                break;
            case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
                printf("Framebuffer incomplete, missing attachment\n");
                break;
            case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT:
                printf("Framebuffer incomplete, duplicate attachment\n");
                break;
            case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
                printf("Framebuffer incomplete, attached images must have same dimensions\n");
                break;
            case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
                printf("Framebuffer incomplete, attached images must have same format\n");
                break;
            case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
                printf("Framebuffer incomplete, missing draw buffer\n");
                break;
            case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
                printf("Framebuffer incomplete, missing read buffer\n");
                break;
            default:
                break;
        }
    	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
     
    }
     
    void init_GLUT(int argc, char ** argv){
    	glutInit(&argc, argv);									
    	glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA |GLUT_DEPTH );	
    	glutInitWindowSize(512,512 );
     
    	glutCreateWindow("test fbo");	
    	printf("%s\n", glGetString(GL_VENDOR));
    	printf("%s\n", glGetString(GL_RENDERER));
    	printf("OpenGL %s\n", glGetString(GL_VERSION));
     
    	glutDisplayFunc(display);	
    }
     
     
    int main(int argc,char **argv)
    {
    	init_GLUT(argc,argv);
    	InitGLExtentions();
    	Init_FrameBufferObject();
     
    	glutMainLoop();
    }

Discussions similaires

  1. Lire une TEXTURE2D attaché au Frame Buffer Object
    Par GloW_on_dub dans le forum OpenGL
    Réponses: 1
    Dernier message: 31/03/2010, 17h17
  2. Frame Buffer Object écran noir
    Par Pixcoder dans le forum OpenGL
    Réponses: 0
    Dernier message: 29/04/2009, 11h52
  3. Réponses: 4
    Dernier message: 14/04/2009, 10h26
  4. Performance du frame buffer object (FBO)
    Par Grosbenji dans le forum OpenGL
    Réponses: 4
    Dernier message: 24/01/2007, 15h19

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo