<div dir="ltr">in the example, the drawing is done in the default buffer and magically read back into a bgl.Buffer object<div><br></div><div>here's what my code looks like</div><div><br></div><div><div>def render_preview(self, scene):</div><div>        pixelCount = self.size_x * self.size_y</div><div><br></div><div>        # Setup</div>        buffer = bgl.Buffer(bgl.GL_FLOAT, [pixelCount, 4])<div>        bgl.glClearColor(1.0, 1.0, 1.0, 1.0)</div><div>        bgl.glClear(bgl.GL_COLOR_BUFFER_BIT or bgl.GL_DEPTH_BUFFER_BIT)</div><div>        </div><div>        # i should have a white screen already</div><div><br></div><div>        bgl.glBegin(bgl.GL_TRIANGLES)</div><div>        bgl.glVertex3f(2.0, 2.0, 0.0)</div><div>        bgl.glVertex3f(2.0, 0.0, 0.0)</div><div>        bgl.glVertex3f(0.0, 2.0, 0.0)</div><div>        bgl.glEnd()</div><div>        </div><div>        # Read pixel data</div><div>        bgl.glReadPixels(0, 0, self.size_x, self.size_y, bgl.GL_RGBA, bgl.GL_FLOAT, buffer)</div><div>        print(str(buffer))</div></div><div>        </div><div>        # After printing, i get a series of 0s</div><div><br></div><div>I'm doing something blatantly wrong, aren't I? <img src="cid:gtalk.338@goomoji.gmail" goomoji="gtalk.338" style="margin: 0px 0.2ex; vertical-align: middle;"></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 23, 2014 at 5:31 PM, Dalai Felinto <span dir="ltr"><<a href="mailto:dfelinto@gmail.com" target="_blank">dfelinto@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Khalifa,<br>
<br>
See if this sample file helps:<br>
<a href="https://svn.blender.org/svnroot/bf-blender/trunk/lib/tests/gameengine_visual/lampRGB.blend" target="_blank">https://svn.blender.org/svnroot/bf-blender/trunk/lib/tests/gameengine_visual/lampRGB.blend</a><br>
<br>
The code runs in the BGE (Blender Game Engine), but the BGE works the<br>
same for Blender and for the BGE.<br>
<br>
Apart from that BGL is simply a wrapper of OpenGL functions, so I<br>
presume the error is in your OpenGL (bgl) code.<br>
<br>
Regards,<br>
Dalai<br>
--<br>
<a href="http://blendernetwork.org/dalai-felinto" target="_blank">blendernetwork.org/dalai-felinto</a><br>
<a href="http://www.dalaifelinto.com" target="_blank">www.dalaifelinto.com</a><br>
<div><div class="h5"><br>
<br>
2014-10-23 16:38 GMT+02:00 Khalifa Lame <<a href="mailto:khalibloo@gmail.com">khalibloo@gmail.com</a>>:<br>
> glReadPixels() returns None. I'm sure it shouldn't be empty, I did some<br>
> clearing and drawing beforehand.<br>
> I even tried specifying the buffer to draw to using glDrawBuffer() and<br>
> glReadBuffer. Tried with GL_BACK and GL_AUX_BUFFERS. Both turn up empty.<br>
><br>
> Is there something i'm missing?<br>
> Another weird thing, the preview window shows some colored dots when in<br>
> fact, the data fed to it was the empty result from glReadPixels().<br>
><br>
> I'm new to openGL programming and even newer to bgl.<br>
><br>
> --<br>
> khalibloo®<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> Bf-python mailing list<br>
> <a href="mailto:Bf-python@blender.org">Bf-python@blender.org</a><br>
> <a href="http://lists.blender.org/mailman/listinfo/bf-python" target="_blank">http://lists.blender.org/mailman/listinfo/bf-python</a><br>
><br>
_______________________________________________<br>
Bf-python mailing list<br>
<a href="mailto:Bf-python@blender.org">Bf-python@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-python" target="_blank">http://lists.blender.org/mailman/listinfo/bf-python</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>khalibloo®<br><br>
</div>