[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
Pete's QBASIC Site Discuss QBasic, Freebasic, QB64 and more 2008-02-10T19:57:41-05:00 http://www.petesqbsite.com/phpBB3/app.php/feed/topic/2549 2008-02-10T19:57:41-05:00 2008-02-10T19:57:41-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=16616#p16616 <![CDATA[Compiling in FB with OpenGL]]> Statistics: Posted by Nodtveidt — Sun Feb 10, 2008 7:57 pm


]]>
2008-02-10T19:10:30-05:00 2008-02-10T19:10:30-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=16613#p16613 <![CDATA[Re: Watch him!]]>
... He used to hound the QB sites with tons of questions...
:D
Okay, who hasn't? I hounded FreeBasic.net, Y!A, and here too. And I'm by far not alone.

Statistics: Posted by Mentat — Sun Feb 10, 2008 7:10 pm


]]>
2008-02-10T18:51:16-05:00 2008-02-10T18:51:16-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=16612#p16612 <![CDATA[Watch him!]]>
At least HE is learning something!

Ted

Statistics: Posted by burger2227 — Sun Feb 10, 2008 6:51 pm


]]>
2008-02-05T02:08:55-05:00 2008-02-05T02:08:55-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=16556#p16556 <![CDATA[Compiling in FB with OpenGL]]>
One thing to start using early is glPushMatrix and glPopMatrix. glLoadIdentity is relatively slow (push and pop matrix are actually just pointer swaps, while loadidentity has to copy a whole matrix). These let you quickly reset the transforms when rendering different sets of objects. A related thing to exploit is that the transform matrix "stacks" up, so if you need to render a bunch of objects evenly spaced apart, you can exploit this.

Assume cube_list and sphere_list are display lists containing a cube and sphere respectively. The first block draws cubes at (1,0,1), (2,0,1)-(2,0,2), (3,0,1)-(3,0,3), (4,0,1)-(4,0,4), and (5,0,1)-(5,0,5).

The second block doesn't pop the matrix back to the starting state after each j-loop, so the spheres show up at (1,1,1), (2,1,2), (2,1,3), (3,1,4), (3,1,5), (3,1,6), (4,1,7), (4,1,8), (4,1,9), (4,1,10), (5,1,11), (5,1,12), (5,1,13), (5,1,14), and (5,1,15).

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
Keep in mind that display lists work as if the code in the list was just pasted in place of the glCallList call, so if you've put any transforms inside a display list and have funky output, keep that in mind. Basically, keep track of where the transforms are, otherwise you might end up with objects rendering somewhere you don't want them to. glPushMatrix and glPopMatrix help immensely in this.

Edit: This code isn't tested, but it should work if you put it inside a render loop and have the right display lists set up.

Statistics: Posted by Xerol — Tue Feb 05, 2008 2:08 am


]]>
2008-02-04T13:44:38-05:00 2008-02-04T13:44:38-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=16549#p16549 <![CDATA[Compiling in FB with OpenGL]]> Statistics: Posted by Codemss — Mon Feb 04, 2008 1:44 pm


]]>
2008-02-03T10:49:21-05:00 2008-02-03T10:49:21-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=16548#p16548 <![CDATA[Compiling in FB with OpenGL]]> Statistics: Posted by Mentat — Sun Feb 03, 2008 10:49 am


]]>
2008-02-03T09:03:02-05:00 2008-02-03T09:03:02-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=16547#p16547 <![CDATA[Compiling in FB with OpenGL]]> Statistics: Posted by Codemss — Sun Feb 03, 2008 9:03 am


]]>
2008-01-06T12:22:34-05:00 2008-01-06T12:22:34-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=16239#p16239 <![CDATA[Compiling in FB with OpenGL]]> ). I kinda understand it now. You post is lika tutorial. :P.

I think I will try to make some rotating poly's soon. I'll post it here. Thanx for your help.

Statistics: Posted by Codemss — Sun Jan 06, 2008 12:22 pm


]]>
2008-01-03T13:55:24-05:00 2008-01-03T13:55:24-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=16221#p16221 <![CDATA[Compiling in FB with OpenGL]]>
All you are doing is telling openGL "I want a screen that does 3d graphics, is this wide and this tall, and can do some really fancy math." The matrice loadings just are for the 'camera' and space, and for the math that comes with it.

Statistics: Posted by Mentat — Thu Jan 03, 2008 1:55 pm


]]>
2008-01-03T13:43:09-05:00 2008-01-03T13:43:09-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=16220#p16220 <![CDATA[Compiling in FB with OpenGL]]> . Well, I will try it later.

Statistics: Posted by Codemss — Thu Jan 03, 2008 1:43 pm


]]>
2007-12-30T10:25:56-05:00 2007-12-30T10:25:56-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=16203#p16203 <![CDATA[Compiling in FB with OpenGL]]>

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.

Next is the DO loop for whatever you want to draw. the first thing to write down is FLIP!!!!!!!!!!! It will be right before LOOP WHILE. If you don't, your system will crash and you'll have to reboot. I forgot 3 times, and each time my screen had the resolution of 40*40, sometimes went blank, and I had to reboot manually. There won't be any permanrnt damage, just an anoying inconvenience. Remember FLIP right before you loop around.

And in the begining of the loop is glClear GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT and then glLoadIdentity. The last thing resets your screen (sort of like cls, but it does much more, such as keeping everything from running away).

Now the looping code looks like

Code:

do    glClear GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT    glLoadIdentity    fliploop until multikey(1)      'escape key
In that space is the steak, the part where you get to DRAW!
Here's how you draw a triangle

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
Put it together and you get

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
For more, go to the NeHe website and there are nehe tutorials that come with the FB ide (you may have to dig a little bit).

And prepare to be amazed. I've got some source code for a small maze (no collision detection).

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
You can change wid around. There shouldn't be any problems.

Statistics: Posted by Mentat — Sun Dec 30, 2007 10:25 am


]]>
2007-12-30T07:00:54-05:00 2007-12-30T07:00:54-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=16201#p16201 <![CDATA[Compiling in FB with OpenGL]]> .

But, to respond on your post, Mentat:
Probably both ways are possible. Where do you learn OpenGL from?
I think OpenGL is a bit complicated, but it gives many possibilities and is very fast. What do you think?
Greets,

Codemss

Statistics: Posted by Codemss — Sun Dec 30, 2007 7:00 am


]]>
2007-12-28T10:11:38-05:00 2007-12-28T10:11:38-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=16192#p16192 <![CDATA[Compiling in FB with OpenGL]]> #include once "GL/glu.bi"

That's what I do. I just learned how to use OpenGL.

Statistics: Posted by Mentat — Fri Dec 28, 2007 10:11 am


]]>
2007-12-27T11:40:38-05:00 2007-12-27T11:40:38-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=16185#p16185 <![CDATA[Compiling in FB with OpenGL]]> . If you don't ask you won't know ;-). Now, you know. hehe.

Got more questions don't hesitate ok?

Statistics: Posted by MystikShadows — Thu Dec 27, 2007 11:40 am


]]>
2007-12-27T09:26:46-05:00 2007-12-27T09:26:46-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=16184#p16184 <![CDATA[Compiling in FB with OpenGL]]> .

Statistics: Posted by Codemss — Thu Dec 27, 2007 9:26 am


]]>