Squirrel V3.0 for FreeBASIC (32/64-bit Windows and Linux)

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Re: Squirrel V3.0 for FreeBASIC (windows and linux)

Postby AGS » Apr 21, 2011 1:48

So with fbc we now got access to

lua
javascript
squirrel
java (jni)


I'd say there are a few more to go.

python
tcl/tk
php
ruby
perl


Did I forget any? (I think euphoria is interesting as well but it's not that well known).

All of the above come with C interfaces, are embeddable/extendable/etc....

So.... what's next, D.J.: python, php, ruby?
D.J.Peters
Posts: 7419
Joined: May 28, 2005 3:28

Postby D.J.Peters » Apr 24, 2011 17:24

Next step after OpenGL i added SOIL as texture library
([S]imple [O]penGL [I]mage [L]ibraray)

texture formats are : *.bmp, *.tga, *.png, *.jpg, *.dds

Joshy

Code: Select all

// soilTest01.nut

// create the OpenGL window
GLFW.OpenWindow(512,512)
// centered on desktop
GLFW.SetWindowPos(GLFW.DESKTOP_WIDTH/4,GLFW.DESKTOP_HEIGHT/4)
GLFW.SetWindowTitle("SOIL the [S]imple [O]penGL [I]mage [L]ibrary")

local w = GLFW.GetWidth()
local h = GLFW.GetHeight()

GL.Viewport(0,0,w,h)
GL.MatrixMode(GL.PROJECTION)
GL.LoadIdentity()
GLU.Perspective(45.0, w/h,0.1, 100.0)
GL.MatrixMode(GL.MODELVIEW)
GL.LoadIdentity()

local rot=0.0
local texture = SOIL.LoadTexture("data/squirrel.png",SOIL.LOAD.AUTO,SOIL.CREATE_NEW_ID,SOIL.FLAG.POWER_OF_TWO)
// enable and use a texture
GL.Enable(GL.TEXTURE_2D)
GL.BindTexture(GL.TEXTURE_2D,texture)

while (GLFW.WindowOpen()==true) {
  GL.Clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT)
  GL.LoadIdentity()

  GL.Translatef(0, 0, -2)
  GL.Rotatef(rot,0,0,-1)

  GL.Color3f(1, 1, 1)
  GL.Begin(GL.QUADS)
    GL.TexCoord2f(0,0); GL.Vertex3f(-0.5,-0.5, 0)
    GL.TexCoord2f(1,0); GL.Vertex3f( 0.5,-0.5, 0)
    GL.TexCoord2f(1,1); GL.Vertex3f( 0.5, 0.5, 0)
    GL.TexCoord2f(0,1); GL.Vertex3f(-0.5, 0.5, 0)
  GL.End()

  GLFW.SwapBuffers()
  rot+=1.0
}
D.J.Peters
Posts: 7419
Joined: May 28, 2005 3:28

Postby D.J.Peters » May 04, 2011 23:39

Now with GLFW Events

Joshy

Code: Select all

' glFrameWorkEvents.bas
' test for the GLFW and events
#include once "inc/nativeminilib.bi"
#include once "inc/glfweventlib.bi"
#include once "inc/gllib.bi"

' create VM
dim as HSQUIRRELVM vm = sq_open(1024)

' register native mini lib
register_nativeminilib(vm)
' register opengl framework
register_glfweventlib(vm)
' register opengl
register_gllib(vm)
' register opengl util
register_glulib(vm)

SetHandlers(vm)

' load, compile and run a script
if SQ_FAILED(RunScriptFromFile(vm,"glFrameWorkEvents.nut")) then
  ? "error: RunScriptFromFile() !":beep
end if

' delete VM
sq_close(vm)


test script:

Code: Select all

/*
  glFrameWorkEvent.nut
  test for: GLFW events
*/

function WindowResizeEvent(w,h) {
  local title = "windowsize = " + w + " x " + h
  GLFW.SetWindowTitle(title)
  if (w<1) w=1
  if (h<1) h=1
  GL.Viewport(0,0,w,h)
  GL.MatrixMode(GL.PROJECTION)
  GL.LoadIdentity()
  GLU.Perspective(45.0, w/h,0.1, 100.0)
  GL.MatrixMode(GL.MODELVIEW)
  GL.LoadIdentity()
}

function MouseMoveEvent(x,y) {
  local title = "mousepos = " + x + " , " + y
  GLFW.SetWindowTitle(title)
}

function MouseButtonEvent(button,state) {
  local title = "mousebutton[" + button + "] = " + state
  GLFW.SetWindowTitle(title)
}

function MouseWheelEvent(wheelpos) {
  local title = "mousewheel = " + wheelpos
  GLFW.SetWindowTitle(title)
}

function KeyEvent(key,state) {
  local title = "key[" + key + "] = " + state
  GLFW.SetWindowTitle(title)
}

// half of the desktop
GLFW.OpenWindow(GLFW.DESKTOP_WIDTH/2,GLFW.DESKTOP_HEIGHT/2)
// centered on desktop
GLFW.SetWindowPos(GLFW.DESKTOP_WIDTH/4,GLFW.DESKTOP_HEIGHT/4)
GLFW.SetWindowTitle("GLFW event test resize window or use mouse or keyboard")
local rot=0.0

// turn off VSync (60Hz. on my box)
GLFW.SwapInterval(0)

GL.ClearColor(0.5,0.25,0,1)
while (GLFW.WindowOpen()==true) {

  GL.Clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT)

  GL.LoadIdentity()

  GL.Translatef(0, 0, -2)
  GL.Rotatef(rot,1,0,0)
  GL.Rotatef(rot,0,1,0)
  GL.Rotatef(rot,0,0,1)
  GL.Begin(GL.QUADS)
    GL.Color3f(1, 0, 0); GL.Vertex3f(-0.5,-0.5, 0)
    GL.Color3f(0, 1, 0); GL.Vertex3f( 0.5,-0.5, 0)
    GL.Color3f(0, 0, 1); GL.Vertex3f( 0.5, 0.5, 0)
    GL.Color3f(0, 1, 1); GL.Vertex3f(-0.5, 0.5, 0)
  GL.End()

  GLFW.SwapBuffers()
  GLFW.Sleep(1.0/100.0)
  rot+=1.0
}
D.J.Peters
Posts: 7419
Joined: May 28, 2005 3:28

Re: Squirrel V3.0 for FreeBASIC (32/64-bit Windows and Linux

Postby D.J.Peters » Dec 21, 2014 12:28

Latest version supports 32/64-bit Windows and Linux.

Make your FreeBASIC application or game scriptable.

Joshy
caseih
Posts: 1281
Joined: Feb 26, 2007 5:32

Re: Squirrel V3.0 for FreeBASIC (windows and linux)

Postby caseih » Jul 10, 2015 14:06

AGS wrote:So.... what's next, D.J.: python, php, ruby?

Translating the libpython header files into FB would be excellent as I think FB is a good language for extending Python. The cool thing about using libpython is that whether you're extending Python (making a new module) or embedding Python to be a scripting language inside your FB app, the process is exactly the same.

I made a feeble attempt to start translating the Python header files, but didn't go very far with it. The automated tools for doing this transliteration are pretty weak and I didn't have time to dive into it manually.
IndigoFuzz
Posts: 5
Joined: Sep 21, 2014 3:25
Contact:

Re: Squirrel V3.0 for FreeBASIC (32/64-bit Windows and Linux)

Postby IndigoFuzz » Aug 13, 2018 9:30

Hi there :)

Thank you very much for your efforts with this - I'm very keen to use Squirrel as a scripting solution for a little project I'm putting together.

I've noticed in the archive 'sqstdlib.bi' isn't included.. Is there a chance you can provide this?

Kind regards

Return to “Libraries”

Who is online

Users browsing this forum: No registered users and 0 guests