Re: Using framebuffers

Uğur Güney <[email protected]> Sun, 29 May 2016 10:16:14 -0400
Newsgroups gmane.comp.python.opengl.user
Message-ID <CALr+-4z8G6tePU7tscxck1Ha12x2RJ-CTW6mvRE3mk1ks9-hQA@mail.gmail.com>
--===============4176086643231230598==
Content-Type: multipart/alternative; boundary=001a114973067e052f0533fbc9b0

--001a114973067e052f0533fbc9b0
Content-Type: text/plain; charset=UTF-8

Hi Ian,

There are two basic ways to get functionality in GL. Either you load it
> from an extension (which PyOpenGL handily does for you) or you use the core
> API. The "Right Thing" is to use the core API if available, with a fallback
> to the extension, with a fallback to a different algorithm. In practice,
> people commonly pick one and go with it. I picked the extension, because
> it's more widely compatible than core, but still not giving up on the
> functionality entirely.
>

Thanks for sharing your wisdom with me! If I'll ever write a project for
public I'll go with this "use the core if available and fallback to
extensions if necessary" method. For now I'll stick with the core one for
my study projects.

PyGame is a very good software package, especially for low-perf 2D drawing.
> It's how I got started in graphics programming and I recommend it still. It
> is unfortunate that distributions haven't been made available, and this is
> a source of active . . . consternation . . . on the PyGame list. Unofficial
> pip wheels can be found here
> <http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame>, or you can use the
> (somewhat outdated) installers on the site
> <http://www.pygame.org/download.shtml>.
>

Thanks for pointing out pip wheels for pygame. This way I'll be able to try
it out. ^_^

Finally, I succeeded to do post-processing using an FBO! Here are
screenshots of before and after the colored triange's pixels are inverted:
http://imgur.com/a/P2wxt I removed all of the abstractions/classes in your
code related to framebuffer and texture generation and pasted to my project
and it worked! Then I compared your code with mine and found the source of
the problem.

When I generate the texture ID, if I use this expressions

texture = GLuint()
glGenTextures(1, texture)

nothing is rendered on the texture. Generating texture ID this way works
fine:

texture = glGenTextures(1)

I don't know whether this is a feature or a bug. :-) I was going with the
former way (creating a GLuint object first, and manipulating it in the
glGenX function by giving it as the second argument) because it looks more
like the C/C++ OpenGL code I find on the Internet. And it works fine with
glGenVertexArrays, glGenBuffers, glGenFramebuffers, and glGenRenderbuffers
but not with glGenTextures.

I updated the code to demonstrate this behavior:
https://gist.github.com/vug/2c7953d5fdf750c727af249ded3e9018

Have a good day!
u

--001a114973067e052f0533fbc9b0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi Ian,<div><br></div><div><div class=3D"gmail_extra"><div=
 class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0p=
x 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-c=
olor:rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div><div style=3D=
"font-family:&#39;times new roman&#39;,serif;display:inline">There are two =
basic ways to get functionality in GL. Either you load it from an extension=
 (which PyOpenGL handily does for you) or you use the core API. The &quot;R=
ight Thing&quot; is to use the core API if available, with a fallback to th=
e extension, with a fallback to a different algorithm. In practice, people =
commonly pick one and go with it. I picked the extension, because it&#39;s =
more widely compatible than core, but still not giving up on the functional=
ity entirely.<br></div></div></div></blockquote><div><br></div><div>Thanks =
for sharing your wisdom with me! If I&#39;ll ever write a project for publi=
c I&#39;ll go with this &quot;use the core if available and fallback to ext=
ensions if necessary&quot; method. For now I&#39;ll stick with the core one=
 for my study projects.</div><div><br></div><blockquote class=3D"gmail_quot=
e" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-styl=
e:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir=3D"lt=
r"><div><div style=3D"font-family:&#39;times new roman&#39;,serif;display:i=
nline">PyGame is a very good software package, especially for low-perf 2D d=
rawing. It&#39;s how I got started in graphics programming and I recommend =
it still. It is unfortunate that distributions haven&#39;t been made availa=
ble, and this is a source of active . . . consternation . . . on the PyGame=
 list. Unofficial pip wheels can be found <a href=3D"http://www.lfd.uci.edu=
/~gohlke/pythonlibs/#pygame" target=3D"_blank">here</a>, or you can use the=
 (somewhat outdated) installers <a href=3D"http://www.pygame.org/download.s=
html" target=3D"_blank">on the site</a>.</div></div></div></blockquote><div=
><br></div><div>Thanks for pointing out pip wheels for pygame. This way I&#=
39;ll be able to try it out. ^_^</div><div><br></div><div>Finally, I succee=
ded to do post-processing using an FBO! Here are screenshots of before and =
after the colored triange&#39;s pixels are inverted: <a href=3D"http://imgu=
r.com/a/P2wxt">http://imgur.com/a/P2wxt</a> I removed all of the abstractio=
ns/classes in your code related to framebuffer and texture generation and p=
asted to my project and it worked! Then I compared your code with mine and =
found the source of the problem.</div><div><br></div><div>When I generate t=
he texture ID, if I use this expressions</div><div><br></div><div><div>text=
ure =3D GLuint()</div><div>glGenTextures(1, texture)</div></div><div><br></=
div><div>nothing is rendered on the texture. Generating texture ID this way=
 works fine:</div><div><br></div><div>texture =3D glGenTextures(1)<br></div=
><div><br></div><div>I don&#39;t know whether this is a feature or a bug. :=
-) I was going with the former way (creating a GLuint object first, and man=
ipulating it in the glGenX function by giving it as the second argument) be=
cause it looks more like the C/C++ OpenGL code I find on the Internet. And =
it works fine with glGenVertexArrays, glGenBuffers, glGenFramebuffers, and =
glGenRenderbuffers but not with glGenTextures.=C2=A0</div><div><br></div><d=
iv>I updated the code to demonstrate this behavior:=C2=A0<a href=3D"https:/=
/gist.github.com/vug/2c7953d5fdf750c727af249ded3e9018">https://gist.github.=
com/vug/2c7953d5fdf750c727af249ded3e9018</a></div><div><br></div><div>Have =
a good day!</div><div>u</div><div><br></div><div><br></div></div></div></di=
v></div>

--001a114973067e052f0533fbc9b0--


--===============4176086643231230598==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
--===============4176086643231230598==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
_______________________________________________
PyOpenGL-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyopengl-users

--===============4176086643231230598==--