This site is no longer active and is available for archival purposes only. Registration and login is disabled.

line function does not work


line function does not work

Postby brendan » Jan 25, 2002 @ 12:40am

why can't I get the line function to work, e.g

line(120,160,120+cx,160+cx,0xFFFF);

it compiles ok, but nothing on the screen.... ?

using the same code for this works ok, so I know cx and cx are ok....

place_item(120+cx,160+cy,20,20, quit_btn_p,screen_buffer_p);
//this function takes a midpoint of an object (buffer) for placment and places it another buffer

place_item(dest buffer locx, locy, source sizex, sizey,source*, dest* (must be 240x320));

anyhow it does not work.... the line thingy.
User avatar
brendan
pm Insider
 
Posts: 451
Joined: Oct 23, 2001 @ 2:51am
Location: Hobart, Australia


line(s)

Postby brendan » Jan 25, 2002 @ 12:44am

and also, since there is no doco ;), whats the differnce between line, line_a and line_x ?

-brendan
User avatar
brendan
pm Insider
 
Posts: 451
Joined: Oct 23, 2001 @ 2:51am
Location: Hobart, Australia


Postby billcow » Jan 25, 2002 @ 1:23am

line_a uses additive blending (it adds the color to each pixel instead of replacing it). line_x plots using XOR (exclusive or... if you draw the same line twice with line_x the image will remain unchanged).

As for your first question, as the line function is written, it takes numbers in fixed point format. In other words, use the IFP(x) macro on each of the arguments.
User avatar
billcow
pm Member
 
Posts: 81
Joined: Jan 6, 2002 @ 12:22am
Location: Dryden, NY


Postby brendan » Jan 25, 2002 @ 1:37am

IFP gives the following error,

error C2296: '<<' : illegal, left operand has type 'double'

from this code:

line(IFP(120),IFP(160),IFP(120 + cos(radians) * 100),IFP(160 + sin(radians) * 100),0xFFFF);

anyhow according to the function dec, it take ints ?
User avatar
brendan
pm Insider
 
Posts: 451
Joined: Oct 23, 2001 @ 2:51am
Location: Hobart, Australia


Postby billcow » Jan 25, 2002 @ 1:43am

yeah, fixed points are integers, they are just shifted left by ten bits. (In other words, multiplied by 2^10=1024) The remaining points represent the fractional part of the number. The reason for using fixed point is mainly speed. I think there is a short tutorial on fixed point numbers at www.flipcode.com at the link "The Art of Demomaking" on the left side.

To use doubles for input, use the FFP(x) (it might be FP(x), I'm not exactly sure and I don't have the EasyCE header handy) macro. That will convert to the nescessary format and preserve the accuracy of the floating-point number, but for speed, you are better off using integers in the first place.
User avatar
billcow
pm Member
 
Posts: 81
Joined: Jan 6, 2002 @ 12:22am
Location: Dryden, NY


worked

Postby brendan » Jan 25, 2002 @ 1:55am

yep, the FP() worked, thanks, speed is not really an issue, it just a clock screen saver to have running on my desk during docked time! (better than seeing the anoying "today list") :)
User avatar
brendan
pm Insider
 
Posts: 451
Joined: Oct 23, 2001 @ 2:51am
Location: Hobart, Australia


Return to Phantom's Forum


Sort


Forum Description

Discuss any of Phantom's projects here (Operation Nutcracker, etc.)

Moderators:

sponge, RICoder, Phantom

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum