Hello
i have modified the QuadRotate.o2bas to become QuadRotate2.o2bas
it is displaying well but i find that the display window size is too big, i need to resize it to
a smaller size of say 300 x 300 pixels
How to do that ?
includepath "$\inc\"
$ FileName "QuadRotate2.exe"
'include "RTL32.inc"
include "RTL64.inc"
$ title "Rotating Quad2"
include "OpenglSceneFrame.inc"
' Note that we must specify exactly these equates
' all in uppercase , otherwise it can results in compilation errors
#define GL_TRIANGLES 0x0004
#define GL_TRIANGLE_FAN 0x0006
#define GL_QUAD_STRIP 0x0008
sub initialize(sys hWnd)
'=======================
end sub
'
sub scene(sys hWnd)
'==================
'
static single s1,s2,s3,s4,ang1
ActiveFrame
' increase this angle for faster rotation between 1 and 10
angi1=1
'
glLoadIdentity
glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
' Greenish Beige background color
glClearColor .91,.94,.82,1
'
'
s1=.2 'x y
s2=-1 'z
s3=0.5 'color
s4=s3*.2 'color
'
glrotatef ang1, 0,0,1
'
' original square -- this work
' glbegin GL_QUADS
' glcolor4f 00, s3, s3, 1 : glvertex3f -s1, -s1, s2
' glcolor4f s3, s3, 00, 1 : glvertex3f s1, -s1, s2
' glcolor4f s4, 0, s3, 1 : glvertex3f s1, s1, s2
' glcolor4f s4, 0, s3, 1 : glvertex3f -s1, s1, s2
' glend
' semi triangle -- this work
' glBegin GL_TRIANGLE_FAN
' glcolor4f 00, s3, s3, 1 : glvertex3f -s1, -s1, s2 '1st triangle
' glcolor4f s3, s3, 00, 1 : glvertex3f s1, -s1, s2
' glcolor4f s4, 0, s3, 1 : glvertex3f -.3,-.1, s2
' glcolor4f s4, 0, s3, 1 : glvertex3f s1, s1 , -s2 '2nd
' glcolor4f 00, s3, s3, 1 : glvertex3f s1, -s1, s2 '3rd
' glcolor4f 00, s3, s3, 1 : glvertex3f s1, s1, -s2 '4th
' glEnd
' Triangle -- this work
' ensure that z = -1. thru' out
' glBegin GL_TRIANGLES
' glColor3f 1.0, 0.0, 0.0 : glVertex3f 0.0, .3,-1.
' glColor3f 0.0, 1.0, 0.0 : glVertex3f 0.2, -0.1,-1.
' glColor3f 0.0, 0.0, 1.0 : glVertex3f -0.2,-0.1,-1.
' glEnd
' Triangle -- this work
' this place triangle off center and if we increase the -ve z
' the object gets smaller and will spin at a distance of 0.8 from the center
' glTranslatef .80, 0.0, -2.0
' glBegin GL_TRIANGLES
' glColor3f 1.0, 0.0, 0.0 : glVertex3f 0.0, .30,-1.0
' glColor3f 0.0, 1.0, 0.0 : glVertex3f 0.26,-0.15,-1.0
' glColor3f 0.0, 0.0, 1.0 : glVertex3f-0.26,-0.15,-1.0
' glEnd
' this work
' Half red square rotated off center
' glTranslatef 2.40,0.0,-10.0
' glBegin(GL_QUADS)
' glColor3f 1.0, 0.0, 1.0
' glVertex3f -1.0,-1.0, 0.0
' glColor3f 1.0, 1.0, 1.0
' glVertex3f 1.0,-1.0, 0.0
' glVertex3f 1.0, 1.0, 0.0
' glColor3f 1.0, 1.0, 1.0
' glVertex3f -1.0, 1.0, 0.0
' glEnd
' rotating off center Cube -- this work
' glTranslatef -2.0, -2.0, -12.0
' glBegin GL_QUADS
' glColor3f 0.0, 1.0, 0.0
' glVertex3f 1.0, 1.0,-1.0
' glVertex3f -1.0, 1.0,-1.0
' glVertex3f -1.0, 1.0, 1.0
' glVertex3f 1.0, 1.0, 1.0
' glColor3f 1.0, 0.5, 0.0
' glVertex3f 1.0,-1.0, 1.0
' glVertex3f -1.0,-1.0, 1.0
' glVertex3f -1.0,-1.0,-1.0
' glVertex3f 1.0,-1.0,-1.0
' glColor3f 1.0, 0.0, 0.0
' glVertex3f 1.0, 1.0, 1.0
' glVertex3f -1.0, 1.0, 1.0
' glVertex3f -1.0,-1.0, 1.0
' glVertex3f 1.0,-1.0, 1.0
'glColor3f 1.0, 1.0, 0.0
' glVertex3f 1.0,-1.0,-1.0
' glVertex3f -1.0,-1.0,-1.0
' glVertex3f -1.0, 1.0,-1.0
' glVertex3f 1.0, 1.0,-1.0
'glColor3f 0.0, 0.0, 1.0
' glVertex3f -1.0, 1.0, 1.0
' glVertex3f -1.0, 1.0,-1.0
' glVertex3f -1.0,-1.0,-1.0
' glVertex3f -1.0,-1.0, 1.0
' glColor3f 1.0, 0.0, 1.0
' glVertex3f 1.0, 1.0,-1.0
' glVertex3f 1.0, 1.0, 1.0
' glVertex3f 1.0,-1.0, 1.0
' glVertex3f 1.0,-1.0,-1.0
' glEnd
' DrawDiamond -- this work very well
' glTranslatef 1.4,0.0,-5.0
' glbegin GL_TRIANGLE_FAN 'top part
' glcolor3ub 255, 0, 0 : glvertex3f 0, 1.414, 0
' glcolor3ub 0, 255, 0 : glvertex3f 1, 0, 1
' glcolor3ub 0, 0, 255 : glvertex3f 1, 0,-1
' glcolor3ub 0, 255, 0 : glvertex3f -1, 0,-1
' glcolor3ub 0, 0, 255 : glvertex3f -1, 0, 1
' glcolor3ub 0, 255, 0 : glvertex3f 1, 0, 1
' glend
' glbegin GL_TRIANGLE_FAN 'bottom part
' glcolor3ub 255, 0, 0 : glvertex3f 0,-1.414, 0
' glcolor3ub 0, 255, 0 : glvertex3f 1, 0, 1
' glcolor3ub 0, 0, 255 : glvertex3f -1, 0, 1
' glcolor3ub 0, 255, 0 : glvertex3f -1, 0,-1
' glcolor3ub 0, 0, 255 : glvertex3f 1, 0,-1
' glcolor3ub 0, 255, 0 : glvertex3f 1, 0, 1
' glend
'draws a 3D cube object -- drawcube works
glTranslatef 1.4,0.0,-5.0
glBegin GL_QUADS
glRotatef ang1, 1.0, 1.0, 1.0 ' Rotate the quad on the X axis
glcolor3ub 255,0,0
glVertex3f 0.5, 0.5, -0.5 ' Top right of the quad (Top)
glVertex3f -0.5, 0.5, -0.5 ' Top left of the quad (Top)
glVertex3f -0.5, 0.5, 0.5 ' Bottom left of the quad (Top)
glVertex3f 0.5, 0.5, 0.5 ' Bottom right of the quad (Top)
glcolor3ub 255,255,0
glVertex3f 0.5, -0.5, 0.5 ' Top right of the quad (Bottom)
glVertex3f -0.5, -0.5, 0.5 ' Top left of the quad (Bottom)
glVertex3f -0.5, -0.5, -0.5 ' Bottom left of the quad (Bottom)
glVertex3f 0.5, -0.5, -0.5 ' Bottom right of the quad (Bottom)
glcolor3ub 255,0,255
glVertex3f 0.5, 0.5, 0.5 ' Top right of the quad (Front)
glVertex3f -0.5, 0.5, 0.5 ' Top left of the quad (Front)
glVertex3f -0.5, -0.5, 0.5 ' Bottom left of the quad (Front)
glVertex3f 0.5, -0.5, 0.5 ' Bottom right of the quad (Front)
glcolor3ub 0,0,255
glVertex3f 0.5, -0.5, -0.5 ' Top right of the quad (Back)
glVertex3f -0.5, -0.5, -0.5 ' Top left of the quad (Back)
glVertex3f -0.5, 0.5, -0.5 ' Bottom left of the quad (Back)
glVertex3f 0.5, 0.5, -0.5 ' Bottom right of the quad (Back)
glcolor3ub 0,255,255
glVertex3f -0.5, 0.5, 0.5 ' Top right of the quad (Left)
glVertex3f -0.5, 0.5, -0.5 ' Top left of the quad (Left)
glVertex3f -0.5, -0.5, -0.5 ' Bottom left of the quad (Left)
glVertex3f -0.5, -0.5, 0.5 ' Bottom right of the quad (Left)
glcolor3ub 255,128,0
glVertex3f 0.5, 0.5, -0.5 ' Top right of the quad (Right)
glVertex3f 0.5, 0.5, 0.5 ' Top left of the quad (Right)
glVertex3f 0.5, -0.5, 0.5 ' Bottom left of the quad (Right)
glVertex3f 0.5, -0.5, -0.5 ' Bottom right of the quad (Right)
glEnd
sleep (2)
glLoadIdentity
glTranslatef 1.5, 0.0, -7.0 ' Move right 1.5 units and into the screen
glRotatef ang1, 1.0, 1.0, 1.0 ' Rotate the quad on the X axis
glBegin GL_QUADS
glColor3f 0.0, 1.0, 0.0 ' Set the color to green
glVertex3f 1.0, 1.0, -1.0 ' Top right of the quad (Top)
glVertex3f -1.0, 1.0, -1.0 ' Top left of the quad (Top)
glVertex3f -1.0, 1.0, 1.0 ' Bottom left of the quad (Top)
glVertex3f 1.0, 1.0, 1.0 ' Bottom right of the quad (Top)
glColor3f 1.0, 0.5, 0.0 ' Set the color to orange
glVertex3f 1.0, -1.0, 1.0 ' Top right of the quad (Bottom)
glVertex3f -1.0, -1.0, 1.0 ' Top left of the quad (Bottom)
glVertex3f -1.0, -1.0, -1.0 ' Bottom left of the quad (Bottom)
glVertex3f 1.0, -1.0, -1.0 ' Bottom right of the quad (Bottom)
glColor3f 1.0, 0.0, 0.0 ' Set the color to red
glVertex3f 1.0, 1.0, 1.0 ' Top right of the quad (Front)
glVertex3f -1.0, 1.0, 1.0 ' Top left of the quad (Front)
glVertex3f -1.0, -1.0, 1.0 ' Bottom left of the quad (Front)
glVertex3f 1.0, -1.0, 1.0 ' Bottom right of the quad (Front)
glColor3f 1.0, 1.0, 0.0 ' Set the color to yellow
glVertex3f 1.0, -1.0, -1.0 ' Top right of the quad (Back)
glVertex3f -1.0, -1.0, -1.0 ' Top left of the quad (Back)
glVertex3f -1.0, 1.0, -1.0 ' Bottom left of the quad (Back)
glVertex3f 1.0, 1.0, -1.0 ' Bottom right of the quad (Back)
glColor3f 0.0, 0.0, 1.0 ' Set the color to blue
glVertex3f -1.0, 1.0, 1.0 ' Top right of the quad (Left)
glVertex3f -1.0, 1.0, -1.0 ' Top left of the quad (Left)
glVertex3f -1.0, -1.0, -1.0 ' Bottom left of the quad (Left)
glVertex3f -1.0, -1.0, 1.0 ' Bottom right of the quad (Left)
glColor3f 1.0, 0.0, 1.0 ' Set the color to violet
glVertex3f 1.0, 1.0, -1.0 ' Top right of the quad (Right)
glVertex3f 1.0, 1.0, 1.0 ' Top left of the quad (Right)
glVertex3f 1.0, -1.0, 1.0 ' Bottom left of the quad (Right)
glVertex3f 1.0, -1.0, -1.0 ' Bottom right of the quad (Right)
glEnd
sleep (2)
' draw the pyramid using triangles
' // Reset the view
glLoadIdentity
glTranslatef -1.5, 0.0, -6.0 ' Move left 1.5 units and into the screen
glRotatef ang1, 0.0, 1.0, 0.0 ' Rotate the triangle on the Y axis
glBegin %GL_TRIANGLES
' Front
glColor3f 1.0, 0.0, 0.0 ' Red
glVertex3f 0.0, 1.0, 0.0 ' Top of triangle (Front)
glColor3f 0.0, 1.0, 0.0 ' Green
glVertex3f -1.0, -1.0, 1.0 ' Left of triangle (Front)
glColor3f 0.0, 0.0, 1.0 ' Blue
glVertex3f 1.0, -1.0, 1.0 ' Right of triangle (Front)
' Right
glColor3f 1.0, 0.0, 0.0 ' Red
glVertex3f 0.0, 1.0, 0.0 ' Top of triangle (Right)
glColor3f 0.0, 0.0, 1.0 ' Blue
glVertex3f 1.0, -1.0, 1.0 ' Left of triangle (Right)
glColor3f 0.0, 1.0, 0.0 ' Green
glVertex3f 1.0, -1.0, -1.0 ' Right of triangle (Right)
' Back
glColor3f 1.0, 0.0, 0.0 ' Red
glVertex3f 0.0, 1.0, 0.0 ' Top of triangle (Back)
glColor3f 0.0, 1.0, 0.0 ' Green
glVertex3f 1.0, -1.0, -1.0 ' Left of triangle (Back)
glColor3f 0.0, 0.0, 1.0 ' Blue
glVertex3f -1.0, -1.0, -1.0 ' Right of triangle (Back)
' Left
glColor3f 1.0, 0.0, 0.0 ' Red
glVertex3f 0.0, 1.0, 0.0 ' Top of triangle (Left)
glColor3f 0.0, 0.0, 1.0 ' Blue
glVertex3f -1.0, -1.0, -1.0 ' Left of triangle (Left)
glColor3f 0.0, 1.0, 0.0 ' Green
glVertex3f -1.0, -1.0, 1.0 ' Right of triangle (Left)
glEnd
'
'UPDATE ROTATION ANGLES
'----------------------
'
ang1+=angi1
if ang1>360 then ang1-=360
'
end sub
sub Release(sys hwnd)
'====================
end sub