13.01.2013 Views

Hands On DarkBASIC Pro - Digital Skills

Hands On DarkBASIC Pro - Digital Skills

Hands On DarkBASIC Pro - Digital Skills

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Images with an Alpha Channel<br />

Introduction<br />

As we saw back in Chapter 30, some picture files contain an alpha channel which<br />

can affect the visibilty of the main image. This type of picture file, when used as a<br />

texture, affects the overall result obtained.<br />

Using Images with an Alpha Channel<br />

FIG-32.28<br />

An Image and its Alpha<br />

Channel<br />

LISTING-32.14<br />

Texturing with<br />

Alpha-Channel Images<br />

The image windmillshaped.tga contains an image and an alpha channel as shown<br />

in FIG-32.28.<br />

We've already seen that the SET OBJECT TRANSPARENCY statement affects<br />

the black area of an texture image, but the statement also controls how an alpha<br />

channel within an image affects the final texture.<br />

The program in LISTING 32-14 textures as cube using windmillshaped.tga. With<br />

the default settings, the alpha channel within the image has no effect on the texturing<br />

of the cube, but after a SET OBJECT TRANSPARENCY statement is used to<br />

modify the texturing, the alpha channel changes the final look of the cube.<br />

REM *** Set display resolution ***<br />

SET DISPLAY MODE 1280, 1024,32<br />

REM *** Create cube ***<br />

MAKE OBJECT CUBE 1,10<br />

REM *** Texture cube ***<br />

LOAD IMAGE "windmillshaped.tga",1<br />

TEXTURE OBJECT 1,1<br />

REM *** Rotate cube ***<br />

DO<br />

REM *** IF key pressed, use alpha channel ***<br />

IF INKEY$() ""<br />

SET OBJECT TRANSPARENCY 1,1<br />

ENDIF<br />

TURN OBJECT LEFT 1,1<br />

LOOP<br />

REM *** End program ***<br />

END<br />

Activity 32.25<br />

Image Alpha Channel<br />

Type in and test the program in LISTING-32.14 (texture14.dbpro).<br />

820 <strong>DarkBASIC</strong> <strong>Pro</strong>: Texturing

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!