Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology
Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered
You are not logged in.
uhhh ...
What bitmap is grey ? The saved bitmap file (and open in an external software) or the render widget is grey ?
If the trnasparency is set, the grey can be the 3d scene background ?
Offline
this work this way :
very strange the _DRAWtext8 make weird things on original bitmap but on the bitmap copy this works well.
or maybe this is the other way, that the _CRalphaBitmap corrupt the bitmap8 ?!
I've tried to look in the code and debug, the only thing I've correct is the palette creation that failed, but this change nothing on this...
typeof widget_font= ObjFont;;
typeof message= MessageBox;;
typeof my_widget= SO3_WIDGET;;
typeof abitmap = AlphaBitmap;;
/*
fun deleteOb(inst)=
let (V3DgetDefaultViewport (V3DgetSessionView c3dXsession)) -> viewportstr in
V3DremoveWidgetControl viewportstr my_widget;
SO3WidgetDestroy my_widget;
_DSalphaBitmap abitmap;
0;;
*/
fun drawBitmap(text, wsize, tsize)=
let wsize -> [texWidth texHeight] in
let tsize -> [tw th] in
let _FILLbitmap (_CRbitmap _channel texWidth texHeight) 0xffffff -> bmpRgb in
let _FILLbitmap8 (_CRbitmap8 _channel texWidth texHeight) 0 -> bmp8 in
(
let _CRalphaBitmap _channel bmpRgb bmp8 nil nil -> abmp in
let _GETalphaBitmaps abmp -> [rgb alpha] in
(
_DRAWtext rgb widget_font (texWidth / 2) (texHeight / 2) - (th / 2) TD_CENTER 0x000000 text;
_DRAWtext8 alpha widget_font (texWidth / 2) (texHeight / 2) - (th / 2) TD_CENTER 0xff text;
SO3BitmapWidgetBlitAlpha my_widget abmp;
set abitmap = abmp;
);
//bitmaps copied in alpha bitmap so we can destroy them
_DSbitmap bmpRgb;
_DSbitmap8 bmp8;
);
0;;
fun mainfunction()=
let (V3DgetDefaultViewport (V3DgetSessionView c3dXsession)) -> viewportstr in
let [10 10] -> [xmargin ymargin] in
let "Arkeon and Iri help me all the time!" -> text in
(
set widget_font = _CRfont _channel 12 0 0 "Lucida Console";
let G2DgetStringSize widget_font text -> [tw th] in //text height
let [(tw + (xmargin * 2)) (th + (ymargin * 2))] -> [texWidth texHeight] in
(
set my_widget = SO3BitmapWidgetCreate (V3DgetSession c3dXsession) viewportstr.V3D_viewport "new_widget" 0 0 texWidth texHeight 100;
V3DaddWidgetControl viewportstr my_widget;
drawBitmap text [texWidth texHeight] [tw th];
);
SO3WidgetSetTransparency my_widget 1;
SO3WidgetSetKeyboardEnable my_widget 0;
SO3WidgetSetMouseEnable my_widget 0;
SO3WidgetSetVisibility my_widget 1;
);
0;;
Offline
It's possible. ObjBitmap8 is a very old api ...
In lib2d os 24 / src / alphaBitmap.c / _CRalphaBitmap, the bg color from the given ObjBitmap8 (not the given background arg in the function) is pushed to nil. May be a reason ...
Offline
It's possible. ObjBitmap8 is a very old api ...
In lib2d os 24 / src / alphaBitmap.c / _CRalphaBitmap, the bg color from the given ObjBitmap8 (not the given background arg in the function) is pushed to nil. May be a reason ...
if using the bitmap widget isn't working well at this point, would using an webnavigator widget offer an option?
Last edited by hebdemnobad (28-Jan-2014 16:39:39)
Offline
I modified the template plugit since it can destroy the widget when the os3d editor is not running the scene. I posted the scene to:
http://ifam.net/widget2/web/index.html
I don't see any widget rendering. I made the background color bluish in case the letters appeared in the default gray.
Here is the image saved by the plugit as per iri's code. I put it in the template plugit since it has a callback allowing for destruction of the widget.
here is the modified template plugit code, with Iri's method of creating the widget:
var WHITE = 0xFF;;
var BLACK = 0x00;;
var MARGIN = 10;; /* a margin around the text to draw, in pixel */
var IS_TRANSPARENT = 1;; /* if you don't want the transparency, set it to 0 */
var FONT_NAME = "Arial";;
var FONT_SIZE = 24;;
typeof widget_font = ObjFont;;
typeof my_widget= SO3_WIDGET;;
/*
fun [S S] I
Display a popup message with the function name
S : the function name
S : the message to show
I : return always 1
*/
/*
fun [ObjBitmap] I
Save a RGB bitmap in a file
*/
fun saveBmp (bmpRGB)=
_SAVEbitmap bmpRGB _getmodifypack "tests/bmpRGB.bmp";
0;;
/*
fun [S] [I I]
return the width and the height depending on the given font
*/
fun getTextSize (text, font)=
G2DgetStringSize font text;;
/*
fun [S] [I I I I]
return the bitmap size according to the text to draw and its margin
S : the text to draw
[I I I I] : the width and the height of the bitmap, the width and
the height of the text
*/
fun getSize (text)=
let getTextSize text widget_font -> [txtWidth txtHeight] in
[(txtWidth + (MARGIN * 2)) (txtHeight + (MARGIN * 2)) txtWidth txtHeight];;
/*
fun [S I I] ObjBitmap
create, fill and draw a text onto a 24-bits bitmap object
S : a text to draw
I : the 24-bits color (like HTML) to fill the bitmap
ObjBitmap : the new bitmap or nil if error
*/
fun drawBitmap (text, colorRGB)=
let getSize text -> [bmpWidth bmpHeight txtWidth txtHeight] in
_DRAWtext
_FILLbitmap
_CRbitmap
_channel
bmpWidth
bmpHeight
colorRGB
widget_font
bmpWidth / 2
MARGIN
TD_CENTER|TD_TOP
BLACK
text;;
/*
fun [S I I] ObjBitmap8
create, fill and draw a text onto a 8-bits bitmap object
S : a text to draw
I : the 24-bits color (like HTML) to fill the bitmap
ObjBitmap8 : the new 8-bits bitmap (alpha) or nil if error
*/
fun drawBitmap8 (text, colorGrey)=
let getSize text -> [bmpWidth bmpHeight txtWidth txtHeight] in
_DRAWtext8
_FILLbitmap8
_CRbitmap8
_channel
bmpWidth
bmpHeight
colorGrey
widget_font
bmpWidth / 2
MARGIN
TD_CENTER|TD_TOP
BLACK
text;;
/*
fun [S [I I] I] [ObjBitmap ObjBitmap8]
create the two components for the AlphaBitmap : a 24-bits bitmap
and a 8-bits bitmap if asked.
S : a text to draw
[I I] : the RGB color and the Grey color to fill the bitmaps background
I : a flag : if you want an alpha channel (a 8-bits bitmap), set it to 1
else set it with another value
[ObjBitmap ObjBitmap8] : a tuple with the two resources or nil if error
The second item can be nil too if you don't want the transparency (flag != 1)
*/
fun drawBitmaps (text, colors, iBmp8Too)=
if widget_font == nil then
nil
else
let colors -> [colorRGB colorGrey] in
let drawBitmap text colorRGB -> bmpRGB in
let
if iBmp8Too then
drawBitmap8 text colorGrey
else
nil
-> bmpGrey in
[bmpRGB bmpGrey];;
/*
fun [S] AlphaBitmap
create a new alphabitmap and save and destroy the temporary 2d resources
S : a text to draw
AlphaBitmap : the new AlphaBitmap or nil if error
*/
fun crAlphaBitmap (text)=
let drawBitmaps text [WHITE BLACK] IS_TRANSPARENT -> [bmpRGB bmpGrey] in
let _CRalphaBitmap _channel bmpRGB bmpGrey nil nil -> abmp in
(
saveBmp bmpRGB;
_DSbitmap bmpRGB;
_DSbitmap8 bmpGrey;
abmp
);;
/*
fun [ ] I
Try to create a font object.
I : return 0 if success, 1 if fail
*/
fun crFont ()=
set widget_font = _CRfont _channel FONT_SIZE 0 0 FONT_NAME;
0;;
/*
fun [S] S
S : a base name for the 3d resource
S : return an unique name
*/
fun getName3dRsc (name)=
strcat name itoa _tickcount;;
/*
fun [S [I I]] I
create a widget.
S : the name of this resource (it will be unique by call to getName3dRsc function)
[I I] : the widget size
I : return 0 if success, 1 if fail
*/
fun crWidget (name, size)=
set name = getName3dRsc name;
let size -> [width height] in
let V3DgetDefaultViewport
V3DgetSessionView c3dXsession
-> viewportstr in
(
set my_widget = SO3BitmapWidgetCreate (V3DgetSession c3dXsession) viewportstr.V3D_viewport name 200 200 width height 100;
V3DaddWidgetControl viewportstr my_widget;
SO3WidgetSetTransparency my_widget 1;
SO3WidgetSetKeyboardEnable my_widget 0;
SO3WidgetSetMouseEnable my_widget 0;
SO3WidgetSetVisibility my_widget 1;
0;
);
0;;
/*! \brief Callback on instance destruction
* Callback called when a plugIT instance is destroyed
*
* <b>Prototype:</b> fun [PInstance u0] I
*
* \param PInstance : destroyed plugIT instance
* \param u0 : user parameter, the type is not defined here because it is not used in this template
*
* \return I : 0
**/
fun deleteOb(inst, uparam)=
V3DremoveWidgetControl (V3DgetDefaultViewport (V3DgetSessionView c3dXsession)) my_widget;
SO3WidgetDestroy my_widget;
0;;
// plugIT doing something
fun doSomething(value)=
// test the value to define a default one
crFont;
let "Arkeon and Iri help me all the time!" -> text in
let crAlphaBitmap text -> abmp in
let getSize text -> [width height _ _] in
(
crWidget "new_widget" [width height];
);
0;;
/*! \brief Callback on "Go" dms action
*
* Call the program function to display a dialog box
*
* <b>Prototype:</b> fun [PInstance DMI S S I u0] I
*
* \param PInstance : plugIT instance
* \param DMI : DMS module who call the action (not used)
* \param S : name of the launched action
* \param S : data posted in DMS action link
* \param I : reply flag (not used)
* \param u0 : user parameter, the type is not defined here because it is not used in this template
*
* \return I : 0
**/
fun cbGo(inst, from, action, param, rep, uparam)=
// call the dialog box and set the link parameter as text
doSomething param;
0;;
/*! \brief Callback on new plugIT instance
*
* Read the parameters from editor values and initialise the plugIT
*
* <b>Prototype:</b> fun [PInstance] I
*
* \param PInstance : plugIT instance
*
* \return I : 0
**/
fun newOb(inst)=
// retrieve the oninit param value
let atoi (getPluginInstanceParam inst "oninit") -> state in
(
// define the function to call when we receive the Go action
PluginRegisterAction inst "Go" mkfun6 @cbGo nil;
// test the oninit param to know if we have to start the plugIT functionalities here
if !state then nil else
doSomething nil;
// define the function to call when the plugIT instance is destroyed
setPluginInstanceCbDel inst mkfun2 @deleteOb nil;
);
0;;
/*! \brief Global plugIT function to initialize the plugIT callbacks
*
* called on plugIT load, here define the functions to use for a new instance and the editor
*
* <b>Prototype:</b> fun [s] I
*
* \param S : plugIT file path
*
* \return I : 0
**/
fun IniPlug(file)=
PlugRegister @newOb nil;
setPluginEditor @dynamicedit;
0;;
Last edited by hebdemnobad (28-Jan-2014 20:24:14)
Offline
a general bitmaps question...I think I am understanding it more now. thanks for your patience (assuming that I understand things correctly)
objBitmap is a bitmap without transparency
AlphaBitmap is an rgb bitmap with a transparency component (the transparency is an 8bit greyscale bitmap where there are 255 levels of gray)
Offline
you're right !
So all bitmap manipulations are done on ObjBitmap (ObjBitmap8). AlphaBitmap encapsulates, that's all.
Ok finally I got something right with these bitmaps....let me know what you see in the page I posted.
Offline
About your code above, try to set SO3WidgetSetTransparency to 0 instead 1. Maybe ...
I tried, still no widget.
Offline
yes that it
look at my previous post for a working code
and you should destroy the objFont and ObjAlphaBitmap, you can do it after the WidgetBlit
Offline
Ok finally I got something right with these bitmaps....let me know what you see in the page I posted.
I'm reinstalling my Windows virtual machine (i'm linuxian), so i'll see later (if Windows install is OK !).
If you are a dirty graphic card, I'd be like you, with a similar rendering. Thus, the comparaison should be easy !
Offline
yes that it
look at my previous post for a working code
and you should destroy the objFont and ObjAlphaBitmap, you can do it after the WidgetBlit
If SO3WidgetSetTransparency my_widget is set to 0, the widget appears!
But, on the downside, there is no transparency, there's a white box with the black text in it. ....how could we fix that?
Last edited by hebdemnobad (28-Jan-2014 21:57:13)
Offline
hebdemnobad wrote:Ok finally I got something right with these bitmaps....let me know what you see in the page I posted.
I'm reinstalling my Windows virtual machine (i'm linuxian), so i'll see later (if Windows install is OK !).
If you are a dirty graphic card, I'd be like you, with a similar rendering. Thus, the comparaison should be easy !
Testing on bad hardware is the best for any type of web based 3d since you don't know who your audience is.
Offline
Thx arkeon for this variant of the widget code. The widget renders in the editor. If the text is drawn in white (in the rgb and in the 8bit alpha channel), sometimes the letters are gray, sometimes they are white. When I publish to my site, the downloaded scene doesn't render anything.:/ ....
thx arkeon and iri for getting me this far. now I know my bitmaps, well a little better than before. here is the code that worked for me, I did some surgery on the template plugit:
typeof widget_font= ObjFont;;
typeof message= MessageBox;;
typeof my_widget= SO3_WIDGET;;
typeof abitmap = AlphaBitmap;;
fun deleteOb(inst, param)=
let (V3DgetDefaultViewport (V3DgetSessionView c3dXsession)) -> viewportstr in
V3DremoveWidgetControl viewportstr my_widget;
SO3WidgetDestroy my_widget;
_DSalphaBitmap abitmap;
0;;
fun drawBitmap(text, wsize, tsize)=
let wsize -> [texWidth texHeight] in
let tsize -> [tw th] in
let _FILLbitmap (_CRbitmap _channel texWidth texHeight) 0xffffff -> bmpRgb in
let _FILLbitmap8 (_CRbitmap8 _channel texWidth texHeight) 0 -> bmp8 in
(
let _CRalphaBitmap _channel bmpRgb bmp8 nil nil -> abmp in
let _GETalphaBitmaps abmp -> [rgb alpha] in
(
_DRAWtext rgb widget_font (texWidth / 2) (texHeight / 2) - (th / 2) TD_CENTER 0xffffff text;
_DRAWtext8 alpha widget_font (texWidth / 2) (texHeight / 2) - (th / 2) TD_CENTER 0xff text;
SO3BitmapWidgetBlitAlpha my_widget abmp;
set abitmap = abmp;
);
//bitmaps copied in alpha bitmap so we can destroy them
_DSbitmap bmpRgb;
_DSbitmap8 bmp8;
);
0;;
fun mainfunction()=
let (V3DgetDefaultViewport (V3DgetSessionView c3dXsession)) -> viewportstr in
let [10 10] -> [xmargin ymargin] in
let "Arkeon and Iri help me all the time!" -> text in
(
set widget_font = _CRfont _channel 22 0 0 "Lucida Console";
let G2DgetStringSize widget_font text -> [tw th] in //text height
let [(tw + (xmargin * 2)) (th + (ymargin * 2))] -> [texWidth texHeight] in
(
set my_widget = SO3BitmapWidgetCreate (V3DgetSession c3dXsession) viewportstr.V3D_viewport "new_widget" 50 50 texWidth texHeight 100;
V3DaddWidgetControl viewportstr my_widget;
drawBitmap text [texWidth texHeight] [tw th];
);
SO3WidgetSetTransparency my_widget 1;
SO3WidgetSetKeyboardEnable my_widget 0;
SO3WidgetSetMouseEnable my_widget 0;
SO3WidgetSetVisibility my_widget 1;
);
0;;
/*! \brief Callback on instance destruction
* Callback called when a plugIT instance is destroyed
*
* <b>Prototype:</b> fun [PInstance u0] I
*
* \param PInstance : destroyed plugIT instance
* \param u0 : user parameter, the type is not defined here because it is not used in this template
*
* \return I : 0
**/
// plugIT doing something
fun doSomething(value)=
mainfunction;
0;;
/*! \brief Callback on "Go" dms action
*
* Call the program function to display a dialog box
*
* <b>Prototype:</b> fun [PInstance DMI S S I u0] I
*
* \param PInstance : plugIT instance
* \param DMI : DMS module who call the action (not used)
* \param S : name of the launched action
* \param S : data posted in DMS action link
* \param I : reply flag (not used)
* \param u0 : user parameter, the type is not defined here because it is not used in this template
*
* \return I : 0
**/
fun cbGo(inst, from, action, param, rep, uparam)=
// call the dialog box and set the link parameter as text
doSomething param;
0;;
/*! \brief Callback on new plugIT instance
*
* Read the parameters from editor values and initialise the plugIT
*
* <b>Prototype:</b> fun [PInstance] I
*
* \param PInstance : plugIT instance
*
* \return I : 0
**/
fun newOb(inst)=
// retrieve the oninit param value
let atoi (getPluginInstanceParam inst "oninit") -> state in
(
// define the function to call when we receive the Go action
PluginRegisterAction inst "Go" mkfun6 @cbGo nil;
// test the oninit param to know if we have to start the plugIT functionalities here
if !state then nil else
doSomething nil;
// define the function to call when the plugIT instance is destroyed
setPluginInstanceCbDel inst mkfun2 @deleteOb nil;
);
0;;
/*! \brief Global plugIT function to initialize the plugIT callbacks
*
* called on plugIT load, here define the functions to use for a new instance and the editor
*
* <b>Prototype:</b> fun [s] I
*
* \param S : plugIT file path
*
* \return I : 0
**/
fun IniPlug(file)=
PlugRegister @newOb nil;
setPluginEditor @dynamicedit;
0;;
Offline
fwiw, I changed the line drawing the text into the alpa channel from
let _FILLbitmap8 (_CRbitmap8 _channel texWidth texHeight) 0 -> bmp8 in
to
let _FILLbitmap8 (_CRbitmap8 _channel texWidth texHeight) 0x00 -> bmp8 in
I thought perhaps the voyager wanted the hexidecimal version of black (0x00) and that would help things, but the behavior is the same (sometimes text appears white in the editor, or gray in the editor, and the text does not render at all in the browser.)
Offline
fwiw, I changed the line drawing the text into the alpa channel from
let _FILLbitmap8 (_CRbitmap8 _channel texWidth texHeight) 0 -> bmp8 in
to
let _FILLbitmap8 (_CRbitmap8 _channel texWidth texHeight) 0x00 -> bmp8 in
I thought perhaps the voyager wanted the hexidecimal version of black (0x00) and that would help things, but the behavior is the same (sometimes text appears white in the editor, or gray in the editor, and the text does not render at all in the browser.)
0 and 0x00 are the same value.
Offline
Hi !
is this the same with the 1.6.4 version I send to you ?
No this was with 6.3. Will try 6.4 later today.
Offline
arkeon wrote:Hi !
is this the same with the 1.6.4 version I send to you ?
No this was with 6.3. Will try 6.4 later today.
Several changes in this beta version can help you.
Offline
It works!!!!!! But sometimes the lettering renders gray, sometimes very dark grey (almost black, it's hard to see the letters) and sometimes (after refreshing the page) it renders white, so now the behavior in the player and editor are the same, but unpredictable:
http://ifam.net/openspace/widgetworks1/web/
Last edited by hebdemnobad (30-Jan-2014 19:31:22)
Offline
arg
the draw text function is a part of the windows api ^^
and I found nothing particular on it...
I'll try to find the problem again tomorrow
Offline
Hey !
finally i've found the bug, in bitmap8 creation methods the color palette was not setted correctly in several ways ^^
Now it works well even with text draw before the Alpha bitmap creation.
I'll commit updated setups in some hours with again more corrections in Scol and OS3D.
Offline
Hey !
finally i've found the bug, in bitmap8 creation methods the color palette was not setted correctly in several ways ^^
Now it works well even with text draw before the Alpha bitmap creation.I'll commit updated setups in some hours with again more corrections in Scol and OS3D.
Great, thanks.
Offline