/*
*簡單繪製三角形例項
*/#define glew_static
#include
#include
#include
#include
#pragma comment(linker, "/subsystem:\"windows\" /entry:\"maincrtstartup\"" )
//這行是取消顯示控制台
char sztitle[64]
="opengl view"
;// window dimensions
const gluint width =
800, height =
600;
static
void
error_callback
(int error,
const
char
* description)
static
void
key_callback
(glfwwindow* window,
int key,
int scancode,
int action,
int mods)
//opengl 繪製
static
void
render
(glfwwindow * window)
intmain
(void
)glfwmakecontextcurrent
(window)
;glfwsetkeycallback
(window, key_callback)
; glewexperimental = gl_true;
glewinit()
;glviewport(0
,0, width, height)
;//設定opengl視口 即看到的顯示區域
glmatrixmode
(gl_projection)
;//設定當前操作的是投影矩陣列表
glloadidentity()
;//將投影矩陣清空成單位矩陣
glortho(0
, width, height,0,
-100
,100);
//產生乙個新的投影矩陣並和上面的投影矩陣列表最上面單位矩陣相乘,實際上就是產生乙個投影矩陣並放到投影矩陣列表的最上面
OpenGL 學習筆記3 3 繪製三角形相關
藍寶書 第三章 畫三角形 1 繪製三角形 三個點確定乙個三角形 glbegin gl s glvertex2f 0.0f,0.0f 點a glvertex2f 25.0f,25.0f 點b glvertex2f 50.0f,0.0f 點c glvertex2f 50.0f,0.0f 點d glver...
OpenGL隨筆二 opengl繪製三角形
define glew static 1 include include include vbo繪製兩個共邊的三角形需要六個點 float vertices const char vertexshadersource version 330 core n layout location 0 in v...
OpenGL學習04 直線 三角形繪製
一 畫線 1 在glbegin中使用gl lines繪製圖元時,每兩個頂點會連成一條直線,例如 glbegin gl lines glvertex3f 20.0f,0.0f,0.0f glvertex3f 50.0f,50.0f,0.0f glvertex3f 50.0f,50.0f,0.0f gl...