Frame Buffer OpenGL

cs_roger000 Messages postés 3 Date d'inscription jeudi 6 juillet 2006 Statut Membre Dernière intervention 17 février 2009 - 17 févr. 2009 à 15:01
bubbathemaster Messages postés 339 Date d'inscription dimanche 26 janvier 2003 Statut Membre Dernière intervention 25 mars 2009 - 18 févr. 2009 à 00:31
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="ProgId" content="Word.Document" />
<meta name="Generator" content="Microsoft Word 11" />
<meta name="Originator" content="Microsoft Word 11" />
<link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CWeb%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" />
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]-->
<!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
</w:LatentStyles>
</xml><![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;
mso-font-charset:2;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:0 268435456 0 0 -2147483648 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
@page Section1
{size:595.3pt 841.9pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;
mso-header-margin:35.4pt;
mso-footer-margin:35.4pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
/* List Definitions */
@list l0
{mso-list-id:40833191;
mso-list-type:hybrid;
mso-list-template-ids:854782796 67895297 67895299 67895301 67895297 67895299 67895301 67895297 67895299 67895301;}
@list l0:level1
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:36.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;}
@list l1
{mso-list-id:983848214;
mso-list-type:hybrid;
mso-list-template-ids:-66406790 67895311 67895321 67895323 67895311 67895321 67895323 67895311 67895321 67895323;}
@list l1:level1
{mso-level-tab-stop:36.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-bidi-font-family:"Times New Roman";}
@list l1:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:72.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-bidi-font-family:"Times New Roman";}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Tableau Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]-->
Hi !



 





For a
project, I need to render some part of my scene in 2 opengl frame buffer, and
to merge them by depth buffer comparison.






 






So I tried
to split this problem in 2 tasks:




<ol style="margin-top: 0cm;" start="1" type="1">
<li class="MsoNormal" style="">
First:


</li>
<ol style="margin-top: 0cm;" start="1" type="a">
<li class="MsoNormal" style="">
Render a part of the scene
into a framebuffer


</li>
<li class="MsoNormal" style="">
Switch this framebuffer with
the backbuffer


</li>
<li class="MsoNormal" style="">
Switch the back buffer with
the framefuffer


</li>
</ol>
<li class="MsoNormal" style="">
Second:


</li>
<ol style="margin-top: 0cm;" start="1" type="a">
<li class="MsoNormal" style="">
Merge the 2 framebuffer


</li>
</ol>
</ol>


 







 






I
implemented the first part:






 






************FBO
SETUP PART ********






 






// Create 2 render buffer





int
[] MyRenderBuffer = newint[2];





glGenRenderbuffersEXT(2, MyRenderBuffer);






 






// Bind the first render buffer





glBindRenderbufferEXT(GL_RENDERBUFFER_EXT,
MyRenderBuffer[0]);





// Allocate memory for its:
colorimetry buffer





glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,GL_RGBA,
CV.width, CV.height);






 






// Bind the first render buffer





glBindRenderbufferEXT(GL_RENDERBUFFER_EXT,
MyRenderBuffer[1]);





// Allocate memory for its: depth
buffer





glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
GL_DEPTH_COMPONENT, CV.width, CV.height);






 






// Create a Frame Buffer Object &
bind it





int
[] MyFBO = newint[1];





glGenFramebuffersEXT(1, MyFBO);





glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFBO[0]);






 






// Attach the fist render buffer with
the FBO “COLOR_ATTACHMENT0”





glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
GL_COLOR_ATTACHMENT0_EXT,GL_RENDERBUFFER_EXT, MyRenderBuffer[0]);





// Attach the fist render buffer with
the FBO “DEPTH _ATTACHMENT0”





glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_RENDERBUFFER_EXT,
MyRenderBuffer[1]);






 






// Bind the OpenGL Standard
framebuffer





glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);






 






// Check FBO Status





int
status_fbo =glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);





int
normal_status =GL_FRAMEBUFFER_COMPLETE_EXT;






 







 







 







 







 






************DRAW
********





// Bind the FBO





glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);






 






// Draw my scene





Draw();






 






// Re bind the OpenGL Standard
framebuffer





glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);






 







 






// Then SDL swaps buffers…






 







 







Results:






<li class="MsoNormal" style="">
My status_fbo is equal to “GL_FRAMEBUFFER_COMPLETE_EXT”
! (good)


</li>
<li class="MsoNormal" style="">
If I disable the line “glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,
fbo);”  in the “Draw part”, my scene
is correctly shown on the screen. (good)


</li>
<li class="MsoNormal" style="">
If I enable line “glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,
fbo);”  in the “Draw part”, nothing
is shown (no good)


</li>



 







Question:






Please, is anyone could help me to identify the
mistake? I think I don’t really switch the back buffer with my FBO, but I don’t
know why...

5 réponses

krimog Messages postés 1860 Date d'inscription lundi 28 novembre 2005 Statut Membre Dernière intervention 14 février 2015 49
17 févr. 2009 à 15:31
Hi.
I'm sorry but I really don't have any knowledge in OpenGL with C#.
But if anyone wants me to translate something, maybe I can help, because I guess you can't speak french.

Je m'y connais pas du tout en OpenGL C#.
Cependant, si quelqu'un peut aider mais ne parle pas anglais, je peux toujours essayer de traduire ;)

Krimog :
while (!succeed = try()) ;
0
cs_roger000 Messages postés 3 Date d'inscription jeudi 6 juillet 2006 Statut Membre Dernière intervention 17 février 2009
17 févr. 2009 à 16:55
Oups.
Je ne sais pas où j'avais la tête en faisant ce post en anglais.  Désolé.

Donc, pour un projet, j'ai besoin de faire de visualiser 2 parties de ma scène dans 2 FBO, puis de fusionner le contenu des 2 FBO par comparaison de leur Depth Buffer.
J'ai décomposé mon travail en 2 tâches :

1. 
   a. Rendre une partie de ma scène dans un framebuffer.
   b. Echanger mon framebuffer avec le backbuffer
   c. Echanger le front buffer avec le back buffer.
2. fusionner le contenu de 2 FBO

J'ai implémenté 1.
Résultats :
le statuts de mon FBO est bien complet. (bien)
Si je commente la line "glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);"  dans la partie "draw", ma scène s'affiche correctement. (bien)
Si je la laisse telle qu'elle est : rien ne s'affiche (pas bien)

Question:<?XML:NAMESPACE PREFIX = O /??>

Est-ce que quelqu'un aurait une idée de ce que je fais mal ?
Je soupsonne que je switch mal mon FBO avec mon Back buffer, mais je ne trouve pas d'informations la dessus.
0
krimog Messages postés 1860 Date d'inscription lundi 28 novembre 2005 Statut Membre Dernière intervention 14 février 2015 49
17 févr. 2009 à 17:09
Ca y est : je suis donc officiellement inutile :)

Krimog :
while (!succeed = try()) ;
0
cs_roger000 Messages postés 3 Date d'inscription jeudi 6 juillet 2006 Statut Membre Dernière intervention 17 février 2009
17 févr. 2009 à 17:26
Merci quand même.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
bubbathemaster Messages postés 339 Date d'inscription dimanche 26 janvier 2003 Statut Membre Dernière intervention 25 mars 2009 4
18 févr. 2009 à 00:31
Amha ta question a plus de chance de trouver preneur du cote de Nehe
http://nehe.gamedev.net/
0
Rejoignez-nous