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.

Topics - fuzzy70

Pages: 1 2 3 [4]
GLBasic - en / Hex$ & Bin
« on: 2011-Nov-22 »
Is there a way to print hex & binary on the screen or do I have to roll my own function to do it. The latter is not a problem but if it is already built in somewhere there is no point re-inventing the wheel so to speak  =D


IDE/Syntax / Foldable types in IDE
« on: 2011-Nov-22 »
Some of my types are getting rather large thanks to adding functions in them etc. Once I have the type all working as it should I am stuck with a big lump of code at the top which basically gets in the way  :D .

Would sticking them in a SUB at the end of my code & doing a GOSUB setuptypes type of thing work?. If so would help in the short term but if they was foldable that would be better  =D


Everything was fine until about an hour ago. For some strange reason when I assign a value to a variable sometimes it does not work. I have loaded some of my projects which worked fine a couple of hours ago & they fail so I wrote the following test program & you can see from the pic whats happening in the debug window.

Only strings seem to be affected & with the included example it is just the global ones but I have seen problems with locals in my other projects. I have un-installed & re-installed GLB yet still the same result  :(. Also tried the clean project & no joy

Code: (glbasic) [Select]
// --------------------------------- //
// Project: test
// Start: Sunday, November 13, 2011
// IDE Version: 10.118

// SETCURRENTDIR("Media") // go to media files

LOCAL ltext1$,ltext2$,ltextarray$[],lnum1%,lnum2#,lnumarray[]

GLOBAL gtext1$,gtext2$,gtextarray$[],gnum1%,gnum2#,gnumarray[]

DIM ltextarray$[4]
DIM gtextarray$[4]
DIM lnumarray[4]
DIM gnumarray[4]

ltext1$="local test string 1"
ltext2$="local test string 2"

ltextarray$[0]="local array test string 1"
ltextarray$[1]="local array test string 2"
ltextarray$[2]="local array test string 3"
ltextarray$[3]="local array test string 4"



gtext1$="global test string 1"
gtext2$="global test string 2"

gtextarray$[0]="global array test string 1"
gtextarray$[1]="global array test string 2"
gtextarray$[2]="global array test string 3"
gtextarray$[3]="global array test string 4"



Any ideas?


[attachment deleted by admin]

GLBasic - en / Yet another TYPES question
« on: 2011-Nov-13 »
Me & TYPES are getting on like fire & water at the moment. It is bound to be something obvious that I am missing but the "penny is not dropping" so to speak. I think most of it is due to using BlitzBasic/Blitz3d for so long (since my Amiga days lol) that adjusting to the different way GLB uses TYPES is my problem.

I have used GLB TYPES as arrays in a few tests no problem, however with them I knew the size of the arrays in advance so did not come across any problems. I presume you have to use arrays if you want more than one of the same type, again am used to the NEW command in Blitz.

If someone could convert the following Blitz code into GLB code I will be able to make the connection & know in future. I have quite a few code snippits in Blitz that I have wrote over the years & would like to use/convert some of them into GLB .

Blitz code
Code: (glbasic) [Select]
Type Ttest
Field x
Field y
Field layer
End Type

Function addtemp(x,y,layer)
additem.Ttest = New Ttest

additem\x = x
additem\y = y
additem\layer = layer
End Function

Function moveitems(dx,dy)
For additem.Ttest = Each Ttest
additem\x = additem\x+dx
additem\y = additem\y+dy
End Function

My attempt at converting the above to GLB

Code: (glbasic) [Select]
TYPE Ttest

GLOBAL test%[] AS Ttest

//DIM test%[1]

GLOBAL additem AS Ttest

FUNCTION additems: x%,y%,layer%
additem.x = x
additem.y = y
additem.layer = layer
DIMPUSH test[],additem

FUNCTION moveitems: dx%,dy%
FOREACH loop IN test[]

Which fails at compile time with a stream of errors
Code: (glbasic) [Select]
C:\Users\LEEFUR~1\AppData\Local\Temp\glbasic\gpc_temp0.cpp: In function `DGInt __GLBASIC__::moveitems(DGNat, DGNat)':
C:\Users\LEEFUR~1\AppData\Local\Temp\glbasic\gpc_temp0.cpp:90: error: no match for call to `(__GLBASIC__::DGArray<__GLBASIC__::Ttest>) (__GLBASIC__::Ttest&)'
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:595: note: candidates are: T& __GLBASIC__::DGArray<T>::operator()(int) [with T = __GLBASIC__::Ttest]
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:640: note:                 __GLBASIC__::DGArray<T>& __GLBASIC__::DGArray<T>::operator()() [with T = __GLBASIC__::Ttest]
C:\Users\LEEFUR~1\AppData\Local\Temp\glbasic\gpc_temp0.cpp:90: error: no match for call to `(__GLBASIC__::DGArray<__GLBASIC__::Ttest>) (__GLBASIC__::Ttest&)'
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:595: note: candidates are: T& __GLBASIC__::DGArray<T>::operator()(int) [with T = __GLBASIC__::Ttest]
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:640: note:                 __GLBASIC__::DGArray<T>& __GLBASIC__::DGArray<T>::operator()() [with T = __GLBASIC__::Ttest]
C:\Users\LEEFUR~1\AppData\Local\Temp\glbasic\gpc_temp0.cpp:94: error: no match for call to `(__GLBASIC__::DGArray<__GLBASIC__::Ttest>) (__GLBASIC__::Ttest&)'
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:595: note: candidates are: T& __GLBASIC__::DGArray<T>::operator()(int) [with T = __GLBASIC__::Ttest]
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:640: note:                 __GLBASIC__::DGArray<T>& __GLBASIC__::DGArray<T>::operator()() [with T = __GLBASIC__::Ttest]
C:\Users\LEEFUR~1\AppData\Local\Temp\glbasic\gpc_temp0.cpp:94: error: no match for call to `(__GLBASIC__::DGArray<__GLBASIC__::Ttest>) (__GLBASIC__::Ttest&)'
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:595: note: candidates are: T& __GLBASIC__::DGArray<T>::operator()(int) [with T = __GLBASIC__::Ttest]
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:640: note:                 __GLBASIC__::DGArray<T>& __GLBASIC__::DGArray<T>::operator()() [with T = __GLBASIC__::Ttest]
*** FATAL ERROR - Please post this output in the forum
*** Finished ***
Elapsed: 1.1 sec. Time: 00:21
Build: 0 succeeded.
*** 1 FAILED ***

not a pretty sight  :D, tried it with the DIM statement & still fails.



Code Snippets / Formatted Print function
« on: 2011-Nov-11 »
This was only meant to just center text but ended up growing into something bigger  :D. Apologies if another one has been posted but I couldn't see one.

The code is commented above the function but will explain it here anyway. Basically it allows you to print text but adds the following over the standard PRINT command.
  • Text can be justified left, centered or right
  • You can specify a width in pixels if you want to limit text to an area, see next point
  • Text will be wrapped if its wider than the screen or the specified width

Call the function fprint(text$,x%,y%,justify%,width%)

text$ = Text to be printed (obviously) :D
x%,y% = Coordinates of where to print text
justify% = Justify the text, 0=Same as normal print(left), 1=Centered, 2=Right
width%=limit text area width, for example if you wanted to limit the text to 200pixels

The text will automatically wrap if
  • The text goes offscreen, only in the x direction
  • The text is longer than the amount of pixels set in width

The Splitter function is what does the wrapping if the text is to wide to fit, It will search for spaces in the string & split the text at that point so as not to cut off words in the middle. It was part of the original print function but to save a lot of code duplication as well as easy maintenance(<- read as easier debugging  :) ) I split it out into a function of its own.

A word of warning, NO checks are made to see if the text goes off the bottom of the screen.

One strange thing, I built this as an external file to be used with other programs of mine but if i try do DIM the type array I  get an error "(10) error : command not inside function or sub". Only way I found to get it to work was to use a REDIM in the splitter function. If there is another or better way please let me know.

Also let me know if you have any problems with this function or ways to improve it. I have tested it with random text, diff fonts etc & not had any troubles but you might send it something which I have not tried  =D


Code: (glbasic) [Select]
// Start of a textlibrary

TYPE textlines

GLOBAL wraptext[] AS textlines

// FormatPrint
// ===========
// text$=Text to print
// x%,y%=Position to print text
// justify%=0 left, 1 centre, 2 right
// width%=limit width(in pixels), if 0 then will default to screenwidth
// if you send an x%=0,width%=0 & justify%=1 text will be screen centered

FUNCTION fprint: text$, x%, y%, justify%, width%
LOCAL screenw%,screenh%,fontw%,fonth%
LOCAL textlength%
LOCAL tempx%,wrap%=FALSE

GETSCREENSIZE screenw%,screenh%
GETFONTSIZE fontw%,fonth%

//  Uncomment below if you want to send character widths to function rather than pixels
// width%=width%*fontw%


IF width%=0 THEN width%=screenw%

IF justify%=0 OR justify%=1 AND x%+width%>screenw% THEN width%=screenw%-x
IF justify%=2 AND x%-width%<0 THEN width%=x

IF textlength%>width% THEN wrap%=TRUE
IF width%<fontw% THEN RETURN

SELECT wrap%
CASE 0 // No Wrap
IF justify=1
PRINT text$,x%+((width%-textlength%)/2),y% // Centered
ELSEIF justify=2
PRINT text$,x%-textlength%,y% // Right
PRINT text$,x%,y% // Normal(left)
CASE 1 // Wrap needed
IF justify=1 // Centered
FOREACH line IN wraptext[]
PRINT line.txt$,x%+tempx%,y%   
INC y%,line.y%
ELSEIF justify=2 // Right
FOREACH line IN wraptext[]
PRINT line.txt$,x%-tempx%,y%
INC y%,line.y%
ELSE // Normal(left)
FOREACH line IN wraptext[]
PRINT line.txt$,x%,y%
INC y%,line.y%


FUNCTION splittext: text$,linewidth%
LOCAL textlength%,space%,fontw%,fonth%,split$,chrsperline%,loop%,temptext$,splitpoint%
LOCAL done%=FALSE,currentline%=0

GETFONTSIZE fontw%,fonth%

IF LEN(text$)<=chrsperline% THEN done%=TRUE
REDIM wraptext[currentline%+1]
space%=INSTR(text$," ") //look for spaces in string, for neater splitting

IF space%<>-1 AND done%=FALSE
FOR loop%=LEN(temptext$) TO 1 STEP -1
IF split$=" "

text$=TRIM$(RIGHT$(text$,textlength%-splitpoint%)," ")
INC currentline%,1

UNTIL done%


FUNCTION printerror: error$
LOCAL txt$

txt$="Program halted, Press anykey to quit"



ENDOFFILE() from the online help is missing its example

Code: (glbasic) [Select]
// Files
test$ = "test.bin"

WRITEWORD 1, 16767
WRITEWORD 1, -16767
WRITEIEEE 1, 1.234E-4

xx$= "Hello World\nYes, Hello\n"
WRITESTR  1, xx$
WRITELONG 1, 16767
WRITELONG 1, -16767

LOCAL b1%, b2%, w1%, w2%, l1%, l2%, ieee
LOCAL x2$, _x1$, _x2$
OPENFILE(1, test$, TRUE)
READIEEE 1, ieee

// READSTR 1, x2$, LEN(xx$)
READLINE 1, _x1$
READLINE 1, _x2$

PRINT "b1="+b1, 0,i); INC(i, 10);
PRINT "b2="+b2, 0,i); INC(i, 10);
PRINT "w1="+w1, 0,i); INC(i, 10);
PRINT "w2="+w2, 0,i); INC(i, 10);
PRINT "ie="+ieee, 0,i); INC(i, 10);
PRINT "st="+_x1 + "-" + _x2, 0,i); INC(i, 10);
PRINT "l1="+l1, 0,i); INC(i, 10);
PRINT "l2="+l2, 0,i); INC(i, 10);


OPENFILE(1, "test.txt", FALSE)


// 1234
OPENFILE(1, "test.txt", TRUE)
DEBUG "pos(0)="+FILEPOSITION(1)+"\n"
READLONG 1,i%; DEBUG "read="+i+"\n"

// 1234
FILESEEK(1, 0, 0)
DEBUG "pos(0)="+FILEPOSITION(1)+"\n"
READLONG 1,i%; DEBUG "read="+i+"\n"

// 1234
FILESEEK(1, -4, 1)
DEBUG "pos(0)="+FILEPOSITION(1)+"\n"
READLONG 1,i%; DEBUG "read="+i+"\n"

// 1234
FILESEEK(1, -12, -1)
DEBUG "pos(0)="+FILEPOSITION(1)+"\n"
READLONG 1,i%; DEBUG "read="+i+"\n"

// 9911
FILESEEK(1, 4, 1)
DEBUG "pos(0)="+FILEPOSITION(1)+"\n"
READLONG 1,i%; DEBUG "read="+i+"\n"


As you can see there is no ENDOFFILE() command in the example in the help file

I worked out how to use it but might be a good idea to correct the help file for people that are new to GLB

GLBasic - en / Functions in TYPES
« on: 2011-Nov-08 »
The first time I came across types was in BlitzBasic & once I had worked out how & when to use them it made certain tasks easier to manage.

Now having moved over to GLB I have the option of having functions in types which I am having trouble working out where & how I could use them. I have adjusted to they way GLB uses types & even arrays of types but what I need is an example of what use functions are in types & the benefits.

I do not need any code examples, although could be useful if it helps the explanation, but just some general description of usage etc.



GLBasic - en / Machine Specs
« on: 2011-Nov-08 »
Just an idea as I could not seem to find it in the forums (as it probably does not exist).

A list of the specs from the various targets GLB can compile for I feel would be quite useful & would help with the planning of a project if you had other targets in mind. I don't mean full on specs down to cpu speed etc but just the basics, for example

                Platform                OS                Resolution                Input Methods
                Pocket PC                WinCE                240x320                Touchscreen, 6 Buttons, 1 Dpad

While there is some info in the online help not all targets resolutions are there for example. Obviously targets like Windows/Mac/Linux do not need to be listed & Android for example may be a problem due to the amount of devices it runs on. The example above is just a rough outline (and yes I do know that some Pocket PC's have higher resolutions) of what I mean.

Unlike a lot of members of this forum my list of targets is tiny, Numerous PC's running Windows & Linux, a G4 Mac (which is only really used as a file/print/web server) & a IPAQ PPC. Also I am still currently learning GLB so multi target projects for me are a little way off but something I would definitely think about in the future.

Any thoughts or comments on this are more than welcome & if such a list was made into a sticky for example I feel it would be useful to quite a few people.


Off Topic / Bloat
« on: 2011-Nov-06 »
Time came today when I finally decided to reformat my drive & re-install win7 as over the past year with adding & removing programs etc things where getting a bit messy & sluggish. Another reason was to remove some bloat as well & look for alternatives. For example I have now ditched iTunes due to it taking up way to much memory while running (300mb+ ram on some occasions) & now have MediaMonkey, a move I should have made ages ago if I was aware of it as memory usage has now dropped to 50-60mb & has far more features than iTunes as well as superior tag handling/editing (way smaller download as well).

Another one to go was Adobe reader as I went on the download site to be greeted by a 64mb download just to view pdfs, I admit reader must do other things as well but they are something I have never used & as such it doesn't warrant a download to me. Also when did Adobe get so poor that they need extra revenue by asking you if you want McAfee security suite & there was something else on the flash download which I just skipped.

While the downloads of the above packages are on the rather large side for what the provide & I think I found out why. What happened to the days when you selected exactly what you wanted to install including what language. Seems now that you don't get the option & they install every language that exists, while some of you are multi-lingual can you speak 30+ languages?, I doubt it lol.

All the extra stuff they throw in as a pain & just causes hassle. If you have a SSD drive then space is a luxury that you try to keep under control & even if you have a old school HD all the extra bloat serves nothing more than to increase defrag times (which is a thing you want to do the least on SSD's) disk checks etc etc.

BTW if you are a Mac user do not think you are immune to disk fragmentation, while apple does it's best to automatically keep your disks frag free it's far from perfect, just download iDefrag & look at your drive.

Developing software tends to create more fragmentation than most other pc activities due to compiling/linking/intermediate files etc, web browsing is another with streams of small files slowing filling the cache.

Right that's my rant over  :D, Just needed to get it out of my system & air it  :rant:

2D / More 2D drawing commands
« on: 2011-Nov-04 »
for example, ShivaVG is an open-source ANSI C implementation of the Khronos' OpenVG specification for hardware-accelerated vector graphics API. It is built entirely on top of OpenGL.

That's just my personal preference as while I enjoy playing 3D games I have no interest in writing them  :D


Inline / 3rd party / ASE Sprite editor
« on: 2011-Nov-04 »
Wasn't to sure if to post this here or the off-topic section, will leave that decision to the moderators  :D

While trawling through the net I cam across the Allegro Sprite Editor (ASE) at

It was recently updated in September & despite it's name it is not tied or for exclusive use with Allegro. Looking through the features it seems to be pretty capable & might be useful for some & I will be giving it a play around later.

At the moment I tend to use GIMP & Fireworks CS5 for my bitmap gfx & occasionally (this will make some people laugh) Dpaint/PPaint on my Amiga emulator. Tools for working with Sprites/Bitmaps are not as easy to find I feel as most programs tend to focus more on Photoediting or Touchup.

If anyone else uses a tool for Sprites or Bitmaps please post them here with what you feel helps with the creation process.



The logo game continues with earnest lol. Just a quick question asking if there is a better way to do the following.

Code: (glbasic) [Select]
// Check Mouse zone
LOCAL gamegrid
IF mx>=10 AND mx<=228 AND my>=10 AND my<=228 THEN gamegrid=TRUE // Mouse clicked in Playarea
IF mx>=200 AND mx<=206 AND my>=270 AND my<=276 THEN colour=0 //  ""     ""    on Blue Option
IF mx>=207 AND mx<=213 AND my>=270 AND my<=276 THEN colour=2 //  ""     ""    on Red Option
IF mx>=214 AND mx<=220 AND my>=270 AND my<=276 THEN colour=4 //  ""     ""    on Green Option
IF gamegrid THEN PieceClicked((mx-10)/22,(my-10)/22)

Ignoring the gamegrid variable for the moment (it's a left over from a test earlier) as that can be moved back on the end of the IF statement. The colour variable just basically allows the changing of the game colours while playing. The above code works fine but just somehow looks odd to me with the multiple AND's & was just wondering if there is a better or alternative method as i may be adding over zones to be checked.

Screenshot attached to help, although they are just working gfx & may (prob will) change.



[attachment deleted by admin]

Off Topic / Logo game help
« on: 2011-Nov-02 »
I presume this is the right place to post this as technically not GLB related regarding coding etc.

As I am still learning GLB I thought that rather than browse through the commands writing little bits here & there, I would instead take the LOGO game tutorial & expand on it. For example do up the graphics, add sound,  title screen etc etc, that way I can pretty much use a lot of the graphics commands & others.

One of the features I thought of adding was some kind of scoring (along with a high score table for example) & one way I could implement that was get the computer to solve the puzzle & work out the minimum amount of clicks required to complete it. So as an example the bonus score is say 1000 points & the pc works out that 45 clicks is the minimum to solve it, for every click over 45 the bonus drops 100 points or something.

Writing the code to solve it will not a problem, the problem is (rather embarrassingly) that I cannot get my head around the tactic/strategy to solve the puzzle myself lol.

It's just one of those puzzles that I cannot figure out, the rules are so simple & more than likely the solution is as well but its just not popping in my head  :rant:. I done a search on the Amiga LOGO game which its based & drew a blank, even got the Amiga version & that's harder as it has a timer which counts down from 1 minute (seeing as I can spend 10mins & still not get past level 1 on the tutorial one the Amiga one does not help).

If anyone knows the tactic or if there is another name for that puzzle (can't really see the Amiga version being an original, but who know's) that I can search for that would be very much appreciated. I have saved the scoring system till last on my to-do list so no rush for answers & if no joy will have to think up another way to score the game, other than the amount of clicks it takes the player as it currently stands.



I can understand if nobody replies for some time while they are busy ROFL at this  :noggin:

Just a quickie. While playing around with the font creator program I had a problem with colours while using opengl commands. The 1st print works perfectly (excuse the colours, they was planned that way as to see the shadow & outline where working), however the 2nd one came out dark (see attached pic).

After a lot of head scratching & commenting/un-commenting the code it works out the glColor3f(0.2, 0.2, 0.2) was to blame, if you set it back to glColor3f(1,1,1) before using print again it comes out as it should.

Just thought I would mention it in case someone else came across it & save them the joys of wondering whats going on  =D

the testcode (obviously you need a font to load with some colour in it)

Code: (glbasic) [Select]
LOADFONT "smalfont6.png",1

//SLEEP 5000
PRINT "Hello", 10,10



glColor3f(0.2, 0.2, 0.2)
FOR x%=0 TO 799
FOR y%=0 TO 599
//SETPIXEL x%,y%,RGB(100,100,100)
//glColor3f(1, 1, 1)
PRINT totaltime%,100,100

[attachment deleted by admin]

GLBasic - en / Quick opengl question.
« on: 2011-Oct-23 »
Hi All,

I have just downloaded GLBasic the other day having come from a background of Blitz3D, Purebasic & minimal amount of VisualBasic.

Getting used to the syntax & differences is slowly getting there but time will sort that out :)

While learning GLBasic I am currently reading the OpenGL Bible & playing around with /common/gl.bas include. The speed difference is quite noticeable using OpenGL compared to the in-built commands I have tested so far, only pixels & lines at the moment. For example to fill the screen (an 800x600) using SETPIXEL takes around  259ms on my system, using glVertex2f to plot the same pixels takes 11ms on average. Lines as well show a big speed increase also but this is not the reason of my question lol.

Is there anyway of adding the glGetString() command/function to the gl.bas code?. The GLOBALS for GL_VENDOR, GL_RENDERER, GL_VERSION & GL_EXTENSIONS etc are all defined but I am unable to get the results from them due to lacking glGetString(). I noticed the functions in gl.bas are inline & contain C code (could be C++ as far as I know as never got passed helloword.c  :-[ ).

While it is not extremely urgent or in some respects required, but might come in handy for checking capabilities etc of the machine on which the code is running, the book mentions using GL_EXTENSIONS to check if a feature is supported & hence the reason for this question.


Pages: 1 2 3 [4]