Hey everyone, I found some time between school work to work on my 3D world at this link.
http://www.freebasic.net/forum/viewtopi ... 942#113942
I am currently trying to figure out how to add a pause menu to it, so it still draws the scene, and adds a overlayed menu on top with variable transparency. What would be the easiest way to accomplish this? Keeping in mind that the world is 3D that is mapped behind the menu.
Making a pause menu in a 3D OpenGL application
Code: Select all
sub osgl_set2dscreen()
myscreen.rendermode=0
glViewport 0, 0, myscreen.realx, myscreen.realy
glMatrixMode GL_PROJECTION
glLoadIdentity
glOrtho myscreen.zoomx , myscreen.x-myscreen.zoomx , myscreen.y-myscreen.zoomy-myscreen.widescreenpixels , myscreen.zoomy+myscreen.widescreenpixels,-1,1 '' Set Up An Ortho Screen
'gluPerspective 90, x/y, 3, .1
glMatrixMode GL_MODELVIEW
glLoadIdentity
glShadeModel GL_SMOOTH '' Enables Smooth Color Shading
glClearColor 0,0,0,0 '' Clear The Background Color To Black
'glBlendFunc GL_SRC_ALPHA, GL_ONE '' Select The Type Of Blending
glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
glEnable GL_BLEND '' Enable Blending
glEnable GL_TEXTURE_2D '' Enable 2D Texture Mapping
glEnable GL_ALPHA_TEST
glAlphaFunc GL_GREATER, 0.001
'glAlphaFunc GL_GREATER, 0.5
glDisable GL_DEPTH_TEST
glEnable GL_COLOR_MATERIAL
glDisable GL_LIGHTING
glDisable GL_LIGHT1
end sub
sub osgl_set3dscreen()
myscreen.rendermode=1
glViewport 0, 0, myscreen.realx, myscreen.realy
glMatrixMode GL_PROJECTION '' Select The Projection Matrix
glLoadIdentity '' Reset The Projection Matrix
gluPerspective 45.0, myscreen.x/myscreen.y, 0.1, 100.0 '' Calculate The Aspect Ratio Of The Window
glMatrixMode GL_MODELVIEW '' Select The Modelview Matrix
glLoadIdentity '' Reset The Projection Matrix
glShadeModel GL_SMOOTH '' Enables Smooth Color Shading
'glClearColor 0.0, 0.0, 0.0, 0.0 '' Clear The Background Color To Black
glClearDepth 1.0 '' Enables Clearing Of The Depth Buffer
'glBlendFunc GL_SRC_ALPHA, GL_ONE '' Select The Type Of Blending
glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
glEnable GL_BLEND '' Enable Blending
glEnable GL_TEXTURE_2D '' Enable 2D Texture Mapping
glEnable GL_ALPHA_TEST
glAlphaFunc GL_GREATER, 0.001
'glAlphaFunc GL_GREATER, 0.5
glEnable GL_DEPTH_TEST '' Enables Depth Testing
glDepthFunc(GL_LESS) '' The Type Of Depth Test To Do
'Dim Shared LightDiffuse(0 To 3) As Single => {3, 3, 3, 1}
LightDiffuse(0)=1:LightDiffuse(1)=1:LightDiffuse(2)=1:LightDiffuse(3)=1
glLightfv GL_LIGHT1, GL_DIFFUSE, @LightDiffuse(0)
'Dim Shared LightPosition(0 To 3) As Single => {0, 0, 0, 1}
LightPosition(0) = 0:LightPosition(1) = 0:LightPosition(2) = -5:LightPosition(3) = 1
glLightfv GL_LIGHT1, GL_POSITION, @LightPosition(0)
glEnable GL_COLOR_MATERIAL
glEnable GL_LIGHTING
glEnable GL_LIGHT1
end sub
Hope you find it useful.