Page 2 of 5

Re: 2D drawing slow as hell

Posted: Tue Sep 20, 2011 6:49 pm
by xorc1zt
yes this is faster (2500 fps) but this method is single buffered. just try with DrawText() and you will see the problem.

why decent speed on XP and not on seven ?

Re: 2D drawing slow as hell

Posted: Tue Sep 20, 2011 10:04 pm
by jboadas
Wow 2500,
here only 540 FPS Windows 7 32
Video Intel G33/G31

Re: 2D drawing slow as hell

Posted: Wed Sep 21, 2011 7:47 am
by dige
Workstation: Win7 x86, Intel Xeon Quad Core, NVIDIA Quadro FX 580

54 FPS / xorc1zt
2.400 FPS / netmaestro

:shock:

Re: 2D drawing slow as hell

Posted: Wed Sep 21, 2011 8:18 am
by MachineCode
xorc1zt wrote:why decent speed on XP and not on seven ?
Do you really have to ask? It's common knowledge that Vista and 7 are slower and more bloated than XP. You're now experiencing it firsthand. :)

Re: 2D drawing slow as hell

Posted: Wed Sep 21, 2011 12:13 pm
by Thorium
MachineCode wrote:
xorc1zt wrote:why decent speed on XP and not on seven ?
Do you really have to ask? It's common knowledge that Vista and 7 are slower and more bloated than XP.
Which isnt true at all.

Re: 2D drawing slow as hell

Posted: Wed Sep 21, 2011 12:17 pm
by MachineCode
(Never mind)

Re: 2D drawing slow as hell

Posted: Wed Sep 21, 2011 12:19 pm
by Kuron
xorc1zt wrote:yes this is faster (2500 fps) but this method is single buffered. just try with DrawText() and you will see the problem.
You would be better off using bitmapped fonts instead of DrawText if you are using DX/OpenGL.

Re: 2D drawing slow as hell

Posted: Wed Sep 21, 2011 1:50 pm
by xorc1zt
MachineCode wrote:
xorc1zt wrote:why decent speed on XP and not on seven ?
Do you really have to ask? It's common knowledge that Vista and 7 are slower and more bloated than XP. You're now experiencing it firsthand. :)
:? not convinced. as i already said i got 1000 fps with java.

pygame 800 fps
freebasic 2400 fps



Python (pygame)

Code: Select all

# Sample Python/Pygame Programs
# Simpson College Computer Science
# http://cs.simpson.edu
 
import pygame
import random
import os
import platform
   
# Define some colors
black    = (   0,   0,   0)
white    = ( 255, 255, 255)
green    = (   0, 255,   0)
red      = ( 255,   0,   0)
 
pygame.init()
  
# Set the height and width of the screen
size=[640,480]
screen=pygame.display.set_mode(size)
 
pygame.display.set_caption("My Game")
 
#Loop until the user clicks the close button.
done=False
 
# Used to manage how fast the screen updates
clock=pygame.time.Clock()

#load font, prepare values
font = pygame.font.Font(None, 80)
text = 'Fonty'
size = font.size(text)

fpscounter = 0
fps = 0
oldtime = pygame.time.get_ticks()
newtime = pygame.time.get_ticks()
fg = 250, 240, 230
bg = 5, 5, 5
wincolor = 40, 40, 90
    
# -------- Main Program Loop -----------
while done==False:
    for event in pygame.event.get(): # User did something
        if event.type == pygame.QUIT: # If user clicked close
                done=True # Flag that we are done so we exit this loop
     
    # Set the screen background
    screen.fill(black)

    if pygame.time.get_ticks() > oldtime + 1000:
        oldtime = pygame.time.get_ticks()
        #print(fpscounter)
        pygame.display.set_caption(str(fpscounter))
        fpscounter = 0
              
    # Limit to 20 frames per second
    # clock.tick(20)
    for i in range(20):
        #rect = pygame.Rect(random.randrange(320), random.randrange(240), random.randrange(320), random.randrange(240))
        #screen.fill(random.randrange(0xFFFFFF), rect, special_flags=0)
        pygame.draw.rect(screen,random.randrange(0xFFFFFF),
                         (random.randrange(320),
                          random.randrange(240),
                          random.randrange(320),
                          random.randrange(240)) ,
                         0)
  
    fpscounter+=1
    
    # Go ahead and update the screen with what we've drawn.
    pygame.display.flip()
# Be IDLE friendly. If you forget this line, the program will 'hang'
# on exit.
pygame.quit ()
FreeBasic

Code: Select all

#if __FB_LANG__ = "fb"
Using FB
#endif
Randomize , 1
screen 18, 32, 2, GFX_WINDOWED 
'ScreenRes 640, 480, 32
dim fps as integer = 0
dim frames as integer = 0
dim oldtime as integer = timer

Function rnd_range (first As Double, last As Double) As Double
    Function = Int( Rnd * (last - first) + first )
End Function

screenset 1,0
Do
    cls
    
    if timer > oldtime + 1 then
        fps = frames
        frames = 0
        oldtime = timer
    end if
    
    for i as integer = 0 to 20
        Line (rnd_range(0,320),rnd_range(0,240))-STEP(rnd_range(0,320),rnd_range(0,240)),rnd_range(0,16711680), BF
    next i
    
    Draw String (20, 430), Str(fps), RGBA(255,255, 255, 255)
    frames += 1
    screencopy
Loop Until MultiKey(SC_Q) Or MultiKey(SC_ESCAPE)

Re: 2D drawing slow as hell

Posted: Wed Sep 21, 2011 10:28 pm
by Nituvious
It's slow because you're using StartDrawing each iteration of your loop. You will get better results by creating a sprite outside of your loop and then using DisplaySprite instead.

Re: 2D drawing slow as hell

Posted: Wed Sep 21, 2011 10:39 pm
by MachineCode
Nituvious wrote:It's slow because you're using StartDrawing each iteration of your loop.
No, he's not. There's only Box() inside the For/Next loop.

Re: 2D drawing slow as hell

Posted: Thu Sep 22, 2011 7:00 am
by xorc1zt
how i can draw random rectangles with a sprite and without box() ? this code has nothing wrong, purebasic just can't do it on windows 7.

Re: 2D drawing slow as hell

Posted: Thu Sep 22, 2011 7:13 am
by Nituvious
Well anyway, this is what I meant.

Code: Select all

#screenwidth   = 640
#screenheight  = 480

#TOTALBOXES = 100 ; change me to display more boxes

InitSprite()
OpenWindow(0, 0, 0, #screenwidth, #screenheight, "PB Drawing", #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget)
OpenWindowedScreen(WindowID(0), 0, 0, #screenwidth, #screenheight, 0, 0, 0, #PB_Screen_NoSynchronization)



;bufferaddress.i = 0
;StartDrawing(ScreenOutput())
;bufferaddress = DrawingBuffer()
;StopDrawing()

fpscounter.i  = 0
timer.i       = 0
fps.i = 0
frames.i = 0
totalTime.l = 0
curTime.l = ElapsedMilliseconds()

Dim sprites.l(201)
For i = 0 To 199
	Debug i
	w = 1+Random(320)
	h = 1+Random(240)
	sprites.l(i) = CreateSprite(#PB_Any, w,h)
	Debug sprites.l(i)
	StartDrawing(SpriteOutput(sprites.l(i))) ; -- Random crash here? what the crap?
	Box(0,0,w,h, Random($FFFFFF))
	StopDrawing()
Next i
    
Repeat
  
  lastTime = curTime
  curTime = ElapsedMilliseconds()
  totalTime + (curTime - lastTime)
  If( totalTime > 1000 ) 
    totalTime - 1000
    fps = frames
    frames = 0
  EndIf
  frames + 1
  
  ClearScreen(RGB(0,0,0))
  For x = 0 To #TOTALBOXES
  	DisplaySprite(sprites.l(Random(#TOTALBOXES)), Random(320),Random(240))
  Next
 
  StartDrawing(ScreenOutput())
  ;For i = 0 To 20
  ;  Box(Random(320), Random(240), Random(320), Random(240), Random($FFFFFF) )
 ; Next i
  DrawText(20,430,Str(fps))
  StopDrawing()
  
  FlipBuffers()
  
  
Until WindowEvent() = #PB_Event_CloseWindow

Re: 2D drawing slow as hell

Posted: Thu Sep 22, 2011 9:02 am
by FlixFlax
Hi Nitu. I think it crashes when your w or h = 0.

Re: 2D drawing slow as hell

Posted: Thu Sep 22, 2011 10:24 am
by Nituvious
FlixFlax wrote:Hi Nitu. I think it crashes when your w or h = 0.
Ah, you're right. I forgot all about that! Thank you. I edited my above post.

Re: 2D drawing slow as hell

Posted: Sat Sep 24, 2011 2:36 pm
by mpz
Hi,

have on my PC Windows XP and Windows 7. For 2d and 3d i make my own Endgine, the mp3d Engine.

For now i have tested it on the Windows XP and Windows 7 partition with PB 4.51, With PB dx9, PB Open Gl and ith PB MP3d as x86 and x64 version

The different between Windows XP and Windows 7 are very big! I don't know the reason but i hope anybody have a idea or solution?

You can load and test the program if you want:
http://www.file-upload.net/download-375 ... t.zip.html

My PC DualCore AMD II 250, 2GByte Ram

x86_______________ Windows XP | Windows7
2D_Testopengl_x86.exe | 194 | 160
2D_Testdx9_x86.exe | 1024 | 66
2D_Testmp3d_x86.exe | 2040 | 184
x64
2D_Testopengl_x64.exe | no | 167
2D_Testdx9_x64.exe | no | 66
2D_Testmp3d_x64.exe | no | 184


Greetings
Michael