Demo Programs
Welcome To CIDCorp
Home of the CIDLib Class Libraries


CIDLib comes with a set of demo programs which are intended to serve partly as practical documentation on the classes, but also to demonstrate the intended use and style of the CIDLib architecture and how the infrastructure fits together. Over time, more programs will be added which demonstrate specific functionality and which provide more real world applications.

Here is a list of links to the descriptions of the demo programs:

Because this version is in the middle of the conversion to custom GUI controls, it does not have any menus. So there is no system menu on the GUI demos. Close them via the task list.

The following sections describe each demo program, what it does, what CIDLib functionality it demonstrates, etc...

DispRGB.Exe, Simple Graphics Display Demo

DispRGB is a small bitmapped graphics display utility that is provided partly as a good demo and partly because some of the other demo's output must be viewed, so they output in a format that DispRGB uses. This one has been prettied up a bit for this third beta release What It Does DispRGB reads in a binary graphics file in a format output by some of the other demo programs, and loads up the contents into a TBackedWnd object. TBackedWnd provides an easy way to display bitmapped graphics without the need for any application level support. It is a window backed by a memory bitmap. How To Use It DispRGB takes the name of its target file from the command line, so you would run it like this:
    DispRGB TheFileToView.Ext
Limitations It does not scroll the image, which would be necessary if the images were quite large. Notable Classes Used

Fractal, Fractal Engine Demo

This demo program demonstrates how to use the fractal engine. Its just a simple TTY app that outputs its image to a file. It does a canned image and automatically outputs it to the Output.Dis file in the current directory. What It Does This demo program uses the fractal rendering engine to render a Mandelbrot image and output it to a Dis file, which you can view with the DispRGB demo program. How To Use It There are no command line parms so just run it. When it completes, look for the Output.Dis file in the current directory. View the file using the DispRGB demo program.

Graph1.Exe. Persistence and Dynamic Typing Demo

Graph1 is a simple demo of the object persistence and dynamic typing systems supported by CIDLib. It implements a very simple graphics app that supports multiple widget objects, each with their own attributes, which are drawn. What It Does Graph1 maintains a collection of 'graphics widgets', and draws them to its client window. It stores and reloads the widgets using the persistence system of CIDLib, which are based on streams. It shows how the dynamic typing system makes such applications very unaffected by the addition of new graphic widget types. How To Use It Just run the program. It will display the canned set of widgets. If the file exists, it reads them from the file, else it creates it. Limitations This first version does not let you edit the widgets in any way. This demo will be built on in successive release. Notable Classes Used

LogDemo.Exe, Logging Architecture Demo

CIDLib has a very extensive logging architecture, which is a necessary evil with large software systems. CIDLib's logging system is intimately tied in with exceptions and text formatting.

Be sure to read the setup/installation chapter since logging requires some runtime environmental variables. What It Does LogDemo just shows the various permuations of logging APIs, how to install your own logging handler, and the way that exceptions interact with logging. It is just a simple TTY program so that program infrastructure does not muddy the waters.

Also keep in mind that most demos log things, they just don't explicitly explain what they are doing and why. How To Use It This one you just run. Read the source code for an explanation of what is going on and what to expect. Limitations None Notable Classes Used

MetricsDemo.Exe, Metrics Architecture Demo

CIDLib supports a very nice runtime metrics collection system. The CIDLib Dlls use this system to collect metrics within the context of the client application; and, client applications can use it to maintain their own metrics. The MiniMetrics utility is used to display metrics for CIDLib programs, and it can be accessed by other external apps, so see the CIDLib Utilities chapter. What It Does This program creates a metrics group (metrics are grouped together in named groups of up to 32 values) which has one of each kind of metric. It then spins off a thread that just manipulates the metrics so that the metrics viewer can be used to watch them change. How To Use It This one is just for reading the source code and/or running it under the debugger to see how it works. See the source code for details. The main thread will just block on keyboard intput and tell you to press Enter when you are ready to kill it. Limitations More metrics types will be added over time, but the ones provided now will serve most purposes. Notable Classes Used

RayTracer.Exe, Ray Tracer Engine Demo

CIDLib supports an object oriented ray tracing engine. This demo program shows the fundamental capabilities of the ray tracer. It is a simple use of the engine that builds a scheme programatically and renders it to file. What It Does RayTracer renders a hard coded image (as apposed to described in a scene description file) to disk. It is a TTY program and just output the line numbers as it renders each line of the image. The output is in the format understood by the DispRGB.Exe demo program, so it can be used to view the results. How To Use It You need to provide the name of the output file and the dimensions of the rendered scene. So, to render the image to OutFile and make it 128 by 128 pixels, you would type:
    RayTracer OutFile 128 128
The extension, .Dis, is provided automatically so don't type it on the command line. Notable Classes Used

RayTracer3.Exe, Ray Tracer Engine Demo

This ray tracer demo is a TTY style text mode application that uses the ray tracer's Scene Description Language (SDL) system, which lets you describe the scene as a text file which it will parse. There are a set of demo scene files in the SceneFiles directory that are used by this demo. What It Does This demo uses the ray tracing engine to parse scene files and render the images. RayTracer.Exe uses the C++ programming interface to the ray tracer to build scenes and render them. This meant you had to modify and recompile the code to play with the scenes. This program allows you to just modify the scene file description file, via your favorite text editor, and render it.

The output is to a dump file in the format used by the DispRGB.Exe demo program, so you can use it to view the results. How To Use It The command line parameters are:

    RayTracer3 SceneFile.Scene OutFile XPels YPels [/option /option...]
The scene file is the input file that describes the scene. See the SceneFiles subdirectory for the available demo files that come with the CIDLib distribution. The outfile, as with the other ray tracer demos, is the output file without the extension. It will be given the Dis extension. XPels and YPels are the number of horizontal and vertical pixels to make the image. The options are: The sample option sets the sampling mode. If its not provided, then the sample mode set in the scene file, if any, is used. If neither are present, then Normal is assumed. If statistical sampling is indicated then the threshold option sets the sampling threshold. This controls how anal the sampling code is. A value of about 1.2 gives results pretty close to Stochastic sampling with usually 2/3 to 1/2 of the actual pixels rendered. The minimum is 0.0, which is basically just like Stochastic sampling. The maximum is 3.0, which is basically just like Normal sampling. The program outputs a status on every ten scan lines so that you can know where it is in the image. Limitations The ray tracer's parser uses an include path to find files. In this demo it is set to ..\SceneFiles, so it assumes that you are running it from the demo program's directory. This lets it find the scene files in its sibling directory. You can modify this and rebuild the program if you wish to find files elsewhere. It should really be settable on the command line. Notable Classes Used

SineWave.Exe, Graphics/Font Demo

This one is a simple program that demonstrates some of the functionality you would use in an average 2D graphics application. What It Does Sinewave draws a sine wave graph with a title above and a legend to the left. It uses a paintbrush object to output the graphics and creates a couple of fonts to draw the title and legend text. It derives from TClientWnd to create its client window. It particular shows how the TArea and TPoint classes work. How To Use It This one you just run and it displays its graph. To close it, use the system menu in the upper left corner. Limitations None Notable Classes Used

SystemInfo.Exe, Information APIs Demo

This program is just a simple TTY program that dumps information available via CIDLib's various sources of information. Keep in mind that this one cannot show information that is available only to graphical applications, of which there is a lot. That can be a another demo eventually. What It Does This program just gathers information about the system from a variety of sources available in CIDLib and formats the output to the standard output. The formatting is pretty simple but shows how a practial TTY output program would do its thing. How To Use It Just run the program. It will output its information and then exit. You can redirect it to a file if desired. Limitations There are still more sources of information to take advantage of. Notable Classes Used
CIDCorp Home Page

CIDCorp
Dean Roddey
Internet: droddey@ng.netgate.net
CIS: 72170,1614