Download GScnd v1.29 User Manual

Transcript
GScnd user manual v1.29 6 th November 2008
Some graphics cards cannot make a sprite which is wider than the screen using video
memory and they have to use system memory for the sprite instead. If this happens you will
get a warning message on the matlab console:>> WRN GPrim:gAddRAS System memory required for wide sprite.
Drawing into sprites
You can select a sprite as the destination for drawing commands using the cgsetsprite
command. From then on, all drawing commands will occur in that sprite. Remember to
reset the destination back to the offscreen area though when you are finished by issuing a
cgsetsprite(0) command.
cgsetsprite(Key)
This command selects the sprite with ID ‘Key’ for subsequent drawing
operations. If ‘Key’ is zero then the offscreen area will receive drawing
operations.
This next exercise creates and selects a sprite that is one quarter the size of the screen…
>> cgloadlib
>> cgopen(1,0,0,0)
GPrim v1.29 Compiled:Nov 6 2008 (GLib DirectDraw v7 DX9.0 Compiled:Nov 6 2008)
Display:640x480x32 72.85Hz
>> cgmakesprite(78,320,240,0,0,0)
>> cgsetsprite(78)
Then we perform some graphics commands…
>> x = [-50 0 50];
>> y = [-25 61 –25];
>> cgpencol(1,0,0)
>> cgrect(0,0,160,120)
>> cgpencol(0,1,0)
>> cgellipse(0,0,160,120,’f’)
>> cgpencol(1,1,0)
>> cgpolygon(x,y)
>> cgpencol(0,0,1)
>> cgdraw(-160,120,160,-120)
>> cgdraw(-160,-120,160,120)
>> cgpencol(1,1,1)
>> cgdraw(-90,0)
>> cgdraw(90,0)
>> cgdraw(0,-70)
>> cgdraw(0,70)
>> cgpencol(0,0,0)
>> cgfont(‘Arial’,14)
>> cgtext(‘To sleep, perchance to dream’,0,0)
The lines above employ all the drawing commands described up to now apart from one, the
cgdrawsprite command. We start by drawing a red rectangle with cgrect then draw a green
filled ellipse with cgellipse. Then we draw a yellow triangle with cgpolygon. All these
figures are centred on the centre of the sprite. Next we draw blue lines across the principal
diagonals of the sprite using cgdraw and we use cgdraw again to draw four white dots.
B.26