Speed up

Miura

Freshman
Joined
Mar 13, 2003
Messages
27
Hi,

I'm trying to blit a bitmap image 259x347 pixels in 24 bit color.
But it's VERY slow.

I'm using VB.Net and DirectX9

Is there any idea's how to speed up this,

thanks,
Miura
 
Can you post the project here so we can take a look?

Also, your bitmap may be odd shapes (non-powers of 2 is "odd" for DirectX), but most hardware won't support it. Instead, you'll want to make your bitmap a power of 2 and use a color key to leave out those bits you don't want. So instead of having a bitmap at 259x347, you'll have to use 512x512. Assuming your bitmap is non-rectangular already (you have some bits being masked out), you can just use that same "mask" color to fill in the rest of the bitmap, to extend it out to 512x512.

-Nerseus
 
I'm using a Pentium 3 450 mHz and the ATI 32 MB graphics card and 384 MB.
Will a faster processor and/or more powerfuld graphics card increase the preformance?
 
Of Cause,

I have made a test, and draw 62 32x32 Pixels in 16 bits color,
and it is very faster. I used the drawfast metod.

Thanks a lot.
Miura
 
Still, one rectangle at size 259x347 should NOT be slow on pretty much any machine. I see you're using DirectDraw, which is made for blt'ing images of various size - ignore my earlier comment about bitmaps with power of 2, that's more for Direct3D.

If your sample is still running slow when you go back to the 259x347 image, post up the project and we can take a look.

-Nerseus
 
I'm using the
C:\DirectX9\Samples\VB.Net\DirectDraw\AnimatePalette\animatepalette.vbproj as "backbone" program.

But When I run the microsoft sample program is sometimes freezes just 1 or 2 frames, and moves normaly again. Freezes again, and the runs again. This can happen many times and differenct places when the program runs.

My program does the same thing.

Maybe my computer is too small to run Win XP, Visual Basic .Net and the DirectX9-program at the same time. OR maybe the program code from Microsoft could be better!!!!!.

Regards,
Miura
 
Maybe you know of a place where I can download samples for Visual Basic.Net. I have only the samples that comes with SDK.
 
You can check out DirectX4VB for a tutorial and sample.

I'm not familiar with the AnimatePaletter project so I can't say what it's doing. Do all of the sample projects have this "stuttering" effect? Have you tried changing to Release mode and running outside the IDE?

-Nerseus
 
It could be you're computer then, I experience jittering problems when running too many things at once, try closing as many programs as possible before running it. If you're on WinXP use the Task Manager to see how much CPU power is being used.
 
Some programs, such as WinAmp, are coded to take up more CPU power than other programs. This may cause a jittering.

Also, if you're doing animation based on a regular timer, the API timeGetTime, or the Environment.TickCount, keep in mind that they have about 20ms accuracy. I had a Ms Pacman clone that ran choppy because of this - I changed it to use QueryPerformanceCounter and all was better. It was only because my machine was running TOO fast that I saw the stuttering (my old 486/VB5 version used timeGetTime without any problems).

-Nerseus
 
In fact I would like to make the animation on base of a framecounter. How can it be done ?

I would like a procedure to run everytime there is a new frame. Ex. 75 Frames a Sek with the monitors 75 Hz and so on.

it seems that my computer is too slow, tried some samples from DirectX7 SDK.

Thanks,
And have a nice day :-)
Miura
 
You mean an FPS counter
Visual Basic:
Private NextCount as Int32 = Environment.TickCount
Private FPS as Int16
Public CurrentFPS as Int16

Public Sub CountFPS()
If Environment.TickCount > NextCount Then
     CurrentFPS = FPS + 1
     FPS = 0
     NextCount = Environment.TickCount + 1000
Else
     FPS += 1
End If
End Sub
 
Thanks,

I will try to study the code to understand it.
I'm sure that it will help me alot.

Thanks again :-)
Miura
Denmark
 
Hmmm, how does the code work ?

Is seems like the FPS value will be the same no matter if the monitor will run at 75 Hz or 100 Hz.

The procedure must count to 75 (75 Hz) and 100 (100 Hz).

Thanks,
Miura
 
Visual Basic:
Private NextCount As Int32 = Environment.TickCount 'Time until 1 second has past
Private FPS As Int16 'variable to count frames(32767 Hz max FPS count)
Public CurrentFPS As Int16 'Total FPS count from the last second

Public Sub CountFPS()
If Environment.TickCount > NextCount Then 'If current time has past time for the end of the second
     CurrentFPS = FPS + 1 'Change the returnable value
     FPS = 0 'Reset the counter for next second
     NextCount = Environment.TickCount + 1000 'update time till next second
Else 'if it has not been 1 second yet
     FPS += 1 'just add 1 to the counter
End If
End Sub
To use it:
Visual Basic:
Public Sub GameLoop()
Do until bRunning = False
    Back.DrawText 0, 0, "Current FPS: " & CurrentFPS.ToString(), False

    Primary.Flip Nothing, .... (Use .NOVSYNC to ignore Windows' max Hz)
    CountFPS() 'Update the FPS counter for this render pass
    Application.DoEvents()
Loop
End Sub
 
Back
Top