|
Post by n00b on Apr 6, 2022 16:43:23 GMT -6
Ok, I guess my laptop is less crappy than I thought. Here it takes ~4s, and a corresponding n6 version takes ~6s. I'll see if I can learn sdlbasic and rcbasic and write the same thing in those languages (but not today). I converted it to RCBasic. It is mostly a line by line conversion to try to have as fair a comparison as possible. rcbasic_blitting_exampleHere is the code: WindowOpen(0, "Blitting", WINDOWPOS_CENTERED, WINDOWPOS_CENTERED, 640, 480, WINDOW_VISIBLE, 0) CanvasOpen(0, 640, 480, 0, 0, 640, 480, 0)
' Load a completely opaque image. opaqueImage = 0 loadimage(opaqueImage, "assets/opaque.png")
' Load an image that contains transparency. transparentImage = 1 loadimage(transparentImage, "assets/transparent.png")
' White color. white = RGB(255, 255, 255)
' Transparent orange color. transparentOrange = RGBA(255, 128, 64, 128)
' Clear screen with a gray color. SetColor(RGB(100, 100, 100))
ClearCanvas()
' Start time in ms. t = timer()
for i = 1 to 100000 ' Draw both images without colorization. SetColor(white) DrawImage(opaqueImage, 0, 0) DrawImage(transparentImage, 100, 0) ' Draw both images with colorization. SetColor(transparentOrange) DrawImage(opaqueImage, 0, 100) DrawImage(transparentImage, 100, 100) next
' Display result. SetColor(RGB(255, 255, 255))
Locate(0, 25) PrintS(Str(timer() - t) + " ms") Update() WaitKey
|
|
|
Post by johnno56 on Apr 6, 2022 16:55:47 GMT -6
Cool... Nicely done.
137ms!
|
|
|
Post by aurel on Apr 7, 2022 0:45:15 GMT -6
Well i am surprised too. It looks that RCBasic is faster than NaaLaa_N7 on my crappy comp Why you Marcus use .png not .bmp ? If all functions do the same it looks that SDL2 is faster than your openGL wrapper functions or i have a wrong ? Resulting image is not the same .
|
|
|
Post by marcus on Apr 7, 2022 8:56:16 GMT -6
Fascinating! I use no OpenGL, but I gotta assume that SDL2 does with that result? Can't see that any software rasterizer can pull off that speed.
"Resulting image is not the same ." That means that colorized blitting doesn't apply, I guess.
|
|
|
Post by aurel on Apr 7, 2022 9:55:51 GMT -6
you dont use openGL not SDL? not GDI? well must be something ?
|
|
|
Post by marcus on Apr 7, 2022 10:33:21 GMT -6
you dont use openGL not SDL? not GDI? well must be something ? I use gdi to blit naalaa's back buffer to the window, that's all. When you call any of the drawing functions (draw pixel, draw line, draw image, draw circle, draw polygon), I use my own routines to draw to the back buffer (or to any other image that's been loaded or created and selected as "destination image" with 'set image'), pixel by pixel. You can see all the functions for that in source/naalaa_image.c. They're fast, but I certainly can't compete with the speed of rcbasic And that's why I have to assume that sdl2 uses hardware acceleration - else I'd cut my arm off to see how it's pulled off Anyhow, the question was which was faster, naalaa, rcbasic or sdlbasic. And I think we have a winner by far. For the user of the language, speed is what matters, not how it's done. I stick with my own renderer because I take pride in it, and I'm sure I could show some (useless, I admit) advantages of it
|
|
|
Post by n00b on Apr 7, 2022 10:34:42 GMT -6
Fascinating! I use no OpenGL, but I gotta assume that SDL2 does with that result? Can't see that any software rasterizer can pull off that speed. "Resulting image is not the same ." That means that colorized blitting doesn't apply, I guess. Hey Marcus, sorry I did not fully understand what the Naalaa code was doing. I fixed it. WindowOpen(0, "Blitting", WINDOWPOS_CENTERED, WINDOWPOS_CENTERED, 640, 480, WINDOW_VISIBLE, 0) CanvasOpen(0, 640, 480, 0, 0, 640, 480, 0)
' Load a completely opaque image. opaqueImage = 0 loadimage(opaqueImage, "assets/opaque.png")
' Load an image that contains transparency. transparentImage = 1 loadimage(transparentImage, "assets/transparent.png")
' White color. white = RGB(255, 255, 255)
' Transparent orange color. transparentOrange = RGBA(255, 128, 64, 128)
' Clear screen with a gray color. SetClearColor(RGB(100, 100, 100))
ClearCanvas()
' Start time in ms. t = timer()
for i = 1 to 100000 ' Draw both images without colorization. SetImageColorMod(opaqueImage, white) SetImageColorMod(transparentImage, white) DrawImage(opaqueImage, 0, 0) DrawImage(transparentImage, 100, 0) ' Draw both images with colorization. SetImageColorMod(opaqueImage, transparentOrange) SetImageColorMod(transparentImage, transparentOrange) DrawImage(opaqueImage, 0, 100) DrawImage(transparentImage, 100, 100) next
' Display result. SetColor(RGB(255, 255, 255))
Locate(0, 25) PrintS(Str(timer() - t) + " ms") Update() WaitKey
Its about 40 ms slower now.
|
|
|
Post by johnno56 on Apr 7, 2022 12:32:35 GMT -6
That looks better... A little slower (199ms) but that is ok. Cool.
|
|
|
Post by tbird on Apr 7, 2022 13:01:05 GMT -6
185ms on my laptop.
|
|
|
Post by aurel on Apr 7, 2022 13:26:58 GMT -6
Thanks Marcus on explanation well i then use same method with GDI ..with one difference u use C and i o2 ...heh i need to test how work with latest release...thanks again and i will look into source ..of course just to confirm in RCB 1.4 sec on my comp well done @noob
|
|
|
Post by kennn on Apr 12, 2022 3:37:50 GMT -6
That looks better... A little slower (199ms) but that is ok. Cool. Hello....you are a SDLBasic user. Will you write this program in SDLBasic for us to do comparison?
|
|
|
Post by johnno56 on Apr 12, 2022 5:43:13 GMT -6
SDLBasic does not have the ability to control the "alpha" channel of an image (opacity). It does the standard RGB() colours but not RGBA().
|
|