| View previous topic :: View next topic |
| Author |
Message |
Simon C.E.O.
Joined: 01 Dec 2004 Posts: 885 Location: Kingston Upon Thames, U.K.
|
Posted: Sun Jan 18, 2009 5:38 pm Post subject: Coding a Dogwaffle Connection in C++ |
|
|
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 |
|
 |
donfelipe
Joined: 18 May 2005 Posts: 7 Location: San Diego, California
|
|
| Back to top |
|
 |
|
|
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
|