www.curvy3d.com Forum Index www.curvy3d.com
Software for Artists - Aartform Curvy 3D
 

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Curvy 3D Home
Features/Screenshots
Forum
Gallery
Download
Order Now

Coding a Dogwaffle Connection in C++

 
Post new topic   Reply to topic    www.curvy3d.com Forum Index -> Tutorials
View previous topic :: View next topic  
Author Message
Simon
C.E.O.


Joined: 01 Dec 2004
Posts: 885
Location: Kingston Upon Thames, U.K.

PostPosted: Sun Jan 18, 2009 5:38 pm    Post subject: Coding a Dogwaffle Connection in C++ Reply with quote

This is not a tutorial for Curvy 3D, but rather a rare look inside Curvy's source code to help application authors link to Dogwaffle.

This example uses VOLE (open source) as a neat OLE wrapper


Code:

/* VOLE Header Files */
#include <vole/vole.hpp>
/* STLSoft Header Files */
#include <comstl/util/initialisers.hpp>
#include <comstl/util/variant.hpp>
#include <winstl/error/error_desc.hpp>

// ... other headers for error reporting here ...

void TestOLE()
{
   try
   {
      TRACE("Test OLE\n");
      comstl::ole_init    coinit;

      // Start server ...
      vole::object dog = vole::object::create("Dogwaffle.Dogwaffle_Class", CLSCTX_LOCAL_SERVER, vole::coercion_level::valueCoercion);

      comstl::variant r = dog.invoke_method<comstl::variant>(L"Dog_GetRBuffer");
      comstl::variant g = dog.invoke_method<comstl::variant>(L"Dog_GetGBuffer");
      comstl::variant b = dog.invoke_method<comstl::variant>(L"Dog_GetBBuffer");
      comstl::variant a = dog.invoke_method<comstl::variant>(L"Dog_GetABuffer");

      SAFEARRAY* sa = r.parray;

      int w = dog.get_property<int>(L"Dog_BufferHeight");
      int h = dog.get_property<int>(L"Dog_BufferWidth");

      int x = (*sa).rgsabound[0].cElements;
      int y = (*sa).rgsabound[1].cElements;

      byte* R = (byte*)((*r.parray).pvData);
      byte* G = (byte*)((*g.parray).pvData);
      byte* B = (byte*)((*b.parray).pvData);
      byte* A = (byte*)((*a.parray).pvData);

      int lx = x-1;
      int ly = y-1;

      ASSERT(w==lx);
      ASSERT(h==ly);

      for(int j=0;j<ly;++j)
         for(int i=0;i<lx;++i)
         {
            int p = i+j*x;
// Example filter - I normally copy Curvy's image buffers to Dogwaffle here...
            R[p] = rand()%32;
            G[p] = rand()%32;
            B[p] = rand()%32;
            A[p] = (i*256)/lx;
         }

         dog.invoke_method<void>(L"Dog_SetRBuffer",r);
         dog.invoke_method<void>(L"Dog_SetGBuffer",g);
         dog.invoke_method<void>(L"Dog_SetBBuffer",b);
         dog.invoke_method<void>(L"Dog_SetABuffer",a);

         dog.invoke_method<void>(L"Dog_Refresh");
   }
   catch(vole::vole_exception &x)
   {
      cout << "error: " << x.what() << ": " << winstl::error_desc(x.hr()).c_str() << endl;
   }
   catch(std::exception &x)
   {
      cout << "error: " << x.what() << endl;
   }

}
[/code]
Back to top
View user's profile Send private message
donfelipe



Joined: 18 May 2005
Posts: 7
Location: San Diego, California

PostPosted: Sun Jan 18, 2009 8:39 pm    Post subject: Reply with quote

Thanks, much appreciated.

If there are other developers looking at this code, and interested in using Dogwaffle as a framework for imaging and frame-by-frame animation or more, check the SDK and free source code snippets, most in VB but also some in Delphi, as submitted by Artweaver:

http://www.thebest3d.com/dogwaffle/sdk

For examples of other applications who have created a plug into Dogwaffle, check
www.thebest3d.com/dogwaffle/3rdpartyplugins

and
www.thebest3d.com/artweaver
_________________
just dog it!
www.thebest3d.com/dogwaffle
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    www.curvy3d.com Forum Index -> Tutorials All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group