Source/ Codesnippets | | | | - page 1 - |
| | Juhu Transparente Texturen - c'est mir gelungen
TGAs peut une 4 layer (transparentslayer) beinhalten - XProfan peux mais aus cette TGAs aucun Texturen erzeugen quelle aussi encore transparent sommes.
Wofür?
Wände avec Lücken? un balle avec rauer surface? Highmap via Bitmap?
ou bien: 2D-Sprites per OGL?
Licht et Partikeleffekte?
eh bien bau je encore une deux tools zum Sauver cette TGAs - et ensuite peux aussi chacun quoi avec anfangen. |
| | | | |
| | | | | - page 1 - |
| | Quelque chose comme allez avec cela... KompilierenMarqueSéparation {$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
KompilierenMarqueSéparation {$cleq}
const appver=0.0.1
const apptitle=tga2texture4XProfan +appver
const faute=Dossier liegt pas im richtigen Format avant.
windowtitle apptitle
cls
string inputfile=spaceship.tga,outputfile=del$(inputfile,len(inputfile)-len(substr$(inputfile,-1,.)),len(substr$(inputfile,-1,.))+1)+.tex
imprimer si(LoadTGA(inputfile)==vrai,OK,faute)
waitkey
end
proc LoadTGA(string fileName)
casenot fileexists(fileName) : return faux
long fSiz:=filesize(fileName)
cas (fSiz<18) : return faux/*headerSize*/
mem mem:=fSiz
long bytesRead:=blockread(fileName,mem,0,fSiz)
casenot (bytesRead==fSiz) : return faux
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)
imprimer FileType,fileType
imprimer ColorMapType,ColorMapType
imprimer ImageType,ImageType
imprimer Width,XX
imprimer Height,YY
imprimer BPP,BPP
imprimer ImageSize,ImageSize
casenot (ImageType==2) : return faux//isnt 32bit rgb uncompressed
casenot (ColorMapType==0) : return faux//no support for colormapped tgas
casenot (BPP==32) : return faux//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
imprimer 100-(y/yy*100);% konvertiert
end
dispose mem
blockwrite outputfile,pdata,0,ImageSize
dispose pdata
return vrai
endproc
je denk la fois cela Thema ist avec cela erschlagen.
(jusqu'à sur eingefilterte Texturen mais cela peux sich oui avec cela chacun selber construire) |
| | | | |
| | | og sources nochmal maginal révisée mais je denk cela wars... |
| | | | |
| | Frank Abbing | Netter effet! Werde je sûrement la fois irgendwann nutzen. |
| | | | |
| | | Um aus 2 BMPs une .tex trop erstellen wobei cela 2. BMP qui Stencil ist: KompilierenMarqueSéparation {$cleq}
const appver=0.0.1
const apptitle=bmpbmp2texture4xprofan +appver
const fehler=Datei liegt nicht im richtigen Format vor.
windowtitle apptitle
cls
string inputStencil=C:\b.bmp,inputfile=c:\a.bmp,outputfile=del$(inputfile,len(inputfile)-len(substr$(inputfile,-1,.)),len(substr$(inputfile,-1,.))+1)+.tex
print if(bmpbmp2tex(inputfile,inputStencil)==true,OK,fehler)
waitkey
end
proc bmpbmp2tex(string fileName,fileNameStencil)
casenot fileexists(fileName) : return false
casenot fileexists(fileNameStencil) : return false
mcls 1,1
startpaint -1
loadbmp fileName,0,0;0
endpaint
case bmpx<>bmpy : return false
mcls bmpx*2,bmpy,0
startpaint -1
loadbmp fileName,0,0;0
loadbmp fileNameStencil,bmpx,0;0
endpaint
long ImageSize:=bmpx*bmpy*4
long x,y,front,back,i,c,xx=bmpx,yy=bmpy
int r,g,b,a
yy-
xx-
mem pdata=ImageSize
for y:=0 to yy do begin
startpaint -1
for x=0 to xx do begin
c:=getpixel(x,y)
r:=getRvalue(C)
g:=getGvalue(C)
b:=getBvalue(C)
a:=getrvalue(getPixel(x+xx+1,y))
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=a
i+
end
endpaint
locate 4,1
print (y/yy*100);% konvertiert
end
blockwrite outputfile,pdata#,0,ImageSize
dispose pdata
return true
endproc
|
| | | | |
| | | Diesmal avec gefiltertem ombre... |
| | | | |
| | | .tex comme highmap trop xpgl: KompilierenMarqueSéparation'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
|
| | | | |
| | funkheld | Hmmm.., ici venez qui Fehlermeldung "Variable doppelt deklariert : HMAP&" beim kompilieren avec XPSE.
Gruss |
| | | | |
| | funkheld |
{$cleq} const appver="0.0.1" const apptitle="tga2texture4XProfan "+appver const fehler="Datei liegt pas im richtigen Format avant." windowtitle apptitle cls string inputfile="spaceship.tga",outputfile=del$(inputfile,len(inputfile)-len(substr$(inputfile,-1,".")),len(substr$(inputfile,-1,"."))+1)+".tex" imprimer si(LoadTGA(inputfile)==true,"OK",faute) waitkey .........
j'ai maintenant avec verschiedenen Programmen un TGA erzeugt. Es venez toujours qui Fehlermledung "Falsches Format".
quoi ist es chez dir pour un TGA et welchem Programme la hâte du es erzeugt ?
merci.
Gruss |
| | | | |
| | | funkheld (19.11.12)
Hmmm.., ici venez qui Fehlermeldung "Variable doppelt deklariert : HMAP&" beim kompilieren avec XPSE.
Gruss
mon faute -
im Code fehlte un Rautezeichen -
habs korrigiert: KompilierenMarqueSéparation'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
|
| | | | |
| | | funkheld (19.11.12)
quoi ist es chez dir pour un TGA et welchem Programme la hâte du es erzeugt ?
Es muss sich um une unkomprimierte rgba-TGA-Dossier agir -
peux on z.B. avec IrfanView Sauver. |
| | | | |
| | Sven Bader | si es quelqu'un braucht, j'ai den 2 BMP trop TEX Konverter dans natves Profan traduit.
UPDATE 15.07. qui Originalcode hat Texturen sur den tête gestellt (ou bien je hatte quelque chose faux traduit)
windowtitle "2abmpbmp2texture4xprofan"
cls
Set("Décimal",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"
imprimer si(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
cas %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
imprimer str$(100 - y& / yy& * 100) ; "% konvertiert "
Endwhile
blockwrite outputfile$,pdata#,0,ImageSize&
dispose pdata#
return 1
ENDPROC
|
| | | | |
| | | | - page 2 - |
| | Sven Bader | et ici encore la fois cela Spaceship Spiel dans plain Profan, si qui OpenGL.ph Profan beiliegt peux je justement pas dire ...
UPDATE 15.07. qui Originalcode hat pas den ganzen Alphakanal genutzt, es donnais seulement durchsichtig ou bien deckend (quoi pour qui verwendete spaceship.tex aussi besser était)
$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
tandis que 1
inc fpsc&
si fpstme&<&gettickcount
fpstme& = fpstme&+200
fps! = fpsc&
fpsc& = 0
endif
cas %mousepressed : pause
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)
'Boden
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)
'ombre
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")
'objet
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!)
cas y!>f! : y!=y!-f!
cas y!<f! : y!=y!+f!
cas x!>f! : x!=x!-f!
cas 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$)
cas (fSiz&<4) : return faux
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 am Texturrand vermeiden
ogl("glTexParameteri",~GL_TEXTURE_2D, ~GL_TEXTURE_WRAP_T, ~GL_CLAMP_TO_EDGE)'Blitzer am Texturrand vermeiden
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 avec glatten Kanten, Transparentverläufe | | Hochgeladen: | 15.07.2021 | | Downloadcounter: | | | | Download | | | | 1 kB | | Bezeichnung: | Motiv | | Kurzbeschreibung: | qui Text muss ici zumindest quelque chose größer son, là on sonst cela sais am rebord durchsieht | | Hochgeladen: | 15.07.2021 | | Downloadcounter: | | | | Download | | | | 17 kB | | Bezeichnung: | Alphakanal | | Kurzbeschreibung: | de noir (transparent) jusqu'à sais (deckend) | | Hochgeladen: | 15.07.2021 | | Downloadcounter: | | | | Download |
| | | | |
|
Zum QuelltextOptions du sujet | 17.668 Views |
Themeninformationencet Thema hat 4 participant: |
|