CSC320 Visual Computing
Assignment 1

Due:Submit by: Jan 30 By the start of tutorial
Late penalty: 15% /day to a maximum of 4 days, not accepted after that.
Hand in: Follow all instructions in the StGeorge 320 assignment but submit electronically here. This is instead of the submit -c csc320h -a assign1 assign1.tar.gz
Marking: See the syllabus
Groups: Each student works on their own.
Environment:We will test your code under cslinux or systems in 1158 under Linux.

Announcements

Please read the Questions and Answers Section at the bottom!!

Requirements

References

Questions and Answers

Question:
How do I start to understand the code given in c-code?
Answer:
Please play with the code, put printf statements, modify it slightly etc. This will give you an idea of how it works. Below, I ask a couple of questions and show you how I find the answers...
  1. Do you know where in the code the rectangle is drawn? [arnold@laptop c-code]$ grep glBegin *.cpp imdraw-draw.cpp: glBegin(GL_LINE_LOOP); [arnold@laptop c-code]$
  2. Do you know what the methods in that file are doing? [arnold@laptop c-code]$ grep -ie drawRect *.cpp *.h imdraw-draw.cpp:void ImDraw::drawRect(int r1, int c1, int r2, int c2) { readDrawing.cpp: window.drawRect(r1, c1, r2, c2); imdraw.h: void drawRect(int r1, int c1, int r2, int c2); [arnold@laptop c-code]$ vim imdraw.h
Question:
I am having troubles with running the fluid executables. I had no problems running the "HELLO WORLD" example, however, when i attempt to run the PARTB.2 exercise, with c-code/scissor -im einstein.v -cmd qq.cmd i get a "c-code/scissor: Permission denied" error. I was wondering if i was doing something wrong, or if there is something else i should try to do.
Answer:
Actually, you have to build the executable first, from the partII directory, execute... [arnold@cslinux partII]$ make clean rm -rf glutils.o Texture.o main.o imdraw-utils.o ScissorUI.o c-code/imdraw-init.o c-code/imdraw-draw.o c-code/imdraw-handle.o c-code/readDrawing.o ScissorUI.cpp ScissorUI.h [arnold@cslinux partII]$ make c-code/scissor fluid -c ScissorUI.fl gcc -c -I /usr/vision/include -Wno-deprecated -o glutils.o glutils.cpp gcc -c -I /usr/vision/include -Wno-deprecated -o Texture.o Texture.cpp gcc -c -I /usr/vision/include -Wno-deprecated -o main.o main.cpp gcc -c -I /usr/vision/include -Wno-deprecated -o imdraw-utils.o imdraw-utils.cpp gcc -c -I /usr/vision/include -Wno-deprecated -o ScissorUI.o ScissorUI.cpp gcc -c -I /usr/vision/include -Wno-deprecated -o c-code/imdraw-init.o c-code/imdraw-init.cpp gcc -c -I /usr/vision/include -Wno-deprecated -o c-code/imdraw-draw.o c-code/imdraw-draw.cpp gcc -c -I /usr/vision/include -Wno-deprecated -o c-code/imdraw-handle.o c-code/imdraw-handle.cpp gcc -c -I /usr/vision/include -Wno-deprecated -o c-code/readDrawing.o c-code/readDrawing.cpp gcc -o c-code/scissor glutils.o Texture.o main.o imdraw-utils.o ScissorUI.o c-code/imdraw-init.o c-code/imdraw-draw.o c-code/imdraw-handle.o c-code/readDrawing.o `fltk-config --use-gl --ldflags` -lstdc++ -L/usr/vision/lib -lvista [arnold@cslinux partII]$ c-code/scissor -im einstein.v -cmd qq.cmd you can then execute c-code/scissor -im einstein.v -cmd qq.cmd
Question:
I did what you said on cslinux above from home and I get the following... Xlib: extension "GLX" missing on display "localhost:10.0". Insufficient GL support Segmentation fault [arnold@cslinux partII]$
Answer:
If you get the above or a 'can't opend display' message it is probably because you are either not running X-Windows or (if you are running X) then your local installation of X does not have OpenGL support (you will need to add this).

The alternative is running on our lab (1158) machines. Note that if you are in the lab, then you should NOT run on cslinux anyway!!

Question:
I can't access all the man pages for Vista in 1158 (or in cslinux)
Answer:
You can find the complete set of man pages for Version 2.1.6 of Vista here. This includes the VTutorial.

The complete set of Vista man pages is not yet available on cslinux. The Vista man pages currently available on cslinux are...(type man VBundle for example)...

VBundle.3 VFillImage.3 VNewString.3 VRGBImageToGray.3 VCalibrateCamera.3 VFlipImage.3 VNoiseImage.3 VRotateImage.3 VCamera.3 VForkImageDisplay.3 VNumber.3 VSameImage.3 VCameraCoord.3 VGaussianConvolveImage.3 VOffset.3 VScaleImage.3 VCameraError.3 VGetAttr.3 VOpenFile.3 VSegEdgesIntoLines.3 VCanny.3 VGetPixel.3 VOptFlowWLS.3 VSelectBand.3 VColormap.3 VIdentifyFiles.3 Voption.3 VSelectDestImage.3 VCombineBands.3 VImage.3 VPackData.3 VSetAttr.3 VConst.3 VImageFFT.3 VParseCommand.3 VSetBandInterp.3 VConvertImageCopy.3 VImageGradient.3 VParseFilterCmd.3 VSetErrorHandler.3 VConvertImageLinear.3 VImageMagnitude.3 VParseParamOptions.3 VSetProgramName.3 VConvertImageOpt.3 VImageOp.3 VParsePSDistance.3 VSetWarningHandler.3 VConvertImageRange.3 VImagePhase.3 VParsePSOptions.3 VTransposeImage.3 VConvolveImage.3 VImageStats.3 VPatternImage.3 Vtype.3 VConvolveImageSep.3 VImageToPS.3 Vpostscript.3 VWarning.3 VCopy.3 VImageView.3 VPrintOptions.3 VWriteEdges.3 VCopyBand.3 VImageWindowSize.3 VPrintParameters.3 VWriteFile.3 VCopyImage.3 VInsertAttr.3 VReadEdges.3 VWriteImages.3 VCreateImage.3 VInvertImage.3 VReadFile.3 VWriteObjects.3 VCropImage.3 VKernel.3 VReadImages.3 VWriteUbcIff.3 VDecodeAttrValue.3 VLinkImage.3 VReadObjects.3 VZeroCrossings.3 Vdictionary.3 VList.3 VReadPlain.3 VEdges.3 VLoadParameters.3 VReadPnm.3 v1to2.1 vcatbands.1 vflip.1 vlayout.1 vphase.1 vselect.1 vblur.1 vcomplex.1 vflow.1 vlink.1 vrgbtogray.1 vsynth.1 vcalsyn.1 vconvert.1 vgauss.1 vmag.1 vrotate.1 vtopgm.1 vcamcal.1 vconvolve.1 vgrad.1 vnegate.1 vscale.1 vtops.1 vcanny.1 vcrop.1 vinvert.1 vop.1 vsegedges.1 vtranspose.1 vcat.1 vfft.1 vistat.1 vpdc.1 vselbands.1 vzeroc.1
Question:
Please note the following typos in the SPECS file (from newsgroup:ut.cdf.csc320h newsServer:news.cs.toronto.edu)
Answer:
In the file SPECS in the assign1/partII directory there was a typo in the specs for the file in which drawings are to be stored. Specifically, the lines - For a point: p <row> <col> should have been - For a point: P <row> <col> That is, the command for drawing a single point should be capital 'P', not lowercase. This change should make it a lot easier to read/parse the command file since lowercase 'p' is already used for drawing polygons.
A
Question:
Fluid GUI code is UGLY!!
Answer:
Yes it is!! The underlying principles are the same as in Java though. that is, if you want to handle an event, you register an event handler (one in this case). Note that the event handler is not a member function in the case of fluid. This makes the code ugly since this non-static event handler is called from the GUI instance. The non-static handler can call any methods or functions it sees fit though.
Question:
I don't remember c++
Answer:
I have included a few good references above (including a bit of refresher code).
Question:
Hi Arnold, I am having the forward referencing problem you described in class today. Suppose I have a function void A::f(B *b) { } and void B::g(A *a) { }. The compiler gets confused because it doesn't know which function to compile first. Did you work around it or is there some trick that I can use? Thanks.
Answer:
You need a forward reference to the class. Have the definitions appear as follows... Note that this may happen in a single include file or as a result of including files in the right order. class A; // Trust me, A is a class (to be defined in a bit) class B { A *myA; void fn1(A *arg); } class A{ void fn2(B *arg); } <xmp> </dd> <dt><font color=red><b>Question:</b></font></dt> <dd> What about that Fl_Color_Chooser? </dd> <dt><font color=green><b>Answer:</b></font></dt> <dd> Actually, try fl_color_chooser, and make sure you set the initial values to something reasonable otherwise you will get a wierd initial choice of colors. </dd> <dt><font color=red><b>Question:</b></font></dt> <dd> Can I have a sample test suite? </dd> <dt><font color=green><b>Answer:</b></font></dt> <dd> Yes, you can find one <a href=http://www.cs.toronto.edu/~kyros/courses/320/Assigns/assign1/test.tar.gz>here</a> The following is from the StGeorge 320 newsgroup... <xmp> You can test your implementation using the following tarfile: http://www.cs.toronto.edu/~kyros/courses/320/Assigns/assign1/test.tar.gz The tarfile contains three files: - test.ppm a test image in ppm format (you can view it using 'xv') - test.v the same image in vista format - test.cmd a set of drawing commands The image is 256x256 and contains a few lines, a circle and a rectangle. The drawing commands attempt to mimick the drawings in that image (but with different colors). Note that if the image is magnified in your panel (ie. it is drawn on a panel larger than 256x256) a pixel in the image will not have the same size as a pixel on the opengl panel. This means that the lines you draw through opengl may be thinner than those in the (magnified) image. This is normal.