CSE 564 - Visualization




Home
Schedule
Labs
Links
Policies
Grades

Labs:

3/2/08:

Here is a revised version of the starter skeleon package, courtesy of your classmate Thomas Betson. I compiled it as well and it worked.

2/28/08

1. I posted a stable version of fltk (version 1.1.5rc3) here. Also, the precompiled libraries, etc, are here. But feel free to use fltk 2.0 which has somewhat more functionality.
2. When you have odd texture sizes:  For textures of width non-multiple of 4 you need to use: glPixelStorei(GL_UNPACK_ALIGNMENT, 1). This parameter is set to 4 by default.

Lab1:

Retrieve the skeleton code and some example image files. You can also use the program irfanview to transform other images that you like into the ppm format.

Here are some helpful links and docs: 


Quick instructions on how to set up VC+ with FLTK:

These instructions are for more experienced VC++ users, more detailed instructions for novice users are given below. These are the required additional settings in your Visual C++ environment (when you work in the CS lab, see further below for instructions on how to set up your computer at home):

1. Project->Settings->Link, in Object/library modules add: comctl32.lib wsock32.lib opengl32.lib glu32.lib fltk.lib fltkgl.lib
2. Project->Settings->Link, add in PROJECT OPTIONS: /nodefaultlib:"LIBC"
4. Tools->Options->Directories, select 'include files' in the 'Show directories for:' selector. Now add in the empty slot: C:\Program Files\fltk
5. Tools->Options->Directories, select 'library files' in the 'Show directories for:' selector. Now add in the empty slot: C:\Program Files\fltk\lib
6. (this may not be necessary:) Project->Settings->C/C++, add in PROJECT OPTIONS: /I "c:\program files\fluid"(or the REAL path CONTAINING the fltk package on your computer
Here is a visual manual on how to use Visual C++.

Links for FLTK and OpenGL can be obtained from the Links page.

Detailed instructions on how to set up VC++ for lab1 (and subsequent ones):

These are the steps I used to setup the lab1 assignment:

1)  Startup Visual C++ 6.0 (this is what I used, you may have a more recent version ) using desktop shortcut
2)  From the File menu, select New.  Pick the tab "projects". Also select a location directory in which you want VisualC to put all the project files. Create your project as a ``Win 32 Console Application''. This means that Windows will consider it a plain old DOS application. Assume the project name is LAB1. Choose 'empty project' when asked.
3)  From the "Tools" menu select "Options".
4)  Select the "Directories" tab.
5)  From the "Show Directories for" menu item select "Include files".
6)  Add "C:\Program Files\fltk" to the list of libraries.
7)  From the "Show Directories for" menu item select "Library files".
8)  Add "C:\Program Files\fltk\lib" to the list of libraries. Click OK.
9)  Click on the "File View" Tab (located below the left list window)
10) Right click on "LAB1 Files" and select "Add Files to Project". Add all existing source code for your project. Make sure you also include gui.cpp and gui.h which you generate using fltk.
11) Right click on "LAB1 Files" and select "Setting".  The settings window should show the "Settings for:" menu item as "Win32 Debug"
12) Select the "Link" tab
13) Add to the front of the "Object/library Modules" the following libs: fltk.lib fltkgl.lib  . All items in the list are separated by a single space.
14) Add to the end of the "Object/library Modules" the following libs: comctl32.lib wsock32.lib glu32.lib opengl32.lib . All items in the list are separated by a single space.
15) From the "Category" menu items select "Input".
16) Add to the "Ignore Libraries" item "LIBCD".
17) Change the "Settings for:" menu item to "Win32 Release"
18) Select the "Link" tab
19) Add to the front of the "Object/library Modules" the following: fltk.lib fltkgl.lib . All items in the list are separated by a single space.
20) Add to the end of the "Object/library Modules" the following: comctl32.lib wsock32.lib glu32.lib opengl32.lib . All items in the list are separated by a single space.
21) From the "Category" menu items select "Input".
22) Add to the "Ignore Libraries" item "LIBC".

Note that the DEBUG version will run much slower than the RELEASE version. When in DEBUG mode you need to make sure that in "Project/Settings/C/C++" the "Optimizations" are set to "Disable(Debug)" and the "Debug Info" is set to "Program Database". Then you can use the debugger to track down those bugs. When in RELEASE mode you need to make sure that "Project/Settings/C/C++" the "Optimizations" are set to "Maximize Speed" and the "Debug Info" is set to "None". Then your program will run at utmost speed.

Make sure you save everything before you exit VC++. You could use "File/Save All". Then, when you want to start another session, select the lab0.dsw file, which is your project file.


Detailed instructions on how to set up Visual Studio .NET  for lab1 (and subsequent ones):

Instructions on how to set up .NET with FLTK:

First, create your project as a ``Win 32 Console Application''. This means that Windows will consider it a plain old DOS application. Unfortunately, it will probably create some other junk you did not ask for: stdafx.cpp and .h as well as new entry point .cpp file. I actually suggest you remove these automatically created files, but if you do not feel safe, just
IGNORE THEM. Add provided .cpp and .h files to the project. Then open Project->Properties window and make the following changes to defauls settings:

1. In "Linker -> Input -> Additional Dependencies" add: comctl32.lib wsock32.lib opengl32.lib glu32.lib fltk.lib fltkgl.lib (If the last library is not found on your system, you might be fine without it - just remove it from the list)
2. In "Linker -> Input -> Ignore Specific library" add LIBCD
4. In "C/C++ -> Additional Include Directories" add C:\ProgramFiles\fltk
5. In "Linker -> Additional Libary Directories" add C:\ProgramFiles\fltk\lib
6. (if you don't want to include stdafx to all your files and compiler starts producing error similar to "fatal error C1010: unexpected end of
file while looking for precompiled header directive") In "C/C++ -> Precomputed Headers -> Create/Use Precomputed header" choose "Automatically Generate" from the menu.


Instructions on how to set up VC+ with FLTK 2.0:

I used Visual Studio 8.0. These are what I have found to be the required additional settings in this environment (further below are instructions on how to compile FLTK 2.0 itself, if the computer you are using does not have it installed).

1. In Tools -> Options -> VC++ Directories add the paths to the fltk include files and libraries.
2. Project->Properties->Configurations-> Linker, in 'additional dependencies' add:
    odbc32.lib odbccp32.lib wsock32.lib opengl32.lib glu32.lib fltk2.lib fltk2_gl.lib comctl32.lib
3. Project->Properties->Configurations-> Linker, in 'ignore specific librar' add: LIBCMT
4. Make sure you add 'using namespace fltk' in every file right after the include statements


A small tutorial on fluid:

Fluid offers a text editor as well as a visual editor that shows the actual GUI. You can move items around in the visual editor, but you need to add items in the text editor. First, load the provided gui.fl into fluid by selecting 'File - open' on the menubar of fluid's text editor. This should pop up the visual editor and fill some text into the text editor. Fluid is quite powerful, but for the matter of this class, you only need to know what is described below. However, feel free to read more about the capabilities of fluid on the documention pages at http://www.fltk.org.

To add a new submenu item for gui.fl, select the already existing 'Menu Bar menu bar' item in the text editor and then go to the 'New' pull down menu and select 'menus - submenus'. A window will pop up where you can enter the properties of this submenu. For 'Name' enter the name you want to give this item (for example 'imageProcess', and for 'Label' enter the tag you want to appear on the GUI menu bar (for example 'Image Process'). You can click on 'OK' and you will see that submenu appear in the visual editor on the menu bar. If you want to move it to the left of the 'Exit' button, you can select the 'imageProcess' item on the list and then choose 'Edit - earlier' on the fluid text editor menu bar.

To add a new menu item for a submenu in gui.fl, select an already existing 'submenu' item in the text editor (for example 'imageProcess') and then go to the 'New' pull down menu and select 'menus - menu item'. A window will pop up. Enter an appropriate name and label as before (for example 'update' and 'Update', respectively), and in 'Callback' enter the name of the routine in the application class in Application.cpp that will service this callback (for example, enter the line: app->Update();  ). Note that you must provide this routine in Application.cpp and also define it in Application.h before you compile the application with the new gui.cpp and gui.h (see below).

Select a few items in gui.fl (double clicking will bring up the property window for that item) that have already been defined to see how things are done. Select 'File - write code' which will write a new gui.cpp and gui.h. You may have to set the extension .cpp in 'Edit - preferences' (it may be set to .cxx). Note that you have to include gui.fl and gui.h into your Visual Studio project before you compile and link.

Save the new gui.fl with 'File - save'.

In the translab, there is a shortcut for fluid in the "Programming and Editors" section of the Programs menu.  The binary can be found in C:\Program Files\fltk\fluid 


Some hints for those who want to work from home:

Most likely you already have the OpenGL libraries on your PC. The DLLs should come with your Windows distribution. So you won't have to do much here.

The FLTK libraries, as well as fluid, you will have to compile yourself. Download the fltk-1.1 source zip file from www.fltk.org. Note, I used version 1.1.5rc3 for these instructions. The fixes described below may no longer be required for version 1.1.7 (while new fixes may be required). In any case, version 1.1.5 is also still available. After unpacking you will find a few README files that explain what you have to do. These are the steps:

I did encounter a few problems with fltk version 1.1.5:, fixes are as follows (these are for MS Windows XP):
1. During the compilation of fltk you may get errors with regards to jpg, zlib, and pg .h files. Do this: Edit config.h (found in the fltk visualc folder) inside Visual C and comment the  HAVE_LIBPNG, HAVE_LIBJPEG, and HAVE_LIBZ definitions out. 
2. You may also get errors that jpeglib cannot be found. Do this: The debug configurations of the pixmap_browser, fltkdll, fluid, help,and file_chooser projects all specify the non-debug versions of png.lib, z.lib, and jpeg.lib. Consequently they don't build if you build the debug config first, or they build with lots of warnings if you build the release config first. Thus, build the release version first and then the debug version.
3. Additionally, on Windows 2000, more problems may come up, in particular when it comes to compiling the fluid program (used for editing the GUIs later). In my case, libraries jpg.lib, png.lib and z.lib could not be found. However, if you go the lib directory in the fltk path, you will find fltklpg.lib. fltkz.lib and fltkpng.lib. Just rename those to jpg.lib, z.lib and png.lib. But, in my case there was no fltkpng.lib, only a fltkpngd.lib. Although it seems that a simple renaming to png.lib works, I specifically generated fltkpng.lib by picking libpng.dsp in the visualc folder and building it in the Relase configuration (set active settings: Release and choose build all when compiling).

The end result are a few files in the 'lib' folder. Create a directory C:\Program Files\fltk and put the entire 'lib' folder there. Also, create a directory C:\Program Files\fltk\include and put the entire 'FL' folder from the fltk distribution there.  So now you should have two folders: C:\Program Files\fltk\lib containing all fltk libs and  C:\Program Files\fltk\include\FL containing all fltk .h (header) files.