Fuente/ Codesnippets | | | |  | Juhu Transparente Texturen - es me gelungen 
TGAs puede una 4 layer (transparentslayer) beinhalten - XProfan kann aber de esta TGAs no Texturen erzeugen welche auch todavía transparent son.
Wofür?
Wände con Lücken? Ein Ball con rauer Oberfläche? Highmap via Mapa de bits?
Oder: 2D-Sprites por OGL?
Licht y Partikeleffekte?
Nun bau Todavía eins zwei tools para speichern dieser TGAs - y luego kann auch cada qué con anfangen.  |
| | | | |
| |  | Algo como va así... KompilierenMarcaSeparación {$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
KompilierenMarcaSeparación {$cleq}
const appver=0.0.1
const apptitle=tga2texture4XProfan +appver
const fehler=Expediente liegt no en el richtigen Formato antes.
windowtitle apptitle
cls
cadena inputfile=spaceship.tga,outputfile=del$(inputfile,len(inputfile)-len(substr$(inputfile,-1,.)),len(substr$(inputfile,-1,.))+1)+.tex
imprimir if(LoadTGA(inputfile)==true,OK,fehler)
waitkey
end
proc LoadTGA(cadena fileName)
casenot fileexists(fileName) : volver falso
long fSiz:=filesize(fileName)
caso (fSiz<18) : volver falso/*headerSize*/
mem mem:=fSiz
long bytesRead:=blockread(fileName,mem,0,fSiz)
casenot (bytesRead==fSiz) : volver falso
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)
imprimir FileType,fileType
imprimir ColorMapType,ColorMapType
imprimir ImageType,ImageType
imprimir Width,XX
imprimir Height,YY
imprimir BPP,BPP
imprimir ImageSize,ImageSize
casenot (ImageType==2) : volver falso//isnt 32bit rgb uncompressed
casenot (ColorMapType==0) : volver falso//no support for colormapped tgas
casenot (BPP==32) : volver falso//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
imprimir 100-(y/yy*100);% konvertiert
end
disponer mem
blockwrite outputfile,pdata,0,ImageSize
disponer pdata
volver true
ENDPROC
Yo denk veces el Thema es así erschlagen. 
(salvo eingefilterte Texturen aber el kann se sí así cada selber bauen) |
 | | | | |
| |  | og sources otra vez maginal überarbeitet pero yo denk el wars... |
| | | | |
| |  Frank Abbing | Netter Effekt! Werde Yo sicher veces irgendwann nutzen.  |
| | | | |
| |  | Um de 2 BMPs una .tex a redactar wobei el 2. BMP el Stencil es: KompilierenMarcaSeparación {$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 con gefiltertem Schatten... |
| | | | |
| |  | .tex como highmap a xpgl: KompilierenMarcaSeparación'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.., hier kommt el Fehlermeldung "Variable doppelt deklariert : HMAP&" beim kompilieren con XPSE.
Gruss |
| | | | |
| |  funkheld |
{$cleq} const appver="0.0.1" const apptitle="tga2texture4XProfan "+appver const fehler="Datei liegt no en el richtigen Formato antes." windowtitle apptitle cls cadena inputfile="spaceship.tga",outputfile=del$(inputfile,len(inputfile)-len(substr$(inputfile,-1,".")),len(substr$(inputfile,-1,"."))+1)+".tex" imprimir if(LoadTGA(inputfile)==true,"OK",fehler) waitkey .........
Yo habe ahora con verschiedenen Programmen una TGA producido. Lo kommt siempre el Fehlermledung "Falsches Format".
Was es en dir para una TGA y welchem Programa hast du lo producido ?
Gracias.
Gruss |
| | | | |
| |  | funkheld (19.11.12)
Hmmm.., hier kommt el Fehlermeldung "Variable doppelt deklariert : HMAP&" beim kompilieren con XPSE.
Gruss
Mein Fehler -
en el Code fehlte una Rautezeichen -
habs korrigiert: KompilierenMarcaSeparación'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)
Was es en dir para una TGA y welchem Programa hast du lo producido ?
Lo muss es una unkomprimierte rgba-TGA-Expediente handeln -
puede ser z.B. con IrfanView speichern. |
| | | | |
| |  Sven Bader | Falls lo alguien braucht, Yo el 2 BMP a TEX Konverter en natves PROFAN traducida.
UPDATE 15.07. el Originalcode ha Texturen en el Kopf gestellt (oder Yo hatte algo falso traducido) 
windowtitle "2abmpbmp2texture4xprofan"
cls
Conjunto("Decimals",2)
declarar inputStencil$,inputfile$,outputfile$,front&,back&,i&,ImageSize&
declarar r%,g%,b%,a%,c&,x&,y&,xx&,yy&
declarar pdata#
inputStencil$ = "demo_alpha.bmp"
inputfile$ = "demo.bmp"
outputfile$ = del$(inputfile$,len(inputfile$)-len(substr$(inputfile$,-1,".")),len(substr$(inputfile$,-1,"."))+1)+".tex"
imprimir if(bmpbmp2tex(inputfile$,inputStencil$)," OK"," Fehler")
waitkey
end
Proc bmpbmp2tex
parámetros fileNameTexture$, fileNameStencil$
casenot fileexists(fileNameTexture$) : volver 0
casenot fileexists(fileNameStencil$) : volver 0
mcls 1,1
startpaint -1
loadbmp fileNameTexture$,0,0;0
endpaint
caso %bmpx<>%bmpy : volver 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& - &bucle
startpaint -1
WhileLoop 0,xx&
x& = &bucle
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
imprimir str$(100 - y& / yy& * 100) ; "% konvertiert "
EndWhile
blockwrite outputfile$,pdata#,0,ImageSize&
disponer pdata#
volver 1
ENDPROC
|
| | | | |
|
Zum QuelltextTema opciones | 17.928 Views |
ThemeninformationenDieses Thema ha 4 subscriber: |
|