Article View: rec.games.programmer
Article #686Graphics help/advice
From: Timothy E Scott
Date: Sun, 13 Sep 1992 02:54
Date: Sun, 13 Sep 1992 02:54
60 lines
3440 bytes
3440 bytes
This is my first post here...so here goes everything: A few months ago I picked up Lee Adam's _Graphics in C: Animation and Simulation_ and gained an large interest in graphics programming for the PC (the book, on the whole, sucked...I'm new to graphics programming and he didn't take too much time justifying/explaining his algorithms.) From there, I found a book at the library by L. Ammeraal entitled _Programming Principles in Computer Graphics_ (which also used C for its examples.) By far, this book was more explanatory in the area of graphics I'm interested in -- that being three dimensional. My interest stems from a friend and I collaborating on making a 3-d space fighter game. I basically lifted a program straight out of Ammeraal's book (which draws a 3-d cube rotated/translated using spherical coordinates) and added animation. The program first sets to a nonvisible page, and either moves to a point, or draws from the current point to a given point. After drawing all lines, it flips the nonvisible page visible, switches operations to a nonvisible page, erases it, and begins the process again, rotating both the angle factors one degree at a time. This, BTW, is only a wire frame model -- no hidden lines, shading etc... The problem is the algorithms, in both books, are WAAAAAAAY too slow. Here are some ways that I've tried to get around this: 1) Created two 180 element arrays sine and cosine, which are equal to the sine/cosine of an angle times 10000. Any references to an angles sine/cosine therefore are not computed. 2) As a result of scaling up the sine/cosines, I was able to eliminate any need for floating point operations (which GREATLY improved speed -- but still fails to draw complex, many-lined objects very fast.) 3) The points to moveto and drawto (as I named the procedures) are stored in memory and referenced through the use of a pointer. I have no idea if this improves performance or not, but it seemed 'like the right thing to do.' :) The drawback to 2) is that now I'm doing more LONG operations to compensate, and I'm sure those slow down computations a bit, but at least not as much as floating point operations would. Now, I'm looking for any suggestions/pointers to books/algorithms/ whatever that'll clue me in on how to make things go faster and look nicer (ie shading and line hiding) -- anything besides learning to program in 80x86 assembly (which I'm afraid I might have to end up doing anyway.) Any help anyone will be able to give me will, of course, be GREATLY appreciated. Thank you.. --tim -- ------------------------------------------------------------------------------ uunet!plains!tscott OR tscott@plains OR tscott@plains.nodak.edu "Call collect!" ------------------------------------------------------------------------------
Technical Details
Message-ID:
<20298@plains.NoDak.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!wupost!sdd.hp.com!uakari.primate.wisc.edu!usenet.coe.montana.edu!news.u.washington.edu!plains!plains.NoDak.edu!tscottShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!wupost!sdd.hp.com!uakari.primate.wisc.edu!usenet.coe.montana.edu!news.u.washington.edu!plains!plains.NoDak.edu!tscott From: tscott@plains.NoDak.edu (Timothy E Scott) Newsgroups: rec.games.programmer Subject: Graphics help/advice Keywords: algorithms 3-d Message-ID: <20298@plains.NoDak.edu> Date: 13 Sep 92 02:54:22 GMT Sender: Unknown@plains.NoDak.edu Distribution: na Organization: North Dakota Higher Education Computing Network Lines: 60 Nntp-Posting-Host: plains.nodak.edu