GLBasic forum

Main forum => Off Topic => Topic started by: Yodaman Jer on 2011-Sep-24

Title: Introducin' Meself
Post by: Yodaman Jer on 2011-Sep-24
Hi everybody!

I just discovered GLBasic last night, and I must say that I'm very, very impressed by it!  I looked through all of the samples on the website and the Sphere Mapping one is what got me convinced to try this thing out. 

I'm not new to programming, I was previously using DarkBASIC for my game programming (and that was a nightmare on Windows 7), and I was just looking into Blitz3D when someone told me about GLBasic.  So glad I checked it out!

Has anyone made 3D games with it run on Linux, specifically Ubuntu?  If I can program my 3D game to run on Windows, Mac and Linux (and so far it looks like I can most definitely do that), I will be the happiest geek on earth! :D

Title: Re: Introducin' Meself
Post by: ampos on 2011-Sep-24
...and iPhone, HP/Palm WebOS, Android, Caanoo, WinCE, GP2X, Pandora,... sure I miss more.

The same source can do all this.
Title: Re: Introducin' Meself
Post by: MrTAToad on 2011-Sep-25
I've got a 3D game up and running, but I never bothered compiling it for Linux :)
Title: Re: Introducin' Meself
Post by: Moru on 2011-Sep-25
Long time ago I did some 3D test and it worked just fine in Ubuntu too.
Title: Re: Introducin' Meself
Post by: Yodaman Jer on 2011-Sep-25
Nice. :)


Can anyone link me to some decent 3D tutorials?  I'd like to see how to use the shaders in particular, and some of the collision detection commands in action, although I won't be able to run it since I don't have the premium version. :P
Title: Re: Introducin' Meself
Post by: Falstaff on 2011-Sep-25
Welcome aboard :)

I'm new to GLB as well, just found out about it a little over a month ago.. Really glad I did though! Started working on a simple match-3 game with an artist friend of mine and we've already made tons of progress. Aside from a few minor gotcha's with the editor, and some Android compatibility concerns with key graphics commands (ie CREATESCREEN and/or I've heard tales of STRETCHSPRITE woes..), I've been very happy with my work in GLB.

Guess that means I can't help much with your 3d questions, sorry..not yet! But I just thought I'd say hi ;)

Title: Re: Introducin' Meself
Post by: Ian Price on 2011-Sep-25
I'm working on a Match3 game too, though for TouchPad :)
Title: Re: Introducin' Meself
Post by: caffeinekid on 2011-Sep-25
I'm working on my first GLB game at the moment too, just getting used to some bits of the language and making something simple. I hope you enjoy your GLB journey. :)
Title: Re: Introducin' Meself
Post by: Ian Price on 2011-Sep-25
Wasn't Blitz your first GLB game Caff? Is it not finished? Any chance of seeing a pc version at some point?
Title: Re: Introducin' Meself
Post by: bigsofty on 2011-Sep-26
Welcome!  :good:
Title: Re: Introducin' Meself
Post by: Slydog on 2011-Sep-26
I can't remember seeing a tutorial on Shaders, but the following seems to work in GLB.
I haven't used it in a while, mainly because it didn't work on my iPhone (3GS), and didn't want to investigate any further!
(I think I've since found out that GLB only uses OpenGL 1.1?  Is that only on iOS?  Or am i wrong?)

Here's my Shader code in GLB:
Code (glbasic) Select
CONSTANT FP_SHADER$ = "Graphics/Shaders/"
CONSTANT SHADER_COLOUR% = 9

FUNCTION ShaderColour%: colour%
STATIC init%, ok%
LOCAL r#, g#, b#

IF init <> TRUE
init = TRUE
ok = ShaderLoad(SHADER_COLOUR, "Color")
ENDIF
IF NOT ok THEN RETURN

r = bAND(colour,           0xff) / 255.0
g = bAND(colour / 0x100,   0xff) / 255.0
b = bAND(colour / 0x10000, 0xff) / 255.0

X_SETSHADER SHADER_COLOUR
X_PUTSHADER "r", r
X_PUTSHADER "g", g
X_PUTSHADER "b", b

RETURN
ENDFUNCTION

FUNCTION ShaderLoad%: index%, fn$
LOCAL ok%
DEBUG ">GFX:{ShaderLoad      } fn:[" + GETCURRENTDIR$() + FP_SHADER$ + fn$ + "]\n"
ok = X_LOADSHADER(index, FP_SHADER$ + fn$ + ".vert", FP_SHADER$ + fn$ + ".frag")
IF NOT ok THEN DEBUG ">{Gfx ShaderLoad  } *** Error Loading:[" + FP_SHADER$ + fn$ + "]\n"
RETURN ok
ENDFUNCTION


And here are the Shader files:
'Color.vert'
Code (glbasic) Select
float FogEyeRadial(vec4 Rh) {
vec4 Re = Rh / Rh.w;
return length(Re);
}

void main(void) {
gl_FogFragCoord = FogEyeRadial(gl_ModelViewMatrix * gl_Vertex);
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
}


'Color.frag'
Code (glbasic) Select
uniform sampler2D TextureID1;
uniform float r;
uniform float g;
uniform float b;

void main (void) {
vec4 color = vec4(r, g, b, 0.5);
gl_FragColor = texture2D(TextureID1,  gl_TexCoord[0].xy) + color;
gl_FragColor = mix(gl_Fog.color, gl_FragColor, clamp((gl_Fog.end - gl_FogFragCoord) * gl_Fog.scale / 5.0, 0.1, 1.0));
}


By looking at the shader files, I think this shader takes in three values, r, g, b, and shades the pixels by that colour.
And it appears to apply the fog settings to the affected pixels too.
This was my first shader, so there are maybe better or simpler ways to do this, but was just a proof of concept to see if I can get shaders to work.  I took bits and pieces from other people's shaders to get this far!

To use it, just call the 'ShaderColour(RGB(255,0,0))' function passing it a colour you want applied.
It also loads the required shader files if they haven't already been loaded.
Finally it sets the shader and passes it the three required colour parts.
Title: Re: Introducin' Meself
Post by: Yodaman Jer on 2011-Sep-26
Thanks, Slydog! That will come in handy once I have the full version.  :good:
Title: Re: Introducin' Meself
Post by: Yodaman Jer on 2011-Sep-27
Hmm... I seem to run into a couple of slight issues and I was just wondering if you guys might know why this is happening?

Every time I try to run one of the 2D demos (3D works fine for some reason), I get a "variable is not explicitly defined" error unless I go back and preface all of the variables with either "GLOBAL" or LOCAL" before the main loop. Is the demo version of GLB the cause, or do I just have to make sure to preface all of my variables in the future with GLOBAL/LOCAL? In which case, running the 2D demos are a hassle because I don't want to modify the file contents of a demo. :P
Title: Re: Introducin' Meself
Post by: Kitty Hello on 2011-Sep-27
That's from old project settings. Please use menu "Project/settings" and diable the checkbox "explicit declarations". (That was from pre V8 projects I think).
Title: Re: Introducin' Meself
Post by: Yodaman Jer on 2011-Sep-27
Thanks! That did the trick. :)
Title: Re: Introducin' Meself
Post by: MrTAToad on 2011-Sep-27
All those projects could do with being updated so that option doesn't need changing...
Title: Re: Introducin' Meself
Post by: mentalthink on 2011-Sep-29
You can make thing very nice in GLbasic whit 3D, under Linux I don´t stay sure about his behavior, but in desktop computers... on Win runs very well.

About your skills don´t worry, I come from DB too, and don´t have nothing in common, Glbasic, it´s too much logic and efficient, in DBPro, you have to write a bunch of line codes for make the same whit only one line.

In example I in DbPro, I never know how modify a 3d Object by my self, here it´s really, really easy.

Don´t doubt, for me ,and I come from 3D, it´s a better solution, quick, easy and a very good price.
Title: Re: Introducin' Meself
Post by: caffeinekid on 2011-Oct-09
Quote from: Ian Price on 2011-Sep-25
Wasn't Blitz your first GLB game Caff? Is it not finished? Any chance of seeing a pc version at some point?

Yes it's finished and it's on the Android market place. I posted in the Android Market thread.

I'm going to release the free PC version when I make my developer licence costs back. It might take some time. lol