Hiya. Another SoC student here, I&#39;ve some experience with porting immediate mode to vertex buffers and I wanted to chime in.<br><br>In some of my projects I made an interface that works like immediate mode but instead of submitting verts to the gpu one at a time it would build a list of verts in a vector and send them all off at once. Is this what you intend to do? If so, it may help you to learn from my experience in the matter.<br>

<br>Doing this has some advantages and some drawbacks. Obviously it reduces effort to port things to vertex buffers, and thus GL 3.0+. Mixing 2/3 is undefined hell and Blender should get away from that as fast as possible. It also has the advantage of being able to modify meshes on the fly. A vertex buffer doesn&#39;t need to be updated every frame and adding/removing verts or attributes is a breeze.<br>

<br>The primary drawback is the copy and memory allocation cost of the vert vector. Depending on how you implement it, you may need to reallocate the vector every frame, that&#39;ll be slow. Then copying the verts one by one into the vector is also costly. It&#39;ll likely still be faster than immediate mode, but it could be optimized more.<br>

<br>I found that for essential and large vert buffers you&#39;re best building a vertex buffer once and using it from there on, but for little things or things that update very often you can easily get away with an immediate mode stand-in.<br>

<br>Hope that helps :)<br><br><div class="gmail_quote">2012/5/26 Sergej Reich <span dir="ltr">&lt;<a href="mailto:sergej.reich@googlemail.com" target="_blank">sergej.reich@googlemail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hey Jason,<br>
<br>
since you&#39;re already working in this area I&#39;ve got a feature<br>
request/suggestion.<br>
I wonder if it would be a good idea to introduce some sort of primitive<br>
render API for the viewport.<br>
There are a lot of places where you just want to draw simple wireframe<br>
shapes like cubes, spheres, circles and what have you.<br>
Instead of all systems having their own OpenGL code we could have<br>
functions like add_line(float start[3], float end[3], float color[3],<br>
int xray), add_box(float pos[3], float size[3], float color[3], int<br>
xray), ... and so on.<br>
These functions would not draw directly but just fill a buffer (or more<br>
likely several buffers) which would be drawn at viewport refresh.<br>
<br>
I&#39;m interested in this not only because it would allow us to get rid of<br>
more GL code but because it would be very useful for debugging since you<br>
could call those functions pretty much from anywhere.<br>
<br>
Of course this is just an idea, I haven&#39;t spent much time with blenders<br>
drawing code yet so it might not be so simple.<br>
<br>
Regards, Sergej.<br>
<br>
Am Samstag, den 26.05.2012, 03:43 -0500 schrieb Jason Wilkins:<br>
<div class="HOEnZb"><div class="h5">&gt; Created the first part of an OpenGL compatibility layer: gpuImmediate<br>
&gt;<br>
&gt; gpuImmediate is meant to be a simple and direct replacement for<br>
&gt; glBegin/glEnd style programming.  The goal is to reduce the work<br>
&gt; required to port this style of code in cases where what is being drawn<br>
&gt; is so simple and small that the effort to convert it to a direct<br>
&gt; vertex array rendering style would be costly in developer time and<br>
&gt; regressions.<br>
&gt;<br>
&gt; glBegin/glEnd is inefficient for large amounts of geometry, but it has<br>
&gt; been highly tuned by the graphics card vendors to be about as good as<br>
&gt; it can possibly be.  I am not yet able to match the performance.  The<br>
&gt; only place I think this will matter however is in the text editor,<br>
&gt; which I was forced to rewrite some parts of, because it sent each<br>
&gt; character to the GL one. at. a. time.  Eventually I think it would be<br>
&gt; better to revisit the text editor by somebody interested in making it<br>
&gt; better generally, for now I just wanted to make sure I did not make it<br>
&gt; slower (it became unusable).<br>
&gt;<br>
&gt; Next week I hope to convert everything that uses GL immediate mode to<br>
&gt; use the new interface.  Also, I will be centralizing much of what<br>
&gt; would be considered GL utility functions in various parts of Blender<br>
&gt; into a central location to reduce duplication (for example there are 3<br>
&gt; different chunks of code that draw &quot;unit cubes&quot; and countless &quot;draw a<br>
&gt; single line&quot; routines.<br>
&gt;<br>
&gt; I&#39;m keeping a day by day development diary here:<br>
&gt; <a href="http://wiki.blender.org/index.php/Viewport_FX_Design_Diary" target="_blank">http://wiki.blender.org/index.php/Viewport_FX_Design_Diary</a><br>
&gt; _______________________________________________<br>
&gt; Soc-2012-dev mailing list<br>
&gt; <a href="mailto:Soc-2012-dev@blender.org">Soc-2012-dev@blender.org</a><br>
&gt; <a href="http://lists.blender.org/mailman/listinfo/soc-2012-dev" target="_blank">http://lists.blender.org/mailman/listinfo/soc-2012-dev</a><br>
<br>
<br>
_______________________________________________<br>
Soc-2012-dev mailing list<br>
<a href="mailto:Soc-2012-dev@blender.org">Soc-2012-dev@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/soc-2012-dev" target="_blank">http://lists.blender.org/mailman/listinfo/soc-2012-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Jorge &quot;Vino&quot; Rodriguez<br>