openmv/drivers/dave2d/docs/files/doc/overview-txt.html
iabdalkader daf2bb30da misc: Restructure repo.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-13 08:28:34 +02:00

80 lines
10 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Driver Overview</title><link rel="stylesheet" type="text/css" href="../../styles/main.css"><script language=JavaScript src="../../javascript/main.js"></script><script language=JavaScript src="../../javascript/prettify.js"></script><script language=JavaScript src="../../javascript/searchdata.js"></script></head><body class="ContentPage" onLoad="NDOnLoad();prettyPrint();"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>
<!-- Generated by Natural Docs, version 1.52 -->
<!-- http://www.naturaldocs.org -->
<!-- saved from url=(0026)http://www.naturaldocs.org -->
<div id=Content><div class="CSection"><div class=CTopic id=MainTopic><h1 class=CTitle><a name="Driver_Overview"></a>Driver Overview</h1><div class=CBody><p>Overview of D/AVE 2D driver V3.14</p><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SMain"><td class=SEntry><a href="#Driver_Overview" >Driver Overview</a></td><td class=SDescription>Overview of D/AVE 2D driver V3.14</td></tr><tr class="SGeneric SIndent1 SMarked"><td class=SEntry><a href="#Coding_conventions" >Coding conventions</a></td><td class=SDescription>Quickinfo about Dave2d Driver implementation</td></tr><tr class="SGeneric SIndent1"><td class=SEntry><a href="#Concept" >Concept</a></td><td class=SDescription>Basic objects and principles</td></tr><tr class="SGeneric SIndent1 SMarked"><td class=SEntry><a href="#Sample_code" >Sample code</a></td><td class=SDescription>Simple example of using the dave driver</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>
<div class="CGeneric"><div class=CTopic><h3 class=CTitle><a name="Coding_conventions"></a>Coding conventions</h3><div class=CBody><p>Quickinfo about Dave2d Driver implementation</p><ul><li>interface and driver are pure ansi C</li><li>code is fully reentrant</li><li>all exports prefixed by <b>d2_</b></li><li>all files are prefixed by <b>dave_</b></li><li>all functions and types are entierly lowercase</li><li>all macros are entierly uppercase</li><li>all functions set an errorcode</li><li>only a single include is necessary from the clientside (dave_driver.h)</li></ul></div></div></div>
<div class="CGeneric"><div class=CTopic><h3 class=CTitle><a name="Concept"></a>Concept</h3><div class=CBody><p>Basic objects and principles</p><p>The driver allows direct access to all hardware features.&nbsp; Functionality not directly supported by hardware is not offered (emulated) by the driver.</p><ul><li>basic object is called a <b>device</b>. all functions require a device pointer as first parameter (see &lt;opendevice&gt;)</li><li>devices are assigned to a hardware unit before anything is rendered through them (see &lt;inithw&gt;)</li><li>material settings like color, texture, blending etc.. are stored in a context</li><li>shapes are rendered by <a href="../code/dave_render-c.html#Rendering_Functions" class=LSection id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">Rendering Functions</a> using the current context(s)</li><li>rendering does not happen immediately but fills a renderbuffer (see <a href="../code/dave_rbuffer-c.html#Render_Buffers" class=LSection id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')">Render Buffers</a>)</li><li>renderbuffers can be executed totally in parallel (without any cpu interaction)</li><li>calling d2 functions from interrupt service routines is not recommended in general and must be done with care</li></ul></div></div></div>
<div class="CGeneric"><div class=CTopic><h3 class=CTitle><a name="Sample_code"></a>Sample code</h3><div class=CBody><p>Simple example of using the dave driver</p><p>Further information and examples can be found in the Driver Tutorial (software/tutorial/driver_tutorial.doc).</p><p>To create a device, allocate and initialize the hardware (errorchecks omitted for clarity) :</p><blockquote><pre class="prettyprint">#include &quot;dave_driver.h&quot;
int main()
{
void *framebuffer;
// Use the default memory management functions and register a wrapper for the normal malloc, free and msize commands of the system.
// Note: On some platforms a different memory manager for video and heap management may be required.
// A different memory manager can be chosen by calling d0_initheapmanager(..) instead of d0_initdefaultheapmanager().
d0_initdefaultheapmanager(); // initialize D/AVE driver memory management interface
d2_device *handle = d2_opendevice( 0 ); // create a device
d2_setdlistblocksize( handle, 25 ); // set blocksize for default displaylist
d2_lowlocalmemmode( handle, 20, 10 ); // systems with low local CPU memory need this mode
d2_inithw( handle, 0 ); // bind the hardware</pre></blockquote><p>now we setup a 32bit 640x480 pixel framebuffer using the lowlevel driver</p><blockquote><pre class="prettyprint">framebuffer = d1_allocvidmem(d2_level1interface(handle), d1_mem_display, 640*480*4);
// define address and memory organisation of framebuffer
d2_framebuffer( handle, framebuffer, 640, 640, 480, d2_mode_rgb888 );</pre></blockquote><p>using the default context we can directly start and setup our material attributes</p><blockquote><pre class="prettyprint">d2_setcolor( handle, 0, 0xffffff ); // just simple white
d2_setblendmode( handle, d2_bm_alpha, d2_bm_one_minus_alpha );
d2_setalphamode( handle, d2_am_constant );
d2_setalpha( handle, 0x7f ); // 50% transparency
d2_setblur( handle, 4*16 );</pre></blockquote><p>the rendering happens inside an endless loop, as it is the case for most realtime animated graphics.&nbsp; In order to avoid having to deal with renderbuffers manual, we use the utility functions startframe and endframe to get automatic buffer management.</p><blockquote><pre class="prettyprint">d2_point x = 320*16;
d2_point y = 240*16;
//
while (1)
{
d2_startframe( handle );
d2_clear( handle, 0x000000 ); // clear the background
d2_rendercircle( handle, x, y, 64*16, 0 ); // draw our circle
d2_endframe( handle );
x += 1;
y += 8;
}</pre></blockquote></div></div></div>
</div><!--Content-->
<div id=Footer>&copy; 2016 by TES Electronic Solutions&nbsp; &middot;&nbsp; <a href="http://www.naturaldocs.org">Generated by Natural Docs</a></div><!--Footer-->
<div id=Menu><div class=MEntry><div class=MFile id=MSelected>Driver Overview</div></div><div class=MEntry><div class=MFile><a href="limitations-txt.html">Limitations</a></div></div><div class=MEntry><div class=MFile><a href="../inc/dave_driver-h.html">Basic Types</a></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent1')">API</a><div class=MGroupContent id=MGroupContent1><div class=MEntry><div class=MFile><a href="../code/dave_driver-c.html">Basic Functions</a></div></div><div class=MEntry><div class=MFile><a href="../code/dave_viewport-c.html">Viewport Functions</a></div></div><div class=MEntry><div class=MFile><a href="../code/dave_context-c.html">Context Functions</a></div></div><div class=MEntry><div class=MFile><a href="../code/dave_texture-c.html">Texture Functions</a></div></div><div class=MEntry><div class=MFile><a href="../code/dave_render-c.html">Rendering Functions</a></div></div><div class=MEntry><div class=MFile><a href="../code/dave_blit-c.html">Blit Functions</a></div></div><div class=MEntry><div class=MFile><a href="../code/dave_rbuffer-c.html">Render Buffers</a></div></div><div class=MEntry><div class=MFile><a href="../code/dave_perfcount-c.html">Profiling</a></div></div><div class=MEntry><div class=MFile><a href="../code/dave_utility-c.html">Utility Functions</a></div></div><div class=MEntry><div class=MFile><a href="../code/dave_64bitoperation-c.html">Functions for 64bit operations</a></div></div><div class=MEntry><div class=MFile><a href="../code/dave_dlist-c.html">Dlist Functions</a></div></div><div class=MEntry><div class=MFile><a href="../inc/dave_math-h.html">Math Functions</a></div></div><div class=MEntry><div class=MFile><a href="../inc/dave_errorcodes-h.html">Errorcodes</a></div></div></div></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent2')">Index</a><div class=MGroupContent id=MGroupContent2><div class=MEntry><div class=MIndex><a href="../../index/General.html">Everything</a></div></div><div class=MEntry><div class=MIndex><a href="../../index/Functions.html">Functions</a></div></div><div class=MEntry><div class=MIndex><a href="../../index/Types.html">Types</a></div></div></div></div></div><script type="text/javascript"><!--
var searchPanel = new SearchPanel("searchPanel", "HTML", "../../search");
--></script><div id=MSearchPanel class=MSearchPanelInactive><input type=text id=MSearchField value=Search onFocus="searchPanel.OnSearchFieldFocus(true)" onBlur="searchPanel.OnSearchFieldFocus(false)" onKeyUp="searchPanel.OnSearchFieldChange()"><select id=MSearchType onFocus="searchPanel.OnSearchTypeFocus(true)" onBlur="searchPanel.OnSearchTypeFocus(false)" onChange="searchPanel.OnSearchTypeChange()"><option id=MSearchEverything selected value="General">Everything</option><option value="Functions">Functions</option><option value="Types">Types</option></select></div></div><!--Menu-->
<!--START_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CSection>There is a rendering function for each supported geometric shape.</div></div><div class=CToolTip id="tt2"><div class=CSection>Renderbuffers (similar in concept to OpenGL display lists) are the main interface between driver and hardware.</div></div><!--END_ND_TOOLTIPS-->
<div id=MSearchResultsWindow><iframe src="" frameborder=0 name=MSearchResults id=MSearchResults></iframe><a href="javascript:searchPanel.CloseResultsWindow()" id=MSearchResultsWindowClose>Close</a></div>
<script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>