WhipExamples/GouraudPolyline.cpp

00001 //
00002 //  Copyright (c) 2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED,
00008 //  AS TO THE CORRECTNESS OF THIS CODE OR ANY DERIVATIVE
00009 //  WORKS WHICH INCORPORATE IT.
00010 //
00011 //  AUTODESK PROVIDES THE CODE ON AN "AS-IS" BASIS
00012 //  AND EXPLICITLY DISCLAIMS ANY LIABILITY, INCLUDING
00013 //  CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00014 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00015 //
00016 //  Use, duplication, or disclosure by the U.S. Government is subject to
00017 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00018 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00019 //  Data and Computer Software), as applicable.
00020 //
00021 
00022 #include "whiptk/whip_toolkit.h"
00023 #include "whiptk/w2d_class_factory.h"
00024 
00025 extern WT_File *whip_file; //Assume this has been opened for writing elsewhere.
00026 
00027 WT_Result GouraudPolyline()
00028 {
00029     WT_W2D_Class_Factory cf;
00030 
00031     //Define some polyline vertices.
00032     int x=0,y=0;
00033     const int delta = 1000 / 7;
00034     WT_Logical_Point  vP[8];
00035     for (int i = 0; i < 8; i += 2) {
00036         vP[i].m_x = x + (2*delta*(i/2));
00037         vP[i].m_y = y;
00038         vP[i + 1].m_x = vP[i].m_x + delta;
00039         vP[i + 1].m_y = y + delta;
00040     }
00041     //Define the colors for those vertices.
00042     WT_RGBA32    rgba[9];
00043     rgba[0] = WT_RGBA32 (0, 0, 0, 255);
00044     rgba[1] = WT_RGBA32 (255, 255, 0, 255);
00045     rgba[2] = WT_RGBA32 (255, 0, 0, 255);
00046     rgba[3] = WT_RGBA32 (0, 255, 0, 255);
00047     rgba[4] = WT_RGBA32 (0, 255, 255, 255);
00048     rgba[5] = WT_RGBA32 (0, 0, 255, 255);
00049     rgba[6] = WT_RGBA32 (255, 0, 255, 255);
00050     rgba[7] = WT_RGBA32 (255, 255, 255, 255);
00051     rgba[8] = WT_RGBA32 (0, 255, 0, 255);
00052     //Create the gouraud polyline.
00053     WT_Gouraud_Polyline *p = cf.Create_Gouraud_Polyline(8, vP, rgba, WD_True);
00054     if (p==NULL)
00055         return WT_Result::Out_Of_Memory_Error;
00056     //Serialize it.
00057     WD_CHECK(p->serialize (*whip_file));
00058     cf.Destroy(p);
00059 
00060     return WT_Result::Success;
00061 }

Generated on Tue Jan 6 22:40:01 2009 for Autodesk DWF Toolkit by  doxygen 1.4.5