Форум программистов, компьютерный форум, киберфорум
Pure Basic
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.81/16: Рейтинг темы: голосов - 16, средняя оценка - 4.81
37 / 37 / 1
Регистрация: 07.09.2010
Сообщений: 752
1

Как подключить библиотеку opengl на Windows 7

13.09.2012, 18:46. Показов 3296. Ответов 1
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Вопрос в теме.
0
Лучшие ответы (1)
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
13.09.2012, 18:46
Ответы с готовыми решениями:

Как подключить библиотеку OpenGL
Сабж.

Как подключить библиотеку openGL?
Товарищи помогите начинающему . осваиваю графику на основе openGL компилятор жалуеться на все...

Как подключить библиотеку OpenGL к файлу .cpp
Здравствуйте, только начал работать с OpenGL, хочу сделать одну небольшую 2d игру и мне хочется...

Можно ли использовать OpenGL в C# и если да, то как подключить библиотеку
Можно ли использовать OpenGL в C# ? если да то как подключить библиотеку, а то преподователь сказал...

1
4393 / 2243 / 252
Регистрация: 28.10.2011
Сообщений: 8,574
Записей в блоге: 6
13.09.2012, 19:19 2
Лучший ответ Сообщение было отмечено Le Thaw как решение

Решение

PureBasic
1
XIncludeFile #PB_Compiler_Home+"Examples\Sources - Advanced\OpenGL Cube\OpenGL.pbi"
Пример из дистрибутива.
PureBasic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
XIncludeFile #PB_Compiler_Home+"Examples\Sources - Advanced\OpenGL Cube\OpenGL.pbi"
 
Global RollAxisX.f
Global RollAxisY.f
Global RollAxisZ.f
 
Global RotateSpeedX.f
Global RotateSpeedY.f
Global RotateSpeedZ.f
 
Global ZoomFactor.f
 
Procedure DrawCube(hdc)
  glPushMatrix_()                  ; Save the original Matrix coordinates
  glMatrixMode_(#GL_MODELVIEW)
 
  glTranslatef_(0, 0, ZoomFactor)  ;  move it forward a bit
 
  glRotatef_ (RollAxisX, 1.0, 0, 0) ; rotate around X axis
  glRotatef_ (RollAxisY, 0, 1.0, 0) ; rotate around Y axis
  glRotatef_ (RollAxisZ, 0, 0, 1.0) ; rotate around Z axis
 
  RollAxisX + RotateSpeedX 
  RollAxisY + RotateSpeedY 
  RollAxisZ + RotateSpeedZ 
 
  ; clear framebuffer And depth-buffer
 
  glClear_ (#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
 
  ; draw the faces of a cube
  
  ; draw colored faces
 
  glDisable_(#GL_LIGHTING)
  glBegin_  (#GL_QUADS)
  
  ; Build a face, composed of 4 vertex ! 
  ; glBegin() specify how the vertexes are considered. Here a group of
  ; 4 vertexes (GL_QUADS) form a rectangular surface.
 
  ; Now, the color stuff: It's r,v,b but with float values which
  ; can go from 0.0 To 1.0 (0 is .. zero And 1.0 is full intensity) 
  
  glNormal3f_ (0,0,1.0)
  glColor3f_  (0,0,1.0)
  glVertex3f_ (0.5,0.5,0.5)   
  glColor3f_  (0,1.0,1.0)         
  glVertex3f_ (-0.5,0.5,0.5)
  glColor3f_  (1.0,1.0,1.0)
  glVertex3f_ (-0.5,-0.5,0.5)
  glColor3f_  (0,0,0)
  glVertex3f_ (0.5,-0.5,0.5) 
 
  ; The other face is the same than the previous one 
  ; except the colour which is nice blue To white gradiant
 
  glNormal3f_ (0,0,-1.0)
  glColor3f_  (0,0,1.0)
  glVertex3f_ (-0.5,-0.5,-0.5)
  glColor3f_  (0,0,1.0)
  glVertex3f_ (-0.5,0.5,-0.5)
  glColor3f_  (1.0,1.0,1.0)
  glVertex3f_ (0.5,0.5,-0.5)
  glColor3f_  (1.0,1.0,1.0)
  glVertex3f_ (0.5,-0.5,-0.5)
  
  glEnd_()
  
  ; draw shaded faces
 
  glEnable_(#GL_LIGHTING)
  glEnable_(#GL_LIGHT0)
  glBegin_ (#GL_QUADS)
 
  glNormal3f_ (   0, 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,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_ (1.0,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_ (-1.0,   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)
 
  glEnd_()
 
  glPopMatrix_()
  glFinish_()
 
  SwapBuffers_(hdc)
EndProcedure
 
 
Procedure HandleError (Result, Text$)
  If Result = 0
    MessageRequester("Error", Text$, 0)
    End
  EndIf
EndProcedure
 
 
pfd.PIXELFORMATDESCRIPTOR
 
FlatMode = 0         ; Enable Or disable the 'Flat' rendering
 
WindowWidth  = 600   ; The window & GLViewport dimensions
WindowHeight = 600
 
RotateSpeedX = 5.0   ; The speed of the rotation For the 3 axis
RotateSpeedY = 0
RotateSpeedZ = 5.0
 
ZoomFactor = 1       ; Distance of the camera. Negative value = zoom back
 
hWnd = OpenWindow(0, 10, 10, WindowWidth, WindowHeight, "First OpenGL Test")
 
hdc = GetDC_(hWnd)
 
pfd\nSize        = SizeOf(PIXELFORMATDESCRIPTOR)
pfd\nVersion     = 1
pfd\dwFlags      = #PFD_SUPPORT_OPENGL | #PFD_DOUBLEBUFFER | #PFD_DRAW_TO_WINDOW
pfd\dwLayerMask  = #PFD_MAIN_PLANE
pfd\iPixelType   = #PFD_TYPE_RGBA
pfd\cColorBits   = 16
pfd\cDepthBits   = 16 
 
pixformat = ChoosePixelFormat_(hdc, pfd)
 
HandleError( SetPixelFormat_(hdc, pixformat, pfd), "SetPixelFormat()")
 
hrc = wglCreateContext_(hdc)
 
HandleError( wglMakeCurrent_(hdc,hrc), "vglMakeCurrent()")
 
glMatrixMode_(#GL_PROJECTION)
 
gluPerspective_(30.0, WindowWidth/WindowHeight, 1.0, 10.0) 
 
; position viewer
glMatrixMode_(#GL_MODELVIEW)
 
glTranslatef_(0, 0, -5.0)
 
If (FlatMode)
  glShadeModel_(#GL_FLAT) 
Else
  glShadeModel_(#GL_SMOOTH) 
EndIf
 
glEnable_(#GL_DEPTH_TEST)   ; Enabled, it slowdown a lot the rendering. It's to be sure than the
                            ; rendered objects are inside the z-buffer.
 
glEnable_(#GL_CULL_FACE)    ; This will enhance the rendering speed as all the back face will be
                            ; ignored. This works only with CLOSED objects like a cube... Singles
                            ; planes surfaces will be visibles only on one side. 
 
glViewport_(0, 0, WindowWidth-30, WindowHeight-30)
 
Repeat
 
  Repeat 
    Event = WindowEvent()
    
    Select Event
      Case #PB_Event_CloseWindow
        Quit = 1
    EndSelect
  
  Until Event = 0
  
  DrawCube(hdc)
  Delay(20)
Until Quit = 1
2
13.09.2012, 19:19
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
13.09.2012, 19:19
Помогаю со студенческими работами здесь

Как подключить библиотеку GTK+ на Windows
Добрый день. Сегодня весь день трачу, чтобы подключить GTK+. Подскажите откуда скачать файлы. ОС:...

Как подключить библиотеку в пайтоне на WINDOWS 7?
import urllib.request r = urllib.request.urlopen('http://yandex.ru ') text =...

Подключить графическую библиотеку OpenGL в VS 2013. Ошибки=(
При подключении в проекте библиотеки <gl/GLU.h> компилятор выводить множество ошибок.... Как решить...

Не могу подключить библиотеку opengl - glaux.dll
Доброго дня! Не могу подключить библиотеку glaux. lib закинул куда надо, h-ник тоже, но все равно...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
2
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru