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!


Directx Blitting Problem form a Beginner


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
2 replies to this topic

#1 Lafo   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 August 1999 - 06:20 PM

Hi, I'm creating my first directX application
and I'm having problems blitting. I'm using ddutil.cpp that comes with directx 6.1.

Here is a part of my code:

void Game_Init(void)
{
g_pVaisseau = DDLoadBitmap(g_pDD, "vaisseau.bmp",0,0);
ShowCursor(0);

}

void Game_Main(void)
{
HRESULT hr;

RECT rectSrc, rectDest;
rectSrc.left = rectSrc.top = 0;
rectDest.left = rectSrc.top = 0;
rectSrc.right = rectSrc.bottom = 150;
rectDest.right = rectDest.bottom = 150;

hr = g_pDDS->Blt(&rectDest, g_pVaisseau, &rectSrc, DDBLT_WAIT,NULL);

while(1)
{
hr = g_pDDS->Flip(NULL, 0);
if (hr == DD_OK)
break;
if (hr = DDERR_SURFACELOST)
{
hr= g_pDDS->Restore();
if (FAILED(hr))
break;
}
if (hr != DDERR_WASSTILLDRAWING)
break;
}

}

My program start without problem, but nothing is drawn to the screen. My application quit normally when I press ESC which means the prog isn't freeze.

Know my problem?


Sponsor:

#2 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 03 August 1999 - 04:52 PM

Well, your code looks good, but there is a little problem : in the main loop (after the while (1) {...) you have to blt the image in each frame, like this :
while(1)
{

hr = g_pDDS->Blt(&rectDest, g_pVaisseau, &rectSrc, DDBLT_WAIT,NULL);

and so on
}
Now, you could say : "Why?". The key is inside the Flip Method. When you call it, the Video Board "exchanges" the primary surface with the secondary surface. In fact, it thinks the primary surface is the secondary, and vice versa. This will happen each time you call Flip.

Good luck....


#3 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 11 August 1999 - 06:20 PM

well actually the guy who posted before me is correct in the fact that you need to blit each loop.. but if you Blit once it should still give you a flicker of the blitted bmp in video memory so you would see something..dirty memory.. but it would still be the bmp if it was blitted.

It sounds almost like your BMP isn't loading correctly.
Check the return codes from the ddutil routine that loads your bitmap.
It's been awhile..but make sure you created a surface for that bmp to be loaded into. I remember some routines in ddutil.cpp used to create surfaces on the fly.. but you might want to make your own and see if you can load the bmp into it.

So..
1: Check your return codes (no matter what dx routine)
2: Make sure your bmp exists... if stored in a directory like c:\pix\pix.bmp.. you would say c:\\pix\\pix.bmp when loading.
3: Make sure you have enough video mem. maybe the surface is trying to create in vid ram.. and you are set at 1280x1024 24 bit color and you have a 2 meg vid card with double buffer active. You probably wont be able to load the bmp at that point.
4: always blit through a loop... do your flips... and umm.. maybe clear the display before a blit to see if anything shows up.. But I recommend that you take off clearing the display each loop ( that will slow yah down..unless you are doing dirty rects routines)

Latez bro,
DL





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