Menu

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.

Show posts Menu

Messages - sf-in-sf

#76
Hope it works o.k. for you too like this.

//1) clean project, "trash" icon.
//2) remove all types of icons IN project folder.
//3) IF you want the white frame, put there an "icon.png"
//   IF you don't want it put there the same image,
//   with name "androidicon.png"
//   The image must be PNG format, 72x72.
//   [PNG is great FOR transparency AND other things]
//4) Rebuild FOR android, AND voila.

If trouble or doubt, try building the project twice.
#77
This prints 256 squares. Look which ones are dithered or not, the repeating patterns. A repeat every 4 means 6 bits for that channel, every 8 means 5 bits for the physical screen. click/touch to change the channels.
My android Archos tablet 10.1 G9 does rgb666, so 18 bits altogether.

Code (glbasic) Select
// --------------------------------- //
// Project: bands
// Start: Friday, January 11, 2013
// IDE Version: 10.244


// SETCURRENTDIR("Media") // go to media files

SETSCREEN 320,480,0
//LIMITFPS 2

GLOBAL hue% =1 // 1->7 only.

WHILE TRUE
plot(hue)
PRINT hue, 150,30
SHOWSCREEN
GOSUB changecolor
WEND
END // (?)

FUNCTION plot: hue%
LOCAL r%, g%, b%
LOCAL shade%, color%, t$
r=bAND(hue, 0x001)
g=bAND(hue, 2)
IF g>0 THEN g=1
b=bAND(hue, 4)
IF b>0 THEN b=1

FOR i% = 0 TO 7 // 8 columns.

// 256/8 = 32 -> 32 rows.
FOR j% =0 TO 31
shade = i*32 +j // like a memory linear position
// from a n-dimension table

color= RGB(r*shade, g*shade, b*shade)
DRAWRECT i*40,j*15,38,15, color

NEXT
NEXT

t$="R:"+r+"   G:"+g+"   b:"+b
PRINT t$, 150,60
ENDFUNCTION

SUB changecolor:
LOCAL mx%, my%, b1%, b2%
REPEAT
HIBERNATE
MOUSESTATE mx,my,b1,b2
UNTIL b1+b2 >0 // click down
REPEAT
HIBERNATE
MOUSESTATE mx,my,b1,b2
UNTIL b1+b2 =0 // click released
INC hue, 1
IF hue >7 THEN hue=1
ENDSUB
//
// P.S.
//How TO use your own icons FOR android:
//1) clean project, "trash" icon.
//2) remove all types of icons IN project folder.
//3) IF you want the white frame, put there "icon.png"
// IF you don't want it put there the same image,
// with name "androidicon.png"
// The image must be PNG format, 72x72.
// [PNG is great FOR transparency AND other things]
//4) Rebuild FOR android, AND voila.

#78
Quote from: Kitty Hello on 2012-Apr-30
See the .java file in the distribute directory. I search for all possible formats (you can print hem out) and pick the "best" one that's supported.

Dear Kitty,
   Please have a look at this, it looks like it's the answer -but i don't know how to integrate it into GLb.
Quotation: By default GLSurfaceView chooses a EGLConfig that has an RGB_888 pixel format................
the page is there:
http://developer.android.com/reference/android/opengl/GLSurfaceView.html
Thank you in advance!

24/32 bit images look possible in android, but someone says they take longer to process/display.
#79
Quote from: MrTAToad on 2012-Apr-30
Its a limitation of current devices....

I don't agree, Dude. To me it means the design was not careful/clever enough. processsing images in memory should be done in RAM and any depth, like 24, 32, or more. Only when it's time to refresh the screen the dithering should be done down to 16 bits or so.
It's no luxury! ....even gimp and films are currently moving to a proper 48 bits resolution, 3 x 16 for quality colors -and editing.
#80
I'd like to share my 3 useful functions. Enjoy and experiment!
More on my artistic experimental programming: google 'artist F.P. Brixey saatchionline'. NEW: my collection is visible on deviant art.

Code (glbasic) Select

// --------------------------------- //
// Project: circle1
// Start: Sunday, February 03, 2013
// IDE Version: 10.244


// SETCURRENTDIR("Media") // go to media files
GLOBAL scrx%=666, scry%=666 //your custom size.
// For PC use menu;project;options;win32
GETSCREENSIZE scrx, scry
SETSCREEN scrx,scry,0    // Size matters.
CREATESCREEN 1,1,scrx,scry
// the drawing surface.
GLOBAL cnt%
//****************************************************
WHILE TRUE
//press F12 to view long lines of code.
LOCAL alpha=(RND(1999)/1000.0 -1.0)+0.00000003
// additive when >0
// interpolated when <0, ='mix' ='cross-fade'
// ...in my opinion.
LOCAL color%=RGB(128*RND(2)-1,128*RND(2)-1,128*RND(2)-1)
LOCAL smoothedge = 1.5+9*RND(2)
LOCAL thickness=1.5+11*RND(3)
// USESCREEN 1

IF RND(1) >0
drawdisc2(RND(scrx), RND(scry), 4+RND(300), color, alpha, smoothedge)   // yes smoothing.
ELSE
drawcircle2_(RND(scrx), RND(scry), 4+RND(300), thickness,color, alpha, smoothedge)   // yes smoothing.
ENDIF
//drawdisc1(RND(scrx), RND(scry), 4+RND(300), color, alpha) // no smoothing. // unused.

//USEASBMP // optional
USESCREEN -1
ALPHAMODE -1
DRAWSPRITE 1,0,0
SHOWSCREEN
INC cnt,1
IF cnt >4
cnt=0
SEEDRND (GETTIMERALL()) //shuffle the cards.
ENDIF

//FOR more clarity:
DEBUG alpha ; DEBUG "\n"
// please activate the 'bug' icon
// SLEEP 2012 // additional time

SLEEP 800 +RND(3333)
//SLEEP 787// Merry dream, liner!
WEND
//****************************************************


FUNCTION drawdisc1:cx%,cy%,r%,col%,a //raw shape
// a fast function with no blending.
//would be nearly 4x faster using symetry, working on just 1/4circle.
LOCAL r2% = r*r
USESCREEN 1
//Only plot within the screen to save time:
LOCAL bx1%=cx-r
IF bx1 <0 THEN bx1=0
LOCAL by1%=cy-r
IF by1 <0 THEN by1=0
LOCAL bx2%=cx+r
IF bx2 >scrx THEN bx2=scrx
LOCAL by2%=cy+r
IF by2 >scry THEN by2=scry

ALPHAMODE a // same speed for a=0, a=-1, strangely. Any suggestion for more speed?

FOR x%=bx1 TO bx2
FOR y%=by1 TO by2
IF (x-cx)*(x-cx) +(y-cy)*(y-cy) <= r2 THEN SETPIXEL x,y,col
NEXT
NEXT
ENDFUNCTION

// On the day the atom is a cube I will start believing in the square pixel.

FUNCTION drawdisc2: cx,cy,r,col%,a,smoo //smoothed.
// Basic values are a=-1, smoo=1.
// N.B. a= -1...+1 but a=0 cancels the smoothing.
//   (if trouble try a permanent "INC a, 0.00000000000000042")
// Higher smoo values blur the edges. (Do try it at home!)
// Smoothing is symetrical across the circle position:
// blurring goes both inwards and outwards. It is done in a quick
// way as it doesn't calculate SQR(d^2), using directly the r^2
// values for interpolation. Not as nice as a proper bicubic one.
// Just feel free to try your own way to interpolate the alpha
// value for a nicer smoothing/halo.
USESCREEN 1
IF smoo <0 THEN smoo =0
LOCAL halfsmoo =smoo*0.5
LOCAL r2  = (r-halfsmoo)*(r-halfsmoo) //contracted
LOCAL r2_ = (r+halfsmoo)*(r+halfsmoo) //expanded
LOCAL d2
LOCAL w=r2_ -r2

//Only plot within the screen to save time:
LOCAL bx1%=cx-r-halfsmoo
IF bx1 <0 THEN bx1=0
LOCAL by1%=cy-r-halfsmoo
IF by1 <0 THEN by1=0
LOCAL bx2%=cx+r+halfsmoo
IF bx2 >scrx THEN bx2=scrx
LOCAL by2%=cy+r+halfsmoo
IF by2 >scry THEN by2=scry


FOR x%=bx1 TO bx2
FOR y%=by1 TO by2

d2=(x-cx)*(x-cx) +(y-cy)*(y-cy)
IF d2 <= r2
ALPHAMODE a
SETPIXEL x,y,col
ELSEIF d2 >= r2_
// leave it alone.
ELSE
//interpolation:
ALPHAMODE (r2_ -d2)*a/w
SETPIXEL x,y,col
ENDIF
NEXT
NEXT
ENDFUNCTION

// On the day the atom is a cube I will start believing in the square pixel.

FUNCTION drawcircle2_: cx,cy,r,thick,col%,a,smoo //smoothed.
// Same principle as drawdisc2( .
// using the real r value instead of r*r looks nicer but takes longer.
// This interpolation is linear but I believe a 'S' shape would
// be perfect. Also keep in mind that only an alpha interpolation is
// NOT enough; at the same time you should also interpolate the
// color into the next area. (Yes it's a bit bizarre.)
USESCREEN 1
IF smoo <0 THEN smoo =0
LOCAL halfsmoo =smoo*0.5
LOCAL th =thick*0.5
LOCAL ra  = (r+halfsmoo+th)
LOCAL ra2  = (r+halfsmoo+th)*(r+halfsmoo+th) //outermost
LOCAL rb2  = (r+th)*(r+th) //
LOCAL rc2  = (r-th)*(r-th) //
LOCAL rd2  = (r-th-halfsmoo)*(r-th-halfsmoo) //innermost
LOCAL rd  = (r-th-halfsmoo)

LOCAL d2
LOCAL r2 =r*r
LOCAL w_out =ra-(r+th) +0.000001//r2_ -r2
LOCAL w_in  =(r-th)-rd +0.000001

//Only plot within the screen to save time:
LOCAL bx1%=cx-r-halfsmoo-th
IF bx1 <0 THEN bx1=0
LOCAL by1%=cy-r-halfsmoo-th
IF by1 <0 THEN by1=0
LOCAL bx2%=cx+r+halfsmoo+th
IF bx2 >scrx THEN bx2=scrx
LOCAL by2%=cy+r+halfsmoo+th
IF by2 >scry THEN by2=scry


FOR x%=bx1 TO bx2
FOR y%=by1 TO by2

d2=(x-cx)*(x-cx) +(y-cy)*(y-cy) //distance to center
IF d2 <= r2 //internal

IF d2 >= rc2
//plot it plain.
ALPHAMODE a
SETPIXEL x,y,col
ELSEIF d2 <=  rd2
// ignore it
ELSE
// interpolate, blend it.
ALPHAMODE (SQR(d2) -rd)*a/w_in
SETPIXEL x,y,col
ENDIF
ELSE //external

IF d2 < rb2
//plot it plain.
ALPHAMODE a
SETPIXEL x,y,col
ELSEIF d2 >=  ra2
// ignore it
ELSE
// interpolate, blend it.
ALPHAMODE (ra -SQR(d2))*a/w_out
SETPIXEL x,y,col
ENDIF
ENDIF
NEXT
NEXT
ENDFUNCTION

//__________________________________________________________________________________

// P.S. On the day the atom is a cube I will start believing in the square pixel.

#81
Normally, this doesn't copy the object. only the k reference gets copied. no j object is created. using j should act on the k object. Try and see.
#82
Code (glbasic) Select

// --------------------------------- //
// Project: objtestA0
// Start: Thursday, November 29, 2012
// IDE Version: 10.244


// SETCURRENTDIR("Media") // go to media files
SETSCREEN 400,400,0
LIMITFPS 25
mymain() // call your own 'main Function' here.



//____________________________________
// quit GLb's main function like this:
FUNCTION foo:
// keep it empty.
ENDFUNCTION



//LOCAL z%
// this 'z' declaration doesn't work here any more,
// because it's outside a function.
INLINE

class Koto{
public:
int fish;
Koto(){}; // constructor
~Koto(){}; // destructor
void ppprint()
{ for (int z=3; z<=13; z++)
{ PRINT( z, 30+2*z,25*z);
PRINT( z+2, 60+2*z,25*z);
}

// F***
// // //ENDINLIN* // ADDING THE 'E' => ERROR.
// although it's printed in yellow like a comment.
// it's a 7-leg bug.
// INLINE ... is ignored properly.

/*
F***
other out-comments work o.k. otherwise.
*/

};
protected:
private: // ad libitum

};
ENDINLINE




FUNCTION mymain:
INLINE
Koto k; // instanciation.
k.ppprint(); // run the Fn.
ENDINLINE

SHOWSCREEN
MOUSEWAIT // please click to quit.
END

ENDFUNCTION // it works fine.

#83
Quote from: Ian Price on 2008-Apr-01
That'll make functions easier, but it doesn't help for a block of comments that aren't in functions (I suppose I could make them functions, but that's excessive). I'd rather /* */ than do that.

Here is a way to get it:

Code (glbasic) Select

inline
/*
here your out-commented code, many lines
...
and then
*/
endinline
#84
How is it possible?   :'( Inside a function, a static variable has useful properties but how can DIM or DIMDATA be used only once to define the array size -typical for static variables-, when they must be located inside the function? Is it possible to locate them outside the function, and be called only once so the values of the array remain STATIC? Or must all arrays be only GLOBAL or LOCAL?

One more array trouble: when i pause the program to debug, only the 1st element var[0] shows a realistic value in the debug window. Did i miss an update?

Thanks everyone!
#85
Quote from: Schranz0r on 2012-Jul-16
you need the headers

Thanks. Can you explain a bit which headers are necessary? Using intents should be useful to open a native keyboard as well, when necessary. (i'm aware of the IMPUT code, but...)
#86
Hi!
Someone already asked how to open a web browser with given url in iOS.
I have the same question for android.
Here are some guidelines, but they are written in java:
Code (glbasic) Select
String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);

or:
Code (glbasic) Select
startActivity(new Intent(Intent.ACTION_VIEW,
    Uri.parse("http://www.google.com")));

(http://stackoverflow.com/questions/3004515/android-sending-an-intent-to-browser-to-open-specific-url)
How can we adapt that for some C inline code in GLbasic?
Many thanks in advance!
#87
Quote from: ampos on 2012-Mar-23
It is working for me...

I feel very happy for you!
Could you mention which device you use, and to which value the accelerators are calibrated to? I use an archos 101G9 and strangely all accelerators return a calibration value of 0.917 -or so- instead of the expected 9.81, when GLbasic reads the value.
is it a non-standard device?
will GLbasic find the same value on all device?
What's going on?
is there any option to read other sensors like gyroscope, in GLbasic?

Thank's for your help, I'm about to release a game that must run correctly on all devices.
#88
Quote from: ampos on 2011-Sep-06
My Android tablet 2.3 fails miserably on grabsprite/mem2sprite, and Gernot says it is a driver issue...

Same problem here, GRABSPRITE not working on android tablet archos 101G9.
Dear Administrator, i'm facing a strange problem with my android tablet:
i use LOADSPRITE (bmp and png), STRETCHSPRITE, GRABSPRITE.
After some tests, GRABSPRITE works on the local win7 compilation, on the Android emulator, but not on the device (Archos 101G9). What's up Doc'? (driver issue?)

The program: one set of a game keeps displaying the same few sprites over and over, and each set has its own sprite size, to maximize screen space usage.
My strategy to spare some repeated stretchings by creating some "pre-fetched" sprites to the right size:
Code (glbasic) Select
LOADSPRITE "name.png", 10 // about twice too big
//  SETORIENTATION 0
STRETCHSPRITE 10, 0,0,  newsize, newsize //correct size, smaller. Printed on backbuffer
GRABSPRITE 10, 0,0,  newsize, newsize // or assign a new SpriteNumber, same result (sob)

//inside the drawing function
DRAWSPRITE 10, poz_x, poz_y   // always working

//even later
SHOWSCREEN


i tried various "setorientation values" to no avail, as well as setting android:resizable="true" in AndroidManifest.xml. I also tried to replace the coordinates 0,0 with 2,2 for stretchsprite and grabsprite, without result.
However, using only some repeated STRETCHSPRITE 's does work (but CPU consumming, not elegant).

Any idea anyone?

PS the rest works well now. i do a fresh win7 boot, connect the tablet or open the simulator, open a console and type "adb devices" or "adb usb", start GLbasic as administrator, then the automatic installation on the device/emulator does work from the IDE compilation for android. Nice job Gernot!  :nw:  =D
#89
Thanks Gernot, now it works. You said:

uninstall GLBasic, delete the directory C:\program files\GLBasic\. Reinstall now.
Now open the editor, press menu web/live-update. Perform update to the latest version.

Then look in your project. Is there an icon.png in the directory where the .gbap file is? If not, put one there. 512x512 is recomended.

Open your proejct now. Press the trashcan icon.
In menu project/options enter your company name and a project name. Don't use spaces, special chars and numbers here.

Now compile for Android again.

...and now it works; Many thanks!!!  :nw:

PS My tip of the day for the beginners, if anything stops to work:
I do a fresh win7 boot, connect the tablet or open the simulator, open a console and type "adb devices" or "adb usb", start GLbasic as administrator, then the automatic installation on the device/emulator does work from the IDE compilation for android. Nice job Gernot!  =D
#90
Hi! Gernot helped me reinstalling everything and now the i d e compiles o.k. and installs directly to the emulator:

Hi,

uninstall GLBasic, delete the directory C:\program files\GLBasic\. Reinstall now.
Now open the editor, press menu web/live-update. Perform update to the latest version.

Then look in your project. Is there an icon.png in the directory where the .gbap file is? If not, put one there. 512x512 is recomended.

Open your proejct now. Press the trashcan icon.
In menu project/options enter your company name and a project name. Don't use spaces, special chars and numbers here.

Now compile for Android again.

Nice one Gernot! (errr... what was wrong actually?)