Qbasicnews.com

Qbasic "like" compilers/interpreters => FB Projects => Topic started by: marzecTM on December 26, 2005, 05:09:48 AM



Title: yagl freebasic port 0.0.7
Post by: marzecTM on December 26, 2005, 05:09:48 AM
update:
get the latest version at http://goddess.selfip.com/yagl


hello party ppl,

yagl the infamous c++ game library is gonna be wrapped.

as yagl's c++ version is done now i was trying to get a basic wrapper working so yagl can be used in fb/c/whatever. you can find a very early version of it here SEE UPDATE. this tiny thing wraps the complete gfx module plus the keyboard input module. documentation is in the workings, i'm currently writting a programmer's guide which is one big tutorial really plus the doxygen documentation for reference ( which is mostly done ). you can use this already for your gfx stuff, i will add the missing parts that have priority ( complete input module, complete sound module ) tonight if i find the time so you can mess around with it. i think everything is pretty straight forward so you can do some stuff without documentation for now ( mind you documentation is gonna be finished soon to hopefully ).http://


Title: yagl freebasic port 0.0.7
Post by: Deleter on December 26, 2005, 05:27:49 AM
sweet  :D


Title: yagl freebasic port 0.0.7
Post by: marzecTM on December 26, 2005, 05:37:46 AM
ihope i didn't screw up the packaging :p so tell me wheter you where able to compile the sample heh


Title: yagl freebasic port 0.0.7
Post by: SBM Productions on December 26, 2005, 11:29:14 AM
The link doesn't work


Title: yagl freebasic port 0.0.7
Post by: marzecTM on December 26, 2005, 11:50:34 AM
my bad, i edited the original post the link works now, stupid me


Title: yagl freebasic port 0.0.7
Post by: SBM Productions on December 27, 2005, 12:27:08 PM
Like all good things in life, it didn't compile the sample. I got the error message cannot find lmingwex or something. Keh?


Title: yagl freebasic port 0.0.7
Post by: marzecTM on December 27, 2005, 12:46:49 PM
i'm really sorry, i uploaded mingwex to http://ratatoskr.dragonhill.cc/public/projects/libmingwex.a. download this and put it into your freebasic/lib/win32 folder. also make sure that you copy the libraries from yaglwrapper/lib/win32 to your freebasic/lib/win32 folder. you'll be asked to overwritte them, do so.


Title: yagl freebasic port 0.0.7
Post by: SBM Productions on December 27, 2005, 03:22:46 PM
libsndfile-1.dll was not found when I ran the exe. Do I have to compile it separately?


Title: yagl freebasic port 0.0.7
Post by: marzecTM on December 27, 2005, 03:53:55 PM
as stated in the readme ( i think ) all the dll's are in the bin folder. just copy them over to the path of the exe or to your windows/system32 folder. note that this "release" is not reallya release just a tiny winy bit to get you started on it. a nicely packaged binary only distribution will be available soon. i just want to finish the documentation first and add more samples.


Title: yagl freebasic port 0.0.7
Post by: SBM Productions on December 28, 2005, 02:49:51 AM
why is there a purple-ish tinge around all my sprites? Is that because of anti-aliasing? Cuz the rotated, scaled sprite has some stray purple pixels that look glitchy.


Title: yagl freebasic port 0.0.7
Post by: marzecTM on December 28, 2005, 07:33:00 AM
this is already fixed, i happened to only have my old laptop with me when i wrote the wrapper and compiled it with an outdated version of the library. the problem is that i used bilinear interpolation on the sprites in the ( very ) old version of yagl which takes the four neighbouring pixels into account. so at the border between a pink ( invisible/colorkeyed ) pixel and a normal pixel of the sprite those get mixed and the pink is taken into the average pixel color.

that interpolation is turned off now in the latest version resulting in a bit less quality when rotating and scaling ( which is still better than any software rotated scaled sprite :p ) and the pink edges are gone.

also note that as i said this above release is just a teaser really. the signatures of the methods will stay the same but the actual library will be replaced maybe this week already with a real release build containing the complete input library, sound library and gfx library (wrapper wise ).

i also noticed that fb is using gcc 3.2 on winblows which is incompatible to the library as it is compiled with 3.4.2. in this gcc release same changes where made to the rtlib. this *might* cause problems if you overwrite the library files of freebasic with the ones i provide.

i'm really sorry for all the inconvinience, next time i don't throw out a not even beta release of that stuff.


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 04, 2006, 12:11:16 AM
finally have a nice easy to use package for the fbwrapper which currently features the complete graphics module pluse the keyboard and mouse module so basically all you need to get your feed wet. Zire and shadowolf already tested it and Zire might use it for fieldview ( possibly delaying the outcome of a first demo further... ). the fb wrapper is currently win32 only due to a lack of a testing system ( my ubuntu cd's will arive this week i hope.. )

http://ratatoskr.dragonhill.cc/public/projects/yaglfb.rar
http://ratatoskr.dragonhill.cc/public/projects/yaglfb.zip

this includes the library file(s) and include file needed plus a users guide in pdf format. i provide rar and zip as some ppl prefer one over the other so chose, the content is the same.

please report any bugs or leaks you find in this thread. i'm probably adding the sound, joystick and networking module tomorrow so you have a the fully working thing in your hands. i still need to finish documenting the sound and networking module, it's a #%$@^&* lot of work.

also responses to this thread are more than welcome otherwise this will probably die the same death as fbirclib

on a sidenode: i used yagl for a very small game project i had going for the qbxl 48h compo

http://ratatoskr.dragonhill.cc/public/projects/asteroids3d.zip
http://ratatoskr.dragonhill.cc/public/projects/asteroids3d.rar

it's a simple 3d asteroids "clone" ( well not really it sucks ) showing the capablities of yagl. note that the 3d graphics are *NOT* done with yagl ( that's plain old opengl ), but the rest is. however integration of yagl with opengl is easy. you can have a look at the c++ sources ( which are a mess given the time limit ) here

http://ratatoskr.dragonhill.cc/public/projects/asteroids3dsrc.rar

well thx for reading this


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 06, 2006, 02:58:58 AM
for those that didn't follow the thread on fb.net the fb wrapper has been updated a couple of times now. probably the last update till february ( univ. work is calling )

the wrapper now wraps the following modules of the c++ version

+ full graphic module
+ full input module
+ full sound module

the documentation is also covering those three modules completely. the latest version can be downloaded from the links in my last post.

i could really need some people that write small samples and maybe translate the documentation to freebasic ( it's currently in c++ with a notes file describing the differences between the c++ original and the fb wrapper ). it is a lot of work todo as a one man show :p

big thanks to nodtveidt for also forcing yagl on people.

you can find the latest version here ( zip or rar whatever you prefer rar is smaller.. )

http://ratatoskr.dragonhill.cc/public/projects/yaglfb.rar
http://ratatoskr.dragonhill.cc/public/projects/yaglfb.zip


Title: yagl freebasic port 0.0.7
Post by: NecrosIhsan on January 07, 2006, 12:11:39 PM
This is going in just about all my FB stuff from now on. :D


Title: Good stuff, man! ^-^
Post by: Adigun A. Polack on January 07, 2006, 06:45:08 PM
To marzecTM:

I have to say, your game library here in FreeBASIC is looking very good so far, and very fast too, seriously speaking!!  :D  And hey, with the documentation all set up and a couple of your tests that I have tried within yagl, this is really shaping up to be one powerful piece of work, man!

See you later, and real good work so far on the lib!!!  :cool:=b !



(http://forum.qbasicnews.com/users/file.php?id=32)
- Adigun Azikiwe Polack
One of the Founders of Aura Flow ::: Continuing Developer of Frantic Journey
Current Developer of Star Angelic Slugger ::: Webmaster of the AAP Official Projects Squad (http://dhost.hopto.org/aapproj/)
Original Creator of the The New FreeBASIC 8-Bit Palette Machine (http://dhost.hopto.org/aapproj/fbpal/index.html) and AFlib2 - Aura Flow Library 2 (http://dhost.hopto.org/aapproj/aflib2/index.html)


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 07, 2006, 09:47:18 PM
thanks for the comment

actually the library is already done ( apart from the missing documentation ) in it's c++ version. i'm just a lazy ass and am slow at writting a c wrapper so ppl can use it in fb. hope it turns out as good as i say it is :p


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 07, 2006, 09:59:04 PM
on another sidenote:

if anyone has written any small programms with yagl please send them to me or post links to them here. i'm in need of samples for the fb version of yagl.

i could also need help translating and correcting the documentation which is atm c++ to fb ( and possibly c if you want )


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 08, 2006, 07:07:22 PM
as z!re is switching to yagl with fieldview i *had* to implement a getKey method. it's basically like inkey$ and buffers keypresses with initial and repeated delay. it is actually capable of reporting unicode however it's and undocumented feature for now as i haven't tested it yet ( the unicode support that is.. ). package is updated, url is the same as above, for your comfort:

http://ratatoskr.dragonhill.cc/public/projects/yaglfb.zip
http://ratatoskr.dragonhill.cc/public/projects/yaglfb.rar


Title: yagl freebasic port 0.0.7
Post by: na_th_an on January 09, 2006, 06:00:39 AM
Awesome news.

Now add JPEG loading and this will be my lib of choice :lol:


Title: yagl freebasic port 0.0.7
Post by: Z!re on January 09, 2006, 07:10:13 AM
Quote from: "na_th_an"
Awesome news.

Now add JPEG loading and this will be my lib of choice :lol:
Use some other lib to load stuff and decode it into a bitmap, then use yaglgfxsurface_loadfrommemory

No need to clutter the lib with a jpeg loader, and a tga loader and a [...]

Yagl works well when used together with SDL, SDL_net and SDL_image


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 09, 2006, 07:45:34 AM
@nathan i'm planning on adding jpg and png support via libjpeg and libpng. maybe i'll add those today as i'm ahead of my univ. work schedule ( just a bit :p ).

@z!re i wouldn't know that yagl works with sdl :p. it might work with sdl_net and the like but you can not use sdl's graphics and input capablities with yagl


Title: yagl freebasic port 0.0.7
Post by: na_th_an on January 09, 2006, 08:14:48 AM
Thanks both for the answers.

Is there any jpeg loading library that's been ported for fB? You know, I'm too lazy to port one myself.


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 09, 2006, 08:32:42 AM
you can use devil or freeimage, i think there's also a libjpeg port however that's a bit more tedious. i mostly use devil for quick and easy image loading


Title: yagl freebasic port 0.0.7
Post by: na_th_an on January 09, 2006, 08:42:02 AM
Thank you - I will try that.

I might have a nice text game with gfx... on the works. Sometime.


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 09, 2006, 09:23:19 AM
neat :p, note that yagl has full truetype font support maybe you can use that. if you find an error or have a question you can find me on efnet at #badlogic


Title: yagl freebasic port 0.0.7
Post by: na_th_an on January 09, 2006, 09:58:56 AM
Great, thanks. I was planning to use yagl. In fact, you read my mind :P My next question was gonna be "Has the truetype support in yagl been wrapped to use it in fB?" :lol:

Thanks again.


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 09, 2006, 10:28:39 AM
well now you got native png loading too :p just included it in the package. the png decoder can read 24-bit and 32-bit pngs. you can find the updated package here

http://ratatoskr.dragonhill.cc/public/projects/yaglfb.zip
http://ratatoskr.dragonhill.cc/public/projects/yaglfb.rar


Title: yagl freebasic port 0.0.7
Post by: NecrosIhsan on January 09, 2006, 11:42:43 AM
The png decoder go crashy-crashy. :(


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 09, 2006, 11:53:17 AM
oi i'm on it, copy and paste error, all this eiffel programming for univ. makes me go nuts... i'll update the package in a bit


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 09, 2006, 12:09:55 PM
k bug fixed and updated

http://ratatoskr.dragonhill.cc/public/projects/yaglfb.rar
http://ratatoskr.dragonhill.cc/public/projects/yaglfb.zip


Title: yagl freebasic port 0.0.7
Post by: NecrosIhsan on January 09, 2006, 12:17:57 PM
The png decoder go worky-worky. :D


Title: yagl freebasic port 0.0.7
Post by: Z!re on January 09, 2006, 12:27:10 PM
It really needs a website now.. anyone?


Title: yagl freebasic port 0.0.7
Post by: Z!re on January 09, 2006, 12:33:11 PM
Mouse is not visible in fullscreen mode :P


Title: yagl freebasic port 0.0.7
Post by: NecrosIhsan on January 09, 2006, 12:33:34 PM
Just steal Clanlib's website... :lol:  :lol:  :lol:


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 09, 2006, 01:04:52 PM
well any body wanna volunteer to create a site? i'm no good with that shit.


Title: yagl freebasic port 0.0.7
Post by: NecrosIhsan on January 09, 2006, 01:55:15 PM
I'm retired...and my sites suck anyways so I doubt you'd want me to do it. :P I could try though, if you'd like...


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 09, 2006, 02:20:37 PM
you are more than welcome too, though if that's a lot of stress for you then i'd say screw it. i could also go to sourceforge.net but i dislike cvs and i want the server to be fast.

well i'd say go for it if you find the time, just don't stress yourself :p


Title: yagl freebasic port 0.0.7
Post by: Z!re on January 09, 2006, 05:31:39 PM
So, I was playing around with Yagl, and decided to do a simple speed test.
So I made a simple, unoptimized particle handler..
Turns out, yagl is blazing fast..

Keep in mind, that every particle is blended.
A particle is made up of a box that get smaller as the particle fade out

The demo adds particles until the FPS is around 50, maximum number of particles (due to the array, not yagl) is 100'000
The windowtitle show the current values/max values
The last two values are Wind and the number of particles added on average the last second.

Screenshots of the demo in action:
(http://FileAnchor.com/15920-t.png) (http://FileAnchor.com/15920-r.png)
(http://FileAnchor.com/15921-t.png) (http://FileAnchor.com/15921-r.png)
(http://FileAnchor.com/15922-t.png) (http://FileAnchor.com/15922-r.png)



EDIT: Yagl now officially beat SDL in terms of speed: both blitting and blending



And here's the source, requires Yagl ofcourse
Code:
'#################################################################
'#
'# Yagl Fire/Particles/Blending/Speed example
'#
'# Author: Z!re
'# Group: Plantasy Studios
'#
'# When: 2006-Jan-9
'#
'# For: Marzec's awesome Yagl
'#
'# Copyright: Do whatever you want, it's an example, use/abuse
'#
'#################################################################

#include "yaglwrapper.bi"

randomize timer

YaglGfxDevice_setScreenMode(640, 480, 32, 0)
option nokeyword color
type particle__
x as single
y as single
xf as single
yf as single
life as integer
blendfact as integer
color as uinteger
end type

dim particle(100000) as particle__

extra = 200
fpc! = timer+1
do
fps += 1

YaglGfxDevice_clear(0)

key = YaglKeyboard_getKey
added = 0
alive = 0
for a = 0 to 100000
with particle(a)
if .life > 0 then
fact! = csng(.life/.blendfact)
YaglGfxDevice_solidBox  ( .x-fact!*5, .y-fact!*5, .x+fact!*5, .y+fact!*5, .color, fact!/5 )
.x += .xf+((480-.y)*wf!)
.y += .yf
.life -= 1
alive += 1
elseif added < extra then

.y = 450-25*rnd+25*rnd

if numf = 0 then
.x = 640*rnd
elseif numf = 1 then
if cint(rnd) = 1 then
.x = 160-25*rnd+25*rnd
else
.x = 480-25*rnd+25*rnd
end if
elseif numf = 2 then
.x = 320-25*rnd+25*rnd
elseif numf = 3 then
b = cint(2*rnd)
if b = 0 then
.x = 100-25*rnd+25*rnd
elseif b = 1 then
.x = 320-25*rnd+25*rnd
elseif b = 2 then
.x = 540-25*rnd+25*rnd
end if
end if
if int(10*rnd) = 1 then
.x += -50*rnd+50*rnd
.y += -50*rnd+50*rnd
end if
.xf = 1*rnd-1*rnd
.yf = -3-6*rnd
.life = 50+10*rnd
.blendfact = .life
r = 255*rnd
.color = RGB(r, (r/2)*rnd, 0)
added += 1
end if
end with
next

YaglGfxDevice_swapBuffers
if timer >= fpc! then
fpc! = timer+1
YaglGfxDevice_setWindowTitle "FPS: "& fps &"/50 :: Live particles: "& alive &"/100'000 :: Wind: "& cint(wf!*1000) &" :: "& extra
wf! += 0.005*rnd -0.005*rnd
if wf! > 0.015 then wf! = 0.015
if wf! < -0.015 then wf! = -0.015
onumf = numf
do
numf = cint(3*rnd)
loop until numf <> onumf
if fps > 50 then extra += fps
if fps < 50 and extra > 0 then extra -= (50-fps)
fps = 0
end if
loop until key = YAGL_KEY_ESCAPE


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 10, 2006, 12:20:52 PM
yagl has now an official website with forums feel free to visit it

http://goddess.selfip.com/hosted/marzec/yagl/index.html

thanks to nodtveidt for getting this thing together.


Title: yagl freebasic port 0.0.7
Post by: Z!re on January 11, 2006, 12:54:27 PM
(http://FileAnchor.com/16075-t.png) (http://FileAnchor.com/16075-r.png)

Download binaries (http://FileAnchor.com/16076-d)

Code:
'#################################################################
'#
'# Yagl Fire/Particles/Blending/Speed example 2
'#
'# Author: Z!re
'# Group: Plantasy Studios
'#
'# When: 2006-Jan-11
'#
'# For: Marzec's awesome Yagl
'#
'# Copyright: Do whatever you want, it's an example, use/abuse
'#
'#################################################################



#include "yaglwrapper.bi"

randomize timer

YaglGfxDevice_setScreenMode(640, 480, 32, 0)

option nokeyword color
type particle__
x as single
y as single
al as single
af as single
xf as single
yf as single
life as integer
blendfact as integer
color as uinteger
end type

dim particle(100000) as particle__
dim someSurf as YaglGfxSurface
dim color as uinteger

extra = 10
fpc! = timer+1

someSurf = YaglGfxDevice_createSurface

'# buildup: BGRA 5x5
a = 16
r = 255
g = 64
b = 16

bla$ = _
chr(0, 0, 0, 0,     0, 0, 0, 0,       b, g, r, a/3,   0, 0, 0, 0,       0, 0, 0, 0)+_
chr(0, 0, 0, 0,     b, g, r, a/2,    b, g, r, a/2,    b, g, r, a/2,    0, 0, 0, 0)+_
chr(b, g, r, a/3,  b, g, r, a/2,    b, g, r, a,        b, g, r, a/2,    b, g, r, a/3)+_
chr(0, 0, 0, 0,     b, g, r, a/2,    b, g, r, a/2,    b, g, r, a/2,    0, 0, 0, 0)+_
chr(0, 0, 0, 0,     0, 0, 0, 0,       b, g, r, a/3,    0, 0, 0, 0,      0, 0, 0, 0)
result = YaglGfxSurface_loadFromMemory( someSurf, cptr(ubyte ptr, strptr(bla$)), 5, 5, BITMAP_FORMAT_ARGB32 )

do
fps += 1

YaglGfxDevice_clear(0)

key = YaglKeyboard_getKey
xmouse = YaglMouse_getX
ymouse = YaglMouse_getY
zmouse = YaglMouse_getZ


added = 0
alive = 0
for a = 0 to 100000
with particle(a)
if .life > 0 then
fact! = csng(.life/.blendfact)
YaglGfxDevice_blitRotatedScaled( .x, .y, .al, fact!*25, fact!*25, someSurf, BLIT_ALPHAMASKED, 1.0! )
.x += .xf
.y += .yf
.al = (.al + .af ) mod 360
.life -= 1
alive += 1
elseif added < extra then
.x = 320-25*rnd+25*rnd
.y = 450-25*rnd+25*rnd
if int(10*rnd) = 1 then
.x += -50*rnd+50*rnd
.y += -50*rnd+50*rnd
end if
.xf = 1*rnd-1*rnd
.yf = -2-4*rnd-fheight*rnd
.af = 16*rnd-16*rnd
.life = 50+10*rnd
.blendfact = .life
.color = RGBA(0, 0, 255, 10)
added += 1
end if
end with
next

YaglGfxDevice_swapBuffers
if timer >= fpc! then
fpc! = timer+1
YaglGfxDevice_setWindowTitle "FPS: "& fps &"/50 :: Live particles: "& alive &"/100'000"
if fps <> 50 then extra += (fps-50)/2
fps = 0
end if

if fps mod 10 = 0 then fheight = 6*rnd

loop until key = YAGL_KEY_ESCAPE


Title: yagl freebasic port 0.0.7
Post by: Deleter on January 11, 2006, 05:38:36 PM
10,000 particles here..dunno where exactly that puts my computer speedwise but it sure looks neat :)


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 11, 2006, 06:18:14 PM
high end :) anyways

i'm planning on official releases for all 3 versions soon ( c, c++, fb ) so please help me write samples and test it a bit more. i really wanna make this a good library that is actually used not another thing that is forgotten in the next 2 days


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 14, 2006, 12:56:56 AM
not really fb related but still news :). yagl can now also be used with vc6 ( and possibly 7 and 8 ). it was a nasty fight but it worked out.


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 14, 2006, 02:03:33 PM
the freebasic wrapper has now a linux port which you can find here

http://goddess.selfip.com/hosted/marzec/yagl/index.php?curr_site=download

note however that this port is experimental and also dependant on a couple of external dev libraries which are listed in the note.txt file


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on January 14, 2006, 05:14:05 PM
Here is something for you.

To get the print thing to work you need a " " infront of it. For some reason string variables cause it to crash.

YaglGfxDevice_printAT( " " + text, 0, 0, &hffffff, font, 1.0 ) works
YaglGfxDevice_printAT( text, 0, 0, &hffffff, font, 1.0 ) doesn't


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 14, 2006, 07:23:52 PM
what version of fb do you use? what is the content of the variable text? the parameter is of type byval zstring. so the only explination is that you pass an empty string which fb is probably doing by passing a null pointer to it. i'll add a check thx for pointing that out


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 15, 2006, 12:10:34 AM
i had a few hours left today so i decided to put together a small sounddemo and add YaglGfxSurface_getHeight/Width which will report the dimensions of GfxSurface to the wrapper. also fixed the null poitner problem pointed out by thedarkjay thx. you can get a standalone version of the sounddemo at

http://goddess.selfip.com/yagl/downloads/yaglsounddemo.rar

this features a win32 binary, should compile with the linux fb wrapper too ( haven't tried due to lack of time.. )

make sure you also get the latest yaglfb version from the download section of the site


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on January 15, 2006, 06:35:09 AM
Quote from: "marzecTM"
what version of fb do you use? what is the content of the variable text? the parameter is of type byval zstring. so the only explination is that you pass an empty string which fb is probably doing by passing a null pointer to it. i'll add a check thx for pointing that out


It's if you remove the extra bits from the keyboard example, so i guess it's an empty string that causes the problem.


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on January 15, 2006, 09:26:39 AM
I've just figured out the basics of rotating, scaling and loading a .png...YAY!

Download Yagl_Rotation_Scaling_Example.zip (http://fileanchor.com/16461-d)

Yagl_Rotation_Scaling_Example.bas
Code:
#include "Yagl.bi"
option explicit

Yagl_Screen(640,480,24,0)

DIM image as YaglGfxSurface
image = Yagl_createSurface
Yagl_loadSurfaceFile(image, "image.png" )

DIM key as integer
DIM x as integer
DIM y as integer
DIM angle as double
DIM scale as double
x = int((640/2)-(39/2))
y = int((480/2)-(29/2))
angle = 0
scale = 1

WHILE Yagl_WindowCloseButton = 0 AND key <> Yagl_Key_Escape
key = Yagl_getKey
Yagl_CLS(0)

if key = YAGL_KEY_LEFT AND angle >= 0 then angle -= 1
if key = YAGL_KEY_RIGHT AND angle <= 359 then angle += 1
if key = YAGL_KEY_UP then scale += 0.5
IF key = Yagl_Key_Down AND scale > 0 then scale -= 0.5

if key = Yagl_Key_F1 then
x = int((640/2)-(39/2))
y = int((480/2)-(29/2))
angle = 0
scale = 1
end if

if angle = 360 then angle = 0
if angle = -1 then angle = 359
Yagl_SetWindowTitle(" Scale And Rotation Example By TheDarkJay. Angle: " + str(angle) + " Scale: " + str(scale) )

Yagl_BlitRotatedScale(x,y,angle,scale,scale,image,BLIT_SOLID,1.0)
yagl_SwapBuffers
WEND


Yagl.bi
Code:
'The Main Libary
#include "yaglwrapper.bi"

'Screen/Window Commands
#Define Yagl_CLS(c) YaglGfxDevice_clear(c)
#Define Yagl_Screen(X,Y,Bit,Full) YaglGfxDevice_setScreenMode(X,Y,Bit,Full)    
#define Yagl_SetWindowTitle(Title) YaglGfxDevice_setWindowTitle(title)  
#define Yagl_SwapBuffers YaglGfxDevice_swapBuffers  
#define Yagl_WindowCloseButton YaglGfxDevice_wasWindowCloseButtonPressed

'KeyBoard commands
#define Yagl_GetKey YaglKeyboard_getKey  
#define Yagl_KeyPress(ScanCode) YaglKeyboard_isKeyPressed(ScanCode)

'Mouse Commands
#define Yagl_MouseLeft YaglMouse_isLeftButtonPressed  
#define Yagl_MouseRight YaglMouse_isRightButtonPressed  
#define Yagl_MouseMiddle YaglMouse_isMiddleButtonPressed  
#define Yagl_MouseX YaglMouse_getX
#define Yagl_MouseY YaglMouse_getY
#define Yagl_MouseZ YaglMouse_getZ
#define Yagl_SetMouse(x,y) YaglMouse_setPosition(x,y)
#define Yagl_HideMouse YaglGfxDevice_hideMouseCursor    
#define Yagl_ShowMouse YaglGfxDevice_ShowMouseCursor  

' Font Commands
#define Yagl_CreateFont YaglGfxDevice_createFont
#define Yagl_LoadFont(font, filename) YaglGfxFont_loadFont(font, filename)
#define Yagl_FontSize(font,size) YaglGfxFont_setSize(font, size)
#define Yagl_Print(text,x,y,colour,font,blend_factor) YaglGfxDevice_printAt(text,x,y,colour,font,blend_factor)
#define Yagl_DestroyFont(font) YaglGfxDevice_destroyFont(font)
#define Yagl_DestroyAllFonts YaglGfxDevice_destroyAllFonts

'  Drawing Commands
#define yagl_Line(x1,y1,x2,y2,color,blendfactor) YaglGfxDevice_line(x1,y1,x2,y2,color,blendfactor)    
#define Yagl_Box(x1,y1,x2,y2,color,blendfactor) YaglGfxDevice_Box(x1,y1,x2,y2,color,blendfactor)      
#define Yagl_SolidBox(x1,y1,x2,y2,color,blendfactor) YaglGfxDevice_SolidBox(x1,y1,x2,y2,color,blendfactor)      
#define Yagl_ClippingRegion(clip_min_x,clip_min_y,clip_max_x,clip_max_y) YaglGfxDevice_setClippingRegion(clip_min_x,clip_min_y,clip_max_x,clip_max_y)  

'Bitmaps and blitting
#define Yagl_CreateSurface YaglGfxDevice_createSurface()
#Define Yagl_LoadSurfaceFile(surface,filename) YaglGfxSurface_loadFile(surface,filename)
#define Yagl_LoadSurfaceMemory(someSurf,aSurf,x,y,FORMAT) YaglGfxSurface_loadFromMemory(someSurf,aSurf,x,y,FORMAT)
#define Yagl_Blit(x,y,surface,BlitMODE,blend_factor) YaglGfxDevice_blit(x,y,surface,BlitMODE,blend_factor)
#define Yagl_Blit2(x,y,src_min_x,src_min_y,src_max_x,src_max_y, surface, BLIT_MODE,blend_factor ) YaglGfxDevice_blit(x,y,src_min_x,src_min_y,src_max_x,src_max_y, surface, BLIT_MODE,blend_factor )
#define Yagl_BlitScaled YaglGfxDevice_blitScaled(x,y,scale_x,scale_y,surface,BLIT_MODE,blend_factor)
#define Yagl_BlitScaled2(x,y,scale_x,scale_y,src_min_x,src_min_y,src_max_x,src_max_y,surface,BLIT_MODE,blend_factor) YaglGfxDevice_blitScaled(x,y,scale_x,scale_y,src_min_x,src_min_y,src_max_x,src_max_y,surface,BLIT_MODE,blend_factor)
#define Yagl_BlitRotated(x,y,angle,surface,BLIT_MODE,blend_factor) YaglGfxDevice_blitRotated(x,y,angle,surface,BLIT_MODE,blend_factor)
#define Yagl_BlitRotated2(x,y,angle,src_min_x,src_min_y,src_max_x,src_max_y,surface,BLIT_MODE,blend_factor) YaglGfxDevice_blitRotated(x,y,angle,src_min_x,src_min_y,src_max_x,src_max_y,surface,BLIT_MODE,blend_factor)
#define Yagl_BlitRotatedScale(x,y,angle,scale_x,scale_y,surface,BLIT_MODE,blend_factor) YaglGfxDevice_blitRotatedScaled(x,y,angle,scale_x,scale_y,surface,BLIT_MODE,blend_factor)
#define Yagl_BlitRotatedScale2(x,y,angle,scale_x,scale_y,src_min_x,src_min_y,src_max_x,src_max_y,surface,BLIT_MODE,blend_factor) YaglGfxDevice_blitRotatedScaled(x,y,angle,scale_x,scale_y,src_min_x,src_min_y,src_max_x,src_max_y,surface,BLIT_MODE,blend_factor)
#define Yagl_BlitRanged(a,b,c,d,e,f,surface,BLIT_Mode,Blend_Factor) YaglGfxDevice_blitRanged(a,b,c,d,e,f,surface,BLIT_Mode,Blend_Factor)
#define Yagl_DestroySurface(surface) YaglGfxDevice_destroySurface(surface)
#define Yagl_DestroyAllSurfaces YaglGfxDevice_destroyAllSurfaces()


image.png
(http://fileanchor.com/16462-r.png)


Title: yagl freebasic port 0.0.7
Post by: Sterling Christensen on January 15, 2006, 11:50:33 AM
I downloaded yaglfb-linux.tar.gz and tried "fbc comecloser.bas -i ../inc -p ../lib" as instructed in note.txt and got a lot of what looks like linker error messages. I copy/pasted it to a text file and uploaded it to fileanchor:
To view in web browser: http://fileanchor.com/16479
To download: http://fileanchor.com/16479-d

I have all the dependencies listed in note.txt installed. I'm using the new Xorg 7.0 modular, gcc 3.4.4, and glibc 2.3.6 on Gentoo Linux.

Glfw has some example programs, and they compile and run.


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 15, 2006, 01:16:36 PM
thanks very much for testing the linux version. the problem is that the current linux version is compiled with gcc 4 thus the stdlib yagl is linked against is not compatible with the gcc 3 stdlib. i currently only have access to gcc 4 on linux but this is a matter of change i will probably throw out a source distribution instead of an already linked version with autoconf support. this will take a while though i'm afraid ( february ). the X related link errors can be solved by linking against libxf86vm which is currently not automatically included in the .bi header of the linux fb wrapper. sorry for the inconveniences.

you can however get the svn repository from http://opensvn.csie.org/gamelibpp and compile the library yourself. the problem is that this is a pretty big rep ( 50mb ) so it might take a while. in case you download it all you have to do is go to the src directory and type make -f makedistris TARGET=linux. depending on your hardware this might take a while ( it will compile the debug and release build of the library plus the wrappers and package the fb and c port in the directories distris/yaglc and distris/yaglfb ). you will find the library and headers in the mentioned distris/ directories. note that you'll still have to link in libxf86vm.


Title: yagl freebasic port 0.0.7
Post by: Sterling Christensen on January 15, 2006, 02:34:37 PM
I thought the C++ ABI change was between 3.3 and 3.4. Isn't 4.x supposed to be 3.4 compatible?

Oh well, that's what you get for writing it in C++ :P. Plain C or FB wouldn't have been a problem.... traitor (j/k).

I'll try it from svn soon.


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 16, 2006, 09:04:39 AM
february is nearing and so is the first official yagl release. there is a lot of stuff that needs to be done before that and i put together a list that you can find at

http://goddess.selfip.com/hosted/marzec/yagl/forum/viewtopic.php?p=65#65

in case you can help me with any of the points listed there please leave me a message. i could really need some help as it's not fun to write docs for 3 different versions :) i could also need some help on the samples etc. etc. any help welcome


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on January 16, 2006, 02:04:49 PM
I just realised: Yagl means we no longer have to find complex methods of getting two .exe's running at the same time and swapping data between each other....We can just use two windows: FBGFX and Yagl...right?


Title: yagl freebasic port 0.0.7
Post by: Z!re on January 16, 2006, 03:16:54 PM
Quote from: "TheDarkJay"
I just realised: Yagl means we no longer have to find complex methods of getting two .exe's running at the same time and swapping data between each other....We can just use two windows: FBGFX and Yagl...right?
You can, but it's not recomended.


Title: yagl freebasic port 0.0.7
Post by: na_th_an on January 16, 2006, 03:48:18 PM
If you want to use two windows, I suggest that you learn to use the Windows API and do it properly. Then you can use whatever in any window.


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on January 16, 2006, 05:33:26 PM
Quote from: "Z!re"
Quote from: "TheDarkJay"
I just realised: Yagl means we no longer have to find complex methods of getting two .exe's running at the same time and swapping data between each other....We can just use two windows: FBGFX and Yagl...right?
You can, but it's not recomended.


I thought that'd be the case. That's why i added the ...right? at the end.

Arrg...Windows Programming...I'm telling you now that if you look up Gibberish in the English dictionary you'll find the windows logo....


Title: yagl freebasic port 0.0.7
Post by: na_th_an on January 17, 2006, 05:19:26 AM
It's the same for every windowing system... Events-based programming is that harsh.


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on January 19, 2006, 01:55:40 PM
Is Yagl available in a complete download for c++ yet? After discovering C++ and OO i'm really hating the "If FB had OO this would be SO much simpler" thoughts that keep on coming...


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 19, 2006, 02:19:11 PM
yes it is, however i'm currently restructuring it to be a dynamical lib on winblows. also, the vc port will have to wait a little longer i want to get the linux and mingw port done first. if you can't wait for the release in february i suggest getting tortoise svn and downloading the svn repository. all you need to compile yagl on windows is a mingw compiler. if you want to do that meet me in #badlogic in case of problems


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on January 19, 2006, 02:32:45 PM
Quote from: "marzecTM"
yes it is, however i'm currently restructuring it to be a dynamical lib on winblows. also, the vc port will have to wait a little longer i want to get the linux and mingw port done first. if you can't wait for the release in february i suggest getting tortoise svn and downloading the svn repository. all you need to compile yagl on windows is a mingw compiler. if you want to do that meet me in #badlogic in case of problems


I'm (sort of) patient, so i can wait and begin coding the non-graphical side of it now...


Title: yagl freebasic port 0.0.7
Post by: Deleter on January 19, 2006, 04:58:47 PM
any rough estimate on when the networking portion will be wrapped?


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 19, 2006, 05:34:46 PM
that will take a while, i'm planning on rewritting that portion *sigh* with imperative styles in mind.


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on January 19, 2006, 06:11:33 PM
something tells me you wrapping that will start a wave of Web games the likes of which we have never seen in a BASIC language.


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 19, 2006, 07:58:37 PM
we'll see. there's already sdl_net which ppl could use, so if ppl wanted to write such games they'd already do so.


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 21, 2006, 02:10:49 AM
today i released yagl 0.0.1 for win32 ( c, fb ). it is a testing version to play around with for ppl that already used yagl, thus it doesn't contain samples or instructions. the linux version is also working properly and there's also a mac version in the workings. you can find more information on the yagl homepage http://goddess.selfip.com/yagl the probably best improvement is that yagl is now a dynamic link library on windows32 which decreases the exe size tremendously. big thank you's go out to Blitz which created a vc2003 workspace for yagl and made yagl compile to a dll on this compiler.  so all you gotta do is distribute the dll once, then send exe patches to your app testers ( from a dev point of view :) ). have fun and please report any bugs you find.

i will probably throw out a few more 0.0.x versions the next few days/weeks just to smooth out some rough edges. i plan on releasing the official 0.1 version in february ( either at the beginning or mid february. ) this is depending on how much i have to work on the documentation and how much contributions find their way.


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 23, 2006, 06:43:49 AM
chello again...

yagl is now in testing version 0.0.2. (c/fb win32, c/fb for liunx will follow today )  a couple of things have been fixed especially the blitters which are now guaranteed to work 100% pixel perfect. also a possible bug concerning heaps and dlls and other nasty things has been eradicated so if you use 0.0.1 make sure you update to 0.0.2 now.

special thanks to blitzi again who gives suggestions and does some debugging too... somewhat. and of course to z!re the annoying swedish fart ...


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 23, 2006, 11:32:49 PM
yagl is now in version 0.0.3, see the homepage for more details ( yes my newsbriefs get shorter every day :p )


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 26, 2006, 02:53:05 PM
revision 0.0.3b is out, please update to it as it fixes a severe bug in the png decoder and gets rid of the border problem when doing scaling/rotating blits. also, keep in mind that this is not even beta yet and all 0.0.x releases are preliminary testing releases for you to possibly help me find bugs. i'd really appreciate bug reports/feature requests on the forums.


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 26, 2006, 10:57:17 PM
revision 0.0.3c, blitters again...


Title: yagl freebasic port 0.0.7
Post by: SBM Productions on January 31, 2006, 08:04:03 AM
I compiled with makefb.bat, and it gives the error

undefined reference to 'EH_FRAME_BEGIN'


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 31, 2006, 09:06:30 AM
what version of yagl did you use?

edit: ok, i just compiled a clean version of yagl, installed a clean version of freebasic and tried the example. i had no problems so the only thing i could imagine is that you are not using the latest version of yagl 0.0.3c


Title: yagl freebasic port 0.0.7
Post by: Z!re on January 31, 2006, 10:02:59 AM
Quote from: "SBM Productions"
I compiled with makefb.bat, and it gives the error

undefined reference to 'EH_FRAME_BEGIN'
Missing/corrupt GL drivers?


Title: yagl freebasic port 0.0.7
Post by: SBM Productions on January 31, 2006, 11:39:53 AM
I did a clean reinstall of fb and stuff, and it compiles. Yay. But how do I get rid of the purlpe outline?


Title: yagl freebasic port 0.0.7
Post by: Z!re on January 31, 2006, 11:59:35 AM
Quote from: "SBM Productions"
I did a clean reinstall of fb and stuff, and it compiles. Yay. But how do I get rid of the purlpe outline?
Wait for 0.0.4 it allows you to specify your own colorkey, or you could manually set the alpha (Which I do) to skip the pink outline.. There's no other way around it sadly..


Title: yagl freebasic port 0.0.7
Post by: SBM Productions on January 31, 2006, 12:02:00 PM
manually set the alpha? could you give me an example? Also, marzec, could you add a feature like some compression methods like ugl did with .pak files?


Title: yagl freebasic port 0.0.7
Post by: marzecTM on January 31, 2006, 12:30:23 PM
a couple of image formats like tga or png allow you to store your pixel data not only in rgb format but in rgba format, each channel represented by 8-bit. rgb should be clear, alpha is just another channel describing the transluency of a pixel ( 0 being transparent, 255 being solid ). but i guess i remember you writting a pretty niffty qb 3d engine so you probably know all that so excuse me if i speak like the uber teacher :p.

what you can do to get rid of the pink outline is not using colorkeying for your images that's automatically done by yagl, but rather add an alpha channel to your images ( gimp photoshop etc. can do that easily ) and make all the background pixels have an alpha value of 0 and black. i'm not so good with gimp but even i can do it in 2 simple steps ( add alpha layer, change alpha by color or something like that ). this is nothing i could avoid unless i used another filter for blitting which would result in VERY ugly quality when you scale or rotate an image.

on your feature request: i already considered it and if you care you could post it on the feature request forum on the yagl site. i can not guarantee to include that in the next time as yagl is still a one man show and it's tedious doing it that way. but as i said i consider it, i hope you understand that it does not have high priority atm though as yagl is still not even alpha and there#s a lot of stuff that needs to be tested and possibly fixed.


Title: yagl freebasic port 0.0.7
Post by: DrV on February 01, 2006, 02:28:17 AM
Quote from: "SBM Productions"
Also, marzec, could you add a feature like some compression methods like ugl did with .pak files?

If I remember correctly, uGL just used the (uncompressed) Quake I pak format...  Though some form of compression support in yagl would be nifty. :)


Title: yagl freebasic port 0.0.7
Post by: marzecTM on February 02, 2006, 04:05:32 AM
revision 0.0.4 is out with a couple of fixes and additions ( that are not yet in the wrapper though ) see the homepage for more information.


Title: yagl freebasic port 0.0.7
Post by: marzecTM on February 05, 2006, 04:14:34 AM
anyone who wants to contribute here's a list of things that needs to be done for release 0.1, it's mostly about writting samples and documentation so if you find the time and want to help out post in this thread below and state what you want to contribute.

http://goddess.selfip.com/yagl/forum/viewtopic.php?p=65#65


Title: yagl freebasic port 0.0.7
Post by: marzecTM on February 06, 2006, 02:47:23 PM
blitz, master of the universe and then some offered to write a collision module for yagl if 30 people vote for yes in the following poll

http://ratatoskr.dragonhill.cc/forum/viewtopic.php?p=888#888

so please vote for the wank!


Title: yagl freebasic port 0.0.7
Post by: marzecTM on February 06, 2006, 10:05:53 PM
new revision 0.0.5 see the site for more info, make sure you check out the changelog and docs :)


Title: yagl freebasic port 0.0.7
Post by: SBM Productions on February 07, 2006, 08:21:48 AM
how do I use the vsynch?


Title: yagl freebasic port 0.0.7
Post by: marzecTM on February 07, 2006, 09:08:43 AM
YaglGfxDevice_enableVSynch to enable vsynching, YaglGfxDevice_disableVSynch to disable vsynching.


Title: yagl freebasic port 0.0.7
Post by: marzecTM on February 08, 2006, 01:18:58 PM
version 0.0.6 is out with direct surface access go fecth :)


Title: yagl freebasic port 0.0.7
Post by: marzecTM on February 09, 2006, 09:57:20 AM
revision 0.0.7 is out with tinting


Title: yagl freebasic port 0.0.7
Post by: Z!re on February 09, 2006, 10:22:57 AM
Woo!

All hail yagl and marzec!


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on February 09, 2006, 05:09:40 PM
Hmm.

Two things

What is Ranging?
What is tinting?

Well, anyway: I've started using the C wrapper in C++ for a project...once i get adapted.

I'm a bit  :barf: at the moment so am really having trouble working on it...Maybe moving the Mouse Click thingy i made to C++ will calm me down....


Title: yagl freebasic port 0.0.7
Post by: Z!re on February 09, 2006, 05:32:16 PM
Quote from: "TheDarkJay"
Hmm.

Two things

What is Ranging?
What is tinting?

Well, anyway: I've started using the C wrapper in C++ for a project...once i get adapted.

I'm a bit  :barf: at the moment so am really having trouble working on it...Maybe moving the Mouse Click thingy i made to C++ will calm me down....
Where do you see ranging?
Tinting is where you "blend" A color ontop of what you blit, such as making a sprite redish, or blueish, or whatever you prefer. Can be used for various effects and coding techniques..


Title: yagl freebasic port 0.0.7
Post by: marzecTM on February 09, 2006, 05:57:52 PM
ranging is only blitting a part of a surface, that is only blit a certain range of the surface.


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on February 09, 2006, 06:31:07 PM
I understand...

Didn't you (marzecTM) originally overload the Blitting functions with this 'ranging'???

I also understand Tinting now...I posted, then saw a pot on the Yagl forums that sort of clarified it, then couldn't be bothered to change the post.

Thanks for taking the time to post Z!re though, sorry about my laziness...with the sleeping and the snoozing and the forgetting to eat...


Title: yagl freebasic port 0.0.7
Post by: marzecTM on February 09, 2006, 06:56:37 PM
yes the c++ version uses overloading instead of a seperate method identifier.


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on February 10, 2006, 05:51:25 PM
I'm almost finished porting the Mouse Click example to C++, I just need a bit of help. In FB I used str() to display the score as a string. Is they anything like that in C++?


Title: yagl freebasic port 0.0.7
Post by: marzecTM on February 10, 2006, 06:00:04 PM
do you use the yagl c wrapper in c++ or in c? if you use c++ you could use string streams and get the char* pointer via c_str, if you just want to output a number as a char* string then you can use itoa http://www.cplusplus.com/ref/cstdlib/itoa.html which you can directly pass to YaglGfxDevice_printAt


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on February 11, 2006, 06:56:02 AM
Everything I try crashes... :(


Title: yagl freebasic port 0.0.7
Post by: marzecTM on February 11, 2006, 09:02:51 AM
gimme code :)


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on February 11, 2006, 09:06:48 AM
Code:
#include <yaglwrapper.h>
#include <time.h>
#include <stdlib.h>

int ScreenX = 0;
int ScreenY = 0;
int ScreenBit = 0;
bool ScreenMode = 0;

bool Yagl_Screen(int Width, int height, int depth, bool mode);
int ColourRGB(int R, int G, int B);

struct Location{int x;int y;};

class Box{
      public:
      Box();
      void Manage();
     
      protected:
      Location location;
      int size;
      int score;
      int speed;
      int Xadj;
      int Yadj;
      YaglGfxFont font;
      char* ScoreString;
     
      void BoxDraw(void)
      {
      YaglGfxDevice_solidBox( location.x, location.y, location.x+size,location.y+size , ::ColourRGB(255,0,100),  1.0 );
      YaglGfxDevice_box( location.x, location.y, location.x+size,location.y+size , ::ColourRGB(0,0,0),  0.75 );
      YaglGfxDevice_box( location.x+1, location.y+1, location.x+(size-1),location.y+(size-1), ::ColourRGB(0,0,0),  0.5 );
      YaglGfxDevice_box( location.x+2, location.y+2, location.x+(size-2),location.y+(size-2), ::ColourRGB(0,0,0),  0.25 );
      }
     
      };          

int main() {
   
if ( !Yagl_Screen(640,400,32,0) )
{
     if ( !Yagl_Screen(640,400,24,0) ) { return 0; }
}
YaglGfxDevice_setWindowTitle ( " Yagl Mouse And Basic Drawing Demo " );

Box Player;
unsigned int UpdateTimer = clock();
YaglGfxDevice_clear(ColourRGB(100,100,100));
Player.Manage();

while ( (!YaglGfxDevice_wasWindowCloseButtonPressed()) && (!YaglKeyboard_isKeyPressed( YAGL_KEY_ESCAPE )) )
{
if(clock() >= UpdateTimer + (1000/50)){
UpdateTimer = clock();
YaglGfxDevice_clear(ColourRGB(100,100,100));
Player.Manage();
}
YaglGfxDevice_swapBuffers( );
}
return 0;
}

bool Yagl_Screen(int Width, int height, int depth, bool mode) {
ScreenX = Width;
ScreenY = height;
ScreenMode = mode;

if (depth == 0) { depth = 24; }
ScreenBit = depth;
    return YaglGfxDevice_setScreenMode(Width, height, depth, mode);
                                         
}

// Thanks to Netman for this:
int ColourRGB(int R, int G, int B)
{
  return (int)((R*65536)+(G*256)+B);
} // End Thanks :D

void Box::Manage()
{

location.x += Xadj;
location.y += Yadj;

int MouseX = ::YaglMouse_getX();
int MouseY = ::YaglMouse_getY();

if (location.y - size <= 0 ) Yadj = speed;
if (location.y + size >= ::ScreenY ) Yadj = -speed;
if (location.x + size >= ::ScreenX ) Xadj = -speed;
if (location.x - size <= 0 ) Xadj = speed;

if ((MouseY >= location.y - size) && (MouseY <= location.y + size) && (MouseX >= location.x - size) && (MouseX <= location.x + size) && (YaglMouse_isLeftButtonPressed()))
{
score += 1;
speed = score;
Xadj = -speed;
Yadj = -speed;
location.x = (ScreenX/2);
location.y = (ScreenY/2);            
}

::YaglGfxDevice_printAt( "Score: ", 16, 16, ::ColourRGB(255,255,255), font, 1.0 );
BoxDraw();
}

Box::Box()
{
location.x = (int)(ScreenX/2);
location.y = (int)(ScreenY/2);
size = 15;
score = 0;
speed = 1;
Xadj = speed;
Yadj = speed;
font = ::YaglGfxDevice_createFont();
::YaglGfxFont_loadFont( font, "font.ttf" );
::YaglGfxFont_setSize( font, 16 );

}


Title: yagl freebasic port 0.0.7
Post by: marzecTM on February 11, 2006, 10:20:34 AM
doesn't crash for me. well it did at first as i did not have font.ttf in the directory of the exe file. but after i placed that file there it worked without a problem.


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on February 11, 2006, 10:40:20 AM
Quote from: "marzecTM"
doesn't crash for me. well it did at first as i did not have font.ttf in the directory of the exe file. but after i placed that file there it worked without a problem.


Odd...what did you do?

EDIT: Oh right, i forgot to put the bit that caused it to crash back in...it runs fine if you just copy THAT source code and compile it.

I need it to display the integer Box::score after  the "Score: " in

::YaglGfxDevice_printAt( "Score: ", 16, 16, ::ColourRGB(255,255,255), font, 1.0 );


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on February 11, 2006, 11:28:05 AM
Never Mind. I've rewritten it so it doesn't use Scores. Also you can control how many boxes are on the screen (up to 1000) and stuff.

Code:
#include <yaglwrapper.h>
#include <time.h>
#include <iostream>

const int MaxNoOfBoxes = 1000;
int ScreenX = 0;
int ScreenY = 0;
int ScreenBit = 0;
bool ScreenMode = 0;

bool Yagl_Screen(int Width, int height, int depth, bool mode);
int ColourRGB(int R, int G, int B);
int IntRnd(int min, int max);

struct Location{int x;int y;};

class Box{
      public:
      Box();
      void Manage();
     
      protected:
      Location location;
      int size;
      int speed;
      int Xadj;
      int Yadj;
     
      void BoxDraw(void)
      {
      YaglGfxDevice_solidBox( location.x, location.y, location.x+size,location.y+size , ::ColourRGB(255,0,100),  1.0 );
      YaglGfxDevice_box( location.x, location.y, location.x+size,location.y+size , ::ColourRGB(0,0,0),  0.75 );
      YaglGfxDevice_box( location.x+1, location.y+1, location.x+(size-1),location.y+(size-1), ::ColourRGB(0,0,0),  0.5 );
      YaglGfxDevice_box( location.x+2, location.y+2, location.x+(size-2),location.y+(size-2), ::ColourRGB(0,0,0),  0.25 );
      }
     
      };          

int main() {
srand(time(NULL));
   
if ( !Yagl_Screen(800,600,32,0) )
{
     if ( !Yagl_Screen(800,600,24,0) ) { return 0; }
}
YaglGfxDevice_setWindowTitle ( " Yagl Mouse And Basic Drawing Demo " );

unsigned int NoOfBoxes = 0;
if (NoOfBoxes > MaxNoOfBoxes) NoOfBoxes = MaxNoOfBoxes;
Box Player[MaxNoOfBoxes];

unsigned int UpdateTimer = clock();
YaglGfxDevice_clear(ColourRGB(100,100,100));

for (int i = 0; i < NoOfBoxes; i++) {Player[i].Manage();}

while ( (!YaglGfxDevice_wasWindowCloseButtonPressed()) && (!YaglKeyboard_isKeyPressed( YAGL_KEY_ESCAPE )) )
{
if(clock() >= UpdateTimer + (1000/50)){
UpdateTimer = clock();
YaglGfxDevice_clear(ColourRGB(100,100,100));
for (int i = 0; i < NoOfBoxes; i++) {Player[i].Manage();}
if ( (YaglKeyboard_isKeyPressed(YAGL_KEY_UP)) && (NoOfBoxes < MaxNoOfBoxes) ) NoOfBoxes++;
if ( (YaglKeyboard_isKeyPressed(YAGL_KEY_DOWN)) && (NoOfBoxes > 0) ) NoOfBoxes--;
}
YaglGfxDevice_swapBuffers( );
}
return 0;
}

bool Yagl_Screen(int Width, int height, int depth, bool mode) {
ScreenX = Width;
ScreenY = height;
ScreenMode = mode;

if (depth == 0) { depth = 24; }
ScreenBit = depth;
    return YaglGfxDevice_setScreenMode(Width, height, depth, mode);
                                         
}

// Thanks to Netman for this:
int ColourRGB(int R, int G, int B)
{
  return (int)((R*65536)+(G*256)+B);
} // End Thanks :D

void Box::Manage()
{

location.x += Xadj;
location.y += Yadj;

int MouseX = ::YaglMouse_getX();
int MouseY = ::YaglMouse_getY();

if (location.y <= 0 ) Yadj = speed;
if (location.y + size >= ::ScreenY ) Yadj = -speed;
if (location.x + size >= ::ScreenX ) Xadj = -speed;
if (location.x <= 0 ) Xadj = speed;

if ((MouseY >= location.y - size) && (MouseY <= location.y + size) && (MouseX >= location.x - size) && (MouseX <= location.x + size) && (YaglMouse_isLeftButtonPressed()))
{
speed += 1;

if (::IntRnd(1,2) == 1){
Xadj = (::IntRnd(1,speed));
}else{Xadj = -(::IntRnd(1,speed));}

if (::IntRnd(1,2) == 1){
Yadj = -(::IntRnd(1,speed));
}else{Yadj = (::IntRnd(1,speed));}

if ((Xadj < speed) && (Yadj < speed)){
if (::IntRnd(1,2) == 1) {Xadj = speed;}else{Yadj = speed;}
}

location.x = ::IntRnd(size, ::ScreenX-size);
location.y = ::IntRnd(size, ::ScreenY-size);            
}

BoxDraw();
}

Box::Box()
{
size = 15;
speed = 1;

if (::IntRnd(1,2) == 1){
Xadj = (::IntRnd(1,speed));
}else{Xadj = -(::IntRnd(1,speed));}

if (::IntRnd(1,2) == 1){
Yadj = -(::IntRnd(1,speed));
}else{Yadj = (::IntRnd(1,speed));}

if ((Xadj < speed) && (Yadj < speed)){
if (::IntRnd(1,2) == 1) {Xadj = speed;}else{Yadj = speed;}
}

location.x = ::IntRnd(size, ::ScreenX-size);
location.y = ::IntRnd(size, ::ScreenY-size);
}

int IntRnd(int min, int max)
{
return (int)((rand()%max)+min);
}
 


Title: yagl freebasic port 0.0.7
Post by: marzecTM on February 11, 2006, 11:29:30 AM
well you could use stl string

#include <string>

stl::string text;
text = "Score: ";
text += itoa( 123123 );

YaglGfxDevice_printAt( text.c_str(), ... )


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on February 11, 2006, 11:34:27 AM
Quote from: "marzecTM"
well you could use stl string

#include <string>

stl::string text;
text = "Score: ";
text += itoa( 123123 );

YaglGfxDevice_printAt( text.c_str(), ... )


Damn...a few minutes earlier and I wouldn't had rewritten it...Oh well, If i put in an FPS counter and remove the 50 fps cap in the new one we can really see how fast Yagl is :D

Edit

well, that didn't work... I got some Invalid conversions...

Oh well, i'll try to figure it out later...


Title: yagl freebasic port 0.0.7
Post by: marzecTM on February 11, 2006, 01:09:10 PM
sorry i wrote it from the top of my head, itoa might need aditional parameters afair. maybe post the compiler output so i can help a bit more.


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on February 11, 2006, 01:19:01 PM
Forget it. I'll just do some googling and stuff and figure it out. Besides, the thing runs fast until...well about 15000 squares in... :D


Title: yagl freebasic port 0.0.7
Post by: marzecTM on February 11, 2006, 01:46:20 PM
hehe ok good look. check out strstream ( string stream ) keyword stl stringstream


Title: yagl freebasic port 0.0.7
Post by: TheDarkJay on February 11, 2006, 03:50:24 PM
I've got it...sort of

Code:
#include <yaglwrapper.h>
#include <time.h>
#include <iostream>
#include <strings.h>

const int MaxNoOfBoxes = 1000;
int ScreenX = 0;
int ScreenY = 0;
int ScreenBit = 0;
bool ScreenMode = 0;

bool Yagl_Screen(int Width, int height, int depth, bool mode);
int ColourRGB(int R, int G, int B);
int IntRnd(int min, int max);

struct Location{int x;int y;};

class Box{
      public:
      Box();
      void Manage();
     
      protected:
      Location location;
      int size;
      int speed;
      int Xadj;
      int Yadj;
     
      void BoxDraw(void)
      {
      YaglGfxDevice_solidBox( location.x, location.y, location.x+size,location.y+size , ::ColourRGB(255,0,100),  1.0 );
      YaglGfxDevice_box( location.x, location.y, location.x+size,location.y+size , ::ColourRGB(0,0,0),  0.75 );
      YaglGfxDevice_box( location.x+1, location.y+1, location.x+(size-1),location.y+(size-1), ::ColourRGB(0,0,0),  0.5 );
      YaglGfxDevice_box( location.x+2, location.y+2, location.x+(size-2),location.y+(size-2), ::ColourRGB(0,0,0),  0.25 );
      }
     
      };          

int main() {
srand(time(NULL));
   
if ( !Yagl_Screen(800,600,32,0) )
{
     if ( !Yagl_Screen(800,600,24,0) ) { return 0; }
}
YaglGfxDevice_setWindowTitle ( " Yagl Mouse And Basic Drawing Demo " );

unsigned int NoOfBoxes = 1;
if (NoOfBoxes > MaxNoOfBoxes) NoOfBoxes = MaxNoOfBoxes;
Box Player[MaxNoOfBoxes];

unsigned int UpdateTimer = clock();
YaglGfxDevice_clear(ColourRGB(100,100,100));

for (int i = 0; i < NoOfBoxes; i++) {Player[i].Manage();}

long Timer = 0;
long fps = 0;
long fpc = 0;
long LastFps = 0;

fpc = clock()+1000;

char sz_FpsCount[10];

while ( (!YaglGfxDevice_wasWindowCloseButtonPressed()) && (!YaglKeyboard_isKeyPressed( YAGL_KEY_ESCAPE )) )
{
Timer = clock();

if(clock() >= UpdateTimer + (1000/50)){
fps++;
UpdateTimer = clock();
YaglGfxDevice_clear(ColourRGB(100,100,100));
for (int i = 0; i < NoOfBoxes; i++) {Player[i].Manage();}
if ( (YaglKeyboard_isKeyPressed(YAGL_KEY_UP)) && (NoOfBoxes < MaxNoOfBoxes) ) NoOfBoxes++;
if ( (YaglKeyboard_isKeyPressed(YAGL_KEY_DOWN)) && (NoOfBoxes > 0) ) NoOfBoxes--;
YaglGfxDevice_swapBuffers( );
}
if (clock() >= fpc){
fpc = clock()+1000;
if ((fps <= 50) && (fps)){itoa(fps, sz_FpsCount, 10);YaglGfxDevice_setWindowTitle ( strcat(sz_FpsCount, "/50 FPS") );}
LastFps = fps;
fps = 0;
    }
    else{
if ((LastFps <= 50) && (LastFps)) {itoa(LastFps, sz_FpsCount, 10);YaglGfxDevice_setWindowTitle ( strcat(sz_FpsCount, "/50 FPS") );}
}
 
}
   return 0;
}

bool Yagl_Screen(int Width, int height, int depth, bool mode) {
   ScreenX = Width;
   ScreenY = height;
   ScreenMode = mode;
   
   if (depth == 0) { depth = 24; }
   ScreenBit = depth;
    return YaglGfxDevice_setScreenMode(Width, height, depth, mode);
                                         
}

// Thanks to Netman for this:
int ColourRGB(int R, int G, int B)
{
  return (int)((R*65536)+(G*256)+B);
} // End Thanks :D

void Box::Manage()
{

location.x += Xadj;
location.y += Yadj;

int MouseX = ::YaglMouse_getX();
int MouseY = ::YaglMouse_getY();

if (location.y <= 0 ) Yadj = speed;
if (location.y + size >= ::ScreenY ) Yadj = -speed;
if (location.x + size >= ::ScreenX ) Xadj = -speed;
if (location.x <= 0 ) Xadj = speed;

if ((MouseY >= location.y - size) && (MouseY <= location.y + size) && (MouseX >= location.x - size) && (MouseX <= location.x + size) && (YaglMouse_isLeftButtonPressed()))
{
speed += 1;

if (::IntRnd(1,2) == 1){
Xadj = (::IntRnd(1,speed));
}else{Xadj = -(::IntRnd(1,speed));}

if (::IntRnd(1,2) == 1){
Yadj = -(::IntRnd(1,speed));
}else{Yadj = (::IntRnd(1,speed));}

if ((Xadj < speed) && (Yadj < speed)){
if (::IntRnd(1,2) == 1) {Xadj = speed;}else{Yadj = speed;}
}

location.x = ::IntRnd(size, ::ScreenX-size);
location.y = ::IntRnd(size, ::ScreenY-size);            
}

BoxDraw();
}

Box::Box()
{
size = 20;
speed = 1;

if (::IntRnd(1,2) == 1){
Xadj = (::IntRnd(1,speed));
}else{Xadj = -(::IntRnd(1,speed));}

if (::IntRnd(1,2) == 1){
Yadj = -(::IntRnd(1,speed));
}else{Yadj = (::IntRnd(1,speed));}

if ((Xadj < speed) && (Yadj < speed)){
if (::IntRnd(1,2) == 1) {Xadj = speed;}else{Yadj = speed;}
}

location.x = ::IntRnd(size, ::ScreenX-size);
location.y = ::IntRnd(size, ::ScreenY-size);
}

int IntRnd(int min, int max)
{
return (int)((rand()%max)+min);
}


It'll count the FPS in the window.

EDIT: Downloads

Get The Binaries Here (the .exe and binaries) NOTE: This one is set to start of with 10000 boxes on-screen
Download CPP-Mouse-Click.cpp.zip (http://fileanchor.com/19405-d)

Get The Binaries Here (the .exe and binaries) NOTE: This one is set to start of with 0 boxes on-screen
Download Cpp-Mouse-Click.zip (http://fileanchor.com/19406-d)