Opportunities and suggestions | | | |  | I benenne here simply time Funktionswünsche which help can the XProfan-Spieleprogrammierer More performance inside the programs achieve can. (Performance is with play Yes often importent as z.B. with of/ one smaller Datenbankanwendung.)
would be me forward if too others here a or others Idea for Roland leave behind would.
• Rechteckintersektionskontrolle (ggf. with Überlappungsfaktor as Float) • Distance zweier spots (2D & 3D) ( [...] ) CompileMarkSeparation • Bound (normalisieren?) bound(x,-30,30) CompileMarkSeparation the likes of course everything narrow-minded wirken, but it power already a vastly Geschwindigkeitsunterschied from if one on such native aide zurückgreifen could, and particularly with play counts each µ. |
| | | | |
| |  | Next Part - sub-topic OpenGL.
following functions - if nativ Umgesetzt - could the XProfan-OGL-Game developers explicit More joy at program verschaffen! CompileMarkSeparation
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)
}<
}
and these: CompileMarkSeparation
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 ruddy,bool filled){
ogl(glBegin,if(filled,GL_POLYGON,GL_LINE_LOOP))
float f:=ruddy*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){
case pcount<5:r3:=0
case pcount<4:r2:=0
if pcount==1 {
r1:=x
x:=ogl.maxx/2
y:=ogl.maxy/2
}
ogl(move,x,y,)
ogl(rotate,r3,r2,r1)
ogl(move,-x,-y,)
}
ogl.2dscale(float x,y,f){
if pcount==1 {
f:=x
x:=ogl.maxx/2
y:=ogl.maxy/2
}
ogl(move,x,y,)
ogl(scale,f)
ogl(move,-x,-y,)
}
ogl.2dmove(float x,y){
ogl(move,x,y,)
}
and hereon aufbauend these: CompileMarkSeparation
ogl.drawpic(long tex,long x,y,xx,yy,float a){
case pcount>5 : ogl(color,1,1,1,a)
ogl(texture,tex,1)
ogl.rectangle(x,y,x+xx,y+yy,true)
}
ogl.color(long col,a){ogl(color,getrvalue(col)/255,getgvalue(col)/255,getbvalue(col)/255,a/255)}
and even if unübersichtlich appear - so importent these: (benötigte Texturdatei in the attachment) CompileMarkSeparation
ogl.drawSysText(float x,y,string txt,float sz,szY,hopX,szX,xtraProcAddr){
case pcount<8 : xtraProcAddr:=0
case pcount<7 : szX:=1
case pcount<6 : hopX:=1
case pcount<5 : szY:=1
case 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
case 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
case 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(move,hopX,,)
}
ogl.pop
return hopX
}
of this integrally To silence: CompileMarkSeparation
ogl.LoadTEX(string fileName,float greater,long modi,bool smooth){
case pcount<2 : greater:=NUL
case pcount<3 : modi:=NUL
case pcount<4 : smooth:=true
case greater==NUL : greater:=0.001
case modi==NUL : modi:=GL_MODULATE
casenot fileexists(fileName) : return false
if lower$(getfileext(fileName))==tex {
long fSiz:=filesize(fileName)
case (fSiz<4) : return false
mem mem:=fSiz
long bytesRead:=blockread(fileName,mem,,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, 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,if(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
} else {
long lxx:=greater
case ogl.percMode : lxx:=lxx*ogl.maxx/100
case pcount==2 : modi:=3
if lxx>1024 {lxx:=1024} else if lxx>512 {lxx:=1024} else if lxx>256 {lxx:=512} else if lxx>128 {lxx:=256} else if lxx>64 {lxx:=128} else if lxx>32 {lxx:=64} else {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
}
and what simple: CompileMarkSeparation and what wichtiges!: CompileMarkSeparation
ogl.vsync(bool vsync){
casenot ogl.hasExtension(WGL_EXT_swap_control) : return -1
long wglSwapIntervalEXT:=wglGetProcAddress(wglSwapIntervalEXT)
long wglGetSwapIntervalEXT:=wglGetProcAddress(wglGetSwapIntervalEXT)
if wglGetSwapIntervalEXT {
bool isVSync:=call(wglGetSwapIntervalEXT)
case pcount <1 : return isVSync
}
call(wglSwapIntervalEXT,vsync)
return ogl.vsync()
}
ogl.hasExtension(string eName){return if(instr(eName,ogl.extensions),true,)}
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)//ought to vlt. xprofanSysVariableString his
|
 | | | | |
| |  | Sub-Topic Vektorkollisionen/Winkelfunktionen:
OK I were rather first once To Roland The conversations To o.g. Topics adopted has.  |
| | | | |
| |  Frank Abbing | I erdreiste me too time... 
Ogl: shadow Nr.1 CompileMarkSeparation {$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#
End
|
| | | | |
| |  Frank Abbing | Ogl: shadow Nr.2 CompileMarkSeparation {$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#
End
|
| | | | |
| |  Frank Abbing | Ogl: Anti-Aliasing CompileMarkSeparation {$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
Sub-Topic Vektorkollisionen/Winkelfunktionen: OK I were rather first once To Roland The conversations To o.g. Topics adopted has. 
Hm, if The Source in tidy strukturiertem XProfan wären, could I tappt im dunkeln Yes time try, to see, what The functions make should ... ;)
sound but not unitinteressant ...
Greeting 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 | 11/05/07 ▲ |
| |
| |  | | | | | |
| |  RGH | Hi,
the Topic oGL in Version 11 comes yet.
to that remainder:
Bound() and RecIntersect() is Yes in the actually Subscriptionsversion include: CompileMarkSeparationbetween(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() is a interesting idea, but (yet) not realized: CompileMarkSeparationdist(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> but The next Subscriptionsversion comes certainly!
Greeting 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 | 11/30/07 ▲ |
| |
|
AnswerThemeninformationenthis Topic has 3 subscriber: |