Author Topic: SETTRANSPARENCY question  (Read 3330 times)

Offline Paul Smith

  • Mr. Polyvector
  • ***
  • Posts: 105
    • View Profile
SETTRANSPARENCY question
« on: 2015-Jun-02 »
I'm having trouble getting this working if its possible at all.
I can set transparency to any colour and overlay with no problems.
I then change the transparency to a different colour , grabsprite , then drawsprite to a new location in essence having 2 layer of transparency, how ever this bit never works no matter what i try.

what I am trying to do is have a font outline which is white and never changes.
the inside of the fonts in pink RGB255,0,128 and is draw over a background. this works
I then change the transparency to blue, grabsprite in the area I need which is the outside of the font background.
and draw it onto a new background.
however it always blue.(or the colour i picked)

Ive changed the colour
its A png image
ive tested the colour is saved right( Hence the bug I noticed in UO Dingsfont)
coded it in different orders but never works

Is it possible or Im I doing about it the wrong way.

cheers Paul

Amstrad CPC 6128, ATARI STE.
Acer  SW5-173 & AMD FX 8350/1050Ti

MrTAToad

  • Guest
Re: SETTRANSPARENCY question
« Reply #1 on: 2015-Jun-02 »
Have you tried setting the transparency back to the original colour ?

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3606
    • View Profile
    • Space Fractal
Re: SETTRANSPARENCY question
« Reply #2 on: 2015-Jun-02 »
if its png, you should uses the transparency  layer instead of a color.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline Paul Smith

  • Mr. Polyvector
  • ***
  • Posts: 105
    • View Profile
Re: SETTRANSPARENCY question
« Reply #3 on: 2015-Jun-03 »
Found out I can't change the 2nd layer as it ignores  the Settransparency, but if I save the first layer sprite to disc then change the transparency and load it then it works.
I need to do this in memory for speed. any Idea's

A PNG with a transparent mask cant have SETTRANSPARENCY function, well not for me anyway.
BMP works better.

This bit of code works but with disc uses.

Code: GLBasic [Select]
SETCURRENTDIR("Media") // go to media files
SETSCREEN 1366,768,0
ALPHAMODE -1
SETTRANSPARENCY RGB(255,3,129)  //inner font colour
//LOADFONT "your1111.png",3
LOADFONT "your1111.bmp",3
//SETTRANSPARENCY RGB(0,0,0)
//SETTRANSPARENCY RGB(255,255,255)

GLOBAL t
SETFONT 3,8
LOADSPRITE "back.jpg",10
DRAWSPRITE 10,0,0
PRINT "TEST TEST",0,500
GRABSPRITE 5,0,450,1366,300
SAVESPRITE "test.bmp",5
SETTRANSPARENCY RGB(129,129,129) //background colour
LOADSPRITE "test.bmp",6
SHOWSCREEN
KEYWAIT
DRAWSPRITE 10,0,0
DRAWSPRITE 6,0,0
SHOWSCREEN
KEYWAIT
 
Amstrad CPC 6128, ATARI STE.
Acer  SW5-173 & AMD FX 8350/1050Ti

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3606
    • View Profile
    • Space Fractal
Re: SETTRANSPARENCY question
« Reply #4 on: 2015-Jun-03 »
SETTRANSPARENCY is not needed for PNG at all anyway. That due PNG does have a alpha layer.

You might want to uses SETTRANSPARENCY -1 here.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4179
    • View Profile
    • Portfolio
Re: SETTRANSPARENCY question
« Reply #5 on: 2015-Jun-04 »
I think I know what you mean, if so, we discussed this before to no end (nether a good solution).
If that is the case, we need a drawing mode that can draw alpha holes.

One thing that GLB is missing IMO, is blending modes, specially the ability do draw alphas.
Hopefully Gernot is thinking about that too. :-[ :-[ :-[ :whistle:

I will try to find the thread so you check if that is the case.

EDIT: Found, check the last post on this thread and the discussions that goes on, is that what you are looking for?
http://www.glbasic.com/forum/index.php?topic=8906.0

If it is, it should be doable on desktops, we were actually discussing about the caanoo. ;)
« Last Edit: 2015-Jun-04 by erico »

Offline Paul Smith

  • Mr. Polyvector
  • ***
  • Posts: 105
    • View Profile
Re: SETTRANSPARENCY question
« Reply #6 on: 2015-Jun-04 »
Cheers I'll read through the link tonight if I'm not busy on call.
Amstrad CPC 6128, ATARI STE.
Acer  SW5-173 & AMD FX 8350/1050Ti

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3606
    • View Profile
    • Space Fractal
Re: SETTRANSPARENCY question
« Reply #7 on: 2015-Jun-04 »
alpha on a virtual screen is also a quite buggy and showing a multiply alpha issue im have seen in my games. That one of the main reason im newer use virtual screen, but instead scaling the graphics directly to avoid the issue.

png uses alpha channel as transperancy, hence SETTRANSPARENCY with them dosent giving any meaning at all. Its a command im have not used in any of my games, because im either uses PNG or JPG (when TRANSPERANCY is not required at all).

Alternative you can tryout disable SMOOTHING, which can help on some cases.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline Paul Smith

  • Mr. Polyvector
  • ***
  • Posts: 105
    • View Profile
Re: SETTRANSPARENCY question
« Reply #8 on: 2015-Jun-14 »
Gave up on this in the end, I just used alphamode and made the top layer fully transparent. but thanks for the pointers.
Stuck on something else now. when trying to add FMOD to my project I get the error below.The project in the GLB sample folder compiles perfectly and works, but I get these error if I try a add them to my project or If I start a new project add the fmod_player source but cut and paste the player_interface.
probably somthing simple

compiling:
C:\Users\PAULSL~1\AppData\Local\Temp\glbasic\gpc_temp1.cpp: In destructor `__GLBASIC__::FMOD_killer::~FMOD_killer()':
C:\Users\PAULSL~1\AppData\Local\Temp\glbasic\gpc_temp1.cpp:34: error: `IF' was not declared in this scope
C:\Users\PAULSL~1\AppData\Local\Temp\glbasic\gpc_temp1.cpp:34: error: expected `;' before "FMod_Stop"
C:\Users\PAULSL~1\AppData\Local\Temp\glbasic\gpc_temp1.cpp: In function `DGInt __GLBASIC__::FMod_Load(__GLBASIC__::DGStr)':
C:\Users\PAULSL~1\AppData\Local\Temp\glbasic\gpc_temp1.cpp:77: error: `IF' was not declared in this scope
C:\Users\PAULSL~1\AppData\Local\Temp\glbasic\gpc_temp1.cpp:77: error: expected `;' before "FSOUND_Init"
C:\Users\PAULSL~1\AppData\Local\Temp\glbasic\gpc_temp1.cpp:81: error: expected `;' before "g_pFMod"
C:\Users\PAULSL~1\AppData\Local\Temp\glbasic\gpc_temp1.cpp:83: error: expected `;' before "good"
*** FATAL ERROR - Please post this output in the forum
_______________________________________
*** Finished ***
Elapsed: 2.9 sec. Time: 00:18
Build: 0 succeeded.
*** 1 FAILED ***
Amstrad CPC 6128, ATARI STE.
Acer  SW5-173 & AMD FX 8350/1050Ti

MrTAToad

  • Guest
Re: SETTRANSPARENCY question
« Reply #9 on: 2015-Jun-14 »
Looks like the IDE has changed C++ commands to uppercase...

Offline Paul Smith

  • Mr. Polyvector
  • ***
  • Posts: 105
    • View Profile
Re: SETTRANSPARENCY question
« Reply #10 on: 2015-Jun-14 »
Well spotted, the IDE changed 4 "if"s to "IF"s. must have look at this about 10x and still missed it.

Thanks TheMapChap

 :nw: :nw: :nw:
Amstrad CPC 6128, ATARI STE.
Acer  SW5-173 & AMD FX 8350/1050Ti

MrTAToad

  • Guest
Re: SETTRANSPARENCY question
« Reply #11 on: 2015-Jun-14 »
It can be annoying when that happens - unfortunately the IDE doesn't check to see whether to leave code inside INLINE code alone.

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1634
  • Particle Hawk
    • View Profile
Re: SETTRANSPARENCY question
« Reply #12 on: 2015-Aug-02 »
I'm having trouble getting this working if its possible at all.
I can set transparency to any colour and overlay with no problems.
I then change the transparency to a different colour , grabsprite , then drawsprite to a new location in essence having 2 layer of transparency, how ever this bit never works no matter what i try.

what I am trying to do is have a font outline which is white and never changes.
the inside of the fonts in pink RGB255,0,128 and is draw over a background. this works
I then change the transparency to blue, grabsprite in the area I need which is the outside of the font background.
and draw it onto a new background.
however it always blue.(or the colour i picked)

Ive changed the colour
its A png image
ive tested the colour is saved right( Hence the bug I noticed in UO Dingsfont)
coded it in different orders but never works

Is it possible or Im I doing about it the wrong way.

cheers Paul


This is something you will have to do by hand i think.
To do this youll need layers, and youll need to follow the opengl rules to keep it all correct..x2 dimensions etc..

Youll need to create a font, and expand the original image size in a 2d image editor like mspaint or something,
 and MOVE all the characters by hand....daunting.
Once dont doing that, make a copy, one copy is the foreground and one is the background layer.
Flip the color of your background outlined font....and go through the whole image by hand and remove all the pixels that you DONT want to see by transparent coloring them.
At this point youll have 2 font which you will need to overlay.

The end result isnt going to be what you expect..because you are anti-kerning these characters.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)