English
Source / code snippets

Juhu Opengl Textures Tga Transparente

 
- Page 1 -


Juhu Transparente Textures - its me been successful

TGAs can a 4 layer (transparentslayer) imply - XProfan can but from this TGAs no Textures produce which too yet transparent are.

For which?

walls with holes? One ball with rauer surface? Highmap via Bitmap?

or: 2D-Sprites by OGL?

light and Partikeleffekte?

now building I yet one two tools to that Save this TGAs - and then can also eachone what with begin.

22 kB
Hochgeladen:11/09/06
Downloadcounter670
Download
 
11/09/06  
 



 
- Page 1 -


Something like goes so...
CompileMarkSeparation
 {$cleq}
cls
ogl(init,%hwnd,0.0,0.0,0.0,1)
ogl(posmode,1)
int tex.spaceShip=ogl.loadtex(spaceship.tex)
int tex.background=ogl(loadtexturebmp,tile4.bmp,3)
float x,y,xpos,ypos,f=1.6,fps=50,speed=0.5,wxpos,wypos
long fpsc,fpstme=gettickcount+200,ompos

while 1

    fpsc+

    if fpstme<gettickcount

        fpstme:=fpstme+200
        fps:=fpsc
        fpsc:=0

    endif

    case mousepressed : break
    oGL(Clear)
    ogl(move,0,0,-3)
    ogl(push)
    ogl(texture,tex.background,10)
    ogl(move,x-3,y-3,0)
    ogl(quad,8,8)
    ogl(pop)
    ogl(rotate,0,0,mousex)
    ogl(texture,tex.spaceShip,1)
    ogl(quad,0.5,0.5)
    ogl(show)
    wypos:=sin((mousex+90)*0.01745329)
    wxpos:=cos((mousex+90)*0.01745329)
    xpos:=xpos+(wxpos-xpos)/(fps*10)
    ypos:=ypos+(wypos-ypos)/(fps*10)
    y:=y-ypos/(fps/speed)
    x:=x-xpos/(fps/speed)
    case y>f : y:=y-f
    case y<f : y:=y+f
    case x>f : x:=x-f
    case x<f : x:=x+f

wend

end

proc ogl.LoadTEX(string fileName)

    casenot fileexists(fileName) : return false
    long fSiz:=filesize(fileName)
    case (fSiz<4) : return false
    mem mem:=fSiz
    long bytesRead:=blockread(fileName,mem,0,fSiz)
    casenot (bytesRead==fSiz) : return false
    long iWidth=sqrt(fSiz4)
    long txID=0
    ogl(glGenTextures,1,addr(txID))
    ogl(glBindTexture,GL_TEXTURE_2D,txID);
    ogl(glEnable,GL_ALPHA_TEST)
    ogl(glAlphaFunc,GL_GREATER, 0.1)
    ogl(glTexEnvi,GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
    ogl(glTexParameteri,GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
    ogl(glTexParameteri,GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR)
    ogl(glMatrixMode,GL_PROJECTION)
    ogl(gluBuild2DMipmaps,GL_TEXTURE_2D, GL_RGBA, iWidth, iWidth, GL_RGBA, GL_UNSIGNED_BYTE, mem)
    dispose mem
    return txID

 href='./../../references-fonction/XProfan/endproc/'>endproc


CompileMarkSeparation
 {$cleq}
const appver=0.0.1
const apptitle=tga2texture4XProfan +appver
const Error=File lying not in the right stature to.
windowtitle apptitle
cls
string inputfile=spaceship.tga,outputfile=del$(inputfile,len(inputfile)-len(substr$(inputfile,-1,.)),len(substr$(inputfile,-1,.))+1)+.tex
print if(LoadTGA(inputfile)==true,OK,Error)
waitkey
end

proc LoadTGA(string fileName)

    casenot fileexists(fileName) : return false
    long fSiz:=filesize(fileName)
    case (fSiz<18) : return false/*headerSize*/
    mem mem:=fSiz
    long bytesRead:=blockread(fileName,mem,0,fSiz)
    casenot (bytesRead==fSiz) : return false
    int FileType:=byte(mem,0)
    int ColorMapType:=byte(mem,1)
    int ImageType:=byte(mem,2)
    long XX:=byte(mem,12)+byte(mem,13)*256
    long YY:=byte(mem,14)+byte(mem,15)*256
    long BPP:=byte(mem,16)
    long ImageInfo:=byte(mem,17)
    long ImageSize:=XX*YY*(BPP8)
    print FileType,fileType
    print ColorMapType,ColorMapType
    print ImageType,ImageType
    print Width,XX
    print Height,YY
    print BPP,BPP
    print ImageSize,ImageSize
    casenot (ImageType==2) : return false//isnt 32bit rgb uncompressed
    casenot (ColorMapType==0) : return false//no support for colormapped tgas
    casenot (BPP==32) : return false//only support 32bit colordepth
    long x,y,front,back,i,c
    int r,g,b,a
    yy-
    xx-
    mem pdata=ImageSize
    for y:=yy downto 0 do begin
    for x=0 to xx do begin
    c:=i*4+18
    b:=byte(mem,c)
    g:=byte(mem,c+1)
    r:=byte(mem,c+2)
    a:=byte(mem,c+3)
    c:=i*4
    //setpixel x,y,rgb(r,g,b)
    byte pdata#,c=r
    byte pdata#,c+1=g
    byte pdata#,c+2=b
    byte pdata#,c+3=(r+g+b)3
    i+
    end
    locate 9,1
    print 100-(y/yy*100);% konvertiert
    end
    dispose mem
    blockwrite outputfile,pdata,0,ImageSize
    dispose pdata
    return true

endproc


I denk time the Topic is so slay.

(except for eingefilterte Textures but the can itself Yes so eachone yourself building)

38 kB
Hochgeladen:11/10/06
Downloadcounter612
Download
484 kB
Hochgeladen:11/10/06
Downloadcounter338
Download
 
11/10/06  
 



og sources again maginal revised but I denk the wars...
 
11/10/06  
 




Frank
Abbing
nicer effect! will be I sure time sometime benefit.
 
11/10/06  
 



circa from 2 BMPs a .tex to create where the 2. BMP the Stencil is:
CompileMarkSeparation
 
11/10/06  
 



this time with gefiltertem shadow...

485 kB
Hochgeladen:11/10/06
Downloadcounter462
Download
 
11/10/06  
 



.tex as highmap To xpgl:
CompileMarkSeparation
'URL: https://xprofan.com/intl/de/quelltexte/juhu-opengl-texturen-tga-transparente/#n
cls
const step=1
const divi=5
string inputfile="ballmap.tex",outputfile=del$(inputfile,len(inputfile)-len(substr$(inputfile,-1,".")),len(substr$(inputfile,-1,"."))+1)+".xpgl"
casenot fileexists(inputfile) : end
long fsiz=filesize(inputfile)
long mapxx=sqrt(fsiz/4),mapyy=mapxx
mem hmap=(mapxx*mapyy)
clear hmap
locate 2,1
print sizeOf(hMap)
mem mem=fsiz
blockread(inputfile,mem,0,fSiz)
long x,y,i=0
fsiz-

whileloop 0,(mapxx*mapyy)-1,step

    byte hmap#,loop=byte(mem,loop*4+3)
    locate 1,1
    print loop

wend

print "loadin"
mapxx=mapxx\step
mapyy=mapyy\step
long fh=assign(outputfile)
rewrite fh
print #fh&,"Q;VC;";mapxx*mapyy-mapxx-mapyy
float p1,p2,p3,p4
string col,col1="0.5,0.5,0.5,1",col2="1,1,1,1"
float ex,ey
for y=0 to mapyy-1 do begin
for x=0 to mapxx-1 do begin

if col==col1

    col=col2

else

    col=col1

endif

p1=byte(hmap,y*mapxx+x)		/divi
p2=byte(hmap,y*mapxx+(x+1))		/divi
p3=byte(hmap,(y+1)*mapxx+(x+1))	/divi
p4=byte(hmap,(y+1)*mapxx+x)		/divi
ex=x-(mapxx/2)
ey=y-(mapyy/2)
print #fh&,ex,",",ey,",",p1	,";"+col
print #fh&,ex+1,",",ey,",",p2	,";"+col
print #fh&,ex+1,",",ey+1,",",p3	,";"+col
print #fh&,ex,",",ey+1,",",p4	,";"+col
end

if col==col1

    col=col2

else

    col=col1

endif

locate 3,1
print y
end
close fh
print "ok"
waitkey
dispose mem
dispose hmap
end
 
11/10/06  
 




funkheld
Hmmm.., here comes The Error Message "Variable twice declared : HMAP&"
at kompilieren with XPSE.

greeting
 
11/19/12  
 




funkheld


{$cleq}
const appver="0.0.1"
const apptitle="tga2texture4XProfan "+appver
const fehler="Datei lying not right stature to."
windowtitle apptitle
cls
string inputfile="spaceship.tga",outputfile=del$(inputfile,len(inputfile)-len(substr$(inputfile,-1,".")),len(substr$(inputfile,-1,"."))+1)+".tex"
print if(LoadTGA(inputfile)==true,"OK",Error)
waitkey
.........


I have now with different Programs one TGA created.
it comes always The Fehlermledung "Falsches Format".

What is it with you for a TGA and welchem Program have you got it created ?

Thank you.

greeting
 
11/19/12  
 



funkheld (19.11.12)

Hmmm.., here comes The Error Message "Variable twice declared : HMAP&"
at kompilieren with XPSE.

greeting


my Error -

in the code fehlte one Rautezeichen -

habs korrigiert:
CompileMarkSeparation
'URL: https://xprofan.com/intl/de/quelltexte/juhu-opengl-texturen-tga-transparente/?q=21905&pg=-1#21905
cls
const step=1
const divi=5
string inputfile="ballmap.tex",outputfile=del$(inputfile,len(inputfile)-len(substr$(inputfile,-1,".")),len(substr$(inputfile,-1,"."))+1)+".xpgl"
casenot fileexists(inputfile) : end
long fsiz=filesize(inputfile)
long mapxx=sqrt(fsiz/4),mapyy=mapxx
mem hmap=(mapxx*mapyy)
clear hmap
locate 2,1
print sizeOf(hMap)
mem mem=fsiz
blockread(inputfile,mem,0,fSiz)
long x,y,i=0
fsiz-

whileloop 0,(mapxx*mapyy)-1,step

    byte hmap#,loop=byte(mem,loop*4+3)
    locate 1,1
    print loop

wend

print "loadin"
mapxx=mapxx\step
mapyy=mapyy\step
long fh=assign(outputfile)
rewrite fh
print #fh&,"Q;VC;";mapxx*mapyy-mapxx-mapyy
float p1,p2,p3,p4
string col,col1="0.5,0.5,0.5,1",col2="1,1,1,1"
float ex,ey
for y=0 to mapyy-1 do begin
for x=0 to mapxx-1 do begin

if col==col1

    col=col2

else

    col=col1

endif

p1=byte(hmap,y*mapxx+x)		/divi
p2=byte(hmap,y*mapxx+(x+1))		/divi
p3=byte(hmap,(y+1)*mapxx+(x+1))	/divi
p4=byte(hmap,(y+1)*mapxx+x)		/divi
ex=x-(mapxx/2)
ey=y-(mapyy/2)
print #fh&,ex,",",ey,",",p1	,";"+col
print #fh&,ex+1,",",ey,",",p2	,";"+col
print #fh&,ex+1,",",ey+1,",",p3	,";"+col
print #fh&,ex,",",ey+1,",",p4	,";"+col
end

if col==col1

    col=col2

else

    col=col1

endif

locate 3,1
print y
end
close fh
print "ok"
waitkey
dispose mem
dispose hmap
end
 
11/19/12  
 



funkheld (19.11.12)


What is it with you for a TGA and welchem Program have you got it created ?


it must itself circa a unkomprimierte rgba-TGA-File deal -

can z.B. with IrfanView Save.
 
11/19/12  
 




Sven
Bader
if it someone need, I have whom 2 BMP To TEX Konverter in natves Profan Translated.

UPDATE 15.07. the Originalcode has Textures on the head set (or I had something wrong Translated)
windowtitle "2abmpbmp2texture4xprofan"
cls
Set("Decimals",2)
declare inputStencil$,inputfile$,outputfile$,front&,back&,i&,ImageSize&
declare r%,g%,b%,a%,c&,x&,y&,xx&,yy&
declare pdata#
inputStencil$ = "demo_alpha.bmp"
inputfile$ = "demo.bmp"
outputfile$ = del$(inputfile$,len(inputfile$)-len(substr$(inputfile$,-1,".")),len(substr$(inputfile$,-1,"."))+1)+".tex"
print if(bmpbmp2tex(inputfile$,inputStencil$)," OK"," Fehler")
waitkey
end

Proc bmpbmp2tex

    parameters fileNameTexture$, fileNameStencil$
    casenot fileexists(fileNameTexture$) : return 0
    casenot fileexists(fileNameStencil$) : return 0
    mcls 1,1
    startpaint -1
    loadbmp fileNameTexture$,0,0;0
    endpaint
    case %bmpx<>%bmpy : return 0
    mcls %bmpx*2,%bmpy,0
    startpaint -1
    loadbmp fileNameTexture$,0,0;0
    loadbmp fileNameStencil$,%bmpx,0;0
    endpaint
    ImageSize&= %bmpx * %bmpy * 4
    xx& = %bmpx - 1
    yy& = %bmpy - 1
    dim pdata#, ImageSize&

    WhileLoop  0,yy&

        y& = yy& - &loop
        startpaint -1

        WhileLoop  0,xx&

            x& = &loop
            c& = getpixel(x&,y&)
            r% = getRvalue(c&)
            g% = getGvalue(c&)
            b% = getBvalue(c&)
            a% = getRvalue(getPixel(x& + xx& + 1,y&))
            c& = i& * 4
            byte pdata#,c&    = r%
            byte pdata#,c& + 1= g%
            byte pdata#,c& + 2= b%
            byte pdata#,c& + 3= a%
            inc i&

        EndWhile

        endpaint
        locate 2, 2
        print st$(100 - y& / yy& * 100) ; "% konvertiert  "

    EndWhile

    blockwrite outputfile$,pdata#,0,ImageSize&
    dispose pdata#
    return 1

Endproc

 
07/09/21  
 



 
- Page 2 -



Sven
Bader
and here once more the Spaceship game in plain Profan, whether The OpenGL.ph Profan beiliegt can I straight not say ...

UPDATE 15.07.
The Originalcode do not have whom whole Channel alpha used, it given only transparent or deckend (take off The used spaceship.tex too rather was)
 $H OpenGL.ph
cls
ogl("init",%hwnd,0.0,0.0,0.0,0)
ogl("posmode",1)
declare  tex_spaceShip%
declare  tex_background%,mem#
declare  x!,y!,xpos!,ypos!,f!,fps!,speed!,wxpos!,wypos!
tex_spaceShip%  = ogl_loadtex("demo.tex")
tex_background%= ogl("loadtexturebmp","tile4.bmp",3)
f! = 1.6
fps!=50
speed!=0.5
declare fpsc&,fpstme&,ompos&
fpstme& = &gettickcount+200

while 1

    inc fpsc&

    if fpstme&<&gettickcount

        fpstme& = fpstme&+200
        fps!  = fpsc&
        fpsc& = 0

    endif

    case %mousepressed : break
    oGL("Clear")
    ogl("color",1,1,1,1)
    ogl("glEnable",~GL_BLEND);
    ogl("glBlendFunc",~GL_SRC_ALPHA, ~GL_ONE_MINUS_SRC_ALPHA);
    oGL("glEnable",~GL_CULL_FACE)
    ogl("move",0,0,-3)
    'ground
    ogl("push")
    ogl("texture",tex_background%,10)
    ogl("move",x!-3.0,y!-3.0,0)
    ogl("quad",8,8)
    ogl("pop")
    'Textur
    ogl("texture",tex_spaceShip%,1)
    'shadow
    ogl("push")
    ogl("move",0.1,-0.1,0)
    ogl("rotate",0,0,%mousex)
    ogl("color",0,0,0,0.25)'Textur abdunkeln + 25% Deckkraft
    ogl("quad",1.5,1.5)
    ogl("pop")
    'Objekt
    ogl("push")
    ogl("rotate",0,0,%mousex)
    ogl("color",1,1,1,1)
    ogl("quad",1.5,1.5)
    ogl("pop")
    ogl("glDisable",~GL_BLEND);
    ogl("show")
    wypos!=sin((%mousex+90)*0.01745329)
    wxpos!=cos((%mousex+90)*0.01745329)
    xpos!=xpos!+(wxpos!-xpos!)/(fps!*10)
    ypos!=ypos!+(wypos!-ypos!)/(fps!*10)
    y!=y!-ypos!/(fps!/speed!)
    x!=x!-xpos!/(fps!/speed!)
    case y!>f! : y!=y!-f!
    case y!<f! : y!=y!+f!
    case x!>f! : x!=x!-f!
    case x!<f! : x!=x!+f!

endwhile

end

proc ogl_LoadTEX

    parameters textureName$
    declare fSiz&, bytesRead&,iWidth&,txID&
    casenot fileexists(textureName$) : return 0
    casenot fileexists(textureName$) : return 0
    fSiz&=filesize(textureName$)
    case (fSiz&<4) : return false
    dim mem#, fSiz&
    bytesRead&=blockread(textureName$,mem#,0,fSiz&)
    casenot (bytesRead&=fSiz&) : return 0
    iWidth&=sqrt(fSiz&\4)
    txID&=0
    ogl("glGenTextures",1,addr(txID&))
    ogl("glBindTexture",~GL_TEXTURE_2D,txID&);
    ogl("glEnable",~GL_ALPHA_TEST)
    'ogl("glAlphaFunc",~GL_GREATER, 0.1)
    ogl("glTexEnvi",~GL_TEXTURE_ENV, ~GL_TEXTURE_ENV_MODE, ~GL_MODULATE)
    ogl("glTexParameteri",~GL_TEXTURE_2D, ~GL_TEXTURE_MAG_FILTER, ~GL_LINEAR)
    ogl("glTexParameteri",~GL_TEXTURE_2D, ~GL_TEXTURE_MIN_FILTER, ~GL_LINEAR_MIPMAP_LINEAR)
    ogl("glTexParameteri",~GL_TEXTURE_2D, ~GL_TEXTURE_WRAP_S, ~GL_CLAMP_TO_EDGE)'Blitzer on the Texturrand avoid
    ogl("glTexParameteri",~GL_TEXTURE_2D, ~GL_TEXTURE_WRAP_T, ~GL_CLAMP_TO_EDGE)'Blitzer on the Texturrand avoid
    ogl("glMatrixMode",~GL_PROJECTION)
    ogl("gluBuild2DMipmaps",~GL_TEXTURE_2D, ~GL_RGBA, iWidth&, iWidth&, ~GL_RGBA, ~GL_UNSIGNED_BYTE, mem#)
    dispose mem#
    return txID&

endproc







46 kB
Bezeichnung:Demo
Kurzbeschreibung: Text with slippery Kanten, Transparentverläufe
Hochgeladen:07/15/21
Downloadcounter71
Download
1 kB
Bezeichnung:Motiv
Kurzbeschreibung: The Text must here at least something larger his, there one otherwise the white on the edge durchsieht
Hochgeladen:07/15/21
Downloadcounter72
Download
17 kB
Bezeichnung:Alphakanal
Kurzbeschreibung: From Black (transparent) To white (deckend)
Hochgeladen:07/15/21
Downloadcounter76
Download
 
07/09/21  
 




Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

17.437 Views

Untitledvor 0 min.
H.Brill10/29/23
Sven Bader12/22/22
p.specht11/18/21
RudiB.11/18/21
More...

Themeninformationen



Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie