Statistics: Posted by Mentat — Sun Feb 10, 2008 7:10 pm
Statistics: Posted by burger2227 — Sun Feb 10, 2008 6:51 pm
Code:
glLoadIdentity()'Draw a bunch of cubesglPushMatrix() for i = 1 to 5 glTranslatef 1.0, 0.0, 0.0 glPushMatrix() 'Matrix contains a transform i units to the right here for j = 1 to i glTranslatef 0.0, 0.0, 1.0 glCallList(cube_list) next j glPopMatrix() 'Restores the matrix at the beginning, meaning the next time the j-loop is called, the z-transform is reset to 0, and can then be looped again next iglPopMatrix()'without the push/pop (or another glLoadIdentity) the next object rendered would be at 5,0,5 (plus whatever other transforms are applied). Instead we're back at the identity matrix, and have saved a relatively slow copy.glTranslatef 0.0, 1.0, 0.0 'The spheres will appear on a layer above the cubesglPushMatrix() for i = 1 to 5 glTranslatef 1.0, 0.0, 0.0 for j = 1 to i glTranslatef 0.0, 0.0, 1.0 glCallList(sphere_list) next j next iglPopMatrix()'even though there's no more rendering to be done, the whole loop is contained for consistency and to make it easier to add more rendering if we need it
Statistics: Posted by Xerol — Tue Feb 05, 2008 2:08 am
Statistics: Posted by Codemss — Sun Jan 06, 2008 12:22 pm
Statistics: Posted by Mentat — Thu Jan 03, 2008 1:55 pm
Statistics: Posted by Codemss — Thu Jan 03, 2008 1:43 pm
Code:
#include once "GL/gl.bi"#include once "GL/glu.bi" screen 18,16,,2 'FB screen glViewport 0,0,640,480 'screen modeglMatrixMode GL_PROJECTION 'projection modelglLoadIdentity 'resets the matrixgluPerspective 45.0, 640.0/480.0, 0.1, 100.0glMatrixMode GL_MODELVIEW 'viewing modelglLoadIdentity 'resets viewing matrixglClearColor 0.0,0.0,0.0,0.5 'background colorglClearDepth 1.0 'Clears depth, for z axisglEnable GL_DEPTH_TEST ' Enables Depth TestingglDepthFunc GL_LEQUAL ' The Type Of Depth Testing To DoglHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST
At first I had no clue what it did. All I knew is that it worked well. After repeated copying and pasting and reading, I figured out what each line does.Code:
do glClear GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT glLoadIdentity fliploop until multikey(1) 'escape key
Code:
glTranslatef 0,0,-3 'moves into the screen three unitsglBegin GL_TRIANGLES glColor3f 0,0,1 'Blue, in the form of RGB glVertex3f 0,1,0 'top vertice, in the form of (x,y,z) glColor3f 0,1,0 'Green glVertex3f 1,0,0 'bottom right glColor3f 1,0,0 'Red glVertex3f -1,0,0 'bottom leftglEnd
Code:
#include once "GL/gl.bi"#include once "GL/glu.bi" screen 18,16,,2 'FB screen glViewport 0,0,640,480 'screen modeglMatrixMode GL_PROJECTION 'projection modelglLoadIdentity 'resets the matrixgluPerspective 45.0, 640.0/480.0, 0.1, 100.0glMatrixMode GL_MODELVIEW 'viewing modelglLoadIdentity 'resets viewing matrixglClearColor 0.0,0.0,0.0,0.5 'background colorglClearDepth 1.0 'Clears depth, for z axisglEnable GL_DEPTH_TEST ' Enables Depth TestingglDepthFunc GL_LEQUAL ' The Type Of Depth Testing To DoglHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICESTdo glClear GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT glLoadIdentity glTranslatef 0,0,-3 'moves into the screen three units glBegin GL_TRIANGLES glColor3f 0,0,1 'Blue, in the form of RGB glVertex3f 0,1,0 'top vertice, in the form of (x,y,z) glColor3f 0,1,0 'Green glVertex3f 1,0,0 'bottom right glColor3f 1,0,0 'Red glVertex3f -1,0,0 'bottom left glEnd fliploop until multikey(1) 'escape key
Code:
#include once "GL/gl.bi"#include once "GL/glu.bi" screen 18,16,,2dim as single x=18 'player's x coordinatedim as single z=21 'player's z coordinatedim bob as single 'bob angledim as short angle=90 'player's facing angledim as byte wid=2 'width of the boxesdim map(2,10,10) as byte 'map array, (level,row,column)const conv as single=3.14159265/180 'conversion factor for degrees to radiansglViewport 0,0,640,480 'screen modeglMatrixMode GL_PROJECTION 'projection modelglLoadIdentity 'does something to the modelsgluPerspective 45.0, 640.0/480.0, 0.1, 100.0glMatrixMode GL_MODELVIEW 'viewing modelglLoadIdentityglClearColor 0.0,0.0,0.0,0.5 'background color?glClearDepth 1.0 'Clears depthglEnable GL_DEPTH_TEST ' Enables Depth TestingglDepthFunc GL_LEQUAL ' The Type Of Depth Testing To DoglHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICESTfor m=1 to 2 for r=1 to 10 for c=1 to 10 read map(m,r,c) next c next rnext mdo glClear GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT glLoadIdentity glRotatef 90-angle,0,1,0 glTranslatef -x,-1-.2*sin(5*bob*conv),-z 'map for m=0 to 1 'm is offset back 1 for r=1 to 10 for c=1 to 10 if map(m+1,c,r)=1 then glBegin GL_QUADS glColor3f 1.0,1.0,0.0 glVertex3f wid*(r-.5),wid+wid*m,wid*(c+.5) 'front, yellow glVertex3f wid*(r+.5),wid+wid*m,wid*(c+.5) glVertex3f wid*(r+.5),wid*m ,wid*(c+.5) glVertex3f wid*(r-.5),wid*m ,wid*(c+.5) glColor3f 1.0,0.0,0.0 'back face, red glVertex3f wid*(r-.5),wid+wid*m,wid*(c-.5) glVertex3f wid*(r-.5),wid*m ,wid*(c-.5) glVertex3f wid*(r+.5),wid*m ,wid*(c-.5) glVertex3f wid*(r+.5),wid+wid*m,wid*(c-.5) glColor3f 0.0,1.0,1.0 'left face, glVertex3f wid*(r-.5),wid+wid*m,wid*(c-.5) glVertex3f wid*(r-.5),wid+wid*m,wid*(c+.5) glVertex3f wid*(r-.5),wid*m ,wid*(c+.5) glVertex3f wid*(r-.5),wid*m ,wid*(c-.5) glColor3f 0.0,0.0,1.0 'right face, blue glVertex3f wid*(r+.5),wid*m ,wid*(c-.5) glVertex3f wid*(r+.5),wid*m ,wid*(c+.5) glVertex3f wid*(r+.5),wid+wid*m,wid*(c+.5) glVertex3f wid*(r+.5),wid+wid*m,wid*(c-.5) glEnd end if next c next r next m 'ground glBegin GL_QUADS glColor3f 0.0,0.5,0.0 'dark green glVertex3f .5*wid ,0.0,wid*10.5 glVertex3f wid*10.5,0.0,wid*10.5 glVertex3f wid*10.5,0.0,wid*.5 glVertex3f .5*wid ,0.0,wid*.5 glEnd 'ceiling glBegin GL_QUADS glColor3f .8,.8,1.0 'light blue glVertex3f .5*wid ,wid,wid*10.5 glVertex3f wid*10.5,wid,wid*10.5 glVertex3f wid*10.5,wid,wid*.5 glVertex3f .5*wid ,wid,wid*.5 glEnd '2nd ceiling glBegin GL_QUADS glColor3f .8,.8,1.0 'light blue glVertex3f .5*wid ,wid*2,wid*10.5 glVertex3f wid*10.5,wid*2,wid*10.5 glVertex3f wid*10.5,wid*2,wid*.5 glVertex3f .5*wid ,wid*2,wid*.5 glEnd 'walk forward if multikey(80) then let x=x-.1*cos(-angle*conv) let z=z-.1*sin(-angle*conv) let bob=bob+1 end if 'walk backward if multikey(72) then let x=x+.1*cos(-angle*conv) let z=z+.1*sin(-angle*conv) let bob=bob-1 end if 'turn left if multikey(75) then let angle=angle+2 'turn right if multikey(77) then let angle=angle-2 if bob>=360 then let bob=1 fliploop while not(multikey(1))end'level 1' 1,2,3,4,5,6,7,8,9,0data 1,1,1,1,1,1,1,1,1,1 :'1data 1,0,0,0,0,0,0,0,0,1 :'2data 1,1,0,1,1,1,1,1,0,1 :'3data 1,0,0,1,0,0,0,0,0,1 :'4data 1,0,1,0,0,1,1,1,0,1 :'5data 1,0,1,0,1,1,0,1,0,1 :'6data 1,0,1,0,1,0,0,0,0,1 :'7data 1,0,1,1,1,0,1,1,0,1 :'8data 1,0,0,1,0,0,0,1,0,1 :'9data 1,1,1,1,1,1,1,1,0,1 :'10'level 2data 1,1,1,1,1,1,1,1,1,1data 1,0,0,0,0,0,0,0,0,0data 1,0,0,0,0,0,0,0,0,1data 1,0,0,0,0,0,0,0,0,1data 1,0,0,0,0,0,0,0,0,1data 1,0,0,0,0,0,0,0,0,1data 1,0,0,0,0,0,0,0,0,1data 1,0,0,0,0,0,0,0,0,1data 1,0,0,0,0,0,0,0,0,1data 1,1,1,1,1,1,1,1,1,1
Statistics: Posted by Mentat — Sun Dec 30, 2007 10:25 am
Statistics: Posted by Codemss — Sun Dec 30, 2007 7:00 am
Statistics: Posted by Mentat — Fri Dec 28, 2007 10:11 am
Statistics: Posted by MystikShadows — Thu Dec 27, 2007 11:40 am
Statistics: Posted by Codemss — Thu Dec 27, 2007 9:26 am