| 914 | |
| 915 | == vaja130 == |
| 916 | |
| 917 | Izrišite trikotnik s prelivanjem osnovnih barv v vozliščih. Za osnovo naj vam bo naslednji fortranski program: |
| 918 | |
| 919 | {{{ |
| 920 | #!f |
| 921 | subroutine display |
| 922 | implicit none |
| 923 | include ’GL/fgl.h’ |
| 924 | call fglClear(GL_COLOR_BUFFER_BIT) |
| 925 | call fglBegin(GL_TRIANGLES) |
| 926 | call fglColor3f(1.0, 0.0, 0.0) |
| 927 | call fglVertex2f(-1.0, -1.0) |
| 928 | call fglColor3f(0.0, 1.0, 0.0) |
| 929 | call fglVertex2f(0.0, 1.0) |
| 930 | call fglColor3f(0.0, 0.0, 1.0) |
| 931 | call fglVertex2f(1.0, 0.0) |
| 932 | call fglEnd |
| 933 | call fglFlush |
| 934 | end |
| 935 | }}} |
| 936 | |
| 937 | |
| 938 | == vaja131 == |
| 939 | Izrišite kocko v prostoru tako, da uporabite podprogram, ki izrisuje kvadrate različnih barv |
| 940 | s funkcijo |
| 941 | {{{ |
| 942 | #!c |
| 943 | void glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); |
| 944 | }}} |
| 945 | Funkcija glRectf riše v ravnini z=0. Z uporabo matričnih transformacij pa lahko rišemo |
| 946 | v poljubni ravini. |
| 947 | Za osnovo naj vam bo naslednji fortarnski program: |
| 948 | {{{ |
| 949 | #!f |
| 950 | subroutine kvadrat(i) |
| 951 | real r(6), g(6), b(6) |
| 952 | data r /1,0,0,1,1,1/, g /0,1,0,1,0,0/ |
| 953 | data b /0,0,1,0,1,1/ |
| 954 | call fglPushMatrix |
| 955 | call fglColor3f(r(i), g(i), b(i)) |
| 956 | call fglTranslatef(0.0, 0.0, 1.0) |
| 957 | call fglRectf(-1.0, -1.0, 1.0, 1.0) |
| 958 | call fglPopMatrix |
| 959 | end |
| 960 | subroutine display |
| 961 | implicit none |
| 962 | include ’GL/fgl.h’ |
| 963 | call fglClear(GL_COLOR_BUFFER_BIT+GL_DEPTH_BUFFER_BIT) |
| 964 | call fglPushMatrix |
| 965 | call fglRotatef(30.0, 1.0, 0.0, 0.0) |
| 966 | call fglRotatef(30.0, 0.0, 1.0, 0.0) |
| 967 | call fglScalef(0.5, 0.5, 0.5) |
| 968 | call kvadrat(1) |
| 969 | call fglRotatef(90.0, 0.0, 1.0, 0.0) |
| 970 | call kvadrat(2) |
| 971 | call fglRotatef(90.0, 0.0, 1.0, 0.0) |
| 972 | call kvadrat(3) |
| 973 | call fglRotatef(90.0, 0.0, 1.0, 0.0) |
| 974 | call kvadrat(4) |
| 975 | call fglRotatef(90.0, 1.0, 0.0, 0.0) |
| 976 | call kvadrat(5) |
| 977 | call fglRotatef(180.0, 1.0, 0.0, 0.0) |
| 978 | call kvadrat(6) |
| 979 | call fglPopMatrix |
| 980 | call fglFlush |
| 981 | end |
| 982 | }}} |
| 983 | |
| 984 | Pri izbiri okna morate vklopiti globinski pomnilnik z |
| 985 | {{{ |
| 986 | #!c |
| 987 | glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGB); |
| 988 | glEnable(GL DEPTH TEST); |
| 989 | }}} |
| 990 | |
| 991 | |
| 992 | == vaja132 == |
| 993 | Tako kot v nalogi 130 izrišite prelivajoč se trikotnik s tem da prijavite še |
| 994 | naslednjo funkcijo pri izrisu okna velikosti 500x300: |
| 995 | {{{ |
| 996 | #!c |
| 997 | void reshape (intw, inth) { |
| 998 | glViewport(0, 0, w, h); |
| 999 | glMatrixMode(GL_PROJECTION); |
| 1000 | glLoadIdentity(); |
| 1001 | gluOrtho2D (0.0, w, 0.0, h); |
| 1002 | } |
| 1003 | }}} |
| 1004 | |
| 1005 | |
| 1006 | == vaja133 == |
| 1007 | Izrišite naslednji mnogokotnik v oknu velikosti 300x300 tako, da bo z leve in desne |
| 1008 | strani okoli 20% praznega prostora. Če želite ga lahko tudi pobarvate. |
| 1009 | {{{ |
| 1010 | #!c |
| 1011 | glBegin(GL_POLYGON); |
| 1012 | glVertex2f(0.0, 0.0); |
| 1013 | glVertex2f(0.0, 3.0); |
| 1014 | glVertex2f(4.0, 3.0); |
| 1015 | glVertex2f(6.0, 1.5); |
| 1016 | glVertex2f(4.0, 0.0); |
| 1017 | glEnd(); |
| 1018 | }}} |
| 1019 | |
| 1020 | == vaja134 == |
| 1021 | |
| 1022 | Kocko iz vaje 124 rišite z gladkimi črtami debeline 1.5, za kar uporabite naslednja |
| 1023 | ukaza v glavnem programu: |
| 1024 | {{{ |
| 1025 | #!c |
| 1026 | glEnable(GL_LINE_SMOOTH); |
| 1027 | glLineWidth(1.5); |
| 1028 | }}} |
| 1029 | |