[bb] 3D mode Chooser by bradford6 [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:38

Previous topic - Next topic

BlitzBot

Title : 3D mode Chooser
Author : bradford6
Posted : 1+ years ago

Description : if your card does not support 3d in a window you will need to modify (a little)

Code :
Code (blitzbasic) Select
; Part Tickle Engine (3D MODE CHOOSER)

Graphics3D 640,480,0,2
Global cam=CreateCamera()
Global lite=CreateLight()

Global modes3d=CountGfxModes3D()
Global fobs=Sqr(modes3d)

Type fob3d
Field xpos#,ypos#,zpos#
Field entity
Field hilite
Field tex,spinspeed#
Field gmode

End Type



setgraphics("set graphicsmodes")



camera=CreateCamera()
light=CreateLight()
cube=CreateCube()

newtex=CreateTexture(256,256)
SetBuffer TextureBuffer(newtex)
For x=0 To 255

For y=255 To 0 Step -1
Color x,y/2,Rnd(x,y)
Plot x,y


Next Next

EntityTexture(cube,newtex)


MoveEntity cube,0,0,3
dir=0
 Repeat
If dir=0
  Stp#=Stp#+.001
  If STP#=50 Then dir=1
EndIf
If dir=1
  Stp#=Stp#-.001
  If STP#=-50 Then dir=0
EndIf



s=s+Stp#
If s=360 Then s=0



TurnEntity cube,Sin(s),Sin(s),Cos(s)

UpdateWorld
RenderWorld
Flip
Until KeyHit(1)=1


; place code here

; please keep this open and improve it--let me know what you do

;  b_radford@yahoo.com
;



Function SetGraphics(title$)
AppTitle(title$)

SetBuffer BackBuffer()

backtex=CreateTexture(256,256)
SetBuffer TextureBuffer(backtex)
For x=0 To 255

For y=255 To 0 Step -1
Color x,y,Rnd(x,255)
Plot x,y


Next Next

sky=CreateSphere()
EntityTexture(sky,backtex)
ScaleEntity sky,30,30,30
PositionEntity sky,fobs*2,fob*2,3
FlipMesh sky







cube=CreateCube()
MoveEntity cam,fobs*2,fobs*2,-5

For x=1 To fobs
For y = 1 To fobs
b.fob3d=New fob3d
bxpos#=x*3
bypos#=y*3
bzpos#=5
bentity = CopyEntity(cube)
HideEntity(bentity)
EntityPickMode(bentity,3)
b ex = CreateTexture(64,64)

PositionEntity bentity,bxpos#,bypos#,bzpos#

Next
Next
; windowed mode entity
b.fob3d=New fob3d
b.fob3d=Last fob3d
bxpos#=fobs*2
bypos#=fobs*2
bzpos#=fobs
bentity= CopyEntity(cube)
bgmode=modes3d+1
EntityPickMode(bentity,3)
b ex = CreateTexture(64,64)
SetBuffer TextureBuffer(b ex)

Text 0,0,"windowed"
Text 3,FontHeight(),"mode"
;ScaleEntity bentity,8,8,8
;EntityBox bentity,0,0,0,8,8,8
EntityTexture (bentity,b ex)
EntityColor (bentity,Rnd(100,255),Rnd(100,255),Rnd(100,255))
PositionEntity bentity,bxpos#,bypos#,bzpos#



; * * * * * * * * * * * *

hilited=CreateBrush(240,240,0)
BrushAlpha (hilited,.6)

SetBuffer BackBuffer()

b.fob3d = First fob3d
For x=1 To modes3d
bgmode = x
SetBuffer TextureBuffer(b ex)
r=Rnd(0,100) g=Rnd(0,100) bl=Rnd(0,100)



fntArial=LoadFont("Arial",22,False,False,False)
SetFont fntarial

ClsColor 255,255,255
Text 0,0,GfxModeWidth(x)
Text 0,FontHeight(),GfxModeHeight(x)
Text 0,FontHeight()*2,GfxModeDepth(x)
ShowEntity(bentity)
EntityTexture (bentity,b ex)
EntityColor (bentity,Rnd(100,255),Rnd(100,255),Rnd(100,255))
b = After b
Next


 


Repeat

pictentity=CameraPick ( cam,MouseX(),MouseY())

For b.fob3d=Each fob3d ; cycle thru all TYPES
If PickedEntity()=bentity
  bspinspeed#=bspinspeed#+.2
If MouseDown(1) Then modepicked=bgmode

EndIf


bspinspeed#=bspinspeed#*.9
EntityAlpha bentity,.8
TurnEntity bentity,0,bspinspeed#,0

TurnEntity sky,0,-.01,0



Next

UpdateWorld
RenderWorld
Flip
Until modepicked>0
For b.fob3d=Each fob3d
FreeEntity bentity
Next

FreeEntity cam
FreeEntity lite
FreeEntity cube



EndGraphics
If modepicked=modes3d+1
Graphics3D 640,480,0,3
Else
Graphics3D GfxModeWidth(modepicked),GfxModeHeight(modepicked),GfxModeDepth(modepicked),1
EndIf

 
End Function



Comments : none...