Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


my own mouse cursor


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 ferceg   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 January 2000 - 11:01 PM

Hello ! I''d like to apologize for my bad English first (I''m from Hungary). I''m totally new to DX, so don''t laugh at me if I ask stupid questions... So.. I tried to write my very first DX program: I have a fixed background, and a transparent mouse cursor moves on it. I created the primary surface with 1 backbuffer, and I also have an offscreen buffer to store the background picture in it. (This is larger than the primary srf, because I store the mouse cursor with colorkey in this surface, too). I didn''t manage to avoid having to blt the full bgpic to the backbuffer then blt the cursor using colorkey to the current mouse position (and then I flip, of course). If I tried to do a restore-bg-save-bg-put-cursor thing, the entire screen was flashing as I moved the mouse. Could anyone explain me, how the flipping exactly works ? I started to experiment: I did: -init DDraw -load a bmp to an offscr. srf. -blt to primary -blt to back -and just flip on mousemove the result: flashing screen. (one of them contains the correct bgpic, the other''s some horrible purple colored...) why ?????????? thanks, Hajdu Ferenc

Sponsor:

#2 DerekSaw   Members   -  Reputation: 243

Like
Likes
Like

Posted 18 January 2000 - 12:48 AM

i''m also new in DX, (anyone) correct me if i''m wrong.

the primary-surface is what the screen is showing.
the back-surface is what working behind the scene.
i seldom see any blt occur in primary-surf (izzit?), most are done in back-surf.
so, after all blt are done on the back-surf, do a flip.
a flip will switches the primary&back surfaces, making your back-surf becoming primary & vice versa (again, izzit?)... resulting the screen showing what u want to show.
this operation is called double-buffering. normally used in game & is one of the known methods to reduce sprites (not screen) flickering.

my suggestion is that try to blit everything to the back surface, and then do a flip. Something like:
- init DD
- load bitmap to offscreen-surf
- blit background to back-surf
- blit mouse cursor to back-surf
- flip

BTW, what u blt to the primary-srf?


#3 I-Shaolin   Members   -  Reputation: 138

Like
Likes
Like

Posted 18 January 2000 - 02:07 AM

Well DerekSaw, you seem to be pretty much on track, but you left out when to flip. A monitor draws an image from left to right and top to down. When the beam reaches the bottom right, it has to move back up to the top left. This is called the vertical retrace. When you are performing page flipping, flip the pages during the vertical retrace so you don't see it while drawing (this may be your problem ferceg). Here's some code in DX7 that will wait until the retrace and flip.

// Flip Our Surfaces
while (FAILED(g_lpDDS7_Front->Flip(NULL, DDFLIP_WAIT)));

Also ferceg, you may try moving your mouse cursor to irs own surface. That should help simplify your code.

Edited by - I-Shaolin on 1/18/00 8:08:18 AM

#4 ferceg   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 January 2000 - 11:43 PM

Thx for the answers.
I understand that I shouldn''t blt to the primary surface.
But if I blt the bgpic to the backbuffer and then the mouse cursor onto it and then I flip, I will have an empty backbuffer and I have to blt the whole bgpic again.
And this is what I''d like to avoid.
(just restore-save-putmousecursor on mousemove)

Another problem:

why doesn''t this code work ?

ZeroMemory(&ddsd,sizeof(ddsd));
ddsd.dwFlags = DDSD_CAPS / DDSD_HEIGHT / DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth=100;
ddsd.dwHeight=100;

ddrval=lpDD->CreateSurface(&ddsd,&lpDDSBG,NULL);

I always get a DDERR_INVALIDPARAMS...

thx again,

ferceg


#5 Melo   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 January 2000 - 12:21 AM

You forgot

ddsd.dwSize = sizeof (ddsd);


You could create another surface for backuping the stuff behind your mouse cursor. I've never tested it, but I think it will work.

Cya

Edited by - Melo on 1/21/00 6:22:13 AM

#6 ferceg   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 January 2000 - 11:02 AM

Yes, that was it... thanx.

Another question:
I load a truecolor bmp with DDLoadBitmap (ddutil.cpp) (my primary surface is in 16 bit)
Is the offscreen surface in 32 bit and will the blt do the conversion ? (Or is it already 16-bit ?)

ferceg

#7 Staffan   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 January 2000 - 12:21 PM

all your offscreen/video memory surfaces will be in the same colordepth as your primary surface. so yes, its already in 16-bit mode (DDLoadBitmap will take care of the conversion between 32 and 16-bits).

Edited by - Staffan on 1/22/00 6:22:51 PM

#8 Melo   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 January 2000 - 03:47 AM

But if you create surfaces with several pixel formats, the Blt/BltFast functions do not convert ''em.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS