======================= 0) > Remember that you can not do your work on > copland.udel.edu because it is the web > server of the University. You can do your > work on strauss.udel.edu, mahler.udel.edu, > etc. > ======================= 1) Chandra, I got my GL Line to draw on the PC by adding glFlush(); after glEnd(); Thought you might like to know, YYY ======================= 2) Try to ``save the file'' rather than ``cut and paste'' the makefile. > Hi, I went to the website and downloaded the makefile for composers and > when I tried to run it with 'make' I get this error message > "make: Fatal error in reader: Makefile, line 31: Unexpected end of line > seen:". I don't know what to do. ======================= 3) To solve the problem, you can use the following function to get the window's height and width. int glutGet(GLenum state) GLUT_WINDOW_WIDTH Width in pixels of the current window. Height in pixels of the current window. For example, int height = glutGet((GLenum) GLUT_WINDOW_HEIGHT); XXX > I was doing the mouse input for Project 3, and I found everything > was being drawn upside down. I realized that this was because of the > differences in the coordinate systems. I've come up with a temporary fix, > which is to just subtract the starting window height (400). However, if I > change the window size, this solution no longer works. I was wondering if > there was a GL function that would grab the current window height or if > there was some other way to make sure the y-coordinates are correct. > Thanks, ======================= 4) YYY, I think you allocated some memory using malloc and trying to assign the returned value to a pointer vaiable of of type Listnode. Since malloc (or similar fucntions) always return a pointer to void, the C++ or C compiler objects this assigment. So you should typecast. Do this: assume t is declared as Listnode * t; then t= (Listnode *) malloc( 100 * sizeof(Listnode)); should allocate a space for 100 Listnodes and assigns the address to the pointer variable t. Does this help? If not, please e-mail me the program so that I can compile it and try to tell what the problem is. YYY wrote > > > I'm having a terrible time with these data structures on this > assignment... It's been a long time since I've written any C code. > > I keep getting "Error: Cannot assign void* to Listnode*" > > Are either of you available this weekend to give me some pointers? > (pun intended) > > YYY > ======================= 5) > Hi, I'm doing the mid-circle operation and I was wonderint if the radius > we are passing in is suppose to be integer or do we pass in a float. > Because if it is a integer p0 will be 1 - r if it's a float it'll be 5/4 > - r. Either way is fine. Just tell the user ahead of time. chandra ======================= 6) > The hello program is not executing > properly. Actually, it doesn't run. When executed with the makefile > for the composers , the following error is printed. > hello > ld.so.l: hello: fatal: libglut.so: open failed: No such file or directory. This happens when running the process as follows: hello &. Do not run the program in the background. i.e, don't use `&' when running the program. ======================= 7) > While implementing the circle algorithm , should it be implemented such > that a full circle be drawn ? If the user inputs the center as (0,0) , > then only the circle in one quadrant appears , right ? Use the window that is created in the hello program to set up your coordinate system. The window size in the program is: 400, 400. So that is your entire space. You can divide it into 4 quadrants. ======================= 8) 1. create a file .classrc-2017 in your home directory 2. put the following line there source /home/base/usrc/135/79217/.classrc 3. start every session with the command newgrp 2017 This will ensure you use project 2017 for this work and have all shell settings correct. ======================= 9) A suggestion to those in class who are struggling with linked lists. - Chris Haase (Fall '2000) Try . http://www.sgi.com/Technology/STL/ http://www.sgi.com/Technology/STL/List.html #include #include #include bool operator<(const list& left, const list& right) {return (left& left, const list& right) {return (left==right);}; typedef list::iterator iter; // Main int main() { iter place; int i, length = 15; list myList; for(i=0;i Hi Dr. Chandra. I need to convert the hello.c and make files, etc to C++ > since I am not too familiar with C. I tried to change some things before, > but just confused myself and messed up the file. Could you tell me what I > should change in the various files so I can code specifically in C++? > Thanks. In my understanding, all you need to do is change the CC line in the makefile to invoke a C++ compiler: either g++ or CC. Both are available on strauss. You may get some warnings or syntax errors if some features of hello.c do not comply with the latest standard, but these are pretty easy to hush or fix. In general, C++ is a superset of C, so whatever you do in the latter should be supported by the former. ======================= 11) > Do you use TeX for your class notes? If so, could you send me a > sample TeX file for laying out matrices? I want to start using > TeX for my homework assignments. Thanks! > > Very commendable!!! Use amsmath and the bmatrix environment... Here's an example: \begin{bmatrix} y_1 & 1 & \ldots & 0 \\ \vdots & & \ddots & \\ y_l & 0 & \ldots & 1 \end{bmatrix} -Pavel Laskov ======================= 12) Drawing polygons in OpenGL: void draw_puzzle(){ glColor3ub (0, 255, 0); /* green */ glBegin (GL_LINE_LOOP); glVertex2i(50,50); glVertex2i(50,200); glVertex2i(200,200); glVertex2i(200,50); glVertex2i(70,50); glVertex2i(70,180); glVertex2i(180,180); glVertex2i(180,70); glVertex2i(90,70); glVertex2i(90,160); glVertex2i(160,160); glVertex2i(160,90); glVertex2i(110,90); glVertex2i(110,140); glVertex2i(140,140); glVertex2i(140,110); glVertex2i(130,110); glVertex2i(130,130); glVertex2i(120,130); glVertex2i(120,100); glVertex2i(150,100); glVertex2i(150,150); glVertex2i(100,150); glVertex2i(100,80); glVertex2i(170,80); glVertex2i(170,170); glVertex2i(80,170); glVertex2i(80,60); glVertex2i(190,60); glVertex2i(190,190); glVertex2i(60,190); glVertex2i(60,50); glEnd (); } ======================= 13) (Triangle) Polygon fill in Open-GL: glBegin(GL_TRIANGLES) glVertex2i(0,0); glVertex2i(100,100); glVertex2i(0,100); glEnd() If there is more than three vertices it draws more than one triangle, which is handy for triangulation routines. If the number of specified vertices is not divisible by three, one or two extra ones are ignored. In case of polygon-fill, use GL_POLYGON. -- ======================= 14) > > > > I've been playing with this idea of trying to access the 3D vertices stored > > in a linked list by trying to calculate their positions and and retrieve > > them directly rather than traversing the list. I'm using the stl > > classes that were suggested in the FAQ's. > > My x,y,z coordinates are stored in a struct which contains just three > > floating points x,y,z. Those are then strung together in a linked list. What > > I've tried so far is to get the pointer to the first element through an > > iterator that I defined. > > > > typedef list::iterator tripletiter; > > > > Since I know that these structs will always be the same size I figured > > there's a good chance that they are stored in contiguous memory. I realize > > this is a pretty shaky assumption. My idea was to just add the > > > > position * sizeof(DataTriplet) > > > > to the pointer to the beginning of the list. > > > > Needless to say it doesn't work.... I don't know that that's the correct > > size to add or even if the object's are stored contiguously - since there > > have been no deletions from the list, it's likely, but there could be > > pointers all over memory. Also, since the pointers to the vertices appear in > > a random order, there's no way to step through them, you have to search for > > them. > > > > So I am back at square one... how to directly access objects from the linked > > list withough having to traverse the entire thing? I know this may not be > > directly related to the course (maybe it's more of a data structures > > question) in the sense that it's easy enough just to declare a huge array so > > we can accomplish our goals, but it does present a practical problem - using > > an array doesn't allow you to draw as many 3d polgyons as you like - and > > wastes memory for small objects. > > > > Do you have any suggestions for approaching this problem... should I be > > using a different data structure like hash table? Is there a way to do this > > with linked lists that I'm missing? > > > > Thanks, > > Glen > > > > > > --- > You're right in your critique of the contiguity assumption: this is a sure way to > get into a trouble. I think the answer to your questions is: use an array (or its > 'vector' equivalent in STL). If you need *random* access to data use a *random > access container* which the array is. With lists you will always have to traverse > the list to get to an element because it is a sequential container. > > If there are other factors that are into this design issue tell me more about > them. > > -- > Pavel aah, that's it! Vectors... I have only used Vectors in Java and didn't realize that they're right in the standard template library. That provides dynamic memory management AND random access of data. I'll give that implementation a go... Thanks Glen ======================= 15) > I am pretty much done with proj3 except that my images are distorted after > repeated rotations. I suspect that it is a rounding problem stemming from > the rotation matrix. How can I solve this problem? I fixed it by making my vertices floats and using glVertex2f 100% Rayon ======================= 16) > the algorithm we have for doing scan conversion, doesn't always plot the > points that are on the polygon's lines itself, correct? so our program > should draw the polygon first, and then use the algorithm to fill it in, > correct? > thanks, > Brian thats correct! - chandra ======================= 17) > have a question for you. I used my first project (hello.c) as a starting >point for my project 2, and simply added functions and data variables as I >needed them. I can use either dda_line, midpoint_line, or gl_line to do >the actual drawing on the screen for my algorithm, but my question is >this. Whichever I decide to use, can I take out the iteration information >from project 1? Otherwise it will be drawing every line 200 times and >timing it as it fills the polygon. Thanks. you do not need to do timing in this project. but a note to those who put the timing code directly into their line drawing functions of project1, timing a functions execution is regarded at the entire amount of time the function takes to do its job. start timer loop # of iterations call function end time result = time / iterations in the future, try to avoid putting timing analysis directly inside of the function that is being tested. -chris ======================= 18) I have recv'd multiple questions regarding the scanline implementation in the book. The only thing i can say is that I would prefer not to see a verbatim copy of the code from the book. Use the code to get an understanding of how to possibly inplement the algorithm. the books code is overly complicated and unorganized. Some Tips (if you haven't already discover their need) STRUCTURES. you may want to encapsulate all of your data into one object a POLYGON will have a few variables associated with it, so why not put them all in one variable. It will need to have an array of its verticies, (VERTEX can and should also be a structure ... x,y) This array should be dynamically created.. here is a possible method /* requires that the data parameter be initialized to NULL before calling the function will otherwise fail sizeof(char0 is = to one byte, an int is 4 bytes so a static array :: int A[10]; // which is 40 bytes is the same as char *A = NULL; allocateBytePtr(A,10*4); A[3] = 9; // */ void allocateBytePtr(char* &data, int size) { if(!data) // Make sure it was cleared first { data = (char *)calloc(size+1, 1); if(!data) { printf("allocateCharPtr(): Error allocating memory!\n"); exit(-1); }; } else { printf("Trying to allocate memory to a nonempty pointer!\n"); printf("Memory leak possible, exiting ... \n"); exit(-1); }; return; }; void freeCharPtr(char* &data) { if(data) { free(data); data = NULL; }; return; }; It will need an Edge stucture of start and end verticies which will be 2 ints that are the index value into the vertex array... FILE FORMAT 3 <-- 3 total verticies 5 5 <-- vertex 1 10 10 <-- vertex 2 15 15 .... 1 2 <-- read in till end of file for the edges 2 3 3 1 http://www.cis.udel.edu/~chandra/640/Data/ has other sample files to test with. -Chris ======================= 19) How to Grab the figure and print out? You can use the utility 'xv' to grab the contents of a window and save it as a postscript file, to be printed out. 1) Type 'xv &' at the prompt, click on the 'Grab' button, 2) click on 'Grab' again, and then click inside the OpenGL window. 3) click 'Save', and choose postscript as the file format. You can now print it as an ordinary file. You can also try printing directly from xv. ======================= 20) Hi, chandra. i keep getting this error and i don't know why. trans.c: In function `void mouse(int, int, int, int)': trans.c:225: warning: implicit declaration of function `int gl_line(...)' Undefined first referenced symbol in file gl_line trans.o ld: fatal: Symbol referencing errors. No output written to trans it says it's just a warning, but i can't get to execute it i've used gl_line( int, int, int, int) to draw the lines my line that generates the error is gl_line( vertex[count].xCoord, vertex[count].yCoord, vertex[count+1].xCoord, vertex[count+1].yCoord ); i don't know what the problem is.. thank you... > you can disregard my mail, cuz i know what the problem is.. > i didn't declare the function void gl_line(...) in the function > declaration part. ======================= 21) good question! Yes! chandra On Tue, 29 Oct 2002, Brian J. Gold wrote: (In Project-3) > When the user selects "Clear Screen" from the > right-clicked menu, should that "destroy" all > traces of all polygons currently in existence? > > -Brian > ======================= 22) Thank you, Jeff! - Chandra. Date: Tue, 4 Mar 2003 15:32:25 -0500 (EST) From: Jeffrey Watson To: Jeff Watson Cc: chandra@cis.udel.edu, qili@cis.udel.edu, Jwatson@cis.udel.edu Subject: Re: Modifications for XP of Hello.c Dr. Chandra, Here is my solution to the XP problems that you asked me for. Jeff Watson The issue with Hello.c not drawing for Windows XP seems to be within the Keyboard function and with you having to switch the focus of the windows in order to input your co-ordinates. I have two solutions to this problem. Marginally successful solution: - Move the variables holding x0,y0 x1,y1 to global variables. - Added glFlush() after gl_Line function This actually made a difference... somewhat... The program would draw a line roughly a 3rd of the time. Not very consistent, but distinctly better then drawing the line 0% of the time... Successful Solution: - Moved the variables holding x0, y0 x1,y1 to global variables - Added glFlush() after gl_Line function - Moved the input of the points to a seperate menu option - Modified menu to reflect current new options and current points This fixes it so that you have your drawing window as the focus window when you tell it to draw. Just hit 1, 2, or 3 and it draws a line with the two previously assigned points. The Hello.c backbone now draws my line 100% of the time for both the DDA and openGL lines. Given below are my new Menu and Keyboard Functions. **Added to Header Section under function Decl** int cx0 = 0, cy0 = 0, cx1 = 0, cy1 = 0; // x1 and y1 conficted with //predefined vars in math.h void menu (void) { /* This menu will be printed in the terminal window you used to invoke the program. However, when typing a menu option you MUST do so with the GL window in focus, NOT the terminal window. Then, if subsequent parameters are required, use the terminal window(e.g. x0, y0, x1, y1). */ printf ("\nMenu\n----\n"); printf ("Current points: (%d , %d) (%d , %d)\n", cx0, cy0, cx1, cy1); printf ("c) Input Co-ordinates\n"); printf ("1) DDA Line\n"); printf ("2) Midpoint Line\n"); printf ("3) GL Line\n"); printf ("4) Clear Screen\n"); /* Pressing the right mouse button will also terminate the program. */ printf ("q) Quit\n"); printf ("\nPlease enter your choice with the GL window in focus.\n"); } void keyboard (unsigned char key, int x, int y) { switch (key) { case 'p': printf ("x = %d, y = %d\n", x, y); break; case 'q': exit (0); break; case 'c': printf ("\nx0 = "); scanf ("%d", &cx0); printf ("y0 = "); scanf ("%d", &cy0); printf ("x1 = "); scanf ("%d", &cx1); printf ("y1 = "); scanf ("%d", &cy1); break; case '1': case '2': case '3': if (key == '1') dda_line (cx0, cy0, cx1, cy1); else if (key == '2') midpoint_line (cx0, cy0, cx1, cy1); else gl_line (cx0, cy0, cx1, cy1); glFlush(); break; case '4': glClear (GL_COLOR_BUFFER_BIT); break; default: break; } menu (); } ======================= 23) Yes, that is true. - Chandra > Date: Mon, 14 Apr 2003 12:20:52 -0400 (EDT) > From: Christopher Raymond Gillin > To: chandra@cis.udel.edu > Subject: Homework 4 > > Dr Chandra, > I am a little confused about the window-viewport transformation we are > doing for homework4. Is the first transformation we are to do is T(-xmin, > xmax) then the scaling then the second transformation? So since Umin and > Vmin are both zero and xmin and ymin are both negative, we are > shifting the imagine into the viewport but since both Vmin and Umin are > zero, there is no second transformation? So the image will be completely > within the viewport. > > Thanks for your help, > Chris Gillin