Programming Code Samples
especially in
|
GLUI widgets GLUI is a utility-extension of OpenGL to provide basic GUI building capability |
! Note !
More code samples may be added ---
if I ever use this page much.
(Not likely, cause I have many Tcl-Tk projects.)
Most of these examples are code that
is to be compiled into binary objects.
Some compile scripts (and even binaries)
could be provided here, if compilations
of any of these code samples are done
(on Linux) in following months/years.
< Go to start of Table of Contents, below. >
(Skip the Introduction)
INTRODUCTION : The intention of this page is to provide complete code examples, to help me learn programming in C (or C++) --- using OpenGL on 3D data --- and using GUI library routines from GLUT, GLUI, FLTK, GTK, wxWidgets, Qt, Tcl-Tk, or other GUI-making systems. Alternatively, I may stick with Tcl-Tk programming and use these 'compiled language' code samples as sources of useful routines that can be re-coded into Tcl-Tk routines. I taught myself Tcl-Tk script programming (in the late 1990's) --- after learning FORTRAN programming (in the 1960's), COBOL programming (in the 1970's), APL programming (in the 1980's), and Unix shell programming (in the early 1990's) --- all through self-training and on-the-job training (not classroom, except for a few less-than-one-week training sessions). In the process of learning Unix shell scripting and Tcl-Tk scripting, I found the best way to learn is to try to do complete code examples as soon as possible --- like the classic 'Hello World' program. And then proceed quickly on to additional complete (and useful) code examples, using simple complete code examples to start with. Even when I was looking for working (de-bugged) code snippets, I usually found the best ones within complete code samples. So I was often doing web searches for code samples containing a string like '/bin/sh' or '/bin/wish', since that was usually a sign of a complete 'script' code example (a complete mini-application) --- starting with a line like '#!/bin/sh' or '#!/usr/bin/wish' or '#!/usr/local/bin/wish'. I find that tutorials and books that are made up completely of code 'snippets' are not nearly as useful as tutorials and books that start off with a 'hello world'-type example and build up to making at least one complete code project --- such as a working file browser or a working game program (even if they are somewhat lacking, and leave some details to be finished later, by the reader). So with that background, I collected the examples which are itemized in the following 'Table of Contents' (actually a 'Table of Links'). I can access these examples from any of my computers --- desktops at home and netbooks/laptops at home or away from home. (A little 'light reading' when 'on the road'.) Many of the examples below are OpenGL demo programs, from SGI staff members, back in the early to mid 1990's --- or they are programs based on those early demo programs. Most of these code samples show how to handle various kinds of keyboard and mouse input. And many examples include code to make GUI's --- using GLUT (basic) or GLUI (a little fancier) or FLTK (still fancier) or even fancier --- using GTK or Qt or wxWidgets. For more information on how to use this page, see the comments below the Table of Contents. |
TABLE OF CONTENTS :(Links to sections, below, on this page.)
End of Table of Contents.
|
HOW THE CODE SAMPLES (BELOW) ARE PRESENTED - and other notes : Each of these code samples is presented as an HTML embedded plain-text 'object' so that you can scroll the text of each code sample, vertically or horizontally, in a 'sub-window' of this page. (This should work in most GUI web browsers.) You can save a code sample locally by using a right-click and choosing an option such as 'This Frame > Show Only This Frame' in the popup menu (of your web browser) that appears. Then, when the code is shown in a separate window, right-click and choose 'Save Page As ...' in the popup menu that appears.
NOTE: However, one advantage is that you can do a 'Find text' operation with a web browser and it will find ALL the occurrences of the text string in ALL the code samples. That said, I may revise this page someday so that it loads faster --- especially if more code samples are to be supplied by this one page. NAVIGATION : Use the table-of-contents (above) to go directly to the display of a code sample-group of interest. OR simply scroll down this page to spot samples of interest.
Alternatively: When looking for code 'snippets' involving an OpenGL Vertex command or an event handling loop, use 'vertex' or 'loop' or 'run()'. When looking for code 'snippets' involving OpenGL shaders or light sources or motion blur or buffers or stencil, use keywords like 'shade' or 'phong' or 'light' or 'blur' or 'buffer' or 'stencil'. When looking for code 'snippets' involving splines or NURBs or heightfields, use keywords like 'spline' or 'nurb' or 'surface' or 'height' or 'field'. When looking for code 'snippets' involving geometric 'primitives' like cubes or spheres or tori or teapots, use keywords like 'cube' or 'sphere' or 'torus' or 'teapot' or 'rectangle' or 'circle'. When looking for code 'snippets' involving reading or writing 3D files of a certain type, like DXF or DWG or OBJ or LW or POV or VRML, use keywords like 'dxf' or 'dwg' or 'obj' or 'lw' or 'pov' or 'vrml' or 'read' or 'write'. When looking for code 'snippets' involving reading or writing 2D files of a certain type, like TARGA or BMP or AVI, use keywords like 'targa' or 'bmp' or 'avi'. FINDING MORE SAMPLES, ON THE INTERNET : One way to look for code samples is to do a Google search on filetype:c or filetype:cpp. You can add additional search terms, such as 'opengl' and/or 'glui' and/or 'gtk'. --- If you do not like the way Google records everything you do, you could use a web searcher, like DuckDuckGo, that has more respect for your desire to avoid running a gauntlet of ads every time you use an app or web site that uses Google utilities. So you could do searches using keywords like the following.
|
Start of the C Code Samples :
Start of C++ code samples :
Bottom of this
To return to a previously visited web page location, click on the
Back button of your web browser, a sufficient number of times.
OR, use the History-list option of your web browser.
< Go to start of
|