Live in southern Ontario? Attending dinner meetings is free.
PegaSoft's April Dinner Meeting
Date: April 21, 2005 at 7:00 pm
Location: Orwell's Pub
Attendance
Ken B, Mel W, William P, Scott E
Mike H had a conflict with work.
Attendance was down due to another talk on the Asterisk project.
Meeting BusinessAnnual Membership Renewals
PegaSoft memberships are $45.00 per year. Although you don't need to be a
member in order to join the mailing lists or attend our monthly dinner
meetings, membership entitles you to discounts on PegaSoft events and the
opportunity to participate in PegaSoft projects and teach in our workshops.
Membership also allows you to attend our annual PegaSoft Summer Retreat.
Members must sign the PegaSoft Employee Conduct Policy/NDA.
Deferred.
Open Forum - Linux in the NewsLinuxWorld Canada was on April 18-20.Linus Torvalds switches from BitKeeper to his own Git project. [CNet]ACM President David Patterson says the United States' poor showing in the
ACM International Collegiate Programming Contest. [ACM TechNews]Nero for Linux released. [Newsforge]PegaSoft Member ProjectsBusiness Shell (BUSH) (Ken B)
Graphing module in progress. Working on pattern fills.
Lease and Rentals (Room Booking) Project
The client has canceled this project.
[Discussion not included.]
Open Source Promotion during Next Federal Election
Scott suggested that PegaSoft create T-shirts promoting open source as an
election issue. Most government departments are completely Microsoft. William
said he was passed up for a large contract with the government because they
required Windows-specifically, even though the Linux solution was Windows
compatiable and met all requirements.
Discussion: Simple DirectMedia Library (SDL) (Ken Burtch)
Ken developed DrawTools, an assembly language gaming toolkit for Apple IIgs
researching integrating SDL into Business Shell (BUSH)
- before 1999 game programmers used libsvga (that is, "SVGA lib")
- must run as root to access the screen hardware
- draw lines, rectangles, basic text, mouse
- drivers only for popular graphics cards
- no longer included with Linux distributions
- Simple DirectMedia Layer (SDL) is at http://libsdl.org
- created by Sam Lantinga, lead programmer of the defunct Loki Entertainment
- licensed under the LGPL
- actually a set of several libraries
- provides low-level hardware access for Linux, Mac or Windows (Direct X)
- access to video, audio, mouse, joystick, and thread interface
- more functionality is provided by third-party libraries
- interfaces for many languages including Ada, Java, Perl, PHP, Python
- basic interface
- uses a variety of SDL-specific data types like SDL_Bool, Sint16
- both simple and complex: doesn't do much but gives you good, portable low-
level control
- various hardware interfaces turned on when SDL is started
- video
- SDL is not a drawing library (no lines, text, image effects, etc.)
- a screen dot is called a pixel ("picture element")
- specify screen resolution when started: will give you a window (or full
screen) meeting or exceeding the resolution you requested
- you don't draw directly on a screen or window
- a drawing area containing pixels called a surface (or a framebuffer)
- mimics various graphics hardware in size, endian-ness and bit layout
- hardware surface: the surface parallels what is seen in a screen or window
- software surface: an off-screen drawing area or a loaded picture
- loaded pictures are in the file format, not the screen format so you
have to convert pictures after load to display them
- "flip" the surface to copy the display the surface
- functionality
- basic translation function
- get information about the graphics card
- calls for hardware accelerated blit (block image transfer, that is, draw
a rectangular image)
- SDL_image aux library loads and handles JPG, GIF, PNG, BMP et al files
with transparency (does not save in these formats)
- transparency
- surfaces have an "alpha channel" that indicates level of transparency
- a surface can be designated OpenGL but you lose all the low-level SDL
features
- no fonts. There is a third-party SDL_ttf true type font library but is
not included with most distributions.
- third-party BUILD 3D engine (Duke Nukem 3D, etc.) ported to SDL
- many third party game engines
----------------------------------------------------------------------
Example: drawing a pixel (from http://libsdl.org)
void DrawPixel(SDL_Surface *screen, Uint8 R, Uint8 G, Uint8 B) {
Uint32 color = SDL_MapRGB(screen->format, R, G, B);
if ( SDL_MUSTLOCK(screen) ) {
if ( SDL_LockSurface(screen) < 0 ) {
return;
}
}
switch (screen->format->BytesPerPixel) {
case 1: { /* Assuming 8-bpp */
Uint8 *bufp;
bufp = (Uint8 *)screen->pixels + y*screen->pitch + x;
*bufp = color;
}
break;
case 2: { /* Probably 15-bpp or 16-bpp */
Uint16 *bufp;
bufp = (Uint16 *)screen->pixels + y*screen->pitch/2 + x;
*bufp = color;
}
break;
case 3: { /* Slow 24-bpp mode, usually not used */
Uint8 *bufp;
bufp = (Uint8 *)screen->pixels + y*screen->pitch + x;
*(bufp+screen->format->Rshift/8) = R;
*(bufp+screen->format->Gshift/8) = G;
*(bufp+screen->format->Bshift/8) = B;
}
break;
case 4: { /* Probably 32-bpp */
Uint32 *bufp;
bufp = (Uint32 *)screen->pixels + y*screen->pitch/4 + x;
*bufp = color;
}
break;
}
if ( SDL_MUSTLOCK(screen) ) {
SDL_UnlockSurface(screen);
}
SDL_UpdateRect(screen, x, y, 1, 1);
}
- problem: example doesn't take into account endian-ness of system
- you must track whether a surface is locked: a common source of problems
----------------------------------------------------------------------
- drawing a line requires
- building a pixel colour in the graphic format of the surface
- calculating the coordinates of the pixels to light
- calculating the byte position of the pixel on the surface
- writing the pixel to the surface without disturbing adjacent bytes
- audio
- load and play WAV files
- set the master volume
- play tracks on a CD-ROM (on Linux, this can be accomplished using ioctl()
on the CD-ROM device)
- more powerful third-party audio libraries available
- event handling
- must periodically poll for new events
- simple mouse and keyboard queue
- summary
- strengths
- portable to many systems
- access to accelerated graphics features
- light weight
- weakness
- need third-party libraries or custom coding to do anything useful
- mode errors such as surface locking or resolution conflicts
- no 3D coordinates
- should fonts should be built-in, even if a simple bitmapped system font
Next Dinner
Unless otherwise notified, the next dinner meeting is Thursday, May 19, 2005
at Orwell's Pub.
« Truth Humility Communication Nobility Freedom Purity
Excellence Right Support Courage Compassion Quality Honesty Trust
Cooperation Challenge Education »
PegaSoft Canada - A Linux Association Since 1994