diff options
-rw-r--r-- | html/en/download.html | 4 | ||||
-rw-r--r-- | html/en/drv/gl.html | 63 | ||||
-rw-r--r-- | html/en/drv/pdf.html | 7 | ||||
-rw-r--r-- | html/en/history.html | 4 | ||||
-rw-r--r-- | html/wb/wb_usr.lua | 4 | ||||
-rw-r--r-- | html/wb_search.txt | 27 | ||||
-rw-r--r-- | html/wb_tree.html | 51 | ||||
-rw-r--r-- | include/cd.h | 2 | ||||
-rw-r--r-- | include/cdluagl.h | 27 | ||||
-rw-r--r-- | mak.vc9/cd.sln | 17 | ||||
-rw-r--r-- | mak.vc9/cdluagl3.vcproj | 106 | ||||
-rw-r--r-- | mak.vc9/cdluagl51.vcproj | 106 | ||||
-rw-r--r-- | mak.vc9/cdluagl52.vcproj | 106 | ||||
-rw-r--r-- | mak.vc9/cdsimple.vcproj | 4 | ||||
-rw-r--r-- | src/cdluagl3.mak | 15 | ||||
-rw-r--r-- | src/cdluagl5.mak | 23 | ||||
-rw-r--r-- | src/drv/cdgl.c | 242 | ||||
-rw-r--r-- | src/lua3/cdluagl.c | 43 | ||||
-rw-r--r-- | src/lua3/cdluagl.def | 2 | ||||
-rw-r--r-- | src/lua5/cdluagl5.c | 53 | ||||
-rw-r--r-- | src/lua5/cdluagl5.def | 3 | ||||
-rw-r--r-- | src/sim/sim_primitives.c | 2 | ||||
-rw-r--r-- | test/simple/iupmain.c | 23 | ||||
-rw-r--r-- | test/simple/simple.c | 515 | ||||
-rw-r--r-- | test/simple/simple.h | 12 | ||||
-rw-r--r-- | test/simple/simple.led | 8 | ||||
-rw-r--r-- | test/simple/simple_led.c | 8 |
27 files changed, 1066 insertions, 411 deletions
diff --git a/html/en/download.html b/html/en/download.html index d24fb87..eef64cb 100644 --- a/html/en/download.html +++ b/html/en/download.html @@ -19,8 +19,8 @@ http://sourceforge.net/projects/canvasdraw/files/</a> </p> <p class="info"> Use this link for the latest version: -<a href="http://sourceforge.net/projects/canvasdraw/files/5.3/"> -http://sourceforge.net/projects/canvasdraw/files/5.3/</a> </p> +<a href="http://sourceforge.net/projects/canvasdraw/files/5.4/"> +http://sourceforge.net/projects/canvasdraw/files/5.4/</a> </p> <p>Before downloading any precompiled binaries, you should read before the <a href="download_tips.html">Tecgraf Library Download Tips</a>.</p> diff --git a/html/en/drv/gl.html b/html/en/drv/gl.html index 2b94b10..cff89db 100644 --- a/html/en/drv/gl.html +++ b/html/en/drv/gl.html @@ -10,6 +10,9 @@ .style1 { margin-top: 0px; } +.style2 { + font-family: Courier; +} </style> </head> @@ -17,13 +20,38 @@ <h2>GL Driver</h2> - <p>This driver represents a basic driver for all system-dependent drivers - implemented in the X-Windows system using the <a href="http://www.opengl.org/"> - OpenGL</a> SDK. The implementation uses the OpenGL, GLU and GLX API functions. + <p>This driver represents a driver for drawing using + <a href="http://www.opengl.org/"> + OpenGL</a>. The implementation uses the OpenGL functions only. For the font support, this driver uses the <a href="http://homepages.paradise.net.nz/henryj/code/index.html#FTGL">FTGL</a> API functions, which it was written against the <a href="http://www.freetype.org/">Free Type</a> library.</p> +<p>The driver is not dependent of system functions. It uses only the OpenGL +portable funtions. So if the window canvas changes its size the attribute "SIZE" +must be set with the new size or cdCanvasGetSize will return an incorrect value.</p> + +<h3>Use</h3> + + <p>The canvas is created by means of a call to the function <font face="Courier"> + <a href="../func/init.html#cdCreateCanvas"><strong>cdCreateCanvas</strong></a>(CD_GL, + Data)</font>, after which other functions in the CD library can be called as usual. The <font face="Courier">Data</font> parameter string has the following format:</p> + + <pre><em>"width<strong>x</strong>height [resolution]"</em> in C "<em><strong><tt>%dx%d %g"</tt></strong></em></pre> + + <p>It must include the initial canvas' dimensions.<font face="Courier"> Width</font> and <font face="Courier">height</font> + are provided in pixels (note the lowercase "x" between them). The + resolution is optional, its default value is "3.78 pixels/mm" (96 DPI).</p> + + + + <p>To use this driver, the application must be linked with the "<strong>cdgl</strong>", + the ftgl library + and the OpenGL library. The FTGL library is dependent also on the GLU + library.</p> + <p>In Lua, it is necessary to call function <font face="Courier"> <strong>cdluagl_open() </strong> </font>after a call + to function <strong><font face="Courier">cdlua_open()</font></strong>, apart from linkediting with the "<strong><font face="Courier">cdluagl</font></strong>" + library. This is not necessary if you do require"cdluagl". </p> <h3>Behavior of Functions</h3> <h4>Control </h4> @@ -79,9 +107,11 @@ <font face="Courier"><strong>NativeFont</strong></font></a>: also accepts the X-Windows font string format.</li> <li><a href="../func/text.html#cdFont"> - <font face="Courier"><strong>Font</strong></font></a>: "Courier" is mapped to + <font face="Courier"><strong>Font</strong></font></a>: In Windows, "Courier" is mapped to "Courier New", "Helvetica" is mapped to "Arial", and "Times" is mapped to - "Times New Roman". Underline and Strikeout are NOT supported.</li> + "Times New Roman". In UNIX, "Courier" is mapped to + "freemono", "Helvetica" is mapped to "freesans", and "Times" is mapped to + "freeserif". Underline and Strikeout are NOT supported.</li> </ul> <h4>Colors </h4> <ul> @@ -92,6 +122,23 @@ <h4>Exclusive Attributes</h4> <ul> + <li>"<b><font face="Courier">ALPHA</font></b>": allows the usage of an alpha + channel for the drawing shapes. Assumes values "1" (active) and "0" + (inactive). Default value: "1".</li> +</ul> + +<ul> + <li>"<b><font face="Courier">ANTIALIAS</font></b>": allows the use of + anti-aliasing for the drawing shapes. Assumes values "1" (active) and "0" + (inactive). Default value: "1".</li> +</ul> + +<ul> + <li><b><font face="Courier">"GLVERSION": </font></b>returns a string with + the OpenGL version or release number. It is empty if the OpenGL is not available.</li> +</ul> + +<ul> <li>"<b><font face="Courier">ROTATE</font></b>": allows the usage of 1 angle and 1 coordinate (x, y), that define a global rotation transformation centered in the specified coordinate. Use 1 real and 2 integer values inside a @@ -99,8 +146,10 @@ </ul> <ul> - <li><b><font face="Courier">"GLVERSION": </font></b>returns a string with - the OpenGL version or release number. It is empty if the OpenGL is not available.</li> + <li>"<strong><span class="style2">SIZE</span></strong>": sets the canvas size. + Must be used after the window is resized. The format is the same of the data + parameter in cdCreateCanvas, <em>"width<strong>x</strong>height [resolution]"</em> + or in C "<em><strong><tt>%dx%d %g".</tt></strong></em></li> </ul> </body> diff --git a/html/en/drv/pdf.html b/html/en/drv/pdf.html index d111a90..c161eeb 100644 --- a/html/en/drv/pdf.html +++ b/html/en/drv/pdf.html @@ -46,6 +46,10 @@ or in C<em> <p>To use this driver, the application must be linked with the "<strong>cdpdf</strong>" and "<strong>pdflib</strong>" libraries. </p> + <p>In Lua, it is necessary to call function <font face="Courier"> <strong>cdluapdf_open() </strong> </font>after a call + to function <strong><font face="Courier">cdlua_open()</font></strong>, apart from linkediting with the "<strong><font face="Courier">cdluapdf</font></strong>" + library. This is not necessary if you do require"cdluapdf".</p> + <p><b>Paper Size - </b>The default paper size is A4. It is possible to change it by using one of the predefined sizes - <strong><tt>CD_A0</tt></strong>, <strong><tt>CD_A1</tt></strong>, <strong><tt>CD_A2</tt></strong>, <strong><tt>CD_A3</tt></strong>, <strong><tt>CD_A4</tt></strong>, <strong><tt>CD_A5</tt></strong>, <strong><tt>CD_LETTER</tt></strong> and <strong><tt> @@ -111,9 +115,6 @@ or in C<em> default value is 300 DPI.</p> <p><b>Orientation -</b> The page can be oriented as portrait or landscape. The default value is portrait, but when the parameter "-o" is used, the horizontal and vertical values are switched.</p> - <p>In Lua, it is necessary to call function <strong><font face="Courier">cdluapdf_open() </strong> </font>after a call - to function <strong><font face="Courier">cdlua_open()</font></strong>, apart from linkediting with the "<strong><font face="Courier">cdluapdf</font></strong>" - library. This is not necessary if you do require"cdluapdf".</p> <h3>Behavior of Functions</h3> <h4>Control</h4> diff --git a/html/en/history.html b/html/en/history.html index 0acfaad..b24d1c3 100644 --- a/html/en/history.html +++ b/html/en/history.html @@ -27,10 +27,12 @@ <body> <h2>History of Changes</h2> -<h3><a href="http://sourceforge.net/projects/canvasdraw/files/5.4/">Version 5.4</a> (XX/June/2010)</h3> +<h3><a href="http://sourceforge.net/projects/canvasdraw/files/5.4/">Version 5.4</a> (24/June/2010)</h3> <ul> <li><span class="hist_new">New:</span> context plus driver <a href="drv/cairo.html">Cairo</a>.</li> + <li><span class="hist_new">New:</span> OpenGL driver <a href="drv/gl.html"> + CD_GL</a>.</li> <li><span class="hist_new">New:</span> "CMD", "OPACITY" and "HATCHBOXSIZE" attributes in the SVG driver.</li> <li><span class="hist_new">New:</span> <a href="func/polygon.html#cdBegin">CD_PATH</a> <strong>cdCanvasBegin</strong> diff --git a/html/wb/wb_usr.lua b/html/wb/wb_usr.lua index 24d9c5b..2fa3518 100644 --- a/html/wb/wb_usr.lua +++ b/html/wb/wb_usr.lua @@ -960,6 +960,10 @@ wb_usr.tree = { name= {nl= "Native Window"}, link= "drv/native.html" + }, + { + name= {nl= "OpenGL"}, + link= "drv/gl.html" } } }, diff --git a/html/wb_search.txt b/html/wb_search.txt index 1d0aa7c..751c0bd 100644 --- a/html/wb_search.txt +++ b/html/wb_search.txt @@ -1,47 +1,48 @@ en/download.html en/drv/xrender.html en/drv/gdiplus.html +en/drv/cairo.html en/drv/debug.html en/func/server.html en/func/wd.html en/func/client.html en/func/region.html -en/drv/cairo.html -en/drv/sim.html en/drv/xwin.html +en/drv/sim.html +en/drv/win32.html en/drv/native.html en/func/control.html en/screenshots_src_lua.html -en/drv/win32.html en/drv/gdk.html +en/func/lines.html en/func/vectortext.html en/cvs.html en/func/init.html -en/drv/pdf.html +en/drv/emf.html en/drv/picture.html en/func/attributes.html -en/drv/emf.html +en/drv/iup.html en/func/text.html en/func/filled.html en/prod.html en/screenshots.html en/samples.html -en/drv/dbufrgb.html -en/func/clipping.html -en/to_do.html +en/drv/gl.html en/drv/cgm.html -en/drv.html +en/to_do.html en/drv/mf.html -en/drv/irgb.html +en/drv.html +en/drv/printer.html en/drv/ps.html +en/drv/pdf.html en/drv/wmf.html -en/func/lines.html +en/drv/dbufrgb.html en/drv/dxf.html en/copyright.html -en/drv/iup.html +en/drv/irgb.html en/drv/svg.html en/screenshots_src_c.html -en/drv/printer.html +en/func/clipping.html en/cdluaim.html en/guide.html en/drv/dgn.html diff --git a/html/wb_tree.html b/html/wb_tree.html index 5bdccbd..35561e2 100644 --- a/html/wb_tree.html +++ b/html/wb_tree.html @@ -511,49 +511,50 @@ <p><img src="wb_img/blank.png"><img name="imgfolder.6.1" src="wb_img/plusnode.png" onclick="toggleFolder('folder.6.1')"> Window Systems</p> <div id="folder.6.1"> <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link189folder.6.1" href="en/drv/iup.html">IUP</a></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/nodelast.png"><a class="el" name="link190folder.6.1" href="en/drv/native.html">Native Window</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link190folder.6.1" href="en/drv/native.html">Native Window</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/nodelast.png"><a class="el" name="link191folder.6.1" href="en/drv/gl.html">OpenGL</a></p> </div> <p><img src="wb_img/blank.png"><img name="imgfolder.6.2" src="wb_img/plusnode.png" onclick="toggleFolder('folder.6.2')"> Devices</p> <div id="folder.6.2"> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link191folder.6.2" href="en/drv/clipbd.html">Clipboard</a></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link192folder.6.2" href="en/drv/printer.html">Printer</a></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/nodelast.png"><a class="el" name="link193folder.6.2" href="en/drv/picture.html">Picture</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link192folder.6.2" href="en/drv/clipbd.html">Clipboard</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link193folder.6.2" href="en/drv/printer.html">Printer</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/nodelast.png"><a class="el" name="link194folder.6.2" href="en/drv/picture.html">Picture</a></p> </div> <p><img src="wb_img/blank.png"><img name="imgfolder.6.3" src="wb_img/plusnode.png" onclick="toggleFolder('folder.6.3')"> Images</p> <div id="folder.6.3"> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link194folder.6.3" href="en/drv/irgb.html">Client Image</a></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link195folder.6.3" href="en/drv/image.html">Server Image</a></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link196folder.6.3" href="en/drv/dbufrgb.html">Client Double Buffer</a></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/nodelast.png"><a class="el" name="link197folder.6.3" href="en/drv/dbuf.html">Server Double Buffer</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link195folder.6.3" href="en/drv/irgb.html">Client Image</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link196folder.6.3" href="en/drv/image.html">Server Image</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link197folder.6.3" href="en/drv/dbufrgb.html">Client Double Buffer</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/nodelast.png"><a class="el" name="link198folder.6.3" href="en/drv/dbuf.html">Server Double Buffer</a></p> </div> <p><img src="wb_img/blank.png"><img name="imgfolder.6.4" src="wb_img/plusnode.png" onclick="toggleFolder('folder.6.4')"> File</p> <div id="folder.6.4"> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link198folder.6.4" href="en/drv/pdf.html">PDF</a></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link199folder.6.4" href="en/drv/ps.html">PS</a></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link200folder.6.4" href="en/drv/svg.html">SVG</a></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link201folder.6.4" href="en/drv/mf.html">MF</a></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link202folder.6.4" href="en/drv/debug.html">DEBUG</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link199folder.6.4" href="en/drv/pdf.html">PDF</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link200folder.6.4" href="en/drv/ps.html">PS</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link201folder.6.4" href="en/drv/svg.html">SVG</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link202folder.6.4" href="en/drv/mf.html">MF</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link203folder.6.4" href="en/drv/debug.html">DEBUG</a></p> <p class="sep"><img src="wb_img/sepblank.png"><img src="wb_img/sepvertline.png"><img src="wb_img/sepnode.png"></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link203folder.6.4" href="en/drv/cgm.html">CGM</a></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link204folder.6.4" href="en/drv/dgn.html">DGN</a></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link205folder.6.4" href="en/drv/dxf.html">DXF</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link204folder.6.4" href="en/drv/cgm.html">CGM</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link205folder.6.4" href="en/drv/dgn.html">DGN</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link206folder.6.4" href="en/drv/dxf.html">DXF</a></p> <p class="sep"><img src="wb_img/sepblank.png"><img src="wb_img/sepvertline.png"><img src="wb_img/sepnode.png"></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link206folder.6.4" href="en/drv/emf.html">EMF</a></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/nodelast.png"><a class="el" name="link207folder.6.4" href="en/drv/wmf.html">WMF</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link207folder.6.4" href="en/drv/emf.html">EMF</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/nodelast.png"><a class="el" name="link208folder.6.4" href="en/drv/wmf.html">WMF</a></p> </div> <p><img src="wb_img/blank.png"><img name="imgfolder.6.5" src="wb_img/plusnode.png" onclick="toggleFolder('folder.6.5')"> Base Drivers</p> <div id="folder.6.5"> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link208folder.6.5" href="en/drv/gdk.html">GDK</a></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link209folder.6.5" href="en/drv/win32.html">Win32</a></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link210folder.6.5" href="en/drv/xwin.html">X-Win</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link209folder.6.5" href="en/drv/gdk.html">GDK</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link210folder.6.5" href="en/drv/win32.html">Win32</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link211folder.6.5" href="en/drv/xwin.html">X-Win</a></p> <p class="sep"><img src="wb_img/sepblank.png"><img src="wb_img/sepvertline.png"><img src="wb_img/sepnode.png"></p> - <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/nodelast.png"><a class="el" name="link211folder.6.5" href="en/drv/sim.html">Simulation</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/vertline.png"><img src="wb_img/nodelast.png"><a class="el" name="link212folder.6.5" href="en/drv/sim.html">Simulation</a></p> </div> <p><img src="wb_img/blank.png"><img name="imgfolder.6.6" src="wb_img/plusnodelast.png" onclick="toggleFolder('folder.6.6')"> Context Plus</p> <div id="folder.6.6"> - <p><img src="wb_img/blank.png"><img src="wb_img/blank.png"><img src="wb_img/node.png"><a class="el" name="link212folder.6.6" href="en/drv/cairo.html">Cairo</a></p> - <p><img src="wb_img/blank.png"><img src="wb_img/blank.png"><img src="wb_img/node.png"><a class="el" name="link213folder.6.6" href="en/drv/gdiplus.html">GDI+</a></p> - <p><img src="wb_img/blank.png"><img src="wb_img/blank.png"><img src="wb_img/nodelast.png"><a class="el" name="link214folder.6.6" href="en/drv/xrender.html">XRender</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/blank.png"><img src="wb_img/node.png"><a class="el" name="link213folder.6.6" href="en/drv/cairo.html">Cairo</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/blank.png"><img src="wb_img/node.png"><a class="el" name="link214folder.6.6" href="en/drv/gdiplus.html">GDI+</a></p> + <p><img src="wb_img/blank.png"><img src="wb_img/blank.png"><img src="wb_img/nodelast.png"><a class="el" name="link215folder.6.6" href="en/drv/xrender.html">XRender</a></p> </div> </div> </div> diff --git a/include/cd.h b/include/cd.h index cf4d678..e3871dc 100644 --- a/include/cd.h +++ b/include/cd.h @@ -21,7 +21,7 @@ extern "C" { #define CD_COPYRIGHT "Copyright (C) 1994-2010 Tecgraf, PUC-Rio." #define CD_VERSION "5.4" /* bug fixes are reported only by cdVersion functions */ #define CD_VERSION_NUMBER 504000 -#define CD_VERSION_DATE "2010/XX/XX" /* does not include bug fix releases */ +#define CD_VERSION_DATE "2010/06/24" /* does not include bug fix releases */ typedef struct _cdContext cdContext; typedef struct _cdCanvas cdCanvas; diff --git a/include/cdluagl.h b/include/cdluagl.h new file mode 100644 index 0000000..412d745 --- /dev/null +++ b/include/cdluagl.h @@ -0,0 +1,27 @@ +/** \file + * \brief OpenGL Canvas Lua Binding + * + * See Copyright Notice in cd.h + */ + +#ifndef __CD_LUAGL_H +#define __CD_LUAGL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LUA_NOOBJECT /* Lua 3 */ +void cdluagl_open(void); +#endif + +#ifdef LUA_TNONE /* Lua 5 */ +int cdluagl_open(lua_State *L); +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/mak.vc9/cd.sln b/mak.vc9/cd.sln index 1713e1a..7959a46 100644 --- a/mak.vc9/cd.sln +++ b/mak.vc9/cd.sln @@ -79,6 +79,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cdsimple", "cdsimple.vcproj ProjectSection(ProjectDependencies) = postProject {01818D2C-65AF-4D5C-9452-4DFF401C6461} = {01818D2C-65AF-4D5C-9452-4DFF401C6461} {51A96255-7EAB-4F36-A6E5-1BAF6245FA18} = {51A96255-7EAB-4F36-A6E5-1BAF6245FA18} + {8441F69D-7135-AB59-1F94-4522123C8467} = {8441F69D-7135-AB59-1F94-4522123C8467} {8441F69D-7135-43B2-974F-45C6123C8467} = {8441F69D-7135-43B2-974F-45C6123C8467} EndProjectSection EndProject @@ -91,6 +92,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cdsimplegdk", "cdsimplegdk. ProjectSection(ProjectDependencies) = postProject {01818D2C-AAAA-DD23-00AA-5678401C6461} = {01818D2C-AAAA-DD23-00AA-5678401C6461} {01818D2C-AAAA-4D5C-ABCD-1234401C6461} = {01818D2C-AAAA-4D5C-ABCD-1234401C6461} + {8441F69D-7135-AB59-1F94-4522123C8467} = {8441F69D-7135-AB59-1F94-4522123C8467} {8441F69D-7135-43B2-974F-45C6123C8467} = {8441F69D-7135-43B2-974F-45C6123C8467} EndProjectSection EndProject @@ -138,6 +140,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cdgl", "cdgl.vcproj", "{844 EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftgl", "cd_ftgl.vcproj", "{1D758EEA-59C3-46E4-BEF5-16DCCA8C0B21}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cdluagl3", "cdluagl3.vcproj", "{B4823266-DA8C-1D56-22DF-C7AC8C234EAC}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cdluagl51", "cdluagl51.vcproj", "{B4823244-DA8C-4467-DE34-AF158C234EAC}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cdluagl52", "cdluagl52.vcproj", "{B4823266-DA8C-D567-A85C-12634C234EAC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -197,6 +205,12 @@ Global {8441F69D-7135-AB59-1F94-4522123C8467}.Debug|Win32.Build.0 = Debug|Win32 {1D758EEA-59C3-46E4-BEF5-16DCCA8C0B21}.Debug|Win32.ActiveCfg = Debug|Win32 {1D758EEA-59C3-46E4-BEF5-16DCCA8C0B21}.Debug|Win32.Build.0 = Debug|Win32 + {B4823266-DA8C-1D56-22DF-C7AC8C234EAC}.Debug|Win32.ActiveCfg = Debug|Win32 + {B4823266-DA8C-1D56-22DF-C7AC8C234EAC}.Debug|Win32.Build.0 = Debug|Win32 + {B4823244-DA8C-4467-DE34-AF158C234EAC}.Debug|Win32.ActiveCfg = Debug|Win32 + {B4823244-DA8C-4467-DE34-AF158C234EAC}.Debug|Win32.Build.0 = Debug|Win32 + {B4823266-DA8C-D567-A85C-12634C234EAC}.Debug|Win32.ActiveCfg = Debug|Win32 + {B4823266-DA8C-D567-A85C-12634C234EAC}.Debug|Win32.Build.0 = Debug|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -208,6 +222,7 @@ Global {01818D2C-65AF-4D5C-9452-4DFF401C6461} = {1EE89DAC-3D3A-450C-9CF8-E200DF5E12E8} {B4823266-DF8C-AAAA-9999-C7E78C234EAC} = {E92DB6FF-5501-4FC0-81D2-00DB8EFA2434} {53FC9752-81C1-4AA6-B366-AF6D0A2B81F6} = {E92DB6FF-5501-4FC0-81D2-00DB8EFA2434} + {B4823266-DA8C-1D56-22DF-C7AC8C234EAC} = {E92DB6FF-5501-4FC0-81D2-00DB8EFA2434} {160DEDA5-C1AA-48C7-8B07-490C6A8DE2EE} = {89C76F13-4572-4A6D-9F6B-9ED4D0809B64} {01818D2C-AAAA-DD23-00AA-5678401C6461} = {89C76F13-4572-4A6D-9F6B-9ED4D0809B64} {51A96255-7EAB-4F36-A6E5-1BAF6245FA18} = {89C76F13-4572-4A6D-9F6B-9ED4D0809B64} @@ -215,6 +230,7 @@ Global {CB863607-6B6C-0000-0000-123400001234} = {EFB1BE3C-2981-456B-8E32-928CBDFF7822} {B4823266-DF8C-ABCD-1234-C7688C234EAC} = {EFB1BE3C-2981-456B-8E32-928CBDFF7822} {53FC9752-81C1-4AA6-B366-A7890A2B81F6} = {EFB1BE3C-2981-456B-8E32-928CBDFF7822} + {B4823244-DA8C-4467-DE34-AF158C234EAC} = {EFB1BE3C-2981-456B-8E32-928CBDFF7822} {A7E49FB8-700A-45EC-9174-FB1C2C7E83C9} = {162715BD-4DB3-4007-8B50-725C0BD11878} {82BC36B1-9F7A-41D4-A24F-DBE012378CE6} = {162715BD-4DB3-4007-8B50-725C0BD11878} {82BC36B1-DDDD-41D4-ABCD-A12312378CE6} = {162715BD-4DB3-4007-8B50-725C0BD11878} @@ -225,6 +241,7 @@ Global {B4823266-DF8C-A169-F6A1-C7656C234EAC} = {9645A3AF-CEAB-4A7E-92AB-BF3420E655FF} {CB863607-6B6C-FF53-DF34-12AA00001234} = {9645A3AF-CEAB-4A7E-92AB-BF3420E655FF} {B4823266-DF8C-ABC1-DF8C-12688C234EAC} = {9645A3AF-CEAB-4A7E-92AB-BF3420E655FF} + {B4823266-DA8C-D567-A85C-12634C234EAC} = {9645A3AF-CEAB-4A7E-92AB-BF3420E655FF} EndGlobalSection GlobalSection(DevPartner Solution Properties) = postSolution EndGlobalSection diff --git a/mak.vc9/cdluagl3.vcproj b/mak.vc9/cdluagl3.vcproj new file mode 100644 index 0000000..7b74b72 --- /dev/null +++ b/mak.vc9/cdluagl3.vcproj @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9,00" + Name="cdluagl3" + ProjectGUID="{B4823266-DA8C-1D56-22DF-C7AC8C234EAC}" + TargetFrameworkVersion="0" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="..\lib" + IntermediateDirectory="..\obj\Debug\$(ProjectName)" + ConfigurationType="4" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\include;..\..\lua\include" + PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS,CD_NO_OLD_INTERFACE,_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="1" + PrecompiledHeaderFile="" + AssemblerListingLocation="" + ObjectFile="$(IntDir)\" + ProgramDataBaseFileName="$(IntDir)\vc90.pdb" + WarningLevel="4" + SuppressStartupBanner="true" + DebugInformationFormat="1" + CompileAs="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)/$(ProjectName).lib" + SuppressStartupBanner="true" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath="..\src\lua3\cdluagl.c" + > + </File> + <File + RelativePath="..\src\lua3\cdluagl.def" + > + </File> + <File + RelativePath="..\include\cdluagl.h" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/mak.vc9/cdluagl51.vcproj b/mak.vc9/cdluagl51.vcproj new file mode 100644 index 0000000..a61f83a --- /dev/null +++ b/mak.vc9/cdluagl51.vcproj @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9,00" + Name="cdluagl51" + ProjectGUID="{B4823244-DA8C-4467-DE34-AF158C234EAC}" + TargetFrameworkVersion="0" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="..\lib" + IntermediateDirectory="..\obj\Debug\$(ProjectName)" + ConfigurationType="4" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\include;..\..\lua5.1\include" + PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS,CD_NO_OLD_INTERFACE,_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="1" + PrecompiledHeaderFile="" + AssemblerListingLocation="" + ObjectFile="$(IntDir)\" + ProgramDataBaseFileName="$(IntDir)\vc90.pdb" + WarningLevel="4" + SuppressStartupBanner="true" + DebugInformationFormat="1" + CompileAs="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)/$(ProjectName).lib" + SuppressStartupBanner="true" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath="..\include\cdluagl.h" + > + </File> + <File + RelativePath="..\src\lua5\cdluagl5.c" + > + </File> + <File + RelativePath="..\src\lua5\cdluagl5.def" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/mak.vc9/cdluagl52.vcproj b/mak.vc9/cdluagl52.vcproj new file mode 100644 index 0000000..f044110 --- /dev/null +++ b/mak.vc9/cdluagl52.vcproj @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9,00" + Name="cdluagl52" + ProjectGUID="{B4823266-DA8C-D567-A85C-12634C234EAC}" + TargetFrameworkVersion="0" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="..\lib" + IntermediateDirectory="..\obj\Debug\$(ProjectName)" + ConfigurationType="4" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\include;..\..\lua52\include" + PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS,CD_NO_OLD_INTERFACE,_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="1" + PrecompiledHeaderFile="" + AssemblerListingLocation="" + ObjectFile="$(IntDir)\" + ProgramDataBaseFileName="$(IntDir)\vc90.pdb" + WarningLevel="4" + SuppressStartupBanner="true" + DebugInformationFormat="1" + CompileAs="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)/$(ProjectName).lib" + SuppressStartupBanner="true" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath="..\include\cdluagl.h" + > + </File> + <File + RelativePath="..\src\lua5\cdluagl5.c" + > + </File> + <File + RelativePath="..\src\lua5\cdluagl5.def" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/mak.vc9/cdsimple.vcproj b/mak.vc9/cdsimple.vcproj index e5746d6..7115e88 100644 --- a/mak.vc9/cdsimple.vcproj +++ b/mak.vc9/cdsimple.vcproj @@ -44,7 +44,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\include,..\..\iup\include" - PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;__CD__;simple;_CRT_SECURE_NO_DEPRECATE;USE_CONTEXTPLUS;USE_OPENGL" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;__CD__;simple;_CRT_SECURE_NO_DEPRECATE;USE_CONTEXTPLUS;USE_OPENGL;CD_NO_OLD_INTERFACE" BasicRuntimeChecks="3" RuntimeLibrary="1" PrecompiledHeaderFile=".\..\obj\cdsimple/cdsimple.pch" @@ -70,7 +70,7 @@ <Tool Name="VCLinkerTool" AdditionalOptions="/MACHINE:I386" - AdditionalDependencies="freetype6.lib cd.lib iupcd.lib iup.lib comctl32.lib cdcontextplus.lib gdiplus.lib cdpdf.lib pdflib.lib iupcontrols.lib iupgl.lib opengl32.lib glu32.lib cdgl.lib ftgl.lib" + AdditionalDependencies="freetype6.lib cd.lib iupcd.lib iup.lib comctl32.lib cdcontextplus.lib gdiplus.lib cdpdf.lib pdflib.lib iupcontrols.lib iupgl.lib glu32.lib opengl32.lib cdgl.lib ftgl.lib" OutputFile="$(OutDir)\$(ProjectName).exe" LinkIncremental="1" SuppressStartupBanner="true" diff --git a/src/cdluagl3.mak b/src/cdluagl3.mak new file mode 100644 index 0000000..e655afd --- /dev/null +++ b/src/cdluagl3.mak @@ -0,0 +1,15 @@ +PROJNAME = cd +LIBNAME = cdluagl3 + +OPT = YES + +DEF_FILE = cdluagl.def +SRCDIR = lua3 +SRC = cdluagl.c +DEF_FILE = cdluagl.def + +INCLUDES = ../include +LIBS = cdlua3 cdgl +LDIR = ../lib/$(TEC_UNAME) + +USE_LUA = YES diff --git a/src/cdluagl5.mak b/src/cdluagl5.mak new file mode 100644 index 0000000..a9077bc --- /dev/null +++ b/src/cdluagl5.mak @@ -0,0 +1,23 @@ +PROJNAME = cd +LIBNAME = cdluagl + +OPT = YES + +DEFINES = CD_NO_OLD_INTERFACE +SRCDIR = lua5 +SRC = cdluagl5.c +DEF_FILE = cdluagl5.def + +LIBS = cdgl + +ifdef USE_LUA52 + LIBNAME := $(LIBNAME)52 +else + USE_LUA51 = Yes + LIBNAME := $(LIBNAME)51 +endif + +NO_LUALINK = Yes +USE_CD = YES +USE_CDLUA = YES +CD = .. diff --git a/src/drv/cdgl.c b/src/drv/cdgl.c index c8f818a..2934684 100644 --- a/src/drv/cdgl.c +++ b/src/drv/cdgl.c @@ -16,7 +16,6 @@ #endif #include <GL/gl.h> -#include <GL/glu.h> #include <FTGL/ftgl.h> @@ -80,16 +79,21 @@ static char* cdglStrConvertToUTF8(cdCtxCanvas *ctxcanvas, const char* str, unsig #ifdef WIN32 { wchar_t* toUnicode; + int wlen = MultiByteToWideChar(CP_ACP, 0, str, len, NULL, 0); + if(!wlen) + return (char*)str; - toUnicode = (wchar_t*)malloc((len+1) * sizeof(wchar_t)); - MultiByteToWideChar(CP_ACP, 0, str, len+1, toUnicode, (len+1)); + toUnicode = (wchar_t*)calloc((wlen+1), sizeof(wchar_t)); + MultiByteToWideChar(CP_ACP, 0, str, len, toUnicode, wlen); + toUnicode[wlen] = 0; - len = WideCharToMultiByte(CP_UTF8, 0, toUnicode, -1, NULL, 0, NULL, NULL); + len = WideCharToMultiByte(CP_UTF8, 0, toUnicode, wlen, NULL, 0, NULL, NULL); if(!len) return (char*)str; - ctxcanvas->glLastConvertUTF8 = (char*)malloc(len * sizeof(char)); - WideCharToMultiByte(CP_UTF8, 0, toUnicode, -1, ctxcanvas->glLastConvertUTF8, len, NULL, NULL); + ctxcanvas->glLastConvertUTF8 = (char*)calloc((len+1), sizeof(char)); + WideCharToMultiByte(CP_UTF8, 0, toUnicode, wlen, ctxcanvas->glLastConvertUTF8, len, NULL, NULL); + ctxcanvas->glLastConvertUTF8[len] = 0; free(toUnicode); } @@ -184,24 +188,22 @@ static void cdcliparea(cdCtxCanvas *ctxcanvas, int xmin, int xmax, int ymin, int static int cdwritemode(cdCtxCanvas *ctxcanvas, int write_mode) { - if(glIsEnabled(GL_COLOR_LOGIC_OP)) - glDisable(GL_COLOR_LOGIC_OP); - switch (write_mode) { case CD_REPLACE: - glLogicOp(GL_COPY); + if(glIsEnabled(GL_COLOR_LOGIC_OP)) + glDisable(GL_COLOR_LOGIC_OP); break; case CD_XOR: + glEnable(GL_COLOR_LOGIC_OP); glLogicOp(GL_XOR); break; case CD_NOT_XOR: + glEnable(GL_COLOR_LOGIC_OP); glLogicOp(GL_EQUIV); break; } - glEnable(GL_COLOR_LOGIC_OP); - (void)ctxcanvas; return write_mode; } @@ -228,36 +230,6 @@ static int cdhatch(cdCtxCanvas *ctxcanvas, int hatch_style) return hatch_style; } -static void cdglEnableBackOpacity(cdCtxCanvas* ctxcanvas) -{ - if (ctxcanvas->canvas->back_opacity == CD_OPAQUE) - { - glColor4ub(cdRed(ctxcanvas->canvas->foreground), - cdGreen(ctxcanvas->canvas->foreground), - cdBlue(ctxcanvas->canvas->foreground), 255); - - glDepthMask(GL_TRUE); - - if(glIsEnabled(GL_DEPTH_TEST)) - glDisable(GL_DEPTH_TEST); - - if(glIsEnabled(GL_BLEND)) - glDisable(GL_BLEND); - } - else - { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glEnable(GL_DEPTH_TEST); - glDepthMask(GL_FALSE); - - glColor4ub(cdRed(ctxcanvas->canvas->foreground), - cdGreen(ctxcanvas->canvas->foreground), - cdBlue(ctxcanvas->canvas->foreground), 0); - } -} - static int cdinteriorstyle(cdCtxCanvas *ctxcanvas, int style) { switch (style) @@ -275,18 +247,16 @@ static int cdinteriorstyle(cdCtxCanvas *ctxcanvas, int style) switch (style) { + case CD_STIPPLE: + case CD_PATTERN: case CD_HOLLOW: case CD_SOLID: if(glIsEnabled(GL_POLYGON_STIPPLE)) glDisable(GL_POLYGON_STIPPLE); break; case CD_HATCH: - cdglEnableBackOpacity(ctxcanvas); cdhatch(ctxcanvas, ctxcanvas->canvas->hatch_style); break; - case CD_STIPPLE: - case CD_PATTERN: - break; } return style; @@ -307,7 +277,6 @@ static int cdlinestyle(cdCtxCanvas *ctxcanvas, int style) case CD_DASH_DOT_DOT: case CD_CUSTOM: glEnable(GL_LINE_STIPPLE); - cdglEnableBackOpacity(ctxcanvas); break; } @@ -326,7 +295,7 @@ static int cdlinestyle(cdCtxCanvas *ctxcanvas, int style) glLineStipple(1, 0x333F); break; case CD_CUSTOM: - /* style patterns more than 16 bits are not completely drawed */ + /* style patterns more than 16 bits are not drawn completely */ glLineStipple(1, (GLushort)*ctxcanvas->canvas->line_dashes); break; } @@ -591,12 +560,8 @@ static long int cdforeground(cdCtxCanvas *ctxcanvas, long int color) unsigned char r, g, b; (void)ctxcanvas; - //TODO - if(glIsEnabled(GL_POLYGON_STIPPLE)) - glDisable(GL_POLYGON_STIPPLE); - cdDecodeColor(color, &r, &g, &b); - glColor3ub(r, g, b); + glColor4ub(r, g, b, cdDecodeAlpha(color)); return color; } @@ -643,6 +608,23 @@ static void cdrect(cdCtxCanvas *ctxcanvas, int xmin, int xmax, int ymin, int yma static void cdfbox(cdCtxCanvas *ctxcanvas, double xmin, double xmax, double ymin, double ymax) { + if(ctxcanvas->canvas->back_opacity == CD_OPAQUE && glIsEnabled(GL_POLYGON_STIPPLE)) + { + /* draw twice, one with background color only, and one with foreground color */ + glDisable(GL_POLYGON_STIPPLE); + glColor4ub(cdRed(ctxcanvas->canvas->background), cdGreen(ctxcanvas->canvas->background), cdBlue(ctxcanvas->canvas->background), cdAlpha(ctxcanvas->canvas->background)); + + glBegin(GL_QUADS); + glVertex2d(xmin, ymin); + glVertex2d(xmax, ymin); + glVertex2d(xmax, ymax); + glVertex2d(xmin, ymax); + glEnd(); + + glColor4ub(cdRed(ctxcanvas->canvas->foreground), cdGreen(ctxcanvas->canvas->foreground), cdBlue(ctxcanvas->canvas->foreground), cdAlpha(ctxcanvas->canvas->foreground)); + glEnable(GL_POLYGON_STIPPLE); + } + glBegin(GL_QUADS); glVertex2d(xmin, ymin); glVertex2d(xmax, ymin); @@ -660,7 +642,7 @@ static void cdbox(cdCtxCanvas *ctxcanvas, int xmin, int xmax, int ymin, int ymax static void cdftext(cdCtxCanvas *ctxcanvas, double x, double y, const char *s, int len) { - int dir = -1; + int dir = -1, stipple = 0; float bounds[6]; int w, h, desc; double x_origin = x; @@ -733,20 +715,20 @@ static void cdftext(cdCtxCanvas *ctxcanvas, double x, double y, const char *s, i cdfRotatePoint(ctxcanvas->canvas, x, y, x_origin, y_origin, &x, &y, sin_angle, cos_angle); } + if(glIsEnabled(GL_POLYGON_STIPPLE)) + { + stipple = 1; + glDisable(GL_POLYGON_STIPPLE); + } + glPushMatrix(); glTranslated(x, y, 0.0); glRotated(ctxcanvas->canvas->text_orientation, 0, 0, 1); - - /* FTGL not operate as expected when a logical pixel operation (write mode) is enabled. */ - if(glIsEnabled(GL_COLOR_LOGIC_OP)) - { - glDisable(GL_COLOR_LOGIC_OP); - ftglRenderFont(ctxcanvas->font, s, FTGL_RENDER_ALL); - glEnable(GL_COLOR_LOGIC_OP); - } - else - ftglRenderFont(ctxcanvas->font, s, FTGL_RENDER_ALL); + ftglRenderFont(ctxcanvas->font, s, FTGL_RENDER_ALL); glPopMatrix(); + + if(stipple) + glEnable(GL_POLYGON_STIPPLE); } static void cdtext(cdCtxCanvas *ctxcanvas, int x, int y, const char *s, int len) @@ -793,6 +775,7 @@ static void cdpoly(cdCtxCanvas *ctxcanvas, int mode, cdPoint* poly, int n) glEvalMesh1(GL_LINE, 0, prec); glDisable(GL_MAP1_VERTEX_3); + free(points); return; } @@ -811,6 +794,21 @@ static void cdpoly(cdCtxCanvas *ctxcanvas, int mode, cdPoint* poly, int n) glBegin(GL_LINE_STRIP); break; case CD_FILL : + if(ctxcanvas->canvas->back_opacity == CD_OPAQUE && glIsEnabled(GL_POLYGON_STIPPLE)) + { + /* draw twice, one with background color only, and one with foreground color */ + glDisable(GL_POLYGON_STIPPLE); + glColor4ub(cdRed(ctxcanvas->canvas->background), cdGreen(ctxcanvas->canvas->background), cdBlue(ctxcanvas->canvas->background), cdAlpha(ctxcanvas->canvas->background)); + + glBegin(GL_POLYGON); + for(i = 0; i < n; i++) + glVertex2i(poly[i].x, poly[i].y); + glEnd(); + + glColor4ub(cdRed(ctxcanvas->canvas->foreground), cdGreen(ctxcanvas->canvas->foreground), cdBlue(ctxcanvas->canvas->foreground), cdAlpha(ctxcanvas->canvas->foreground)); + glEnable(GL_POLYGON_STIPPLE); + } + glBegin(GL_POLYGON); break; } @@ -847,6 +845,7 @@ static void cdfpoly(cdCtxCanvas *ctxcanvas, int mode, cdfPoint* poly, int n) glEvalMesh1(GL_LINE, 0, prec); glDisable(GL_MAP1_VERTEX_3); + free(points); return; } @@ -865,6 +864,20 @@ static void cdfpoly(cdCtxCanvas *ctxcanvas, int mode, cdfPoint* poly, int n) glBegin(GL_LINE_STRIP); break; case CD_FILL : + if(ctxcanvas->canvas->back_opacity == CD_OPAQUE && glIsEnabled(GL_POLYGON_STIPPLE)) + { + glDisable(GL_POLYGON_STIPPLE); + glColor4ub(cdRed(ctxcanvas->canvas->background), cdGreen(ctxcanvas->canvas->background), cdBlue(ctxcanvas->canvas->background), cdAlpha(ctxcanvas->canvas->background)); + + glBegin(GL_POLYGON); + for(i = 0; i < n; i++) + glVertex2d(poly[i].x, poly[i].y); + glEnd(); + + glColor4ub(cdRed(ctxcanvas->canvas->foreground), cdGreen(ctxcanvas->canvas->foreground), cdBlue(ctxcanvas->canvas->foreground), cdAlpha(ctxcanvas->canvas->foreground)); + glEnable(GL_POLYGON_STIPPLE); + } + glBegin(GL_POLYGON); break; } @@ -1022,6 +1035,7 @@ static void cdputimagerectrgb(cdCtxCanvas *ctxcanvas, int iw, int ih, const unsi static void cdputimagerectrgba(cdCtxCanvas *ctxcanvas, int iw, int ih, const unsigned char *r, const unsigned char *g, const unsigned char *b, const unsigned char *a, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax) { /* Images are bitmaps, and cannot be directly rotated or scaled */ + int blend = 1; GLubyte* glImage; int rw = xmax-xmin+1; int rh = ymax-ymin+1; @@ -1048,21 +1062,18 @@ static void cdputimagerectrgba(cdCtxCanvas *ctxcanvas, int iw, int ih, const uns if (w != rw || h != rh) glPixelZoom((GLfloat)w/rw, (GLfloat)h/rh); - glEnable(GL_BLEND); + if (!glIsEnabled(GL_BLEND)) + { + blend = 0; + glEnable(GL_BLEND); + } glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glRasterPos2i(x, y); + glDrawPixels(rw, rh, GL_RGBA, GL_UNSIGNED_BYTE, glImage); - if(glIsEnabled(GL_COLOR_LOGIC_OP)) - { - glDisable(GL_COLOR_LOGIC_OP); - glDrawPixels(rw, rh, GL_RGBA, GL_UNSIGNED_BYTE, glImage); - glEnable(GL_COLOR_LOGIC_OP); - } - else - glDrawPixels(rw, rh, GL_RGBA, GL_UNSIGNED_BYTE, glImage); - - glDisable(GL_BLEND); + if (!blend) + glDisable(GL_BLEND); (void)ih; (void)ctxcanvas; @@ -1110,7 +1121,7 @@ static void cdputimagerectmap(cdCtxCanvas *ctxcanvas, int iw, int ih, const unsi static void cdpixel(cdCtxCanvas *ctxcanvas, int x, int y, long int color) { - glColor3ub(cdRed(color), cdGreen(color), cdBlue(color)); + glColor4ub(cdRed(color), cdGreen(color), cdBlue(color), cdAlpha(color)); /* Draw pixel */ glPointSize(1); @@ -1119,7 +1130,7 @@ static void cdpixel(cdCtxCanvas *ctxcanvas, int x, int y, long int color) glEnd(); /* restore the foreground color */ - glColor3ub(cdRed(ctxcanvas->canvas->foreground), cdGreen(ctxcanvas->canvas->foreground), cdBlue(ctxcanvas->canvas->foreground)); + glColor4ub(cdRed(ctxcanvas->canvas->foreground), cdGreen(ctxcanvas->canvas->foreground), cdBlue(ctxcanvas->canvas->foreground), cdAlpha(ctxcanvas->canvas->foreground)); (void)ctxcanvas; } @@ -1188,11 +1199,83 @@ static void cdtransform(cdCtxCanvas *ctxcanvas, const double* matrix) glLoadIdentity(); glMultMatrixd(&transformMTX[0][0]); } + else + glLoadIdentity(); (void)ctxcanvas; } /******************************************************************/ +static void set_alpha_attrib(cdCtxCanvas* ctxcanvas, char* data) +{ + if (!data || data[0] == '0') + { + glDisable(GL_BLEND); + } + else + { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + + (void)ctxcanvas; +} + +static char* get_alpha_attrib(cdCtxCanvas* ctxcanvas) +{ + (void)ctxcanvas; + + if (glIsEnabled(GL_BLEND)) + return "1"; + else + return "0"; +} + +static cdAttribute alpha_attrib = +{ + "ALPHA", + set_alpha_attrib, + get_alpha_attrib +}; + +static void set_aa_attrib(cdCtxCanvas* ctxcanvas, char* data) +{ + if (!data || data[0] == '0') + { + glDisable(GL_POINT_SMOOTH); + glDisable(GL_LINE_SMOOTH); + glDisable(GL_POLYGON_SMOOTH); + } + else + { + glEnable(GL_POINT_SMOOTH); + glEnable(GL_LINE_SMOOTH); + glEnable(GL_POLYGON_SMOOTH); + + glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); + glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); + glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); + } + + (void)ctxcanvas; +} + +static char* get_aa_attrib(cdCtxCanvas* ctxcanvas) +{ + (void)ctxcanvas; + + if (glIsEnabled(GL_LINE_SMOOTH)) + return "1"; + else + return "0"; +} + +static cdAttribute aa_attrib = +{ + "ANTIALIAS", + set_aa_attrib, + get_aa_attrib +}; static void set_poly_attrib(cdCtxCanvas *ctxcanvas, char* data) { @@ -1329,6 +1412,11 @@ static void cdcreatecanvas(cdCanvas* canvas, void *data) cdRegisterAttribute(canvas, &version_attrib); cdRegisterAttribute(canvas, &poly_attrib); cdRegisterAttribute(canvas, &size_attrib); + cdRegisterAttribute(canvas, &alpha_attrib); + cdRegisterAttribute(canvas, &aa_attrib); + + cdCanvasSetAttribute(canvas, "ALPHA", "1"); + cdCanvasSetAttribute(canvas, "ANTIALIAS", "1"); } static void cdinittable(cdCanvas* canvas) diff --git a/src/lua3/cdluagl.c b/src/lua3/cdluagl.c new file mode 100644 index 0000000..408eadb --- /dev/null +++ b/src/lua3/cdluagl.c @@ -0,0 +1,43 @@ +/** \file + * \brief GL Canvas Lua 3 Binding + * + * See Copyright Notice in cd.h + */ + +#include <stdlib.h> +#include <stdio.h> + +#include "cd.h" +#include "cdgl.h" + +#include <lua.h> +#include <lauxlib.h> + +#include "cdlua.h" +#include "cdluagl.h" +#include "cdlua3_private.h" + +static void *cdgl_checkdata(int param) +{ + lua_Object data = lua_getparam(param); + if (!lua_isstring(data)) + lua_error("cdCreateCanvas CD_GL: data should be of type string!"); + + return lua_getstring(data); +} + +static cdContextLUA cdluaglctx = +{ + 0, + "CD_GL", + cdContextGL, + cdgl_checkdata, + NULL, + 0 +}; + +void cdluagl_open(void) +{ + cdlua_addcontext(&cdluaglctx); +} + diff --git a/src/lua3/cdluagl.def b/src/lua3/cdluagl.def new file mode 100644 index 0000000..85639b9 --- /dev/null +++ b/src/lua3/cdluagl.def @@ -0,0 +1,2 @@ +EXPORTS + cdluagl_open
\ No newline at end of file diff --git a/src/lua5/cdluagl5.c b/src/lua5/cdluagl5.c new file mode 100644 index 0000000..ad81730 --- /dev/null +++ b/src/lua5/cdluagl5.c @@ -0,0 +1,53 @@ +/** \file + * \brief OpenGL Canvas Lua 5 Binding + * + * See Copyright Notice in cd.h + */ + +#include <stdlib.h> +#include <stdio.h> + +#include "cd.h" +#include "cdgl.h" + +#include <lua.h> +#include <lauxlib.h> + +#include "cdlua.h" +#include "cdluagl.h" +#include "cdlua5_private.h" + + +static void *cdgl_checkdata(lua_State *L, int param) +{ + return (void *)luaL_checkstring(L, param); +} + +static cdluaContext cdluaglctx = +{ + 0, + "GL", + cdContextGL, + cdgl_checkdata, + NULL, + 0 +}; + +int cdluagl_open (lua_State *L) +{ + cdluaLuaState* cdL = cdlua_getstate(L); + lua_pushliteral(L, "cd"); +#if LUA_VERSION_NUM > 501 + lua_pushglobaltable(L); +#else + lua_gettable(L, LUA_GLOBALSINDEX); /* leave "cd" table at the top of the stack */ +#endif + cdlua_addcontext(L, cdL, &cdluaglctx); + return 1; +} + +int luaopen_cdluagl(lua_State* L) +{ + return cdluagl_open(L); +} + diff --git a/src/lua5/cdluagl5.def b/src/lua5/cdluagl5.def new file mode 100644 index 0000000..80e1e2d --- /dev/null +++ b/src/lua5/cdluagl5.def @@ -0,0 +1,3 @@ +EXPORTS + cdluagl_open + luaopen_cdluagl diff --git a/src/sim/sim_primitives.c b/src/sim/sim_primitives.c index 29fc6af..2040c66 100644 --- a/src/sim/sim_primitives.c +++ b/src/sim/sim_primitives.c @@ -381,7 +381,7 @@ void cdSimChord(cdCtxCanvas* ctxcanvas, int xc, int yc, int width, int height, d void cdfSimSector(cdCtxCanvas *ctxcanvas, double xc, double yc, double w, double h, double a1, double a2) { - sfElipse(ctxcanvas, xc, yc, w, h, a1, a2, 0); + sfElipse(ctxcanvas, xc, yc, w, h, a1, a2, 1); } void cdfSimChord(cdCtxCanvas *ctxcanvas, double xc, double yc, double w, double h, double a1, double a2) diff --git a/test/simple/iupmain.c b/test/simple/iupmain.c index df081e3..de01979 100644 --- a/test/simple/iupmain.c +++ b/test/simple/iupmain.c @@ -23,13 +23,15 @@ int cmdExit(void) void simple_loadled (void); +#ifdef USE_OPENGL /* USE_OPENGL - add to linker: -iupgl -opengl32 -glu32 cdgl +iupgl ftgl +glu32 +opengl32 */ + void SimpleUpdateSize(cdCanvas* cnv) { Ihandle* canvas = IupGetHandle("SimpleCanvas"); @@ -52,6 +54,11 @@ void SimpleUpdateSize(cdCanvas* cnv) } } +void SimpleFlush(void) +{ + IupGLSwapBuffers(IupGetHandle("SimpleCanvas")); +} +#endif int main(int argc, char** argv) { @@ -126,12 +133,12 @@ int main(int argc, char** argv) IupSetFunction("SimpleContextPlus", (Icallback) SimpleContextPlus); IupSetFunction("SimpleTransform", (Icallback) SimpleTransform); - IupSetFunction("SimpleDrawAll", (Icallback) SimpleDrawAll); - IupSetFunction("SimpleDrawTextAlign", (Icallback) SimpleDrawTextAlign); - IupSetFunction("SimpleDrawTextFonts", (Icallback) SimpleDrawTextFonts); - IupSetFunction("SimpleDrawTest", (Icallback) SimpleDrawTest); + IupSetFunction("SimpleAll", (Icallback) SimpleAll); + IupSetFunction("SimpleTextAlign", (Icallback) SimpleTextAlign); + IupSetFunction("SimpleTextFonts", (Icallback) SimpleTextFonts); + IupSetFunction("SimpleTest", (Icallback) SimpleTest); - IupSetFunction("SimpleRepaint", (Icallback) SimpleDrawRepaint); + IupSetFunction("SimpleRepaint", (Icallback) SimpleRepaint); SimpleDrawWindow(); diff --git a/test/simple/simple.c b/test/simple/simple.c index 76676fd..e9e3429 100644 --- a/test/simple/simple.c +++ b/test/simple/simple.c @@ -67,7 +67,7 @@ unsigned char alpha[IMAGE_SIZE*IMAGE_SIZE]; /* Alpha image buffer */ /* Prototype of the function that makes the drawing independent of canvas. */ -void SimpleDraw(void); +void SimpleDraw(cdCanvas* canvas); void SimpleInitAlpha(int width, int height, unsigned char* _alpha) { @@ -146,7 +146,7 @@ void SimpleCreateCanvas(char* data) int SimpleTransform(void) { use_transform = !use_transform; - SimpleDrawRepaint(); + SimpleDraw(curCanvas); return 0; } @@ -156,7 +156,7 @@ int SimpleContextPlus(void) contextplus = !contextplus; SimpleKillCanvas(); SimpleCreateCanvasWindow(); - SimpleDrawRepaint(); + SimpleDraw(curCanvas); #endif return 0; } @@ -164,12 +164,12 @@ int SimpleContextPlus(void) void PlayCanvasDriver(cdContext* ctx, char* StrData) { int w, h; - cdActivate(curCanvas); - cdBackground(CD_WHITE); - cdClear(); - cdGetCanvasSize(&w, &h, 0, 0); - cdPlay(ctx, 100, w-100, 100, h-100, StrData); -// cdPlay(ctx, 0, 0, 0, 0, StrData); + cdCanvasActivate(curCanvas); + cdCanvasBackground(curCanvas, CD_WHITE); + cdCanvasClear(curCanvas); + cdCanvasGetSize(curCanvas, &w, &h, 0, 0); + cdCanvasPlay(curCanvas, ctx, 100, w-100, 100, h-100, StrData); +// cdCanvasPlay(curCanvas, ctx, 0, 0, 0, 0, StrData); } int SimplePlayClipboard(void) @@ -208,18 +208,18 @@ int SimplePlayEMF(void) return 0; } -int SimpleDrawRepaint(void) +int SimpleRepaint(void) { - cdActivate(curCanvas); - SimpleDraw(); - cdFlush(); + SimpleDraw(curCanvas); return 0; } int SimpleDrawWindow(void) { + use_opengl = 0; curCanvas = winCanvas; - return SimpleDrawRepaint(); + SimpleDraw(curCanvas); + return 0; } void DrawCanvasDriver(cdContext* ctx, char* StrData) @@ -231,12 +231,9 @@ void DrawCanvasDriver(cdContext* ctx, char* StrData) return; } printf("CreateCanvas(%s)\n", StrData); - cdActivate(tmpCanvas); - SimpleDraw(); + SimpleDraw(tmpCanvas); cdKillCanvas(tmpCanvas); printf("KillCanvas()\n"); - - cdActivate(curCanvas); } void DrawCanvasDriverSize(cdContext* ctx, char* name, int pixels) @@ -244,8 +241,7 @@ void DrawCanvasDriverSize(cdContext* ctx, char* name, int pixels) char StrData[100]; int w, h; double w_mm, h_mm; - cdActivate(curCanvas); - cdGetCanvasSize(&w, &h, &w_mm, &h_mm); + cdCanvasGetSize(curCanvas, &w, &h, &w_mm, &h_mm); if (pixels == 1) sprintf(StrData, "%s %dx%d", name, w, h); else if (pixels == 2) @@ -259,8 +255,7 @@ void DrawCanvasDriverSizeParam(cdContext* ctx, char* param) { char StrData[100]; int w, h; - cdActivate(curCanvas); - cdGetCanvasSize(&w, &h, 0, 0); + cdCanvasGetSize(curCanvas, &w, &h, 0, 0); sprintf(StrData, "%dx%d %s", w, h, param); DrawCanvasDriver(ctx, StrData); } @@ -382,56 +377,77 @@ int SimpleDrawClipboardEMF(void) int SimpleReplace(void) { write_mode = CD_REPLACE; - cdActivate(curCanvas); - SimpleDrawAll(); + SimpleDraw(curCanvas); return 0; } int SimpleXor(void) { write_mode = CD_XOR; - cdActivate(curCanvas); - SimpleDrawAll(); + SimpleDraw(curCanvas); return 0; } int SimpleNotXor(void) { write_mode = CD_NOT_XOR; - cdActivate(curCanvas); - SimpleDrawAll(); + SimpleDraw(curCanvas); return 0; } int SimpleClippingOff(void) { clipping = CD_CLIPOFF; - cdActivate(curCanvas); - SimpleDrawAll(); + SimpleDraw(curCanvas); return 0; } int SimpleClippingArea(void) { clipping = CD_CLIPAREA; - cdActivate(curCanvas); - SimpleDrawAll(); + SimpleDraw(curCanvas); return 0; } int SimpleClippingPolygon(void) { clipping = CD_CLIPPOLYGON; - cdActivate(curCanvas); - SimpleDrawAll(); + SimpleDraw(curCanvas); return 0; } int SimpleClippingRegion(void) { clipping = CD_CLIPREGION; - cdActivate(curCanvas); - SimpleDrawAll(); + SimpleDraw(curCanvas); + return 0; +} + +int SimpleAll(void) +{ + simple_draw = DRAW_ALL; + SimpleDraw(curCanvas); + return 0; +} + +int SimpleTextAlign(void) +{ + simple_draw = DRAW_TEXTALIGN; + SimpleDraw(curCanvas); + return 0; +} + +int SimpleTextFonts(void) +{ + simple_draw = DRAW_TEXTFONTS; + SimpleDraw(curCanvas); + return 0; +} + +int SimpleTest(void) +{ + simple_draw = DRAW_TEST; + SimpleDraw(curCanvas); return 0; } @@ -440,15 +456,16 @@ void* CreateImageRGBA(int w, int h) void* myImage; unsigned char * _alpha = malloc(w * h); SimpleInitAlpha(w, h, _alpha); - cdSetAttribute("IMAGEALPHA", (char*)_alpha); - cdSetAttribute("IMAGEFORMAT", "32"); // afetara´ o proximo cdCreateImage - myImage = cdCreateImage(w, h); - cdSetAttribute("IMAGEFORMAT", NULL); // remove o atributo para nao afetar outros cdCreateImage + cdCanvasSetAttribute(curCanvas, "IMAGEALPHA", (char*)_alpha); + cdCanvasSetAttribute(curCanvas, "IMAGEFORMAT", "32"); // afetara´ o proximo cdCreateImage + myImage = cdCanvasCreateImage(curCanvas, w, h); + cdCanvasSetAttribute(curCanvas, "IMAGEFORMAT", NULL); // remove o atributo para nao afetar outros cdCreateImage return myImage; } int SimpleDrawImage(void) { + use_opengl = 0; if (dbCanvas) cdKillCanvas(dbCanvas); if (contextplus) cdUseContextPlus(1); @@ -456,13 +473,14 @@ int SimpleDrawImage(void) if (contextplus) cdUseContextPlus(0); curCanvas = dbCanvas; - SimpleDrawRepaint(); + SimpleDraw(curCanvas); return 0; } int SimpleDrawImageRGB(void) { + use_opengl = 0; if (dbCanvas) cdKillCanvas(dbCanvas); if (contextplus) cdUseContextPlus(1); @@ -470,7 +488,7 @@ int SimpleDrawImageRGB(void) if (contextplus) cdUseContextPlus(0); curCanvas = dbCanvas; - SimpleDrawRepaint(); + SimpleDraw(curCanvas); return 0; } @@ -481,8 +499,11 @@ int SimpleDrawGL(void) char StrData[100]; int w, h; double w_mm, h_mm; - cdActivate(curCanvas); - cdGetCanvasSize(&w, &h, &w_mm, &h_mm); + + if (use_opengl) + return 0; + + cdCanvasGetSize(curCanvas, &w, &h, &w_mm, &h_mm); sprintf(StrData, "%dx%d %g", w, h, ((double)w/w_mm)); @@ -492,8 +513,7 @@ int SimpleDrawGL(void) curCanvas = dbCanvas; use_opengl = 1; - SimpleDrawRepaint(); - use_opengl = 0; + SimpleDraw(curCanvas); return 0; } @@ -501,16 +521,14 @@ int SimpleDrawGL(void) int SimpleDrawSimulate(void) { - cdActivate(curCanvas); - simulate = !simulate; if (simulate) - cdSimulate(CD_SIM_ALL); + cdCanvasSimulate(curCanvas, CD_SIM_ALL); else - cdSimulate(CD_SIM_NONE); + cdCanvasSimulate(curCanvas, CD_SIM_NONE); - SimpleDrawRepaint(); + SimpleDraw(curCanvas); return 0; } @@ -529,33 +547,40 @@ void SimpleKillCanvas(void) } } -void SimpleDraw(void) +void SimpleDrawTextFonts(cdCanvas* canvas); +void SimpleDrawTextAlign(cdCanvas* canvas); +void SimpleDrawAll(cdCanvas* canvas); +void SimpleDrawTest(cdCanvas* canvas); + +void SimpleDraw(cdCanvas* canvas) { +#ifdef USE_OPENGL + if (use_opengl) + SimpleUpdateSize(canvas); +#endif + if (simple_draw == DRAW_TEXTFONTS) - SimpleDrawTextFonts(); + SimpleDrawTextFonts(canvas); else if (simple_draw == DRAW_TEXTALIGN) - SimpleDrawTextAlign(); + SimpleDrawTextAlign(canvas); else if (simple_draw == DRAW_TEST) - SimpleDrawTest(); + SimpleDrawTest(canvas); else - SimpleDrawAll(); -} + SimpleDrawAll(canvas); -int SimpleDrawAll(void) -{ - cdCanvas* canvas = cdActiveCanvas(); - int w, h; + cdCanvasFlush(canvas); #ifdef USE_OPENGL if (use_opengl) - SimpleUpdateSize(canvas); + SimpleFlush(); #endif +} - +void SimpleDrawAll(cdCanvas* canvas) +{ + int w, h; cdCanvasGetSize(canvas, &w, &h, NULL, NULL); - simple_draw = DRAW_ALL; - /* Clear the background to be white */ cdCanvasBackground(canvas, CD_WHITE); // cdBackground(CD_GREEN); @@ -599,53 +624,53 @@ int SimpleDrawAll(void) switch(clipping) { case CD_CLIPOFF: - cdClip(CD_CLIPOFF); + cdCanvasClip(canvas, CD_CLIPOFF); break; case CD_CLIPAREA: /* Defines the clipping area equals the canvas area minus a 100 pixels margin. */ - cdClipArea(100, w - 100, 100, h - 100); - cdClip(CD_CLIPAREA); + cdCanvasClipArea(canvas, 100, w - 100, 100, h - 100); + cdCanvasClip(canvas, CD_CLIPAREA); break; case CD_CLIPPOLYGON: - cdBegin(CD_CLIP); - cdVertex(100, 100); - cdVertex(w - 100, 100); - cdVertex(w / 2, h - 100); - cdEnd(); - cdClip(CD_CLIPPOLYGON); + cdCanvasBegin(canvas, CD_CLIP); + cdCanvasVertex(canvas, 100, 100); + cdCanvasVertex(canvas, w - 100, 100); + cdCanvasVertex(canvas, w / 2, h - 100); + cdCanvasEnd(canvas); + cdCanvasClip(canvas, CD_CLIPPOLYGON); break; case CD_CLIPREGION: - cdTextAlignment(CD_CENTER); - cdFont(CD_TIMES_ROMAN, CD_BOLD, 50); - - cdBegin(CD_REGION); - cdRegionCombineMode(CD_UNION); - cdBox(100, 200, 100, 200); - cdSector(w/2-50, h/2+50, 150, 150, 0, 360); - cdSector(w/2-50, h/2-50, 150, 150, 0, 360); - cdSector(w/2+50, h/2+50, 150, 150, 0, 360); - cdSector(w/2+50, h/2-50, 150, 150, 0, 360); - cdRegionCombineMode(CD_DIFFERENCE); - cdText(w/2, h/2, "TEXT"); - cdEnd(); -// cdOffsetRegion(-50, 50); - cdClip(CD_CLIPREGION); - - cdForeground(CD_DARK_RED); - cdBox(0,w,0,h); + cdCanvasTextAlignment(canvas, CD_CENTER); + cdCanvasFont(canvas, "Times", CD_BOLD, 50); + + cdCanvasBegin(canvas, CD_REGION); + cdCanvasRegionCombineMode(canvas, CD_UNION); + cdCanvasBox(canvas, 100, 200, 100, 200); + cdCanvasSector(canvas, w/2-50, h/2+50, 150, 150, 0, 360); + cdCanvasSector(canvas, w/2-50, h/2-50, 150, 150, 0, 360); + cdCanvasSector(canvas, w/2+50, h/2+50, 150, 150, 0, 360); + cdCanvasSector(canvas, w/2+50, h/2-50, 150, 150, 0, 360); + cdCanvasRegionCombineMode(canvas, CD_DIFFERENCE); + cdCanvasText(canvas, w/2, h/2, "TEXT"); + cdCanvasEnd(canvas); +// cdCanvasOffsetRegion(canvas, -50, 50); + cdCanvasClip(canvas, CD_CLIPREGION); + + cdCanvasForeground(canvas, CD_DARK_RED); + cdCanvasBox(canvas, 0,w,0,h); break; } switch(write_mode) { case CD_REPLACE: - cdWriteMode(CD_REPLACE); + cdCanvasWriteMode(canvas, CD_REPLACE); break; case CD_XOR: - cdWriteMode(CD_XOR); + cdCanvasWriteMode(canvas, CD_XOR); break; case CD_NOT_XOR: - cdWriteMode(CD_NOT_XOR); + cdCanvasWriteMode(canvas, CD_NOT_XOR); break; } @@ -698,7 +723,7 @@ int SimpleDrawAll(void) } cdCanvasForeground(canvas, CD_BLUE); cdCanvasText(canvas, w/2, h/2, "cdMin Draw (çãí)"); -// cdTextOrientation(0); + cdCanvasTextOrientation(canvas, 0); /* Prepare World Coordinates */ wdCanvasViewport(canvas, 0,w-1,0,h-1); @@ -936,124 +961,122 @@ int SimpleDrawAll(void) /* Draw the image on the top-right corner but increasing its actual size, and uses its full area */ cdCanvasPutImageRectRGBA(canvas, IMAGE_SIZE, IMAGE_SIZE, red, green, blue, alpha, w - 400, h - 310, 3*IMAGE_SIZE, 3*IMAGE_SIZE, 0, 0, 0, 0); - cdSetAttribute("ROTATE", NULL); + cdCanvasSetAttribute(canvas, "ROTATE", NULL); if (use_transform) cdCanvasTransform(canvas, NULL); - cdClip(CD_CLIPOFF); + cdCanvasClip(canvas, CD_CLIPOFF); /* Adds a new page, or flushes the file, or flushes the screen, or swap the double buffer. */ cdCanvasFlush(canvas); - - return 0; } -void DrawVectorTextBox(int x, int y, char* text) +void DrawVectorTextBox(cdCanvas* canvas, int x, int y, char* text) { int rect[8], draw_box; - cdLineWidth(1); - cdLineStyle(CD_CONTINUOUS); + cdCanvasLineWidth(canvas, 1); + cdCanvasLineStyle(canvas, CD_CONTINUOUS); draw_box = 0; if (draw_box) { int xmin, xmax, ymin, ymax; - cdCanvasGetVectorTextBox(cdActiveCanvas(), x, y, text, &xmin, &xmax, &ymin, &ymax); - cdForeground(CD_GREEN); - cdRect(xmin, xmax, ymin, ymax); + cdCanvasGetVectorTextBox(canvas, x, y, text, &xmin, &xmax, &ymin, &ymax); + cdCanvasForeground(canvas, CD_GREEN); + cdCanvasRect(canvas, xmin, xmax, ymin, ymax); - if (cdTextOrientation(CD_QUERY) == 0) + if (cdCanvasTextOrientation(canvas, CD_QUERY) == 0) { - cdForeground(CD_RED); - cdLine(xmin, y, xmax, y); + cdCanvasForeground(canvas, CD_RED); + cdCanvasLine(canvas, xmin, y, xmax, y); } } else { /* bounding box */ - cdGetVectorTextBounds(text, x, y, rect); - cdForeground(CD_GREEN); - cdBegin(CD_CLOSED_LINES); - cdVertex(rect[0], rect[1]); - cdVertex(rect[2], rect[3]); - cdVertex(rect[4], rect[5]); - cdVertex(rect[6], rect[7]); - cdEnd(); + cdCanvasGetVectorTextBounds(canvas, text, x, y, rect); + cdCanvasForeground(canvas, CD_GREEN); + cdCanvasBegin(canvas, CD_CLOSED_LINES); + cdCanvasVertex(canvas, rect[0], rect[1]); + cdCanvasVertex(canvas, rect[2], rect[3]); + cdCanvasVertex(canvas, rect[4], rect[5]); + cdCanvasVertex(canvas, rect[6], rect[7]); + cdCanvasEnd(canvas); } /* reference point */ - cdForeground(CD_BLUE); - cdMarkType(CD_PLUS); - cdMarkSize(30); - cdMark(x, y); + cdCanvasForeground(canvas, CD_BLUE); + cdCanvasMarkType(canvas, CD_PLUS); + cdCanvasMarkSize(canvas, 30); + cdCanvasMark(canvas, x, y); - cdForeground(CD_BLACK); - cdVectorText(x, y, text); + cdCanvasForeground(canvas, CD_BLACK); + cdCanvasVectorText(canvas, x, y, text); } -void DrawTextBox(int x, int y, char* text) +void DrawTextBox(cdCanvas* canvas, int x, int y, char* text) { int rect[8], draw_box; - cdLineWidth(1); - cdLineStyle(CD_CONTINUOUS); + cdCanvasLineWidth(canvas, 1); + cdCanvasLineStyle(canvas, CD_CONTINUOUS); draw_box = 0; if (draw_box) { int xmin, xmax, ymin, ymax; - cdTextBox(x, y, text, &xmin, &xmax, &ymin, &ymax); - cdRect(xmin, xmax, ymin, ymax); + cdCanvasGetTextBox(canvas, x, y, text, &xmin, &xmax, &ymin, &ymax); + cdCanvasRect(canvas, xmin, xmax, ymin, ymax); - if (cdTextOrientation(CD_QUERY) == 0) + if (cdCanvasTextOrientation(canvas, CD_QUERY) == 0) { - cdForeground(CD_RED); - cdLine(xmin, y, xmax, y); + cdCanvasForeground(canvas, CD_RED); + cdCanvasLine(canvas, xmin, y, xmax, y); } } else { /* bounding box */ - cdTextBounds(x, y, text, rect); - cdForeground(CD_GREEN); - cdBegin(CD_CLOSED_LINES); - cdVertex(rect[0], rect[1]); - cdVertex(rect[2], rect[3]); - cdVertex(rect[4], rect[5]); - cdVertex(rect[6], rect[7]); - cdEnd(); + cdCanvasGetTextBounds(canvas, x, y, text, rect); + cdCanvasForeground(canvas, CD_GREEN); + cdCanvasBegin(canvas, CD_CLOSED_LINES); + cdCanvasVertex(canvas, rect[0], rect[1]); + cdCanvasVertex(canvas, rect[2], rect[3]); + cdCanvasVertex(canvas, rect[4], rect[5]); + cdCanvasVertex(canvas, rect[6], rect[7]); + cdCanvasEnd(canvas); } /* reference point */ - cdForeground(CD_BLUE); - cdMarkType(CD_PLUS); - cdMarkSize(30); - cdMark(x, y); + cdCanvasForeground(canvas, CD_BLUE); + cdCanvasMarkType(canvas, CD_PLUS); + cdCanvasMarkSize(canvas, 30); + cdCanvasMark(canvas, x, y); - cdForeground(CD_BLACK); - cdText(x, y, text); + cdCanvasForeground(canvas, CD_BLACK); + cdCanvasText(canvas, x, y, text); } -int SimpleDrawTextAlign(void) +void SimpleDrawTextAlign(cdCanvas* canvas) { int w, h, i, xoff, yoff, use_vector; int text_aligment[] = { - CD_NORTH, - CD_SOUTH, - CD_EAST, - CD_WEST, - CD_NORTH_EAST, - CD_NORTH_WEST, - CD_SOUTH_EAST, - CD_SOUTH_WEST, - CD_CENTER, - CD_BASE_CENTER, - CD_BASE_RIGHT, - CD_BASE_LEFT + CD_NORTH, + CD_SOUTH, + CD_EAST, + CD_WEST, + CD_NORTH_EAST, + CD_NORTH_WEST, + CD_SOUTH_EAST, + CD_SOUTH_WEST, + CD_CENTER, + CD_BASE_CENTER, + CD_BASE_RIGHT, + CD_BASE_LEFT }; #if 1 @@ -1088,90 +1111,83 @@ int SimpleDrawTextAlign(void) }; #endif - cdGetCanvasSize(&w, &h, 0, 0); + cdCanvasGetSize(canvas, &w, &h, 0, 0); - cdBackground(CD_WHITE); - cdClear(); - - simple_draw = DRAW_TEXTALIGN; + cdCanvasBackground(canvas, CD_WHITE); + cdCanvasClear(canvas); use_vector = 0; #if 0 if (use_vector) - cdVectorTextDirection(0, 0, 1, 1); + cdCanvasVectorTextDirection(canvas, 0, 0, 1, 1); else - cdTextOrientation(45); + cdCanvasTextOrientation(canvas, 45); #endif xoff = w/4; yoff = h/7; if (use_vector) - cdVectorCharSize(30); + cdCanvasVectorCharSize(canvas, 30); else { - //cdFont(CD_TIMES_ROMAN, CD_PLAIN, 14); - cdFont(CD_HELVETICA, CD_PLAIN, 24); + //cdCanvasFont(canvas, "Times", CD_PLAIN, 14); + cdCanvasFont(canvas, "Helvetica", CD_PLAIN, 24); } for (i = 0; i < 12; i++) { - cdTextAlignment(text_aligment[i]); + cdCanvasTextAlignment(canvas, text_aligment[i]); if (i < 6) { if (use_vector) - DrawVectorTextBox(xoff, yoff*(i+1), text_aligment_str[i]); + DrawVectorTextBox(canvas, xoff, yoff*(i+1), text_aligment_str[i]); else - DrawTextBox(xoff, yoff*(i+1), text_aligment_str[i]); + DrawTextBox(canvas, xoff, yoff*(i+1), text_aligment_str[i]); } else { if (use_vector) - DrawVectorTextBox(3*xoff, yoff*(i-5), text_aligment_str[i]); + DrawVectorTextBox(canvas, 3*xoff, yoff*(i-5), text_aligment_str[i]); else - DrawTextBox(3*xoff, yoff*(i-5), text_aligment_str[i]); + DrawTextBox(canvas, 3*xoff, yoff*(i-5), text_aligment_str[i]); } } - - cdFlush(); - return 0; } -void DrawTextFont(int font, int size, int xoff, int yoff, char* text) +void DrawTextFont(cdCanvas* canvas, const char* font, int size, int xoff, int yoff, char* text) { - cdFont(font, CD_PLAIN, size); - DrawTextBox(xoff, yoff, text); + cdCanvasFont(canvas, font, CD_PLAIN, size); + DrawTextBox(canvas, xoff, yoff, text); - cdFont(font, CD_BOLD, size); - DrawTextBox(2*xoff, yoff, text); + cdCanvasFont(canvas, font, CD_BOLD, size); + DrawTextBox(canvas, 2*xoff, yoff, text); - cdFont(font, CD_ITALIC, size); - DrawTextBox(3*xoff, yoff, text); + cdCanvasFont(canvas, font, CD_ITALIC, size); + DrawTextBox(canvas, 3*xoff, yoff, text); - cdFont(font, CD_BOLD_ITALIC, size); - DrawTextBox(4*xoff, yoff, text); + cdCanvasFont(canvas, font, CD_BOLD_ITALIC, size); + DrawTextBox(canvas, 4*xoff, yoff, text); } -int SimpleDrawTextFonts(void) +void SimpleDrawTextFonts(cdCanvas* canvas) { int xoff, yoff, size; - cdBackground(CD_WHITE); - cdClear(); - - simple_draw = DRAW_TEXTFONTS; + cdCanvasBackground(canvas, CD_WHITE); + cdCanvasClear(canvas); xoff = 470; yoff = 150; size = -30; - cdTextAlignment(CD_CENTER); + cdCanvasTextAlignment(canvas, CD_CENTER); - DrawTextFont(CD_COURIER, size, xoff, yoff, "Courier"); - DrawTextFont(CD_TIMES_ROMAN, size, xoff, 2*yoff, "Times Roman"); - DrawTextFont(CD_HELVETICA, size, xoff, 3*yoff, "Helvetica"); - DrawTextFont(CD_SYSTEM, size, xoff, 4*yoff, "System"); + DrawTextFont(canvas, "Courier", size, xoff, yoff, "Courier"); + DrawTextFont(canvas, "Times", size, xoff, 2*yoff, "Times Roman"); + DrawTextFont(canvas, "Helvetica", size, xoff, 3*yoff, "Helvetica"); + DrawTextFont(canvas, "System", size, xoff, 4*yoff, "System"); { // static char native[50] = "Tecmedia, -60"; @@ -1204,26 +1220,21 @@ int SimpleDrawTextFonts(void) //cdText(10, 160, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); //cdText(10, 260, "1234567890"); //cdText(500, 360, "'\"!@#$%¨&*()_+-=[]^/;.,"); - - cdFlush(); - return 0; } -void SimpleDrawTest(void) -//void SimpleDrawMainTest(void) +void SimpleDrawTest(cdCanvas* canvas) +//void SimpleDrawMainTest(cdCanvas* canvas) { long pattern[16]; /* 4x4 pattern */ int w, h; int xmin, xmax, ymin, ymax; - simple_draw = DRAW_TEST; - /* notice that if we are not using world coordinates it is harder to position all the objetcs we want. */ - cdGetCanvasSize(&w, &h, 0, 0); + cdCanvasGetSize(canvas, &w, &h, 0, 0); - cdBackground(CD_WHITE); - cdClear(); + cdCanvasBackground(canvas, CD_WHITE); + cdCanvasClear(canvas); /* pattern initialization */ pattern[0] = CD_RED; pattern[1] = CD_RED; /* first line */ @@ -1236,55 +1247,55 @@ void SimpleDrawTest(void) pattern[14] = CD_YELLOW; pattern[15] = CD_YELLOW; /* set the line attributes */ - cdLineWidth(4); - cdLineStyle(CD_CONTINUOUS); + cdCanvasLineWidth(canvas, 4); + cdCanvasLineStyle(canvas, CD_CONTINUOUS); /* in the center draw a pattern pizza with a slice mising */ - cdPattern(4, 4, pattern); - cdSector(w/2, h/2, w/2, h/2, 45, 0); + cdCanvasPattern(canvas, 4, 4, pattern); + cdCanvasSector(canvas, w/2, h/2, w/2, h/2, 45, 0); /* draws a dark red border */ - cdForeground(CD_DARK_RED); - cdInteriorStyle(CD_HOLLOW); - cdSector(w/2, h/2, w/2, h/2, 45, 0); + cdCanvasForeground(canvas, CD_DARK_RED); + cdCanvasInteriorStyle(canvas, CD_HOLLOW); + cdCanvasSector(canvas, w/2, h/2, w/2, h/2, 45, 0); /* on the left a red hash diamond */ /* notice the the default back opacity is transparent and the pattern of the sector will still be visible inside the hatch where the two objects intersect */ - cdForeground(CD_RED); - cdHatch(CD_DIAGCROSS); - cdBegin(CD_FILL); - cdVertex(w/4, h/4); - cdVertex(w/2-w/8, h/2); - cdVertex(w/4, 3*h/4); - cdVertex(w/8, h/2); - cdEnd(); + cdCanvasForeground(canvas, CD_RED); + cdCanvasHatch(canvas, CD_DIAGCROSS); + cdCanvasBegin(canvas, CD_FILL); + cdCanvasVertex(canvas, w/4, h/4); + cdCanvasVertex(canvas, w/2-w/8, h/2); + cdCanvasVertex(canvas, w/4, 3*h/4); + cdCanvasVertex(canvas, w/8, h/2); + cdCanvasEnd(canvas); /* draws a blue roof.*/ - cdForeground(CD_BLUE); - cdLine(w/8, h/2, w/4, 3*h/4); - cdLine(w/4, 3*h/4, w/2-w/8, h/2); + cdCanvasForeground(canvas, CD_BLUE); + cdCanvasLine(canvas, w/8, h/2, w/4, 3*h/4); + cdCanvasLine(canvas, w/4, 3*h/4, w/2-w/8, h/2); /* draws a dashed ribbon on the right with a custom color */ - cdForeground(cdEncodeColor(100, 25, 200)); - cdLineStyle(CD_DASH_DOT); - cdBegin(CD_BEZIER); - cdVertex(3*w/4-20, h/2-50); - cdVertex(3*w/4+150, 3*h/4-50); - cdVertex(3*w/4-150, 3*h/4-50); - cdVertex(3*w/4+20, h/2-50); - cdEnd(); + cdCanvasForeground(canvas, cdEncodeColor(100, 25, 200)); + cdCanvasLineStyle(canvas, CD_DASH_DOT); + cdCanvasBegin(canvas, CD_BEZIER); + cdCanvasVertex(canvas, 3*w/4-20, h/2-50); + cdCanvasVertex(canvas, 3*w/4+150, 3*h/4-50); + cdCanvasVertex(canvas, 3*w/4-150, 3*h/4-50); + cdCanvasVertex(canvas, 3*w/4+20, h/2-50); + cdCanvasEnd(canvas); - cdFont(CD_HELVETICA, CD_BOLD, 40); - cdTextAlignment(CD_CENTER); - cdText(w/2, h/4-50, "Canvas Draw"); - cdTextBox(w/2, h/4-50, "Canvas Draw", &xmin, &xmax, &ymin, &ymax); - cdRect(xmin, xmax, ymin, ymax); - cdFlush(); + cdCanvasFont(canvas, "Helvetica", CD_BOLD, 40); + cdCanvasTextAlignment(canvas, CD_CENTER); + cdCanvasText(canvas, w/2, h/4-50, "Canvas Draw"); + cdCanvasGetTextBox(canvas, w/2, h/4-50, "Canvas Draw", &xmin, &xmax, &ymin, &ymax); + cdCanvasRect(canvas, xmin, xmax, ymin, ymax); } +#if 0 void draw_wd(void) { char* text; @@ -1324,18 +1335,14 @@ void draw_wd(void) wdVertex(rect[4], rect[5]); wdVertex(rect[6], rect[7]); cdEnd(); - - cdFlush(); } -//void SimpleDrawTest(void) -void SimpleDrawTestHardCopy(void) +//void SimpleDrawTest(cdCanvas* canvas) +void SimpleDrawTestHardCopy(cdCanvas* canvas) { int w, h; cdGetCanvasSize(&w, &h, 0, 0); - simple_draw = DRAW_ALL; - wdViewport(0,w-1,0,h-1); if (w>h) wdWindow(0,(double)w/(double)h,0,1); @@ -1345,19 +1352,16 @@ void SimpleDrawTestHardCopy(void) draw_wd(); //wdHardcopy(CD_CLIPBOARD, "800x600", cdActiveCanvas(), draw_wd ); - //cdFlush(); } -//void SimpleDrawTest(void) -void SimpleDrawTestImageRGB(void) +//void SimpleDrawTest(cdCanvas* canvas) +void SimpleDrawTestImageRGB(cdCanvas* canvas) { int size = 2048*2048; unsigned char *red, *green, *blue; cdCanvas* canvas = cdCreateCanvas(CD_IMAGERGB, "2048x2048"); cdActivate(canvas); - simple_draw = DRAW_TEST; - red = calloc(size, 1); green = calloc(size, 1); blue = calloc(size, 1); @@ -1369,14 +1373,11 @@ void SimpleDrawTestImageRGB(void) free(blue); cdKillCanvas(canvas); - cdFlush(); } -//void SimpleDrawTest(void) -void SimpleDrawVectorFont(void) +//void SimpleDrawTest(cdCanvas* canvas) +void SimpleDrawVectorFont(cdCanvas* canvas) { - simple_draw = DRAW_TEST; - cdBackground(CD_WHITE); cdClear(); cdLineStyle(CD_CONTINUOUS); @@ -1431,17 +1432,14 @@ void SimpleDrawVectorFont(void) // } // } } - cdFlush(); } -//void SimpleDrawTest(void) -void SimpleDrawPoly(void) +//void SimpleDrawTest(cdCanvas* canvas) +void SimpleDrawPoly(cdCanvas* canvas) { int w, h; cdGetCanvasSize(&w, &h, 0, 0); - simple_draw = DRAW_TEST; - cdBackground(CD_WHITE); cdClear(); @@ -1465,3 +1463,4 @@ void SimpleDrawPoly(void) cdEnd(); } +#endif diff --git a/test/simple/simple.h b/test/simple/simple.h index f400d2f..a69c69d 100644 --- a/test/simple/simple.h +++ b/test/simple/simple.h @@ -6,7 +6,9 @@ void SimpleCreateCanvas(char* data); void SimpleKillCanvas(void); + void SimpleUpdateSize(cdCanvas* cnv); +void SimpleFlush(void); int SimplePlayClipboard(void); int SimplePlayCGMBin(void); @@ -48,10 +50,10 @@ int SimpleClippingRegion(void); int SimpleTransform(void); int SimpleContextPlus(void); -int SimpleDrawAll(void); -int SimpleDrawTextAlign(void); -int SimpleDrawTextFonts(void); -void SimpleDrawTest(void); -int SimpleDrawRepaint(void); +int SimpleAll(void); +int SimpleTextAlign(void); +int SimpleTextFonts(void); +int SimpleTest(void); +int SimpleRepaint(void); #endif diff --git a/test/simple/simple.led b/test/simple/simple.led index b1e67df..a431079 100644 --- a/test/simple/simple.led +++ b/test/simple/simple.led @@ -76,10 +76,10 @@ mnSurface = MENU mnPrimitives = MENU ( - ITEM("All", SimpleDrawAll), - ITEM("Text Align", SimpleDrawTextAlign), - ITEM("Text Fonts", SimpleDrawTextFonts), - ITEM("Test", SimpleDrawTest) + ITEM("All", SimpleAll), + ITEM("Text Align", SimpleTextAlign), + ITEM("Text Fonts", SimpleTextFonts), + ITEM("Test", SimpleTest) ) mnSimpleMenu = MENU diff --git a/test/simple/simple_led.c b/test/simple/simple_led.c index 9c5d786..dbfb37b 100644 --- a/test/simple/simple_led.c +++ b/test/simple/simple_led.c @@ -95,10 +95,10 @@ void simple_loadled (void) IupItem( "OpenGL", "SimpleDrawGL" ), NULL), NULL ); named[8] = decl( "mnPrimitives", IupMenu( - IupItem( "All", "SimpleDrawAll" ), - IupItem( "Text Align", "SimpleDrawTextAlign" ), - IupItem( "Text Fonts", "SimpleDrawTextFonts" ), - IupItem( "Test", "SimpleDrawTest" ), + IupItem( "All", "SimpleAll" ), + IupItem( "Text Align", "SimpleTextAlign" ), + IupItem( "Text Fonts", "SimpleTextFonts" ), + IupItem( "Test", "SimpleTest" ), NULL), NULL ); named[9] = decl( "mnSimpleMenu", IupMenu( IupSubmenu( "File", |