Jump to content

GLBasic: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
MrTAToad (talk | contribs)
Added OOP-style details
MrTAToad (talk | contribs)
No edit summary
Line 80: Line 80:
KEYWAIT
KEYWAIT


== Limited Object Oriented Scope ===
== Limited Object Oriented Scope ==
With Version 8, GLBasic will be adding basic object oriented commands to the TYPE command. This will allow structures to access itself (using the 'self' command) and to have functions in TYPE's
With Version 8, GLBasic will be adding basic object oriented commands to the TYPE command. This will allow structures to access itself (using the 'self' command) and to have functions in TYPE's


'''Simple OOP Test'''
== Simple OOP Test ==
TYPE Tvec
TYPE Tvec
x;y;z
x;y;z
FUNCTION null:
FUNCTION null:
self.x = 0; self.y=0; self.z=0
self.x = 0; self.y=0; self.z=0
ENDFUNCTION
ENDFUNCTION


FUNCTION add: v AS Tvec
FUNCTION add: v AS Tvec
INC self.x, v.x
INC self.x, v.x
INC self.y, v.y
INC self.y, v.y
INC self.z, v.z
INC self.z, v.z
ENDFUNCTION
ENDFUNCTION
ENDTYPE
ENDTYPE


LOCAL vec AS Tvec, vec2 AS Tvec
LOCAL vec AS Tvec, vec2 AS Tvec


vec.null()
vec.null()
vec.x=50
vec.x=50
vec2.x = 100
vec2.x = 100
vec.add(vec2)
vec.add(vec2)


== See also==
== See also==

Revision as of 11:58, 4 May 2010

GLBasic
Developer(s)Dream Design Entertainment Software
Stable release
7.336 / 24th April 2010
Operating systemWindows
PlatformWindows, Intel/PowerPC Mac, Linux (and XBox Linux), PocketPC, GP32, GP2X/GP2X Wiz, iPhone
TypeCompiler
LicenseDemo (free time-limited), Lite, 3D Add-on, Net Add-on, Premium
Websitehttp://www.glbasic.com

GLBasic is a commercial BASIC programming language, that can compile to various platforms, including Windows, Linux, Mac OS X as well as Handhelds like Apple iPhone and iPod Touch, Pocket PC, GP2X, GP2X Wiz. The language is designed to be simple and intuitive.

Overview

GLBasic started as an interpreted Language with 2D commands but now uses the GCC compiler for many different platforms to achieve fast, native code results for various platforms. The GLBasic precompiler "GPC" converts the simple BASIC language into C++ code and compiles that later. Thus, the user can extend GLBasic using the INLINE command to mix C/C++ code directly with GLBasic source code. Due to this, GLBasic can easily access 3rd party dynamic libraries on all platforms. The GLBasic SDK came with an IDE, debugger and an engine built on OpenGL for the platforms Windows, Linux and Mac OS X. For the Handheld devices (Apple iPhone, Windows Mobile, GP2X and GP2X Wiz) GLBasic uses its own close to hardware routines for fast graphics.

To compile for the iPhone, you will need an iMac (on which to compile the generated code - to comply with Apple's requirements) and the latest version of XCode, which is a free download from Apple.

To be able to actually run the program on the iPhone (GLBasic programs will not work on the emulator), you need to be a member of the iPhone Apple Development Connection.

Features

GLBasic has the following features :

General

  • Programs are written in BASIC
  • String and numbers are automatically converted between types
  • Arrays can be fixed size or dynamic
  • Sound, graphics and data can be compressed into a single file
  • User can define their own types. Types within type and dynamic arrays are allowed
  • C code can be included by putting appropriate code between a starting and ending command, or can be included during compilation. In addition, for Windows, functions within DLL's can be called.
  • A few features are PC format only
  • Programs for the iPhone can use OpenFeint

3D Features

  • The 3D engine is simple to use and maintains fast processing of objects
  • Objects can be animated
  • Works with most of the common 3D formats
  • Objects can have shadows

2D Features

  • Sprites can be rotated and scaled, and take account of blending values
  • Lines, filled rectangles and other shapes can be drawn

Network Features

  • TCP and UDP sockets are available

Compiler

  • The compiler is cross-platform. You do need an Intel iMac to compile the generated iPhone code though, as per Apple's legal requirements.

IDE

  • The editor is Windows only, but can run at a decent speed in most virtual machines. With WINE though, you can only compile for windows.

Versions

GLBasic has gone through the following revisions :

  • Version 1.2 - The first version of GLBasic (also known as The DiNGS Game Basic sequel)
  • Version 2.4 - This introduced PocketPC support
  • Version 3.0 - (Codename: Behemoth) added TYPE's
  • Version 4.0 - Introduced the ability to interface with Window's DLL's and introduced compiling for the Xbox (if Linux is installed on it). It should also run on standard Linux, although there is no hardware acceleration, so programs run much slower.
  • Version 5.0 - Introduced compiling for the Apple Mac as a Universal application
  • Version 6.0 - Introduced integers into GLBasic for the first time. Previously variables could either be floating-point or strings
  • Version 7.0 - Introduced the ability to compile for Apple iPhone and iPod Touch devices.

Sample code

Hello World

// this is a comment
// Print "Hello World" to the screen position 0,0 (top, left)
PRINT "Hello World", 0,0
// swap backbuffer and visible screen, prepare backbuffer for next rendering
SHOWSCREEN
// wait for a key to be pressed
KEYWAIT

Limited Object Oriented Scope

With Version 8, GLBasic will be adding basic object oriented commands to the TYPE command. This will allow structures to access itself (using the 'self' command) and to have functions in TYPE's

Simple OOP Test

TYPE Tvec
 x;y;z
 FUNCTION null:
  self.x = 0; self.y=0; self.z=0
 ENDFUNCTION
 FUNCTION add: v AS Tvec
  INC self.x, v.x
  INC self.y, v.y
  INC self.z, v.z
 ENDFUNCTION
ENDTYPE
LOCAL vec AS Tvec, vec2 AS Tvec
vec.null()
vec.x=50
vec2.x = 100
vec.add(vec2)

See also

References

  • This article is based on content taken from GP2X wiki, which is available under the terms of the GFDL.

External links