Developing Graphics Program with UWBGL

Essentials of Interactive Computer Graphics: Concepts and Implementation

 

 


 

 

Working with (or Modifying) UWBGL:

 

Question: Where/What are the headers files I should use for working with UWBGL and where are these files included in the given tutorials?

 

Answer: All the tutorials from Chapter 6 on are based on two libraries: UWBGL_MFC_Lib and versions of UWBGL_D3D_Lib. The header files for these:

  • UWBGL_MFC_Lib1: uwbgl_MFC_Lib1.h
  • UWBGL_D3D_Libv: uwbgl_D3D_Libv.h (where v is a number between 1 to 17, for version)

These two files are included at the end of the pre-compile header file: StdAfx.h in each tutorial projects.

 

 

Question: I have added a new class (with new .cpp and .h files) into the UWBGL library, and the library compiles with no errors. However, the compiler complains about undefined symbol when I try to instantiate an object based on my class. What is going on?

 

Answer: You need to add the header file of your new class into the library header file. In Visual Studio, go to the library project (for example, if you are working with library version 5: Lib5):

  • UWBGL_D3D_Lib5: under the Header Files folder
  • You will find: uwbgl_D3D_Lib5.h

You need to add the header file of your new class into this file.

 


Drawing with DrawHelper:

 

Question: I want to coordinate drawing between WindowHandler and my Model, so in my WindowHandler:

void CDrawAndMouseHandlerWorld::DrawGraphics() {

BeginDraw();

// get ready to set up initial transform in the WORLD matrix

UWBD3D_DrawHelper draw_helper;

UWB_XformInfo xform;

 

draw_helper.InitializeModelTransform();

draw_helper.PushModelTransform();

// set xform

xform.SetUpModelStack(draw_helper);

 

//draw the model

theApp.GetModel().DrawModel();

}

 

And in my Model:

void CModel::DrawModel()

{

UWBD3D_DrawHelper draw_helper;

draw_helper.PushModelTransform();

m_root_node.GetXformInfo().SetUpModelStack(draw_helper);

m_root_node.Draw( draw_helper.GetLOD(), draw_helper );

 

Why is it I cannot see any of the transformations performed in by DrawGraphics() function?

 

Answer: DrawHelper class uses a local instance of MatrixStack to keep track of world transformation. Each separate instance of DrawHelp has its own matrix stack. In this case, there are two separate and independent instances of DrawHelper (the red and the green ones), and there are two independent matrix stacks!

 

Solution: Declare a DrawHelper in the Model. In the above case, make sure both WindowHandler and Model both uses this same instance for setting up matrix.

 

In general: if a sequence of operations are sharing the same transformation results then they should share the same DrawHelper.

 

 

General:

 

Question: Should I use math3d++ (e.g., vec3) or the D3D library (e.g., D3DXVECTOR3D)?

Answer: Either one will do, UWBGL uses math3d++ simply because we must support both D3D and OGL. In general, the tutorials try to use math3d++. The important thing is to use a math library whenever possible. It greatly simplifies your code and makes your program much easier to understand.

 

 

 

 


 

This material is based upon work supported by the National Science Foundation under Grant No. 0442420. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the Nation Science Foundation.

The refinement of this course material is supported by a grant from Microsoft Research under the Computer Gaming Curriculum in Computer Science RFP, Award Number 15871.


Kelvin Sung  |   Kelvin Research Page  |   CSS Home  |   UW Bothell  |   UW Seattle



18115 Campus Way NE
Bothell, WA 98011-8246

(425) 352-5000
(425) 352-5303 (TDD)

*

University of Washington, Bothell
Copyright 2008, UWB. All rights reserved.
Comments to Kelvin Sung: ksung@u.washington.edu
Information about UWB: uwbothel@u.washington.edu
Last updated: Jun 2008 KS