Here is a new patch with some changes.  This is what's changed (and what hasn't):<br><br>1.  Fonts are now rendered with Freetype 2.  Hopefully this works out better as a cross-platform high-quality option.  It automatically anti-aliases the text which makes it look nicer than the X/GLX version.  Both ways generate display lists, so I could use your X code as a fallback if necessary.  Even if we don't do this, I may refactor the freetype-specific code to a separate file just to make it easier to read.<br>
<br>2.  The code still uses fontconfig at the moment, but I plan to bundle a font so that fontconfig doesn't get a chance to make any weird font choices for anyone.<br><br>3.  I added the GTK configuration dialog for video settings (nothing is hooked up to configuration values yet). I added an option for font size because on a PC a smaller font would be readable, whereas on a TV you'd want a bigger font.<br>
<br>4.  I didn't realize just how many INFO messages there were until I started showing them on the OSD!  These and probably the warnings as well are going to need to be cleaned up, many should probably be switched to DEBUG.<br>
<br>5.  The OSD functions are now top-level and initialized in main.c, instead of tied to the driver.<br><br>6.  I still need to look at the flickering/double buffering.  I also need to make sure my opengl code doesn't cause any bad side-effects in the rest of the opengl drawing functions.<br>
<br><br>Just wanted to let you see where things are at currently.  Also, if you could let me know if Freetype will be ok, that would be helpful.  Any other feedback is always welcome, too.<br><br>Thanks,<br>Jon<br><br><br>
<br><br><br><div class="gmail_quote">On Wed, Jul 15, 2009 at 6:04 PM, Jon Ring <span dir="ltr"><<a href="mailto:jonnyring@gmail.com">jonnyring@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Sorry if this shows up twice... I don't think the first one made it to the list.<div><div></div><div class="h5"><br><br><br><div class="gmail_quote">On Wed, Jul 15, 2009 at 6:02 PM, Jon Ring <span dir="ltr"><<a href="mailto:jonnyring@gmail.com" target="_blank">jonnyring@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br><br><div class="gmail_quote"><div>On Sat, Jul 11, 2009 at 8:13 PM, Nathan Keynes <span dir="ltr"><<a href="mailto:nkeynes@lxdream.org" target="_blank">nkeynes@lxdream.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br><div class="gmail_quote"><div>On Fri, Jul 10, 2009 at 1:15 PM, Jon Ring <span dir="ltr"><<a href="mailto:jonnyring@gmail.com" target="_blank">jonnyring@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">




I have attached a patch that demonstrates the OSD functionality at this<br>
point.  Here are some things to note and/or discuss, in no particular order:<br>
<br>
1.  I used the FTGL library to do the drawing.  It is cross platform and<br>
should be lightweight enough.<br>
</blockquote></div><div><br>Hmm. I am unable to install this library on debian as something is wrong with the dependencies (it tries to remove the X server if I install it...), and I can't build it manually on this machine as I have no GL/glu.h (which I also can't install for the same reason). On mac I can install 2.1.2, which appears to have different type names to whichever version you used (ie it doesn't have FTGLfont) and osd_ftgl.c won't compile.</div>



</div></blockquote></div><div><br><br>That's pretty weird that GLU won't even install, from what I can tell it's used by some pretty big names like glut and SDL.  Even if you did have it working, the mac issues are still a negative for FTGL.<br>


<br> </div><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="gmail_quote"><div><br>
<br>So... I think we can't have it as a mandatory dependency under the circumstances - either we bundle FTGL (or some subset) into the source tree and integrate it fully (which admittedly doesn't help with my missing glu.h problem), or we have a fallback to a non-ftgl font rendering, or we drop it and just do the rendering ourselves. Which option probably depends on how good the FTGL font quality is, and whether you want to use any of it's fancier options, but I'd be happy with a fallback.</div>



</div></blockquote></div><div><br><br>I mainly went with FTGL because I figured it would be a nice easy way to do fonts in a cross-platform manner.  Unfortunately, our real-world experiences here have proven otherwise.  Between your GLX font code below and the source of FTGL, I've started looking at rendering the font without FTGL.  It shouldn't really have an impact on the font quality, since with a monospaced font there aren't as many of those little details such as kerning to implement.<br>



<br> </div><div><div></div><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="gmail_quote"><div><br>
<br>If you check an old revision (was in lxdream_0_8, not sure when I took it out), there was actually some font code once upon a time, spread across video_glx.c and render.c. I'm not saying it was particularly pretty, but it's fairly simple:<br>




<br><div style="margin-left: 40px;"><span style="font-family: courier new,monospace;">int video_glx_load_font( const gchar *font_name )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">{</span><br style="font-family: courier new,monospace;">




<span style="font-family: courier new,monospace;">    int lists;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    XFontStruct *font = XLoadQueryFont(video_x11_display, font_name );</span><br style="font-family: courier new,monospace;">




<span style="font-family: courier new,monospace;">    if (font == NULL)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        return -1;</span><br style="font-family: courier new,monospace;">




<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    lists = glGenLists(96);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    glXUseXFont(font->fid, 32, 96, lists);</span><br style="font-family: courier new,monospace;">




<span style="font-family: courier new,monospace;">    XFreeFont(video_x11_display, font);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    return lists;</span><br style="font-family: courier new,monospace;">




<span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">int pvr2_render_font_list = -1;</span><br style="font-family: courier new,monospace;">




<span style="font-family: courier new,monospace;">int glPrintf( int x, int y, const char *fmt, ... )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">{</span><br style="font-family: courier new,monospace;">




<span style="font-family: courier new,monospace;">    va_list ap;     /* our argument pointer */</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    char buf[256];</span><br style="font-family: courier new,monospace;">




<span style="font-family: courier new,monospace;">    int len;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    if (fmt == NULL)    /* if there is no string to draw do nothing */</span><br style="font-family: courier new,monospace;">




<span style="font-family: courier new,monospace;">        return 0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    va_start(ap, fmt); </span><br style="font-family: courier new,monospace;">




<span style="font-family: courier new,monospace;">    len = vsnprintf(buf, sizeof(buf), fmt, ap);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    va_end(ap);</span><br style="font-family: courier new,monospace;">




<br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    glPushAttrib(GL_LIST_BIT);</span><br style="font-family: courier new,monospace;">




<span style="font-family: courier new,monospace;">    glDisable( GL_DEPTH_TEST );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    glDisable( GL_BLEND );</span><br style="font-family: courier new,monospace;">




<span style="font-family: courier new,monospace;">    glDisable( GL_TEXTURE_2D );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    glDisable( GL_ALPHA_TEST );</span><br style="font-family: courier new,monospace;">




<span style="font-family: courier new,monospace;">    glDisable( GL_CULL_FACE );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    glListBase(pvr2_render_font_list - 32);</span><br style="font-family: courier new,monospace;">




<span style="font-family: courier new,monospace;">    glColor3f( 1.0, 1.0, 1.0 );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    glRasterPos2i( x, y );</span><br style="font-family: courier new,monospace;">




<span style="font-family: courier new,monospace;">    glCallLists(len, GL_UNSIGNED_BYTE, buf);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    glPopAttrib();</span><br style="font-family: courier new,monospace;">




<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    return len;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br>




</div> <br>On the downside it doesn't give you the font boxes, but I guess you could use the X methods for that.<br><br></div><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">




<br>
2.  I am currently using fontconfig to get the path to a font.  I'm pretty<br>
sure it's X-specific, so that part won't work on OSX.  We'd need to find a<br>
different way to get the path to an appropriate font there.  OSX, I believe,<br>
comes with a default set of fonts that will always be there, so perhaps<br>
getting a path to a well-known font won't be so bad on that platform.<br>
Possible alternatives to trying to automatically find a font (on any<br>
platform) are making the user pick a font (not the best idea in the world)<br>
and including a font with lxdream.  Including a font also has the advantage<br>
of being guaranteed to look the same on every platform.<br>
</blockquote></div><div><br>Yeah no biggie, this bit will probably be platform-specific anyway. Bundling a font might be nice for consistency (if we can find a good free one), but not sure how easy it would be to get it into the system font list at install time.</div>


</div></blockquote></div></div><div><br><br>The more I think about it, the more I lean towards just including a font and not worrying about trying to find one on the system.  I don't think we necessarily need to get it into the system font list.  I should be able to load a font by its absolute path, but then again that raises the issue of knowing where we install the font to...<br>


<br><br> <br></div><div><div></div><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="gmail_quote"><div><br>

<br></div><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
3.  Do we want the OSD to be a main feature, or something that can be<br>
optionally compiled in?</blockquote></div><div><br>I can't think of any reason to make it conditional, so preferably always compiled in.   I'd also enable it by default, at least for fullscreen mode.<br></div><div>



<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
4.  To put a message on the OSD, I currently have it so you use<br>
display_driver->display_show_osd(...).  This function could also be global<br>
or a member of something else if this isn't the best location for it.</blockquote><div> </div></div><div>Yeah this doesn't really belong in the driver code - it's more top-level stuff.<br></div><div>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>
5.  Do you think we need to go as far as to have some sort of messaging<br>
class?  It could push messages to the OSD, status bar, and/or log depending<br>
on a setting.  This might be a "something else" of #4.</blockquote></div><div><br>My thinking is that messages generally into one of the following categories:<br>  * Error - GUI should pop up a message and halt<br>



  * Warn - probably display same as for status (maybe more visible though)<br>
  * Status update (ie info) - GUI should display in the status bar and/or osd <br>  * Debug - print to console if enabled, otherwise ignore<br><br>So it would make sense to use the INFO() log for status updates. (of course some of the current INFO messages should really be DEBUG). I don't think anything more sophisticated is going to be needed at this stage..<br>




 <br></div><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
6.  The saved and loaded OSD messages in there now are more or less<br>
placeholders until we answer #4 and #5.  I think the final version should<br>
say which file/slot was saved or loaded, and also have a message when you<br>
switch quick save slots.</blockquote></div><div><br>Agreed. </div></div></blockquote><div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


<div class="gmail_quote"><div><br></div><div><div> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

7.  I'm guessing not everyone will want to see on screen messages.  I think<br>
it would be good to have GUI options to toggle the speed from showing up,<br>
and maybe options regarding whether the OSD messages show when you are in<br>
windowed mode, fullscreen, or both (since there is the less obtrusive status<br>
bar when you are in windowed mode.  Perhaps this is a good reason to keep<br>
the status bar messages around?)  An OSD configuration GUI could be the<br>
start of the currently grayed out Settings->Video menu item.<br>
</blockquote></div><div><br>Ok, so we've got something like <br>    OSD: < always | fullscreen | never > (default fullscreen)<br>    OSD speed display: < yes | no >  (default no)<br>I think that works pretty well.</div>


</div></blockquote></div></div><div><br><br>[#3 - #7] Thanks for the input - I'll aim for this behavior.<br><br> </div><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


<div class="gmail_quote"><div><br>

 </div><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">8.  Timers.  The OSD messages, if any exist, get rendered every frame, so I<br>




update the remaining display time every frame.  This is also used to<br>
smoothly fade out the OSD when its display time is up.  Is this OK or should<br>
it be a g_timeout?  The status message timer would be best switched to a<br>
g_timeout, but it will also need a special case to keep the speed update<br>
from clobbering it while another message is being displayed.<br>
</blockquote></div><div><br>It probably needs to key off the GUI timer as well, for the same reason (consistent message times) rather than keeping it's own count. Handling fadeout smoothly may be tricky though. Speed update is more of an ongoing thing, so it can update whenever (assuming it occupies a different spot to the message).</div>


</div></blockquote></div><div><br>The OSD time is keyed to real time using a struct timeval that gets updated every frame, so it should have a consistent message time.  In addition to the fading code, g_timeout might also get messy when it comes to cancelling/changing the timeout if a new message replaces an old one before it expires.  If you think the current method is particularly bad, though, I'll change it to the GUI timer.<br>


<br> </div><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="gmail_quote"><div><br>

</div><div><div> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
9.  I'm an opengl noob.  Let me know if I did anything stupid in my drawing<br>
code or hooked up osd_render() to the rest of the code in a horrible way<br>
:-)  Something's still not perfect, as I get a little flickering in the text<br>
on my mythtv box.<br></blockquote></div></div><br>I'll go through the code properly after I get it to build, but you're probably being being caught out by the fact that we currently draw directly to the front buffer and don't bother double-buffering (ie treating the render texture as the back buffer). Because we're now compositing on top of the render texture, will probably need to go back to double-buffering. Basically, (IIRC) glDrawBuffer( GL_BACK ) before drawing into the window, then video_glx_swap_buffers() at the end. Might need to reset the draw buffer back to GL_FRONT afterwards, I'm not sure off the top of my head.</blockquote>


</div><div><br>Now that you say it, that sounds like it has to be right.  I never saw it on my desktop because I have sync to vblank enabled by default.<br><br><br>Thanks again for your detailed response.<br><br>Jon<br><br>

<br>
 </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>

<br>Cheers,<div><br><font color="#888888">Nathan<br>
</font><br>_______________________________________________<br>
Lxdream-dev mailing list<br>
<a href="mailto:Lxdream-dev@lists.lxdream.org" target="_blank">Lxdream-dev@lists.lxdream.org</a><br>
<a href="http://lists.lxdream.org/listinfo.cgi/lxdream-dev-lxdream.org" target="_blank">http://lists.lxdream.org/listinfo.cgi/lxdream-dev-lxdream.org</a><br>
<br></div></blockquote></div><br>
</blockquote></div><br>
</div></div></blockquote></div><br>