|
Post by DJLinux on Nov 17, 2013 15:21:37 GMT -5
shadow008 Don't crash my box here :lol: Wrong use of glNormalPointer(3, GL_FLOAT, pNor) ! take a look in the *.rtf doc a short hint normalpointer the size is allways the same !!! DJ
|
|
|
Post by DJLinux on Nov 17, 2013 15:31:22 GMT -5
here are your working code with light and color material enabled. DJ dim LightPos#(3) sub InitOpenGL() dim MaxVertex,MaxIndex glGetIntegerv(GL_MAX_ELEMENTS_VERTICES,MaxVertex) glGetIntegerv(GL_MAX_ELEMENTS_INDICES ,MaxIndex) if MaxVertex<1 or MaxIndex<1 then print "sorry no support for elements" beep():end end if glLoadIdentity() gluLookAt(0,5,-20, 0,0,0, 0,1,0) end sub
' cube ' v6----- v5 ' /| /| ' v1------v0| ' | | | | ' | |v7---|-|v4 ' |/ |/ ' v2------v3
' 8 vertices data 1, 1, 1, -1, 1, 1, -1,-1, 1, 1,-1, 1 data 1,-1,-1, 1, 1,-1, -1, 1,-1, -1,-1,-1 ' 6 colors data 1, 0, 0 data 0, 1, 0 data 0, 0, 1 data 1, 1, 0 data 0, 1, 1 data 1, 0, 1
' 6 quads data 1,2,3,0 data 0,3,4,5 data 5,4,7,6 data 6,7,2,1 data 6,1,0,5 data 2,7,4,3
InitOpenGL()
dim Ver#(8*3-1) dim Col#(6*3-1) dim Ind(6*4-1) dim Norm#(8*3-1)'(8-1)(2) dim temp#(2) dim i for i=0 to 8*3-1 read Ver#(i) next for i=0 to 6*3-1 read Col#(i) next for i=0 to 6*4-1 read Ind(i) next
'Calculate normals as perpendicular to the verticies of the cube for i = 0 to 8*3-1 step 3 Norm#(i) = Ver#(i) Norm#(i+1) = Ver#(i + 1) Norm#(i+2) = Ver#(i + 2) temp# = Normalize(vec3(Norm#(i), Norm#(i+1), Norm#(i+2))) Norm#(i) = temp#(0) Norm#(i+1) = temp#(1) Norm#(i+2) = temp#(2) next
' create 2 float and 1 byte pointer dim MEM pVer=AllocFloatPointer(Ver#) dim MEM pCol=AllocFloatPointer(Norm#) dim MEM pInd=AllocShortPointer(Ind) dim MEM pNor=AllocFloatPointer(Norm#)
dim Rot# ' activate and specify pointers glEnableClientState(GL_VERTEX_ARRAY) : glVertexPointer(3, GL_FLOAT, 0, pVer) glEnableClientState(GL_COLOR_ARRAY) : glColorPointer (3, GL_FLOAT, 0, pCol) glEnableClientState(GL_NORMAL_ARRAY) : glNormalPointer(GL_FLOAT, 0, pNor)
'Enable for crash glEnable(GL_LIGHTING) glEnable(GL_LIGHT0) glEnable(GL_COLOR_MATERIAL)
while inkey$()="" glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) glPushMatrix() glScalef(5,5,5) glRotatef(Rot#, 0.5,0.25,0.125) ' draw 6 quads with 24 coords from index array glDrawElements(GL_QUADS, 24, GL_UNSIGNED_SHORT, pInd) glPopMatrix()
SwapBuffers() WaitTimer(1000/50) Rot#=Rot#+1 wend glDisableClientState(GL_NORMAL_ARRAY) glDisableClientState(GL_COLOR_ARRAY) glDisableClientState(GL_VERTEX_ARRAY)
|
|
|
Post by DJLinux on Nov 17, 2013 18:17:58 GMT -5
New version is out i added glFogCoordf
With glFogCoord you can define for every vertex it's own fog value.
Normaly the fog effect exists only in the depth of the camera frustum, but if you define a fog coord per vertex the fog effect can be exists anywhere. For example on the ground of a terrain ...
DJ
|
|
|
Post by DJLinux on Dec 2, 2013 3:26:51 GMT -5
Hello shadow008 and all others, a new version is out I found and fixed an error in the OpenGL plugin all kinds of INDEX pointer are OK now.
Test it on your box please:
Nice_Shape_BYTE.gb Nice_Shape_SHORT.gb Nice_Shape_INT.gb
Thank you.
Joshy
Note: The OpenGL type for byte short and int must be GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT and GL_UNSIGNED_INT
|
|