BASIC

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.


Messages - Hemlos

Pages: [1] 2 3 ... 106
1
Off Topic / Re: Shaders
« on: 2019-May-15 »
hmm oh ya, i started this thread when i started playing with the shaders in glb

https://www.glbasic.com/forum/index.php?topic=3148.msg22927#msg22927

note: its 10 years old thread with some relevent information tho, however, i dont know if the code still works the same.
gernot helped share some important info there too

2
Off Topic / Re: Shaders
« on: 2019-May-14 »
Glbasic doesn't have vector variables, you have to pass single values, and rebuild it inside the shader code as a vec2 3 4

3
Off Topic / Re: Shaders
« on: 2019-May-13 »
shaders are wonky in glbasic
i have a thread somewhere with a couple examples
one of the main things is, you cannot pass vectors like typical shaders code eg. vec2 vec3 etc
To get it to work, you have to split inputs into single values and then pass them into the shader code.
other than that, shaders seem to work as expected, its just alot of work to convert them to glbasic friendly.

ps. no, i don't see enough info on those pages to get started in glbasic....there isn't anywhere on the web that will.
You have to learn the gpu language before even attempt glbasic shaders.
You have to learn minimally about vec2 vec3 vector lists, and be able to expand them into single dimensions as input.

4
Competitions / Re: GLBasic Contest 02: 2D Art
« on: 2019-May-08 »
ps snoopy needs to be added to the poll.

5
Competitions / Re: GLBasic Contest 02: 2D Art
« on: 2019-May-08 »
For my AVG AV program i think it checks each program on first run, after anything is compiled and run.
Only once, and on first run only.

6
Competitions / Re: GLBasic Contest 02: 2D Art
« on: 2019-May-08 »
Nice work Snoopy, that high pitch sound though, scared me lol

7
Competitions / Re: GLBasic Contest 02: 2D Art
« on: 2019-Apr-27 »
Qedo i don't know how that works, but i want to figgure it out!
Looks really cool!

8
Competitions / Re: GLBasic Contest 02: 2D Art
« on: 2019-Apr-27 »
Fantastic dreamerman, really nice!  :good:
And thank you for this, it might be useful for something i'm working on.

9
Competitions / Re: GLBasic Contest 02: 2D Art
« on: 2019-Apr-25 »
I will try to do something (I like the concurence friendly). The code of WPShadow is simpler but the optical effect is nice (and according to the rules of the contest, the complexity doesn't matter this time).

Sounds good, looking forward to more entries.
I like these contests because it gives access to some cool functions.
The more the merrier!

10
Competitions / Re: GLBasic Contest 02: 2D Art
« on: 2019-Apr-23 »
I'm not a pro, but i have read a few books.
And to give credit where it's due, Gernot was a huge influence on my thirst for math.
I'm looking forward to more entries!

About the program, it was simply really.
It was a benchtest program to show what the function DrawStar() could do.
DrawStar was a brainstorm, as you can see in the remarks of the function showing a progression of the idea.
All the effects, are a result of using several combinations and configurations of this function:
Code: GLBasic [Select]
DrawStar(x%, y%, Color#, NumberOfPoints%, TextureID%, Rotate#, Depth#)


11
Competitions / Re: GLBasic Contest 02: 2D Art
« on: 2019-Apr-20 »
This is an experimental piece i tinkered with a few years ago, hardly worth being called art.
It uses a rocking motion of sins and cos. eg. -1 to 1 to -1 to 1 etc

1. compile fullscreen 1920x1080
2. dont forget to grab this background image, or the special effect at the end will not look right.


Code: GLBasic [Select]
// --------------------------------- //
// Project: ColorPalette
// Start: Saturday, August 08, 2015
// IDE Version: 12.312


// compile 1920 x 1080 resolution fullscreen

LOADSPRITE "sky2.png", 9999

WHILE TRUE

        STATIC a# = 0
        a# = a# + 0.1
        IF a# > 359.0
                a# = 0.0
        ENDIF
        b# = SIN(a#) * 127.0

        // the meters - still experimenting with colors..these are read to go...they have inputs [0.0..1.0] or [-1.0..1.0]
        METER_Volume(30,40,20,300,SIN(a/2))
        METER_SINE(60,40,20,300,SIN(a) )//, 0x604020, 0x707070)
        METER_SINE(90,40,20,300,COS(b) )//, 0x604020, 0x707070)

//       stars
        DrawStar(200,500, 0xffffff, 5 , -50 , a , 0.5)
        DrawStar(300,600, 0xff00ff, 5 , -100 , a , 0.75)
        DrawStar(200,640, 0x808080 + RGB(COS(a)*127,128,0), 24 , -128 , 0 , SIN(a) * 1.0)
        DrawStar(200,640, 0x808080 + RGB(0,COS(a)*127,128), 24 , -128 , a , 0.2)

        // fractal sun
        // this one needs HEAVY experimenting!
        MakeSun(960,540, 2048, 2048+COS(b)*2048, 1, RGB( (127+COS(b*10)*127), (127+SIN(b*10)*127),COS(b*5)*127+127), 0x000000, b#, 0.1)  //this is the fractal...its a lil messy
        IF (GETTIMERALL() >20000)
                c=c+0.01
                IF c>1.0 THEN c=1.0
                DrawStar( 940, 540, 0xffffff, 5, 9999, a, c)
        ENDIF
        IF (GETTIMERALL() >24000) THEN END


        SHOWSCREEN

WEND

//
FUNCTION MakeSun: x1%, y1%, Points2%, Size2%, Wander%, Color#, Color2#, Angle#, Depth#
        DrawStar(x1% , y1%+2 , Color#, Points2%, -Size2%  ,  COS(Angle#)*2.0, Depth#)
        DrawStar(x1% , y1% , Color2#, Points2% , -Size2% ,  0 , Depth#)
        RETURN 0
ENDFUNCTION



FUNCTION METER_SINE: x%, y%, w%, h%, Level#, Color1% = 0x00f0f0, Color2% = 0xf0f000 // Level# = -1.0 to 1.0 eg. [-1.0..1.0]
        IF Level# < -1.0 THEN Level# = -1.0
        IF Level# > 1.0 THEN Level# = 1.0
        PRINT Level,10,10
        LOCAL MeterLevel# = (h% - 1 ) * Level#
        POLYVECTOR x%,y%,w%,h%,0x0000f0
        DRAWRECT x%+2,y%+2,w%-4,h%-4,Color2%
        DRAWRECT x%+4,y%+4,w%-8,h%-8,Color2% * 0.4
        DRAWRECT x%+4,y%+(h%/2),w%-8,-MeterLevel#/2,Color1%
        RETURN 0
ENDFUNCTION


FUNCTION METER_Volume: x%, y%, w%, h%, Level#, Color1% = 0x806040, Color2% = 0xf0f000 //Level# = 0 to 1.0 [0..1]
        IF Level# < 0 THEN Level# = 0
        IF Level# > 1.0 THEN Level# = 1.0
        PRINT Level,10,10
        LOCAL MeterLevel# = ( h% - 4 ) * Level#
        DRAWRECT x%,y%,w%,h,Color1%
        DRAWRECT x%+4,y%+4,w%-8,h%-9,Color1% * 0
        DRAWRECT x%+4,y%+h%-4,w%-8,-MeterLevel#, Color2%
        RETURN 0
ENDFUNCTION


FUNCTION DrawStar: x%, y%, Color#, NumberOfPoints%, TextureID%, Rotate#, Depth# // make some stars! -TextureID# = SIZE If No Sprites ID is supplied. (-) Negative ID
        // Star Creator Code Designed Neil M. Silver,  Aug. 9, 2015
        //
        // The Algorithm:
        // --
        //   NumberOfPoints = Number of visually obvious points, eg. An American Star is 5 pointed.
        // --
        //   Vector Count = The number of actual vectors a polyvector needs, in fan mode, can be calculated:
        //
        //     ( V = P * 2 + 2 )
        //     VectorCount% = ( NumberOfPoints% * 2 ) + 2 )
        //     Note: Add Two, one for the center point, one for the last point.
        // --
        //   VectorAngleSize% = is the turn size for each vector to draw.
        //     ( A = 180 / P )
        //     VectorAngleSize# = ( 180.0 / NumberOfPoints% )
        // --
        //   Depth%
        //     The inner and outer radius represent the length of the points, and the depth of thier inner corners.
        //     The Depth% value is a scalar, a ratio of the outer radius, 0.5 is good for stars...play with this [0.1~~1.0]
        //
        //                           . ________________
        //                                            ^
        //                    .   .    .     .        |   Outer Radius
        //                                            V
        //                       .     ________________
        //                                            V  Inner Radius (Depth#)
        //                           .   ______________
        //                      .          .
        //
        //
        // --
        //   Rotate%, 360 degrees
        // --
        //  A negative value for TextureID% will make the star that size, without an image.
        //  eg ( TextureID%  = -5 ) will make the star 10 wide, radius 5...no skin.
        // --
        //
        // Other notes:
        // Its midhandled.
        // Use a square image, root 2
        //
        STATIC Phase%
        LOCAL iW%, iH%, ViR#, VoR#
        LOCAL VectorCount% = ( ( NumberOfPoints% * 2 ) + 2 )
        LOCAL VectorAngleSize# = ( 180.0 / NumberOfPoints% ) * 1.0
        LOCAL tX#, tY#, vX#, vY#

        // Get the outer radius:
        IF TextureID% >= 0
                GETSPRITESIZE TextureID%, iW%, iH%
                ViR# = ( iW% * 0.5 ) * Depth#
                VoR# = ( iW% * 0.5 ) * 1.0
        ELSE
                VoR# = ABS(TextureID%) //use -textureid for a size param
                ViR# = ( VoR# * Depth# )
        ENDIF
        //STAR:

        STARTPOLY TextureID%, 0 // FAN Mode only!
        POLYVECTOR x%, y%, VoR#, VoR#, Color# // center vector
        LOCAL AngleNow#
        FOR i% = 0 TO VectorCount% - 1
                AngleNow# = ( ( VectorAngleSize# * i% * 1.0 ) + Rotate# ) * 1.0
                Phase% = Phase% + 1
                IF Phase% > 1
                        Phase% = 0
                ENDIF
                IF Phase%
                        vX# = COS( AngleNow# ) * VoR#
                        vY# = SIN( AngleNow# ) * VoR#
                ELSE
                        vX# = COS( AngleNow# ) * ViR#
                        vY# = SIN( AngleNow# ) * ViR#
                ENDIF
                tX# = vX# + VoR#
                tY# = vY# + VoR#
                POLYVECTOR x% + vX#, y% + vY#, tX#, tY#, Color#
        NEXT
        ENDPOLY
        RETURN 0
ENDFUNCTION


 

12
Competitions / Re: Hello World - Contest
« on: 2019-Apr-09 »
 :good:
The string object lib i used, is up-to-date and ready to rock and roll.
Feel free to use it if you find handy, enjoy.

13
Competitions / Re: Hello World - Contest
« on: 2019-Mar-29 »
i have a guess, the code will procrastinate  :good:

14
Competitions / Re: Hello World - Contest
« on: 2019-Mar-13 »
Game on!
Compiled as a console program.
Note: only a few lines in main code, but what it does is pretty complicated.


Code: GLBasic [Select]
// --------------------------------- //
// Project: HelloWorld
// Start: Tuesday, March 12, 2019
// IDE Version: 15.238
// By Hemlos

// Instructions: compile as console

AUTOPAUSE FALSE
SYSTEMPOINTER TRUE

LOCAL HelloWorld AS lib_String_Object_
HelloWorld.is$ = "hElLo wOrLd"

LOCAL BGColor% = 0, TColor% = 15
STDCOLOR TColor,BGColor


STD_OUT( HelloWorld.is$ )
STD_OUT( HelloWorld._Capitalize$() )
STD_OUT( HelloWorld._Capwords$() )
STD_OUT( HelloWorld._Swapcase$() )
STD_OUT( HelloWorld._RFill$(3, "!") )
STD_OUT( HelloWorld._LFill$(3, "!") )
STD_OUT( HelloWorld._Left$(14) )
STD_OUT( HelloWorld._Right$(11) )
STD_OUT( HelloWorld._Swapcase$() )
STD_OUT( HelloWorld._Upper$() )
STD_OUT( HelloWorld._Lower$() )
STD_OUT( HelloWorld._Encrypt$("GLBasic") )
STD_OUT( HelloWorld._Decrypt$("GLBasic") )
STD_OUT( HelloWorld._Replace$("world","GLBasic") )
STD_OUT( HelloWorld._Replace$("GLBasic","world") )
STD_OUT( HelloWorld._Capitalize$() )
STD_OUT( HelloWorld._Capwords$() )


SLEEP 60000
END


FUNCTION STD_OUT: showThis$, restTimeMS% = 1000 // clearscreen, stdout, sleep. restTimeMS% = millseconds sleep time (integer) defaults one second
        CLEARSCREEN
        STDOUT "\n\n\n                            "
        STDOUT showThis$
        SLEEP restTimeMS%
        RETURN 0
ENDFUNCTION

Include this String object library lib_String_Object.gbas :
Quote
The message exceeds the maximum allowed length (20000 characters).
You'll have to download the .rar to see it in action.  :zzz:
Note: the string lib is mine own creation, based 100% on GLBasic command structures, and inspired by the Python Language.


15
Beta Tests / Re: 3d Space Sim
« on: 2019-Mar-09 »
Very cool. How do you come up with that kind of ideas?

I randomly study of math and astrophysics on a regular basis, using GLBasic to visualize some math.
I really wanted to see gravity in action, to see; stars, planets and moons form and take on unique orbits.
When i saw the formula for gravity from Isaac Newtons principia, i figured it could be worked out using a double nested loop.
Also, it has become a great platform for refining my 3d libs for cameras, particle engine, lighting, and sfx, etc etc

Pages: [1] 2 3 ... 106