Slashdot Mirror


Linux Graphics Programming with SVGAlib

A technical book with personality? Chromatic claims just that in his review of Linux Graphics Programming with SVGAlib. If you're a graphics guru, or are looking for a book that describes a lot of the low level functions that put pretty pictures on your screen, this one sounds like one you should at least consider.

Linux Graphics Programming with SVGAlib author Jay Link pages 513 publisher Coriolis Open Press rating 7.5 reviewer chromatic ISBN 1-57610-524-5 summary A tour of the SVGAlib library, designed to help you create new Linux applications or port existing applications to Linux.

The Scoop XFree86 isn't the be-all end-all of Linux graphics. Consider the embedded space, or dedicated turnkey apps, or console games, or... Jay Link introduces readers to SVGAlib in a flawed, but entertaining and useful tutorial. (If you've never heard of SVGAlib, it's a Linux-specific graphics library providing fast functions for full-screen use, joystick and keyboard input, and even 3D. It's undergone development and refinement for a few years, and it's easy to use but still powerful.) What's to Like? More than a listing of SVGAlib functions and their uses, the author covers a wide scope of graphics topics. They're all explored in the context of SVGAlib, but the basic principles apply to other libraries. Monitors display information the same way, polygons and primitives have the same algorithms, and something has to save the background before you draw something over top of it. The first three chapters cover libraries, competing tools, graphics modes, hardware fundamentals, and the primitive primitives. It's a good introduction to graphics in general.

Starting simply, SVGAlib functions obviously build on each other. For the most part, so do the chapters. Once you've mastered setting pixels and drawing lines, it's time to draw circles and arcs or fill in your shapes. You'll want fonts after that, and then animation. Basically, this is a book you can read straight through with little trouble. Link travels a lot of ground -- input devices, 3D development, raytracing, animation, and user interfaces. Appendices B and C list and describe the vga and vgagl functions of SVGAlib. Though usually short, the descriptions have information enough to be useful to a casual programmer, often listing caveats and gotchas.

The most enjoyable part of the book, though, is the author's enthusiasm. It's obvious he had great fun in writing the book, and that shines through his prose. It's infectious -- he's found something cool and wants to share that with the world. There's room to grow, too. The last two code chapters build a simple paint utility and discuss ways it could be improved. If you've done your homework up 'til that point, you should be able to complete it and add more whizbang features at will.

What's to Consider? The author's pretty casual. It's refreshing to read a technical book with personality. If you're a big X fan, though, or a closet Microsoft sympathizer, you might disagree with Link's rhetoric in a couple of spots. Of course, those aren't the people likely to pick up the book, leaving the rest of us free to chuckle along with the personable prose.

Two things might put you off if you're considering the purchase. First, it's not precisely a tutorial. Some chapters have pages of source code with little actual commentary. If your C-reading skills are low, be prepared to do a lot of homework to figure out what's going on. Second, there's also not a lot of explanation of the math involved. In places (geometric shapes, advanced primitive drawing, ray tracing) either dig up those old trigonometry notes or a battered copy of Michael Abrash's Zen of Graphics Programming (recommended in the text). This isn't an exploration of specific graphics theory as much as an exploration of the library.

The only thing I really disliked was the book's formatting. As is usual with techie books, warnings and notes are interspersed throughout the text. In a few spots, there also are glossary-like definitions mingled with notes, text, and figures in a hard-to-read mess of words, lines, and icons. More consistency would improve the readibility. Having additional explanations would have helped, but most of the code is clear enough that the a-ha factor comes into play. (Moderately experienced programmers can read the accompanying code and description and things will click the first or second time through). The overall tone says, "Here are the tools, now go explore and play and have fun."

The Summary Somewhat experienced programmers with a decent math background will get the most out of this book. It's an entertaining look at a library I'd overlooked for quite some time. For a good introduction to SVGAlib (and a healthy dose of fun programming), check it out. Table of Contents
  1. Getting Started
  2. Graphics Basics
  3. First Programs
  4. Complex Shapes, Formulas, And Functions
  5. Color
  6. Shades, Fills, And Patterns
  7. Fonts
  8. Fractals
  9. Graphic Files
  10. Basic Animation
  11. Polygons
  12. 3D Images
  13. Raytracing And Photorealism
  14. Game Basics
  15. Using The Mouse And Joystick
  16. Landscapes
  17. A Look At Existing SVGAlib Applications
  18. Simple Paint Program
  19. Thoughts On A GUI
  20. Video Card Drivers
  1. GNU General Public License
  2. Libvga Functions
  3. Libvgagl Functions
  4. ASCII Character Codes
  5. Chipsets Supported By SVGAlib
  6. A Brief History of SVGAlib
  7. FAQs And Troubleshooting

Purchase this book at ThinkGeek.

14 of 42 comments (clear)

  1. Ok...... by xtermz · · Score: 2

    great. Ive always wanted a book on svgalib, but that was like 4 years ago. Is anybody even supporting svgalib? I dont use it because only X supports my graphics card. If the guy wanted to make a decent effort to write a book, I think a GTK or QT manual would be much more timely.
    I can see where this would be useful though, maybe coding apps for older machines, and possibly make some cheap embedded stuff (kiosks, etc etc.). But does any applications still rely upon svgalib ?

    "sex on tv is bad, you might fall off..."

    --


    I lost my concept of community when my community lost all concept of me.
  2. SVGAlib is better than X. by AFCArchvile · · Score: 2
    Just try playing original Quake on a Linux box sometime; squake is much faster than xquake. Unfortunately, Q3 only runs inside X; however, that doesn't matter at all if you're running a server.

    I wish that there was a graphics and sound API for Linux that had the low-latency properties that DirectDraw and DirectSound do under Windows. From what I've seen, SVGAlib and OSS are the only comparable ones, and they still need work.

    --
    "Ancillary does not mean you get to rule the world." --U.S. Circuit Judge Harry Edwards, speaking to the FCC's lawyer
    1. Re:SVGAlib is better than X. by Emil+Brink · · Score: 3

      Sounds to me like OpenGL using the DRI stuff with XFRee86 4.0 should be pretty low-latency, since that makes your app talk directly to the hardware. Oh, and modern 3D hardware sure beats (S)VGA when it comes to doing stuff on screen. (And no, I'm not karma-whoring with those links) ;^)

      --
      main(O){10<putchar(4^--O?77-(15&5128 >>4*O):10)&&main(2+O);}
    2. Re:SVGAlib is better than X. by Leimy · · Score: 2

      Try SDL. It works through direct X in windows. Its cross platform portable library. www.libsdl.org

  3. Linux Specific? by slim · · Score: 2

    Linux Specific?

    I know for a fact there's a BSD port of SVGALib.

    For portability, though, GGI might be a better bet.
    --

  4. What about an svgalibd daemon? by tchuladdiass · · Score: 2
    One of the major complaints about svgalib is that if a program does nasty things and doesn't clean up properly, or crashes, it can leave your display hosed. What I thought about doing is creating an svgalibd that would link to svgalib, and a replacement svgalib that impliments all the functions as calls to svgalibd through sockets or shared memory. Therefore, svgalibd can act as a traffic cop, and the individual user programs wouldn't need to be suid root.

    Does anyone see any reason why this wouldn't be practicle?

    1. Re:What about an svgalibd daemon? by PD · · Score: 2

      It would work really well, but why not just make an X server that uses SVGALIB as the display driver? That would amount to the same thing, PLUS you could run all your X apps through the thing.

  5. Use SDL and forget about X, GGI, SVGAlib, etc. by ianezz · · Score: 4
    SDL at http://libsdl.org is a LGPL library implementing a layer that can use X, SVGAlib, GGI, the Linux kernel framebuffer, and Windows and BeOS graphics systems as a backend. It is well documented, easy to use, provides a nice framework to manage input events and sound, and it is here to stay for a looong time. There are Free (as in speech) extensions to manage even more types of audio files and images, MPEG video, TrueType font rendering. There are also a couple of nice toolkits providing buttons, textfields, lists, checkboxes, etc.

    On the ohter hand, SVGAlib is SVGAlib, and as of today, I'm more inclined to trust an XFree86 X server running as root than whichever app running as root and messing around with SVGAlib. But your mileage may vary, of course.

  6. GGI dead? by OlympicSponsor · · Score: 2

    I learned a bit about GGI and thought it was pretty neat. Later, I had to write a graphics program so I looked them up again--no new release in over a year. Ummmm....yeah. I see activity on the mailing list, but they don't appear to be putting anything out (or updating the docs on the website).

    I used it anyway because I wanted something right away, but I agree with another poster that OpenGL is probably the way to go now.
    --
    An abstained vote is a vote for Bush and Gore.

    --
    Non-meta-modded "Overrated" mods are killing Slashdot
    (Hey Ryan! Here's your proof!)
    1. Re:GGI dead? by Evangelion · · Score: 2
      from http://www.ggi-project.com/

      2000-10-15

      XGGI 1.6.2 has been released. Summary of changes:
      • Now uses XFree 3.3.6 as it's base.
      • Don't try to open a new VT by default when running on a console-based target. This used to cause problems when running XGGI without any root privileges.
      • Italian, Polish and Norwegian keymaps added.
      • Save and restore all screens in a multihead configuration upon VT switching.

      Yeah, it's not the most current, but i wouldn't say stagnating...
      --

  7. Utterly useless by Idaho · · Score: 2

    Just something everyone has been waiting for: as if X isn't enough hassle to set up right (OK, so modern distro's have solved this problem for the most of it), add in another, seperate library that does about the same things!

    I mean, what can SVGALib do that X can't? If you find something, implement it in X, tadah, it supports many SVGA cards at once!

    I used to play the SVGALib version of Koules, that game sure was a lot of fun :-)
    However, it was quite hard to get SVGALib to work at all.

    --
    Every expression is true, for a given value of 'true'
    1. Re:Utterly useless by Anonymous Coward · · Score: 3
      I don't understand how some people here have the audacity to put down a project that doesn't quite fit their idea of something that is worth doing.

      Please, no more comments such as:
      do we really NEED that

      or

      why don't you spend YOUR spare time coding this OTHER project, which I, in my not-so-humble-opinion, think is much more interesting than the one you are working on?

      These posts are rude, and very unproductive.

      Regarding this book:

      • Nobody is making you read it.
      • Your opinion of a worthwhile book will differ from another's opinion of a worthwhile book.
      • If you think SVGALIB is a waste of the author's time, then you need definately need to shut up and write your own book on what IS important (to you).


        This book promotes learning, some people will find it useful, so STFU.
  8. Hmm... by cr0sh · · Score: 2

    While I haven't had time to implement anything yet in my homebrew VR pursuit, I have spent time trying to decide on what I want to use for the display.

    So far, my choice has settled on some sort of full-screen X window interface (maybe using SDL or GGI). The driver hardware for my HMD is a VGA->TV converter, and I need a 640x480 screen @ 60 Hz refresh to get the converter working. I once got X doing it on an old Redhat box, but I lost the config settings. So, I know it is possible.

    I am not sure what it would take to go "full screen" with X, or if I could use something else to drop into that mode. I like SDL for its cross platform use, plus the fact that it can work console or in X. IIRC, it also supports OpenGL, which I will need for my work.

    The one thing I didn't like about SVGAlib was the root access issue. Has this been corrected yet, or is it just because it needs to access the hardware in such a direct manner, that it does this? SVGAlib, otherwise, would probably be fine for me to use...

    I support the EFF - do you?

    --
    Reason is the Path to God - Anon
  9. svgalib 1.9.6 and root access by kapheine · · Score: 2

    With the current development version of svgalib, 1.9.6, you no longer need root access. Instead, it uses svgalib_helper, a linux kernel module, along with /dev/svga[0-9]. The only thing you would need root for is the mouse, unless you chmod 666 it. This version of svgalib can be gotten from here.

    --
    -- kapheine