Wünsche et Anregungen | | | |  | je benenne ici simple la fois Funktionswünsche quelle aider peut cela XProfan-Spieleprogrammierer plus Performance dedans qui Programme erreichen peut. (Performance ist chez Spielen oui souvent wichtiger comme z.B. chez einer kleineren Datenbankanwendung.)
Würde mich freuen si aussi autre ici qui une ou bien autre concept pour Roland hinterlassen würden.
• Rechteckintersektionskontrolle (ggf. avec Überlappungsfaktor comme Float) • Distance zweier Punkte (2D & 3D) ( [...] ) KompilierenMarqueSéparation • Bound (normalisieren?) bound(x,-30,30) KompilierenMarqueSéparation cela mag zwar alles kleinlich wirken, mais es pouvoir déjà une erheblichen Geschwindigkeitsunterschied aus si on sur solche native Helfer zurückgreifen pourrait, et besonders chez Spielen zählt chaque µ. |
| | | | |
| |  | prochaine Part - unterthema OpenGL.
Folgende Funktionen - si nativ Umgesetzt - könnten dem XProfan-OGL-Spieleentwickler deutlich plus freude beim Programmieren verschaffen! KompilierenMarqueSéparation
ogl.rectangle(float x,y,xx,yy,bool filled){
if filled {
/*
xx:=xx-x
yy:=yy-y+1
x:=x+xx/2+1
y:=y+yy/2
ogl(move,x,y-1,)
ogl(quad,xx+1,0-yy)
ogl(move,-x,-y+1,0)
*/
ogl(glBegin,GL_QUADS)
oGL(glTexCoord2f,0.0,1.0)
ogl(glVertex3f,x,y,)
oGL(glTexCoord2f,1.0,1.0)
ogl(glVertex3f,xx,y,)
oGL(glTexCoord2f,1.0,0.0)
ogl(glVertex3f,xx,yy,)
oGL(glTexCoord2f,0.0,0.0)
ogl(glVertex3f,x,yy,)
ogl(glEnd)
} else {
ogl(glBegin,GL_LINE_LOOP)
ogl(glVertex3f,x,y,)
ogl(glVertex3f,xx,y,)
ogl(glVertex3f,xx,yy,)
ogl(glVertex3f,x,yy,)
ogl(glEnd)
}<
}
et cet: KompilierenMarqueSéparation
ogl.line(float x,y,xx,yy){
ogl(glBegin,GL_LINES)
ogl(glVertex3f,x,y,)
ogl(glVertex3f,xx,yy,)
ogl(glEnd)
}
ogl.ngon(float x,y,xx,yy,long cnt,float rouge,bool filled){
ogl(glBegin,si(filled,GL_POLYGON,GL_LINE_LOOP))
float f:=rouge*pi180,ffac:=(my2PI/cnt)
whileloop cnt {
ogl(glVertex3f,x+cos(f)*xx,y+sin(f)*yy,)
f:=f+ffac
}
ogl(glEnd)
}
ogl.2drotate(float x,y,r1,r2,r3){
cas pcount<5:r3:=0
cas pcount<4:r2:=0
si pcount==1 {
r1:=x
x:=ogl.maxx/2
y:=ogl.maxy/2
}
ogl(déplacer,x,y,)
ogl(rotate,r3,r2,r1)
ogl(déplacer,-x,-y,)
}
ogl.2dscale(float x,y,f){
si pcount==1 {
f:=x
x:=ogl.maxx/2
y:=ogl.maxy/2
}
ogl(déplacer,x,y,)
ogl(scale,f)
ogl(déplacer,-x,-y,)
}
ogl.2dmove(float x,y){
ogl(déplacer,x,y,)
}
et puis aufbauend cet: KompilierenMarqueSéparation
ogl.drawpic(long tex,long x,y,xx,yy,float a){
cas pcount>5 : ogl(color,1,1,1,a)
ogl(texture,tex,1)
ogl.rectangle(x,y,x+xx,y+yy,vrai)
}
ogl.color(long col,a){ogl(color,getrvalue(col)/255,getgvalue(col)/255,getbvalue(col)/255,a/255)}
et aussi si unübersichtlich erscheint - desto wichtiger cet: (benötigte Texturdatei im Anhang) KompilierenMarqueSéparation
ogl.drawSysText(float x,y,string txt,float sz,szY,hopX,szX,xtraProcAddr){
cas pcount<8 : xtraProcAddr:=0
cas pcount<7 : szX:=1
cas pcount<6 : hopX:=1
cas pcount<5 : szY:=1
cas pcount<4 : sz:=1
hopX:=hopX*sz
szX:=szX*sz
float xx:=x+32*szX
float yy:=y+32*sz*szY
float tx,ty,txx,tyy
long column,row,o,c:=len(txt)
ogl.push
ogl(texture,ogl.texSysfnt,1)
hopX:=16*hopX
cas xtraProcAddr:call(xtraProcAddr,c,0,(x-xx)*1000000,(y-yy)*1000000,hopX*1000000)
whileloop c {
o:=ord(mid$(txt,loop,1))
column:=o16
row:=o-column*16
tx:=0.0625*column-0.005
ty:=0.0625*(16-row-1)-0.005
txx:=tx+0.0625
tyy:=ty+0.0625
cas xtraProcAddr:call(xtraProcAddr,c,loop,(x-xx)*1000000,(y-yy)*1000000,hopX*1000000)
oGL(glBegin,GL_QUADS)
oGL(glTexCoord2f,tx,tyy)
oGL(glVertex3f,x,y,)
oGL(glTexCoord2f,txx,tyy)
oGL(glVertex3f,xx,y,)
oGL(glTexCoord2f,txx,ty)
oGL(glVertex3f,xx,yy,)
oGL(glTexCoord2f,tx,ty)
oGL(glVertex3f,x,yy,)
ogl(glEnd)
casenot xtraProcAddr:ogl(déplacer,hopX,,)
}
ogl.pop
return hopX
}
de cette entier trop schweigen: KompilierenMarqueSéparation
ogl.LoadTEX(string fileName,float greater,long modi,bool smooth){
cas pcount<2 : greater:=NUL
cas pcount<3 : modi:=NUL
cas pcount<4 : smooth:=vrai
cas greater==NUL : greater:=0.001
cas modi==NUL : modi:=GL_MODULATE
casenot fileexists(fileName) : return faux
si lower$(getfileext(fileName))==tex {
long fSiz:=filesize(fileName)
cas (fSiz<4) : return faux
mem mem:=fSiz
long bytesRead:=blockread(fileName,mem,,fSiz)
casenot (bytesRead==fSiz) : return faux
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, greater)
ogl(glTexEnvi,GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, modi)
ogl(glTexParameteri,GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_LINEAR)
ogl(glTexParameteri,GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,si(smooth,GL_LINEAR_MIPMAP_LINEAR,GL_LINEAR))
ogl(glMatrixMode,GL_PROJECTION)
ogl(gluBuild2DMipmaps,GL_TEXTURE_2D, GL_RGBA, iWidth, iWidth, GL_RGBA, GL_UNSIGNED_BYTE, mem)
dispose mem
} d'autre {
long lxx:=greater
cas ogl.percMode : lxx:=lxx*ogl.maxx/100
cas pcount==2 : modi:=3
si lxx>1024 {lxx:=1024} d'autre si lxx>512 {lxx:=1024} d'autre si lxx>256 {lxx:=512} d'autre si lxx>128 {lxx:=256} d'autre si lxx>64 {lxx:=128} d'autre si lxx>32 {lxx:=64} d'autre {lxx:=32}
casenot mid$(fileName,2,1)==: : fileName:=getdir$(@)+/+filename
long h:=create(hSizedPic,-1,fileName,lxx,lxx,)
long txID:=ogl(gettexturebmp,h,modi)
deleteobject h
}
ogl.clear()//important
return txID
}
et quoi simple: KompilierenMarqueSéparation et quoi wichtiges!: KompilierenMarqueSéparation
ogl.vsync(bool vsync){
casenot ogl.hasExtension(WGL_EXT_swap_control) : return -1
long wglSwapIntervalEXT:=wglGetProcAddress(wglSwapIntervalEXT)
long wglGetSwapIntervalEXT:=wglGetProcAddress(wglGetSwapIntervalEXT)
si wglGetSwapIntervalEXT {
bool isVSync:=call(wglGetSwapIntervalEXT)
cas pcount <1 : return isVSync
}
call(wglSwapIntervalEXT,vsync)
return ogl.vsync()
}
ogl.hasExtension(string eName){return si(instr(eName,ogl.extensions),vrai,)}
ogl.ortho(long x,y,xx,yy,z,zz){
glLoadIdentity()
glViewport(0,0,width(hwnd),height(hwnd))
mem mem=48
float mem#,0 =x,xx,y,yy,z,zz
ogl(glOrtho,long(mem#,0 ),long(mem#,4 ),long(mem#,8 ),long(mem#,12),long(mem#,16),long(mem#,20),long(mem#,24),long(mem#,28),long(mem#,32),long(mem#,36),long(mem#,40),long(mem#,44))
dispose mem
}
ogl.extensions:=string$(glGetString(GL_EXTENSIONS),0)//sollte vlt. xprofanSysVariableString son
|
 | | | | |
| |  | Unterthema Vektorkollisionen/Winkelfunktionen:
Ok je attends besser seulement einmal jusqu'à Roland qui Gespräche trop o.g. Sujets aufgenommen hat.  |
| | | | |
| |  Frank Abbing | je erdreiste mich aussi la fois... 
Ogl: ombre Nr.1 KompilierenMarqueSéparation {$iq}
declare time&, frames%
declare ende%,x!
declare g_fSpinX_L!,g_fSpinY_L!
g_fSpinX_L! = 0.0
g_fSpinY_L! = -10.0
declare g_fSpinX_R!,g_fSpinY_R!
g_fSpinX_R! = 0.0
g_fSpinY_R! = 0.0
declare g_floorQuad#
dim g_floorQuad#,96
long g_floorQuad#, 0 = single(0.0), single(1.0), single(0.0), single(-5.0), single(0.0), single(-5.0)
long g_floorQuad#,24 = single(0.0), single(1.0), single(0.0), single(-5.0), single(0.0), single(5.0)
long g_floorQuad#,48 = single(0.0), single(1.0), single(0.0), single(5.0), single(0.0), single(5.0)
long g_floorQuad#,72 = single(0.0), single(1.0), single(0.0), single(5.0), single(0.0), single(-5.0)
declare g_shadowMatrix![16],g_lightPosition![4]
g_lightPosition![0] = 2.0
g_lightPosition![1] = 6.0
g_lightPosition![2] = 0.0
g_lightPosition![3] = 1.0
declare g_lightPosition#
dim g_lightPosition#,16
declare shadowPlane![4],v0![3],v1![3],v2![3]
declare g_shadowMatrix#
dim g_shadowMatrix#,128
proc init
oGL(Init, %hWnd, 0.35, 0.53, 0.7, 1)
oGL(PosMode, 1)
endproc
proc buildShadowMatrix
Calculate the dot-product between the plane and the lights position
declare dotp!
dotp! = shadowPlane![0] * g_lightPosition![0] + shadowPlane![1] * g_lightPosition![1] + shadowPlane![1] * g_lightPosition![2] + shadowPlane![3] * g_lightPosition![3]
First column
g_shadowMatrix![0] = dotp! - g_lightPosition![0] * shadowPlane![0]
g_shadowMatrix![4] = 0.0 - g_lightPosition![0] * shadowPlane![1]
g_shadowMatrix![8] = 0.0 - g_lightPosition![0] * shadowPlane![2]
g_shadowMatrix![12] = 0.0 - g_lightPosition![0] * shadowPlane![3]
Second column
g_shadowMatrix![1] = 0.0 - g_lightPosition![1] * shadowPlane![0]
g_shadowMatrix![5] = dotp! - g_lightPosition![1] * shadowPlane![1]
g_shadowMatrix![9] = 0.0 - g_lightPosition![1] * shadowPlane![2]
g_shadowMatrix![13] = 0.0 - g_lightPosition![1] * shadowPlane![3]
Third column
g_shadowMatrix![2] = 0.0 - g_lightPosition![2] * shadowPlane![0]
g_shadowMatrix![6] = 0.0 - g_lightPosition![2] * shadowPlane![1]
g_shadowMatrix![10] = dotp! - g_lightPosition![2] * shadowPlane![2]
g_shadowMatrix![14] = 0.0 - g_lightPosition![2] * shadowPlane![3]
Fourth column
g_shadowMatrix![3] = 0.0 - g_lightPosition![3] * shadowPlane![0]
g_shadowMatrix![7] = 0.0 - g_lightPosition![3] * shadowPlane![1]
g_shadowMatrix![11] = 0.0 - g_lightPosition![3] * shadowPlane![2]
g_shadowMatrix![15] = dotp! - g_lightPosition![3] * shadowPlane![3]
Alles jetzt in die Bereichsvariable schreiben
(sollte man natürlich direkt machen, aber so ist es erstmal übersichtlicher...)
float g_shadowMatrix#, 0 = g_shadowMatrix![0],g_shadowMatrix![1],g_shadowMatrix![2],g_shadowMatrix![3]
float g_shadowMatrix#,32 = g_shadowMatrix![4],g_shadowMatrix![5],g_shadowMatrix![6],g_shadowMatrix![7]
float g_shadowMatrix#,64 = g_shadowMatrix![8],g_shadowMatrix![9],g_shadowMatrix![10],g_shadowMatrix![11]
float g_shadowMatrix#,96 = g_shadowMatrix![12],g_shadowMatrix![13],g_shadowMatrix![14],g_shadowMatrix![15]
endproc
proc findPlane
declare vec0![3], vec1![3]
Need 2 vectors to find cross product
vec0![0] = v1![0] - v0![0]
vec0![1] = v1![1] - v0![1]
vec0![2] = v1![2] - v0![2]
vec1![0] = v2![0] - v0![0]
vec1![1] = v2![1] - v0![1]
vec1![2] = v2![2] - v0![2]
Find cross product to get A, B, and C of plane equation
shadowPlane![0] = vec0![1] * vec1![2] - vec0![2] * vec1![1]
shadowPlane![1] = -(vec0![0] * vec1![2] - vec0![2] * vec1![0])
shadowPlane![2] = vec0![0] * vec1![1] - vec0![1] * vec1![0]
shadowPlane![3] = -(shadowPlane![0] * v0![0] + shadowPlane![1] * v0![1] + shadowPlane![2] * v0![2])
endproc
proc renderObject
oGL(Push)
oGL(glTranslatef, 0.0, 2.5, 0.0)
oGL(glRotatef, -g_fSpinY_R!, 1.0, 0.0, 0.0)
oGL(glRotatef, -g_fSpinX_R!, 0.0, 1.0, 0.0)
oGL(Rotate, 90, 0, 0)
oGL(Cuboid, 2, 2, 2)
oGL(Move, 0, -2, 2)
oGL(Sphere, 1.2, 16, 16)
oGL(Pop)
endproc
proc render
To define a plane that matches the floor, we need to 3 vertices from it
v0![0] = double(long(g_floorQuad#,12))
v0![1] = double(long(g_floorQuad#,16))
v0![2] = double(long(g_floorQuad#,20))
v1![0] = double(long(g_floorQuad#,36))
v1![1] = double(long(g_floorQuad#,40))
v1![2] = double(long(g_floorQuad#,44))
v2![0] = double(long(g_floorQuad#,60))
v2![1] = double(long(g_floorQuad#,64))
v2![2] = double(long(g_floorQuad#,68))
findPlane
Build a shadow matrix using the lights current position and the plane
buildShadowMatrix
oGL(Clear)
oGL(glClear, ~GL_COLOR_BUFFER_BIT | ~GL_DEPTH_BUFFER_BIT)
Place the view
oGL(glMatrixMode, ~GL_MODELVIEW)
oGL(glLoadIdentity)
oGL(glTranslatef, 0.0, -2.0, -15.0)
oGL(glRotatef, -g_fSpinY_L!, 1.0, 0.0, 0.0)
oGL(glRotatef, -g_fSpinX_L!, 0.0, 1.0, 0.0)
Create a shadow by rendering the teapot using the shadow matrix.
oGL(glDisable, ~GL_DEPTH_TEST)
oGL(glDisable, ~GL_LIGHTING)
oGL(glColor3f, 0.2, 0.4, 0.6) Shadows color
oGL(Push)
oGL(glMultMatrixd, g_shadowMatrix#)
renderObject
oGL(Pop)
oGL(glEnable, ~GL_DEPTH_TEST)
oGL(glEnable, ~GL_LIGHTING)
Render the lights position as a sphere...
oGL(glDisable, ~GL_LIGHTING)
oGL(Push)
long g_lightPosition#,0 = single(g_lightPosition![0]),single(g_lightPosition![1]),single(g_lightPosition![2]),single(g_lightPosition![3])
oGL(glLightfv, ~GL_LIGHT0, ~GL_POSITION, g_lightPosition#)
Place a sphere to represent the light
oGL(glTranslatef, g_lightPosition![0], g_lightPosition![1], g_lightPosition![2])
oGL(glColor3f, 1.0, 1.0, 0.5)
oGL(Sphere,0.1, 8, 8)
oGL(Pop)
oGL(glEnable, ~GL_LIGHTING)
oGL(glColor3f, 1.0, 0.3, 0.0) Objektss color
Render normal teapot
renderObject
oGL(Show)
endproc
-----------------------------------------------------------------------------------
Cls
init
time& = &GetTickCount
frames% = 0
ende% = 0
SetTimer 10
whilenot ende%
WaitInput
if IsKey(27)
ende% = 1
elseif IsKey(38)
g_lightPosition![3] = g_lightPosition![3] + 0.1
elseif IsKey(40)
g_lightPosition![3] = g_lightPosition![3] - 0.1
elseif IsKey(37)
g_lightPosition![2] = g_lightPosition![2] - 0.1
elseif IsKey(39)
g_lightPosition![2] = g_lightPosition![2] + 0.1
endif
render
SetText %hWnd, str$(g_lightPosition![2]) + , +str$(g_lightPosition![3])
wend
KillTimer
dispose g_floorQuad#
dispose g_lightPosition#
Fin
|
| | | | |
| |  Frank Abbing | Ogl: ombre Nr.2 KompilierenMarqueSéparation {$iq}
declare time&, frames%
declare ende%,x!,xx!,yy!,zz!
declare g_fSpinX_L!,g_fSpinY_L!
g_fSpinX_L! = 0.0
g_fSpinY_L! = -10.0
declare g_fSpinX_R!,g_fSpinY_R!
g_fSpinX_R! = 0.0
g_fSpinY_R! = 0.0
declare g_floorQuad#
dim g_floorQuad#,96
long g_floorQuad#, 0 = single(0.0), single(1.0), single(0.0), single(-5.0), single(0.0), single(-5.0)
long g_floorQuad#,24 = single(0.0), single(1.0), single(0.0), single(-5.0), single(0.0), single(5.0)
long g_floorQuad#,48 = single(0.0), single(1.0), single(0.0), single(5.0), single(0.0), single(5.0)
long g_floorQuad#,72 = single(0.0), single(1.0), single(0.0), single(5.0), single(0.0), single(-5.0)
declare g_shadowMatrix![16],g_lightPosition![4]
g_lightPosition![0] = 2.0
g_lightPosition![1] = 20.0
g_lightPosition![2] = 0.0
g_lightPosition![3] = 1.0
declare g_lightPosition#
dim g_lightPosition#,16
declare shadowPlane![4],v0![3],v1![3],v2![3]
declare g_shadowMatrix#
dim g_shadowMatrix#,128
proc init
oGL(Init, %hWnd, 0.35, 0.53, 0.7, 1)
oGL(PosMode, 1)
endproc
proc buildShadowMatrix
Calculate the dot-product between the plane and the lights position
declare dotp!
dotp! = shadowPlane![0] * g_lightPosition![0] + shadowPlane![1] * g_lightPosition![1] + shadowPlane![1] * g_lightPosition![2] + shadowPlane![3] * g_lightPosition![3]
First column
g_shadowMatrix![0] = dotp! - g_lightPosition![0] * shadowPlane![0]
g_shadowMatrix![4] = 0.0 - g_lightPosition![0] * shadowPlane![1]
g_shadowMatrix![8] = 0.0 - g_lightPosition![0] * shadowPlane![2]
g_shadowMatrix![12] = 0.0 - g_lightPosition![0] * shadowPlane![3]
Second column
g_shadowMatrix![1] = 0.0 - g_lightPosition![1] * shadowPlane![0]
g_shadowMatrix![5] = dotp! - g_lightPosition![1] * shadowPlane![1]
g_shadowMatrix![9] = 0.0 - g_lightPosition![1] * shadowPlane![2]
g_shadowMatrix![13] = 0.0 - g_lightPosition![1] * shadowPlane![3]
Third column
g_shadowMatrix![2] = 0.0 - g_lightPosition![2] * shadowPlane![0]
g_shadowMatrix![6] = 0.0 - g_lightPosition![2] * shadowPlane![1]
g_shadowMatrix![10] = dotp! - g_lightPosition![2] * shadowPlane![2]
g_shadowMatrix![14] = 0.0 - g_lightPosition![2] * shadowPlane![3]
Fourth column
g_shadowMatrix![3] = 0.0 - g_lightPosition![3] * shadowPlane![0]
g_shadowMatrix![7] = 0.0 - g_lightPosition![3] * shadowPlane![1]
g_shadowMatrix![11] = 0.0 - g_lightPosition![3] * shadowPlane![2]
g_shadowMatrix![15] = dotp! - g_lightPosition![3] * shadowPlane![3]
Alles jetzt in die Bereichsvariable schreiben
(sollte man natürlich direkt machen, aber so ist es erstmal übersichtlicher...)
float g_shadowMatrix#, 0 = g_shadowMatrix![0],g_shadowMatrix![1],g_shadowMatrix![2],g_shadowMatrix![3]
float g_shadowMatrix#,32 = g_shadowMatrix![4],g_shadowMatrix![5],g_shadowMatrix![6],g_shadowMatrix![7]
float g_shadowMatrix#,64 = g_shadowMatrix![8],g_shadowMatrix![9],g_shadowMatrix![10],g_shadowMatrix![11]
float g_shadowMatrix#,96 = g_shadowMatrix![12],g_shadowMatrix![13],g_shadowMatrix![14],g_shadowMatrix![15]
endproc
proc findPlane
declare vec0![3], vec1![3]
Need 2 vectors to find cross product
vec0![0] = v1![0] - v0![0]
vec0![1] = v1![1] - v0![1]
vec0![2] = v1![2] - v0![2]
vec1![0] = v2![0] - v0![0]
vec1![1] = v2![1] - v0![1]
vec1![2] = v2![2] - v0![2]
Find cross product to get A, B, and C of plane equation
shadowPlane![0] = vec0![1] * vec1![2] - vec0![2] * vec1![1]
shadowPlane![1] = -(vec0![0] * vec1![2] - vec0![2] * vec1![0])
shadowPlane![2] = vec0![0] * vec1![1] - vec0![1] * vec1![0]
shadowPlane![3] = -(shadowPlane![0] * v0![0] + shadowPlane![1] * v0![1] + shadowPlane![2] * v0![2])
endproc
proc renderObject
oGL(Push)
oGL(glTranslatef, 0.0, 2.0, 0.0)
oGL(glRotatef, -g_fSpinY_R!, 1.0, 0.0, 0.0)
oGL(glRotatef, -g_fSpinX_R!, 0.0, 1.0, 0.0)
oGL(Rotate, xx!, yy!, zz!)
oGL(Cuboid, 4, 2, 8)
oGL(Pop)
endproc
proc render
To define a plane that matches the floor, we need to 3 vertices from it
v0![0] = double(long(g_floorQuad#,12))
v0![1] = double(long(g_floorQuad#,16))
v0![2] = double(long(g_floorQuad#,20))
v1![0] = double(long(g_floorQuad#,36))
v1![1] = double(long(g_floorQuad#,40))
v1![2] = double(long(g_floorQuad#,44))
v2![0] = double(long(g_floorQuad#,60))
v2![1] = double(long(g_floorQuad#,64))
v2![2] = double(long(g_floorQuad#,68))
findPlane
Build a shadow matrix using the lights current position and the plane
buildShadowMatrix
oGL(Clear)
oGL(glClear, ~GL_COLOR_BUFFER_BIT | ~GL_DEPTH_BUFFER_BIT)
Place the view
oGL(glMatrixMode, ~GL_MODELVIEW)
oGL(glLoadIdentity)
oGL(glTranslatef, 0.0, -2.0, -15.0)
oGL(glRotatef, -g_fSpinY_L!, 1.0, 0.0, 0.0)
oGL(glRotatef, -g_fSpinX_L!, 0.0, 1.0, 0.0)
Create a shadow by rendering the teapot using the shadow matrix.
oGL(glDisable, ~GL_DEPTH_TEST)
oGL(glDisable, ~GL_LIGHTING)
oGL(glColor3f, 0.2, 0.4, 0.6) Shadows color
oGL(Push)
oGL(glMultMatrixd, g_shadowMatrix#)
renderObject
oGL(Pop)
oGL(glEnable, ~GL_DEPTH_TEST)
oGL(glEnable, ~GL_LIGHTING)
Render the lights position as a sphere...
oGL(glDisable, ~GL_LIGHTING)
oGL(Push)
long g_lightPosition#,0 = single(g_lightPosition![0]),single(g_lightPosition![1]),single(g_lightPosition![2]),single(g_lightPosition![3])
oGL(glLightfv, ~GL_LIGHT0, ~GL_POSITION, g_lightPosition#)
Place a sphere to represent the light
oGL(glTranslatef, g_lightPosition![0], g_lightPosition![1], g_lightPosition![2])
oGL(glColor3f, 1.0, 1.0, 0.5)
oGL(Sphere,0.1, 8, 8)
oGL(Pop)
oGL(glEnable, ~GL_LIGHTING)
oGL(glColor3f, 1.0, 0.3, 0.0) Objektss color
Render normal teapot
renderObject
oGL(Show)
endproc
-----------------------------------------------------------------------------------
Cls
init
time& = &GetTickCount
frames% = 0
ende% = 0
SetTimer 10
whilenot ende%
WaitInput
if IsKey(27)
ende% = 1
elseif IsKey(38)
xx!=xx!+.5
elseif IsKey(40)
xx!=xx!-.5
elseif IsKey(37)
yy!=yy!+.5
elseif IsKey(39)
yy!=yy!-.5
elseif IsKey($41)
zz!=zz!+.5
elseif IsKey($59)
zz!=zz!-.5
endif
render
inc frames%
if &GetTickCount - time& >= 1000
SetText %hWnd, str$(frames%) + Frames/sek
time& = &GetTickCount
frames% = 0
endif
wend
KillTimer
dispose g_floorQuad#
dispose g_shadowMatrix#
dispose g_lightPosition#
Fin
|
| | | | |
| |  Frank Abbing | Ogl: Anti-Aliasing KompilierenMarqueSéparation {$cleq}
$H Windows.ph
$H ARB_const.ph
declare arbMultisampleSupported%
declare arbMultisampleFormat%
WGLisExtensionSupported: This Is A Form Of The Extension For WGL
proc WGLisExtensionSupported
parameters ext$
declare len%,pProc&,pSupported&
len% = Len(ext$)
pProc& = oGL(wglGetProcAddress, wglGetExtensionsStringARB)
case pProc& : pSupported& = Call(pProc&, oGL(wglGetCurrentDC))
casenot pSupported& : pSupported& = oGL(glGetString, ~GL_EXTENSIONS)
casenot pSupported& : return 0
declare supported$
let supported$ = string$(pSupported&, 0)
declare temp#
dim temp#, Len(supported$) + 1
string temp#, 0 = supported$
declare pos&
pos& = MemPos(temp#,0,ext$)
while pos& <> -1
if (pos& = 0) or (Byte(temp#, pos& - 1) = 32)
if (Byte(temp#, pos& + len%) = 32) or (Byte(temp#, pos& + len%) = 0)
dispose temp#
return 1
endif
endif
pos& = MemPos(temp#, pos&, ext$)
endwhile
dispose temp#
return 0
endproc
InitMultisample: Used To Query The Multisample Frequencies
proc InitMultisample(HINSTANCE hInstance,HWND hWnd,PIXELFORMATDESCRIPTOR pfd)
parameters hInst&,hWnd&,pfd#
ifnot WGLisExtensionSupported(WGL_ARB_multisample)
arbMultisampleSupported% = 0
return 0
endif
declare pProc&
pProc& = oGL(wglGetProcAddress,wglChoosePixelFormatARB)
ifnot pProc&
arbMultisampleSupported% = 0
return 0
endif
declare hDC&
hDC& = ~GetDC(hWnd&)
declare pixelFormat%,valid%,numFormats%
declare fAttributes#
dim fAttributes#, 8
clear fAttributes# = {0,0};
declare iAttributes#
dim iAttributes#, 88
Long iAttributes#, 0 = ~WGL_DRAW_TO_WINDOW_ARB,~GL_TRUE,
~WGL_SUPPORT_OPENGL_ARB,~GL_TRUE,
~WGL_ACCELERATION_ARB,~WGL_FULL_ACCELERATION_ARB,
~WGL_COLOR_BITS_ARB,24,
~WGL_ALPHA_BITS_ARB,8,
~WGL_DEPTH_BITS_ARB,16,
~WGL_STENCIL_BITS_ARB,0,
~WGL_DOUBLE_BUFFER_ARB,~GL_TRUE,
~WGL_SAMPLE_BUFFERS_ARB,~GL_TRUE,
~WGL_SAMPLES_ARB,8, Test For 8 Samples
0,0
valid% = Call(pProc&, hDC&, iAttributes#, fAttributes#, 1, Addr(pixelFormat%), Addr(numFormats%))
if valid% and (numFormats% >= 1)
arbMultisampleSupported% = 1
arbMultisampleFormat% = pixelFormat%
dispose fAttributes#
dispose iAttributes#
return arbMultisampleSupported%
endif
Our Pixel Format With 4 Samples Failed, Test For 4 Samples
Long iAttributes#, 19 * 4 = 4
valid% = Call(pProc&, hDC&, iAttributes#, fAttributes#, 1, Addr(pixelFormat%), Addr(numFormats%))
if valid% and (numFormats% >= 1)
arbMultisampleSupported% = 1
arbMultisampleFormat% = pixelFormat%
dispose fAttributes#
dispose iAttributes#
return arbMultisampleSupported%
endif
Our Pixel Format With 4 Samples Failed, Test For 2 Samples
Long iAttributes#, 19 * 4 = 2
valid% = Call(pProc&, hDC&, iAttributes#, fAttributes#, 1, Addr(pixelFormat%), Addr(numFormats%))
if valid% and (numFormats% >= 1)
arbMultisampleSupported% = 1
arbMultisampleFormat% = pixelFormat%
endif
dispose fAttributes#
dispose iAttributes#
return arbMultisampleSupported%
endproc
proc DrawGLScene
oGL(Clear)
oGL(Origin, -1.5, 0, -6)
oGL(Color, .5, .5, .8, .5)
oGL(Rotate, 0, rtri!, y!)
oGL(Pyramid, 2, 4, 2)
oGL(Origin, 1.5, 0, -6)
oGL(Color, .8, .2, .3, 1)
oGL(Rotate, rquad!, y!/1.2, 0)
oGL(Cuboid, 2, 2, 2)
oGL(Show)
rtri! = rtri! + .5
rquad! = rquad! - .3
y!=y!+.1
endproc
Zum Testen:
Cls
declare wnd&
let wnd& = Create(Window,%hwnd,Test,100,100,400,400)
oGL(Init,wnd&,1,1,1,1)
InitMultisample(%hInstance,wnd&,0)
DestroyWindow(wnd&)
If arbMultisampleFormat%
oGL(Init,%hwnd,0,0,0,1,arbMultisampleFormat%)
Else
oGL(Init,%hwnd,0,0,0,1)
EndIf
declare time&, frames%
declare rtri!,rquad!,y!
declare ende%, lm%
Ogl(PosMode, 1)
time& = &GetTickCount
frames% = 0
Ende% = 0
setTimer 20 max 50 Frames /sek.
WhileNot ende%
WaitInput
if isKey(27)
ende% = 1
endif
DrawGLScene()
inc frames%
if &GetTickCount - time& >= 1000 1 Sekunde ist rum
setText %hWnd, str$(frames%) + Frames/sek
time& = &GetTickCount
frames% = 0
endif
Endwhile
killTimer
end
|
 | | | | |
| |  RGH | iF
Unterthema Vektorkollisionen/Winkelfunktionen: Ok je attends besser seulement einmal jusqu'à Roland qui Gespräche trop o.g. Sujets aufgenommen hat. 
Hm, si le Source dans net strukturiertem XProfan wären, pourrait je vous oui la fois ausprobieren, afin de voyons, quoi qui Funktionen faire devoir ... ;)
Klingt mais pas unitinteressant ...
Salut Roland |
| | | Intel Duo E8400 3,0 GHz / 4 GB RAM / 1000 GB HDD - ATI Radeon HD 4770 512 MB - Windows 7 Home Premium 32Bit - XProfan X4 | 05.11.2007 ▲ |
| |
| |  | | | | | |
| |  RGH | Salut,
cela Thema oGL dans Version 11 venez encore.
Zum reste:
Bound() et RecIntersect() ist oui dans qui aktuellen Subscriptionsversion enthalten: KompilierenMarqueSéparationbetween(X!, vonX!, bisX!)
between(X!, vonX!, bisX!, Y!, vonY!, bisY!)
between(X!, vonX!, bisX!, Y!, vonY!, bisY!, Z!, vonZ!, bisZ!)
Intersec(typ$, object1#, object2#)
range(X!, vonX!, bisX!) = iFs bound()/pre> Dist() ist une interessante concept, mais (encore) pas realisiert: KompilierenMarqueSéparationdist(X1!, Y1!, X2!, Y2!) sqrt((X2! -X1!)^2 + (Y2! - Y1!)^2)
dist(X1!, Y1!, Z1!, X2!, Y2!, Z2!) sqrt((X2! -X1!)^2 + (Y2! - Y1!)^2 + (Z2! - Z1!)^2)e> mais qui prochain Subscriptionsversion venez bestimmt!
Salut Roland |
| | | Intel Duo E8400 3,0 GHz / 4 GB RAM / 1000 GB HDD - ATI Radeon HD 4770 512 MB - Windows 7 Home Premium 32Bit - XProfan X4 | 30.11.2007 ▲ |
| |
|
répondreOptions du sujet | 2.795 Views |
Themeninformationencet Thema hat 3 participant: |