Click here to Skip to main content
15,891,136 members
Articles / Desktop Programming / MFC

Basic Curves And Surfaces Modeler

Rate me:
Please Sign up or sign in to vote.
4.17/5 (40 votes)
18 Apr 2012CPOL3 min read 247.5K   16.4K   117  
A basic demo of modeling curves and surfaces in OpenGL.
// hdibapi.h


#ifndef _INC_DIBAPI
#define _INC_DIBAPI

/* Handle to a DIB */
DECLARE_HANDLE(HDIB);

/* DIB constants */
#define PALVERSION   0x300
#define PW_WINDOW        1
#define PW_CLIENT        2

/* DIB Macros*/

#define IS_WIN30_DIB(lpbi)  ((*(LPDWORD)(lpbi)) == sizeof(BITMAPINFOHEADER))
#define RECTWIDTH(lpRect)     ((lpRect)->right - (lpRect)->left)
#define RECTHEIGHT(lpRect)    ((lpRect)->bottom - (lpRect)->top)

// WIDTHBYTES performs DWORD-aligning of DIB scanlines.  The "bits"
// parameter is the bit count for the scanline (biWidth * biBitCount),
// and this macro returns the number of DWORD-aligned bytes needed
// to hold those bits.

#define WIDTHBYTES(bits)    (((bits) + 31) / 32 * 4)

/* Function prototypes */
BOOL      WINAPI  PaintDIB (HDC, LPRECT, HDIB, LPRECT, HPALETTE hPal);
HPALETTE  WINAPI  CreateDIBPalette(HDIB hDIB);
LPSTR     WINAPI  FindDIBBits (LPSTR lpbi);
DWORD     WINAPI  DIBWidth (LPSTR lpDIB);
DWORD     WINAPI  DIBHeight (LPSTR lpDIB);
WORD      WINAPI  PaletteSize (LPSTR lpbi);
WORD      WINAPI  DIBNumColors (LPSTR lpbi);
HANDLE    WINAPI  CopyHandle (HANDLE h);
BOOL      WINAPI  SaveDIB (HDIB hDib, HANDLE file);
HDIB      WINAPI  ReadDIBFile(HANDLE file);
void      WINAPI  InitBitmapInfoHeader (LPBITMAPINFOHEADER, DWORD, DWORD, int);
HANDLE    WINAPI  BitmapToDIB (HBITMAP hBitmap, HPALETTE hPal);
int       WINAPI  PalEntriesOnDevice (HDC hDC);
HPALETTE  WINAPI  GetSystemPalette (void);
HDIB	  WINAPI  CopyRectToDIB(HWND hWnd, LPRECT lpRect);
HDIB      WINAPI  CopyWindowToDIB(HWND hWnd, WORD fPrintArea);
HDIB      WINAPI  CopyScreenToDIB(LPRECT lpRect);
HBITMAP   WINAPI  CopyScreenToBitmap(LPRECT lpRect);                                          

enum {
      ERR_MIN = 0,                     // All error #s >= this value
      ERR_NOT_DIB = 0,                 // Tried to load a file, NOT a DIB!
      ERR_MEMORY,                      // Not enough memory!
      ERR_READ,                        // Error reading file!
      ERR_LOCK,                        // Error on a GlobalLock()!
      ERR_OPEN,                        // Error opening a file!
      ERR_CREATEPAL,                   // Error creating palette.
      ERR_GETDC,                       // Couldn't get a DC.
      ERR_CREATECHILD,                 // Error creating MDI child.
      ERR_CREATEDDB,                   // Error create a DDB.
      ERR_STRETCHBLT,                  // StretchBlt() returned failure.
      ERR_STRETCHDIBITS,               // StretchDIBits() returned failure.
      ERR_NODIBORDDB,                  // Error painting -- need BOTH DDB & DIB.
      ERR_SETDIBITSTODEVICE,           // SetDIBitsToDevice() failed.
      ERR_STARTDOC,                    // Error calling StartDoc().
      ERR_NOGDIMODULE,                 // Couldn't find GDI module in memory.
      ERR_SETABORTPROC,                // Error calling SetAbortProc().
      ERR_STARTPAGE,                   // Error calling StartPage().
      ERR_NEWFRAME,                    // Error calling NEWFRAME escape.
      ERR_ENDPAGE,                     // Error calling EndPage().
      ERR_ENDDOC,                      // Error calling EndDoc().
      ERR_ANIMATE,                     // Only one DIB animated @ a time.
      ERR_NOTIMERS,                    // No timers avail for pal animation.
      ERR_NOCLIPWINDOW,                // Now current window for clipboard.
      ERR_CLIPBUSY,                    // Clipboard is busy.
      ERR_NOCLIPFORMATS,               // During paste can't find DIB or DDB.
      ERR_SETDIBITS,                   // Error calling SetDIBits().
      ERR_FILENOTFOUND,                // Error opening file in GetDib()
      ERR_WRITEDIB,                    // Error writing DIB file.
      ERR_MAX                          // All error #s < this value
     };

void WINAPI  DIBError (int ErrNo);

#endif //!_INC_DIBAPI

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Product Manager Mahindra & Mahindra
India India
Sharjith is a Mechanical Engineer with strong passion for Automobiles, Aircrafts and Software development.

Comments and Discussions