|
Post by Darkjester on Nov 23, 2010 22:04:10 GMT -5
thanks djlinux that helps alot heres one with texturing working on clipping the colors use whatever image you like ' only a short test ' ##################################### ' # create a unit 1 x 1 x 1 solid box # '##################################### dim tex = loadtex("colorkey.jpg") function CreateCube() dim ret = glGenLists(1) glNewList(ret,GL_COMPILE) glBindTexture(GL_TEXTURE_2D, tex) glBegin(GL_QUADS) glTexCoord2f(0,0):glVertex2f(0,0) glTexCoord2f(0,1):glVertex2f(0,1) glTexCoord2f(1,1):glVertex2f(1,1) glTexCoord2f(1,0):glVertex2f(1,0) glEnd() glEndList() return ret end function
dim hVertex,hProgram,status dim frames,box = CreateCube() dim rot#, status2 dim v$, f$,hFragment
' use the incoming vertex as color and scale it by 3.0 v$=v$ + "void main(void){ " + NL v$=v$ + " gl_TexCoord[0] = gl_MultiTexCoord0;" + NL v$=v$ + " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;" + NL v$=v$ + "}" + NL ' texture the following fragment f$=f$ + "uniform sampler2D tex;" + NL f$=f$ + "#define epsilon 0.0001;" + NL f$=f$ + "void main(){" + NL f$=f$ + " vec4 value = texture2D(tex, gl_TexCoord[0].st);" + NL f$=f$ + " if (value.rgb == vec3(1,0,0))discard;" + NL f$=f$ + " gl_FragColor = value;" + NL f$=f$ + "}" + NL
' create vertex shader object hVertex = CreateVertexShader() if glIsShader(hVertex)=GL_FALSE then printr "error: CreateVertexShader !" end end if ' create fragment shader hFragment =CreateFragmentShader() if glIsShader(hFragment)=GL_FALSE then print "error" end endif ' set shader source code ShaderSource(hVertex,v$) 'set fragment source ShaderSource(hFragment,f$) ' compile shader glCompileShader(hVertex) glGetShaderiv(hVertex,GL_COMPILE_STATUS,status) if status=GL_FALSE then printr "compile error:" printr getShaderInfolog(hVertex) end end if 'compile frag shader glCompileShader(hFragment) glGetShaderiv(hFragment, GL_COMPILE_STATUS, status2) if status2=GL_FALSE then print "compile error: fragment shader" print getShaderInfoLog(hFragment) end end if
' create program object hProgram = glCreateProgram() if glIsProgram(hProgram)=GL_FALSE then printr "error: glCreateProgram !" end end if ' add vertex shader to program glAttachShader(hProgram,hVertex) ' add frag shader to program glAttachShader(hProgram,hFragment) ' link program glLinkProgram(hProgram) glGetProgramiv(hProgram,GL_LINK_STATUS,status) if status=GL_FALSE then printr "link error:" printr getProgramInfolog(hProgram) input$():end end if ' use the program glUseProgram(hProgram)
' free shader glDeleteShader(hVertex) glDeleteShader(hFragment)
'glEnable(GL_LIGHT0) 'glEnable(GL_LIGHTING)
dim UniLoc = glGetUniformLocation(hProgram, "tex")
status=1 ' active shader program while inkey$()="" frames=frames+1 glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) glLoadIdentity() glTranslatef(0,0,-3) glRotatef(rot#,1,1,1) 'glUniform1f(UniLoc, tex) glCallList(Box) SwapBuffers()
WaitTimer(1000/50) rot#=rot#+1 wend ' disable program glUseProgram(0) ' free program glDeleteProgram(hProgram) printr "ok"
|
|
|
Post by DJLinux on Dec 1, 2010 4:05:52 GMT -5
Result can be TRUE or FALSE (if something goes wrong)
first you have to create your shaders objects
hShader = CreateVertexShader() hShader = CreateFragmentShader()
optional set the folder for your shaders SetShaderPath(Path$)
than you load the shader code from text files Result = LoadShaderSource(hFragment,File$) Result = LoadShaderSource(hVertex,File$)
not really usefull but simpler as: void glGetShaderSource(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar *source);
VertexCode$ = GetShaderSource(hVertex) FragmentCode$ = GetShaderSource(hFragment)
Joshy
|
|
|
Post by shadow008 on Dec 9, 2010 11:30:10 GMT -5
I did bump mapping from here: www.swiftless.com/tutorials/glsl/8_bump_mapping.htmlNew one from here: www.ozone3d.net/tutorials/bump_mapping_p4.php ' test for normal mapping
dim tex = LoadTex("brick-c.jpg") dim norm = LoadTex("brick-n.jpg")
declare function CreateCube() declare function CreateSphere()
dim hVertex,hProgram,status dim box = CreateCube() dim sphere = CreateSphere() dim rot#, status2 dim v$, f$,hFragment
v$=v$ + "varying vec3 lightVec;" + NL v$=v$ + "varying vec3 eyeVec; " + NL v$=v$ + "varying vec2 texCoord; " + NL v$=v$ + "varying vec3 vTangent; " + NL
v$=v$ + "void main(void)" + NL v$=v$ + "{" + NL v$=v$ + " gl_Position = ftransform();" + NL v$=v$ + " texCoord = gl_MultiTexCoord0.xy;" + NL v$=v$ + " vec3 n = normalize(gl_NormalMatrix * gl_Normal);" + NL v$=v$ + " vec3 c1 = cross( gl_Normal, vec3(0.0, 0.0, 1.0) );" + NL v$=v$ + " vec3 c2 = cross( gl_Normal, vec3(0.0, 1.0, 0.0) );" + NL
v$=v$ + " if( length(c1)>length(c2) )" + NL v$=v$ + " {" + NL v$=v$ + " vTangent = c1;" + NL v$=v$ + " }else{" + NL v$=v$ + " vTangent = c2;" + NL v$=v$ + " }" + NL v$=v$ + " vTangent = -normalize(vTangent);" + NL'negated for handedness
v$=v$ + " vec3 t = normalize(gl_NormalMatrix * vTangent);" + NL v$=v$ + " vec3 b = normalize(cross(n, t));" + NL v$=v$ + " b = -b;"+NL'negated for handedness v$=v$ + " vec3 vVertex = vec3(gl_ModelViewMatrix * gl_Vertex);" + NL v$=v$ + " vec3 lv = vec3(gl_LightSource[0].position.x,-gl_LightSource[0].position.y,gl_LightSource[0].position.z);" + NL v$=v$ + " vec3 tmpVec = lv - vVertex;" + NL
v$=v$ + " lightVec.x = dot(tmpVec, t);" + NL v$=v$ + " lightVec.y = dot(tmpVec, b);" + NL v$=v$ + " lightVec.z = dot(tmpVec, n);" + NL
v$=v$ + " tmpVec = -vVertex;" + NL v$=v$ + " eyeVec.x = dot(tmpVec, t);" + NL v$=v$ + " eyeVec.y = dot(tmpVec, b);" + NL v$=v$ + " eyeVec.z = dot(tmpVec, n);" + NL v$=v$ + "}" + NL
f$=f$ + "varying vec3 lightVec;" + NL f$=f$ + "varying vec3 eyeVec;" + NL f$=f$ + "varying vec2 texCoord;" + NL f$=f$ + "uniform sampler2D tex;" + NL f$=f$ + "uniform sampler2D norm;" + NL
f$=f$ + "void main (void)" + NL f$=f$ + "{" + NL f$=f$ + " float distSqr = dot(lightVec, lightVec);" + NL f$=f$ + " vec3 lVec = lightVec * inversesqrt(distSqr);" + NL
f$=f$ + " vec3 vVec = normalize(eyeVec);" + NL f$=f$ + " vec4 base = texture2D(tex, texCoord);" + NL f$=f$ + " vec3 bump = normalize( texture2D(norm, texCoord).xyz * 2.0 - 1.0);" + NL
f$=f$ + " vec4 vAmbient = gl_LightSource[0].ambient;" + NL
f$=f$ + " float diffuse = max( dot(lVec, bump), 0.0 );" + NL f$=f$ + " vec4 vDiffuse = gl_LightSource[0].diffuse * diffuse;" + NL
'f$=f$ + " float specular = pow(clamp(dot(reflect(-lVec, bump), vVec), 0.0, 1.0), gl_LightSource[0].specular );" + NL 'uncomment this for testing f$=f$ + " vec4 vSpecular = gl_LightSource[0].specular;" + NL 'comment this out for testing 'f$=f$ + " vec4 vSpecular = vec4(1.0,1.0,1.0,1.0) * specular;" + NL 'uncomment this for testing f$=f$ + " gl_FragColor = ( vAmbient*base + vDiffuse*base );" + NL 'comment this out for testing 'f$=f$ + " gl_FragColor = ( vAmbient*base + vDiffuse*base + vSpecular );" + NL 'uncomment this for testing
f$=f$ + "}" + NL
' create vertex shader object hVertex = CreateVertexShader() if glIsShader(hVertex)=GL_FALSE then printr "error: CreateVertexShader !" end end if ' create fragment shader hFragment =CreateFragmentShader() if glIsShader(hFragment)=GL_FALSE then print "error" end endif
' set shader source code ShaderSource(hVertex,v$) 'set fragment source ShaderSource(hFragment,f$) ' compile shader glCompileShader(hVertex) glGetShaderiv(hVertex,GL_COMPILE_STATUS,status) if status=GL_FALSE then printr "compile error:" printr getShaderInfolog(hVertex) end end if 'compile frag shader glCompileShader(hFragment) glGetShaderiv(hFragment, GL_COMPILE_STATUS, status2) if status2=GL_FALSE then print "compile error: fragment shader" print getShaderInfoLog(hFragment) end end if
' create program object hProgram = glCreateProgram() if glIsProgram(hProgram)=GL_FALSE then printr "error: glCreateProgram !" end end if ' add vertex shader to program glAttachShader(hProgram,hVertex) ' add frag shader to program glAttachShader(hProgram,hFragment) ' link program glLinkProgram(hProgram)
glGetProgramiv(hProgram,GL_LINK_STATUS,status) if status=GL_FALSE then printr "link error:" printr getProgramInfolog(hProgram) input$():end end if ' use the program glUseProgram(hProgram)
' free shader glDeleteShader(hVertex) glDeleteShader(hFragment)
glEnable(GL_LIGHT0) glEnable(GL_LIGHTING) glLightfv(GL_LIGHT0,GL_AMBIENT ,vec4(.1,.1,.1,1.0)) glLightfv(GL_LIGHT0,GL_DIFFUSE ,vec4(1,1,1,1.0)) 'glLightfv(GL_LIGHT0,GL_SPECULAR ,vec4(1,1,1,1)) gllightfv(gl_light0,gl_position ,vec4(0,0,0,1)) gllightfv(gl_light0,gl_shininess,vec4(1.0,1.0,1.0,0.0)) gldisable(gl_lighting)
'////////////////////////////////////////CUBE///////////////////////////////////////////// function CreateCube() dim ret = glGenLists(1) glNewList(ret,GL_COMPILE) glBegin(GL_QUADS) ' Front face glnormal3f(0,0,1) glTexCoord2f(0.0, 0.0): glVertex3f(-1.0, -1.0, 1.0) ' Bottom left of the texture and quad glTexCoord2f(1.0, 0.0): glVertex3f( 1.0, -1.0, 1.0) ' Bottom right of the texture and quad glTexCoord2f(1.0, 1.0): glVertex3f( 1.0, 1.0, 1.0) ' Top right of the texture and quad glTexCoord2f(0.0, 1.0): glVertex3f(-1.0, 1.0, 1.0) ' Top left of the texture and quad ' Back face glnormal3f(0,0,-1) glTexCoord2f(1.0, 0.0): glVertex3f(-1.0, -1.0, -1.0) ' Bottom right of the texture and quad glTexCoord2f(1.0, 1.0): glVertex3f(-1.0, 1.0, -1.0) ' Top right of the texture and quad glTexCoord2f(0.0, 1.0): glVertex3f( 1.0, 1.0, -1.0) ' Top left of the texture and quad glTexCoord2f(0.0, 0.0): glVertex3f( 1.0, -1.0, -1.0) ' Bottom left of the texture and quad ' Top face glnormal3f(0,1,0) glTexCoord2f(0.0, 1.0): glVertex3f(-1.0, 1.0, -1.0) ' Top left of the texture and quad glTexCoord2f(0.0, 0.0): glVertex3f(-1.0, 1.0, 1.0) ' Bottom left of the texture and quad glTexCoord2f(1.0, 0.0): glVertex3f( 1.0, 1.0, 1.0) ' Bottom right of the texture and quad glTexCoord2f(1.0, 1.0): glVertex3f( 1.0, 1.0, -1.0) ' Top right of the texture and quad ' Bottom face glnormal3f(0,-1,0) glTexCoord2f(1.0, 1.0): glVertex3f(-1.0, -1.0, -1.0) ' Top right of the texture and quad glTexCoord2f(0.0, 1.0): glVertex3f( 1.0, -1.0, -1.0) ' Top left of the texture and quad glTexCoord2f(0.0, 0.0): glVertex3f( 1.0, -1.0, 1.0) ' Bottom left of the texture and quad glTexCoord2f(1.0, 0.0): glVertex3f(-1.0, -1.0, 1.0) ' Bottom right of the texture and quad ' Right face glnormal3f(1,0,0) glTexCoord2f(1.0, 0.0): glVertex3f( 1.0, -1.0, -1.0) ' Bottom right of the texture and quad glTexCoord2f(1.0, 1.0): glVertex3f( 1.0, 1.0, -1.0) ' Top right of the texture and quad glTexCoord2f(0.0, 1.0): glVertex3f( 1.0, 1.0, 1.0) ' Top left of the texture and quad glTexCoord2f(0.0, 0.0): glVertex3f( 1.0, -1.0, 1.0) ' Bottom left of the texture and quad ' Left face glnormal3f(-1,0,0) glTexCoord2f(0.0, 0.0): glVertex3f(-1.0, -1.0, -1.0) ' Bottom left of the texture and quad glTexCoord2f(1.0, 0.0): glVertex3f(-1.0, -1.0, 1.0) ' Bottom right of the texture and quad glTexCoord2f(1.0, 1.0): glVertex3f(-1.0, 1.0, 1.0) ' Top right of the texture and quad glTexCoord2f(0.0, 1.0): glVertex3f(-1.0, 1.0, -1.0) ' Top left of the texture and quad glEnd() glEndList() return ret end function
'////////////////////////////////////////SPHERE///////////////////////////////////////////// function CreateSphere() const segments = 24 const US# = (m_PI*2) / segments const VS# = m_PI / segments const NumOfPoints = (segments + 1) * (segments + 1) dim PS#(NumOfPoints*3-1) dim ret,pc,yc,xc,p0,p1,p2,p3 dim VW#,UW#,UR#,YP#,VR#,VA#(2) For yc = 0 To segments UR# = Sin(VW#) * 0.5 YP# = Cos(VW#) * 0.5 VR# = Sin(VW#) * 0.5 VW# = VW#+VS# UW# = 0 For xc = 0 To segments PS#(PC*3+0)=Sin( UW#) * UR# PS#(PC*3+1)=YP# PS#(PC*3+2)=Cos(m_PI+UW#) * VR# PC=PC+1: UW#=UW#+US# Next Next
ret=glGenLists(1) glNewList (ret, GL_COMPILE) glBegin (GL_TRIANGLES) For yc= 0 To segments - 1 For xc= 0 To segments - 1 P0 = ((yc + 0) * (segments + 1) + (xc + 0))*3 P1 = ((yc + 0) * (segments + 1) + (xc + 1))*3 P2 = ((yc + 1) * (segments + 1) + (xc + 1))*3 P3 = ((yc + 1) * (segments + 1) + (xc + 0))*3 VA#=Vec3(PS#(p0),PS#(p0+1),PS#(p0+2)) glNormal3fv(Normalize(VA#)):glVertex3fv(VA#) VA#=Vec3(PS#(p1),PS#(p1+1),PS#(p1+2)) glNormal3fv(Normalize(VA#)):glVertex3fv(VA#) VA#=Vec3(PS#(p3),PS#(p3+1),PS#(p3+2)) glNormal3fv(Normalize(VA#)):glVertex3fv(VA#) VA#=Vec3(PS#(p1),PS#(p1+1),PS#(p1+2)) glNormal3fv(Normalize(VA#)):glVertex3fv(VA#) VA#=Vec3(PS#(p2),PS#(p2+1),PS#(p2+2)) glNormal3fv(Normalize(VA#)):glVertex3fv(VA#) VA#=Vec3(PS#(p3),PS#(p3+1),PS#(p3+2)) glNormal3fv(Normalize(VA#)):glVertex3fv(VA#) Next Next glEnd() glEndList() return ret end function
dim texture_location dim normal_location dim lightpos(2) as single,dis as single = -3.5 textmode(text_overlaid) status=1 ' active shader program
dim counter as single dim timer as integer dim avg as single dim newavg as single dim timebool as integer = true
while inkey$()="" if timebool then timer = performancecounter() timebool = false endif cls glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) glLoadIdentity() glpushmatrix() glTranslatef(0,0,-5) glRotatef(rot#,1,1,0) 'uncheck this if you want to glUseProgram(hProgram) glActiveTexture(GL_TEXTURE0) 'set our regular texture to texture 0 glEnable(GL_TEXTURE_2D) texture_location = glGetUniformLocation(hProgram, "tex") glUniform1i(texture_location, 0) glBindTexture(GL_TEXTURE_2D, tex) glActiveTexture(GL_TEXTURE1) 'set our normal texture to texture 1 normal_location = glGetUniformLocation(hProgram, "norm") glUniform1i(normal_location, 1) glBindTexture(GL_TEXTURE_2D, norm) glCallList(Box) glActiveTexture(GL_TEXTURE1) glBindTexture(GL_TEXTURE_2D, 0) 'bind them to nothing glActiveTexture(GL_TEXTURE0) glBindTexture(GL_TEXTURE_2D, 0) glDisable(GL_TEXTURE_2D) 'disable textureing glpopmatrix() glUseProgram(0)'STOP USING THE SHADER 'glenable(gl_lighting) glpushmatrix() gltranslatef(lightpos(0),-lightpos(1),lightpos(2)) glscalef(.1,.1,.1) glRotatef(rot#,1,1,0) glEnable(GL_TEXTURE_2D) glBindTexture(gl_texture_2d,tex) glcolor3f(1,1,0) glCallList(Sphere) glDisable(gl_texture_2d) glpopmatrix() printr "FPS = "newavg printr "Camera: " + lightpos(0)+","+lightpos(1)+","+lightpos(2) DrawText() SwapBuffers() counter = counter + 1 dis = dis + mouse_wheel() *.1 lightpos = vec3(mouse_x()*7-3.5,mouse_y()*4-2,dis) gllightfv(gl_light0,gl_position ,lightpos)
'WaitTimer(1000/50) rot#=rot#+.3 if performancecounter() - timer >= 1000 then newavg = counter counter = 0 timebool = true endif
wend ' disable program glUseProgram(0) ' free program glDeleteProgram(hProgram) printr "ok"
I edited it right before posting it, so if it doesnt work, tell me. Use any normal map you can find and any regular texture. just google->images->"normal maps"... that works too On to normal maps!
|
|
|
Post by shadow008 on Dec 25, 2010 21:14:18 GMT -5
soz for the dp but...
^^^ That doesn't seem to work at all. It fails to load anything. Maybe im doing it wrong?
pseudo code:
SetShaderPath("Shaders/") LoadShaderSource(hVertex,"VertexShaderSource.txt") v$ = GetShaderSource(hVertex) glCompileShader(hVertex)
With or without the SetShaderPath function called, it doesnt do anything. Is there something wrong with ^that^ logic?
|
|
|
Post by shadow008 on Dec 28, 2010 20:00:08 GMT -5
Yes, i guess i didnt put that above. But how exactly is this working? I was messing around with it and got: (more psudo code) SetShaderPath("shaders") LoadShaderSource(hVertex," /VertexShaderSource.txt") v$ = GetShaderSource(hVertex) .... And i get an error with the parsing of the shader... And v$ ends up being "/VertexShaderSource.txt" Not the actual code within the file. I realize that the SetShaderPath() function should contain the file name AND the backslash... but why would v$ end up being the argument passed in LoadShaderSource() when GetShaderSource() is called, when the backslash is in LoadShaderSource filename  Hope i said that correctly : /
|
|
|
Post by DJLinux on Dec 29, 2010 10:32:26 GMT -5
Ok seams to be a bug here are a workaround in Basic4GL happy "color" coding Joshy function LoadShader(hShader,Path$) if glIsShader(hShader) = GL_FALSE then printr "error: LoadShader() wrong handle!" return GL_FALSE end if dim hFile = OpenFileRead(Path$) if hFile<1 then printr "error: LoadShader() file not found!" return GL_FALSE end if dim Code$,aLine$ while EndOfFile(hFile) = False aLine$ = ReadLine(hFile) Code$ = Code$ + aLine$ + NL wend CloseFile(hFile) ShaderSource(hShader,Code$) return GL_TRUE end function here are "test01.vert" void main(void) { gl_Position = gl_ModelViewProjectionMatrix * (gl_Vertex * vec4(3.0,3.0,3.0,1.0)); gl_FrontColor = gl_Vertex; }
here are "load_shader01.gb" ' only a short test ' ##################################### ' # create a unit 1 x 1 x 1 solid box # '##################################### function CreateCube() dim ret = glGenLists(1) glNewList(ret,GL_COMPILE) glBegin(GL_QUADS) glNormal3f(0,0,1) glVertex3f(-0.5, 0.5, 0.5):glVertex3f(-0.5,-0.5, 0.5) glVertex3f( 0.5,-0.5, 0.5):glVertex3f( 0.5, 0.5, 0.5) glNormal3f(1,0,0) glVertex3f( 0.5, 0.5, 0.5):glVertex3f( 0.5,-0.5, 0.5) glVertex3f( 0.5,-0.5,-0.5):glVertex3f( 0.5, 0.5,-0.5) glNormal3f (0,0,-1) glVertex3f( 0.5, 0.5,-0.5):glVertex3f( 0.5,-0.5,-0.5) glVertex3f(-0.5,-0.5,-0.5):glVertex3f(-0.5, 0.5,-0.5) glNormal3f(-1,0,0) glVertex3f(-0.5, 0.5,-0.5):glVertex3f(-0.5,-0.5,-0.5) glVertex3f(-0.5,-0.5, 0.5):glVertex3f(-0.5, 0.5, 0.5) glNormal3f(0,1,0) glVertex3f(-0.5, 0.5,-0.5):glVertex3f(-0.5, 0.5, 0.5) glVertex3f( 0.5, 0.5, 0.5):glVertex3f( 0.5, 0.5,-0.5) glNormal3f(0,-1,0) glVertex3f(-0.5,-0.5, 0.5):glVertex3f(-0.5,-0.5,-0.5) glVertex3f( 0.5,-0.5,-0.5):glVertex3f( 0.5,-0.5, 0.5) glEnd() glEndList() return ret end function
function LoadShader(hShader,Path$) if glIsShader(hShader)=GL_FALSE then printr "error: LoadShader() wrong handle!" return GL_FALSE end if dim hFile=OpenFileRead(Path$) if hFile<1 then printr "error: LoadShader() file not found!" return GL_FALSE end if dim Code$,aLine$ while EndOfFile(hFile)=False aLine$ = ReadLine(hFile) Code$=Code$+aLine$+NL wend CloseFile(hFile) ShaderSource(hShader,Code$) return GL_TRUE end function
dim hVertex,hProgram,status dim ret,frames,box = CreateCube() dim rot#
' create vertex shader object hVertex = CreateVertexShader() if glIsShader(hVertex)=GL_FALSE then printr "error: CreateVertexShader !" end end if
' Load the shader from source code if LoadShader(hVertex,"test01.vert")=GL_FALSE then glDeleteShader(hVertex) printr "error: LoadShader !" end end if
' compile shader glCompileShader(hVertex) glGetShaderiv(hVertex,GL_COMPILE_STATUS,status) if status=GL_FALSE then printr "compile error:" printr getShaderInfoLog(hVertex) end end if
' create program object hProgram = glCreateProgram() if glIsProgram(hProgram)=GL_FALSE then printr "error: glCreateProgram !" end end if ' add vertex shader to program glAttachShader(hProgram,hVertex) ' link it glLinkProgram(hProgram) glGetProgramiv(hProgram,GL_LINK_STATUS,status) if status=GL_FALSE then printr "link error:" printr getProgramInfolog(hProgram) input$():end end if ' use the program glUseProgram(hProgram)
' free shader glDeleteShader(hVertex)
glEnable(GL_LIGHT0) glEnable(GL_LIGHTING)
status=1 ' active shader program while inkey$()="" frames=frames+1 glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) glLoadIdentity() glTranslatef(0,0,-10) glRotatef(rot#,1,1,1)
glCallList(Box) SwapBuffers() WaitTimer(1000/50) rot#=rot#+1 ' togle program on/off if (frames % 100)=0 then status=1-status if status then glUseProgram(hProgram) else glUseProgram(0) end if end if
wend ' disable program glUseProgram(0) ' free program glDeleteProgram(hProgram) printr "ok"
|
|