home *** CD-ROM | disk | FTP | other *** search
- /*
- * File: showquad.c
- *
- * Author: Taken from RenderMan Companion by Steve Upstill
- *
- * Purpose: Demonstrate Windows app which converts RenderMan to RDC bytestream.
- *
- */
-
- #include <windows.h>
- #include "rdc.h" /* RenderDotC interface definition */
- #include "ri.h" /* RenderMan interface definition */
-
- /*
- * function: showquads
- *
- * input: none
- *
- * returns: void
- *
- * purpose: Example RenderMan program.
- *
- */
- static void showquads(void)
- {
- RtFloat fov = 11;
- RtColor white = {1.0, 1.0, 1.0};
- RtPoint hypert1, hypert2;
-
- RiBegin(RI_NULL);
- RiFormat(200, 150, -1);
- RiDisplay("showquad.tif", RI_FILE, RI_RGB, RI_NULL);
- RiProjection(RI_PERSPECTIVE, RI_FOV, (RtPointer)&fov, RI_NULL);
- RiShadingInterpolation("smooth");
-
- RiWorldBegin();
- RiColor(white);
- RiLightSource(RI_DISTANTLIGHT, RI_NULL);
- RiSurface("matte", RI_NULL);
- RiSides(1);
-
- RiTranslate(0, 0, 14.0);
- RiRotate(-90, 1, 0, 0);
-
- RiTranslate(-1.2, 0, 1.2 / 2);
- RiSphere(0.5, -0.5, 0.5, 360, RI_NULL);
-
- RiTranslate(1.2, 0, 0);
- RiTranslate(0, 0, -0.5);
- RiCone(1, 0.5, 360, RI_NULL);
-
- RiTranslate(0.0, 0, 0.5);
- RiTranslate(1.2, 0, 0);
- RiCylinder(0.5, -0.5, 0.5, 360, RI_NULL);
-
- RiTranslate(-2.4, 0, -1.2);
- hypert1[0] = 0.4;
- hypert1[1] = -0.4;
- hypert1[2] = -0.4;
- hypert2[0] = 0.4;
- hypert2[1] = 0.4;
- hypert2[2] = 0.4;
-
- RiHyperboloid(hypert1, hypert2, 360, RI_NULL);
-
- RiTranslate(1.2, 0, -0.5);
- RiParaboloid(0.5, 0, 0.9, 360, RI_NULL);
-
- RiTranslate(1.2, 0, 0.5);
- RiTorus(0.4, 0.15, 0, 360, 360, RI_NULL);
- RiWorldEnd();
- RiEnd();
- }
-
- /*
- * function: MainWndProc
- *
- * input: Window handle, message id, first and second message parameters.
- *
- * returns: LRESULT - Result of message processing.
- *
- * purpose: Destroys app when main window closes. Calls default for rest.
- *
- */
- static LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg,
- WPARAM wParam, LPARAM lParam)
- {
- switch(msg) {
- case WM_DESTROY:
- PostQuitMessage(0); /* Kill the app when the window goes */
- break;
-
- default: /* Do the default thing */
- return DefWindowProc(hWnd, msg, wParam, lParam);
- }
-
- return FALSE;
- }
-
- /*
- * function: WinMain
- *
- * input: Handles to current and previous instances, command line, show state.
- *
- * returns: int APIENTRY - 0 on success
- *
- * purpose: Main entry point for 32 bit windows program.
- *
- */
- int APIENTRY WinMain(HANDLE hInstance, HANDLE hPrevInstance,
- LPSTR lpCmdLine, int nCmdShow)
- {
- HWND hMainWnd;
- WNDCLASS wc;
- MSG msg;
-
- /*
- * Create a main window
- */
- wc.style = 0;
- wc.hInstance = hInstance;
- wc.lpfnWndProc = MainWndProc;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.lpszClassName = "QUAD:MAIN";
- wc.lpszMenuName = NULL;
- wc.cbClsExtra = wc.cbWndExtra = 0;
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
- if (!RegisterClass(&wc))
- return 1;
- hMainWnd = CreateWindow("QUAD:MAIN", "Quads App", WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT, 0, 100, 100, NULL, NULL, hInstance, NULL);
- if (!hMainWnd)
- return 1;
- ShowWindow(hMainWnd, nCmdShow);
- UpdateWindow(hMainWnd);
-
- /*
- * The following line sets the name of the output rdc file.
- */
- rdcOutputFile(RDC_BYTESTREAM, "showquad.rdc");
-
- /*
- * Draw the quadrics
- */
- showquads();
-
- /*
- * Run message loop until user closes main window.
- */
- while (GetMessage(&msg, NULL, 0, 0)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
-
- return 0;
- }
-