Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - Ruidesco

#2
Hi, I am curious about which fonts do you guys use for programming.

Mine is "Amiga" which mimics the Amiga DOS font; since it's a bitmap is clear despite being small (GLBasic's IDE font dialog doesn't acknowledge it though, so I had to set it through the registry). I'd rather have a C64 font that was a bitmap and had an extended character set, but alas...

[attachment deleted by admin]
#3
Is there a fast way to copy a defined subset of data from one array to another, that doesn't involve scanning the source array index by index to copy each value individually?
#4
Rather than a tutorial, these are just a few pieces of advice I've stumbled upon while coding the attached array performance example. This is probably something that the more seasoned GLBasic coders know, but newbies such as myself might find useful.

Dimensioning arrays:

  • Linear (1D) arrays are the fastest to use
  • It is slightly faster to use 2D arrays than simulating them through 1D arrays
  • It is considerably faster to simulate 3D or 4D arrays through 1D arrays than using real 3D or 4D arrays

Traversing arrays:

  • Traversing arrays linearly is the fastest way to work
  • To traverse both real multidimensional and simulated arrays the fastest way, nestle the dimension loops from highest to lowest dimension (as seen in the attached example)
  • Integer indexes (eg. i%) are faster to use than float indexes (eg. i#, i)

Additions are very much welcomed.

The result of the test in my own computer is attached as well.

[attachment deleted by admin]
#5
This is probably not something important, but it's a difference in behaviour that had me scratching my head for a good while.
Code (glbasic) Select
LOCAL colorData[]; DIMDATA colorData[], 0xffffff, 0, 0xff, 0xffff, 0xff00, 0xffff00, 0xff0000, 0xff00ff
LOCAL x, y, c
LOCAL size = 8, shift = 88, y2 = 16, y3 = 32

FOR c = 0 TO LEN(colorData[]) - 1

STARTPOLY

POLYVECTOR shift + c * size + size, 0, 0, 0, colorData[c]
POLYVECTOR shift + c * size, 0, 0, 0, colorData[c]
POLYVECTOR shift + c * size, size, 0, 0, colorData[c]
POLYVECTOR shift + c * size + size, size, 0, 0, colorData[c]

ENDPOLY

DRAWRECT shift + c * size, y2, size, size, colorData[c]

FOR x = 0 TO size - 1
FOR y = 0 TO size - 1
SETPIXEL shift + x + (c * size), y3 + y, colorData[c]
NEXT
NEXT

NEXT

PRINT "POLYVECTOR", 0, 0
PRINT "DRAWRECT", 0, y2
PRINT "SETPIXEL", 0, y3

SHOWSCREEN; KEYWAIT; END

This is just a dummy code that draws the same series of coloured squares using POLYVECTOR, DRAWRECT and SETPIXEL. While I would have expected any method to be the same, their output varied:

#6
When using the toon lighting, bare polygons' colours are swapped in a way that the red channel value will become the blue channel value, and vice versa.
Example:

Code (glbasic) Select
// PRESS SPACE TO SWITCH BETWEEN NORMAL LIGHT AND TOON LIGHT

LOCAL spacePressed = FALSE
LOCAL lightIndex = 0
LOCAL lightNames$[]; DIMDATA lightNames$[], "NORMAL", "CARTOON"
LOCAL x, y
LOCAL spotx = -50, spoty = 50, spotz = 50

X_OBJSTART 0

X_OBJADDVERTEX x - 1, y - 1, 0, 0, 0, RGB(255, 0, 0)
X_OBJADDVERTEX x, y + 1, 0, 0, 0, RGB(0, 255, 0)
X_OBJADDVERTEX x + 1, y - 1, 0, 0, 0, RGB(0, 0, 255)

X_OBJEND

WHILE TRUE

IF KEY(57)

IF NOT spacePressed

lightIndex = 1 - lightIndex
spacePressed = TRUE

ENDIF

ELSE

spacePressed = FALSE

ENDIF

X_MAKE3D 1, 1000, 45
X_CAMERA 0, 0, 20, 0, 0, 0
X_CULLMODE 1

X_AMBIENT_LT lightIndex * -2, RGB(255, 255, 255)

X_DRAWOBJ 0, 0

X_MAKE2D
PRINT lightNames$[lightIndex], 4, 4

SHOWSCREEN

WEND

END


Another thing I've noticed (not in the example code) is that spot lights coordinates seem to work different than the normal objects ones, probably completely reversed. (?)
#7
Hello GLBasic forums!

I'm a new user of GLBasic and have been fiddling with it about a couple of weeks, so it was about time I started participating in the community.
Since this is something I am going to use in my current project, and was a good exercise for learning to make a (simple) wrapper, I'm going to share it here.

SunVox is a recent synth-tracker in continual development, and its creator was generous enough to give a Win32/MacOSX/Linux player library to be used in other apps. You will need to download the library package and extract the one that matches your OS into the .app directory of the project for it to work (so far I could only test it in Windows).

So without further ado, I attach the SunVox Engine wrapper for GLBasic coupled with a very simple usage example.

Regards.

[attachment deleted by admin]