- immediate mode
- The easiest way to do drawing in OpenGL is using the Immediate Mode. For this, you use the glBegin() function which takes as one parameter the “mode” or type of object you want to draw.
glBegin(GL_LINE_LOOP);//start drawing a line loop
glVertex3f(-1.0f,0.0f,0.0f);//left of window
glVertex3f(0.0f,-1.0f,0.0f);//bottom of window
glVertex3f(1.0f,0.0f,0.0f);//right of window
glVertex3f(0.0f,1.0f,0.0f);//top of window
glEnd();//end drawing of line loop- display list
- Display list is a group of OpenGL commands that have been stored (compiled) for later execution. Once a display list is created, all vertex and pixel data are evaluated and copied into the display list memory on the server machine. It is only one time process. After the display list has been prepared (compiled), you can reuse it repeatedly without re-evaluating and re-transmitting data over and over again to draw each frame.
// create one display list
GLuint index = glGenLists(1);
// compile the display list, store a triangle in it
glNewList(index, GL_COMPILE);
glBegin(GL_TRIANGLES);
glVertex3fv(v0);
glVertex3fv(v1);
glVertex3fv(v2);
glEnd();
glEndList();
...
// draw the display list
glCallList(index);- vertex array
- This means that your vertices and vertex attributes and indices are in RAM.
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(3, GL_FLOAT, 0, Colors);
glVertexPointer(3, GL_FLOAT, 0, Vertices);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
2013年3月11日 星期一
immediate mode? display list? vertex array?
2013年3月10日 星期日
OpenGL Blend
glBlendFunc — specify pixel arithmetic
- void glBlendFunc(GLenum sfactor, GLenum dfactor);
- void glBlendFunci(GLuint buf, GLenum sfactor, GLenum dfactor);
- buf
- For glBlendFunci, specifies the index of the draw buffer for which to set the blend function.
- sfactor
- Specifies how the red, green, blue, and alpha source blending factors are computed. The initial value is GL_ONE.
- dfactor
- Specifies how the red, green, blue, and alpha destination blending factors are computed. The initial value is GL_ZERO. The following symbolic constants are accepted:
- GL_ZERO, GL_ONE
- GL_SRC_COLOR
- GL_ONE_MINUS_SRC_COLOR
- GL_DST_COLOR
- GL_ONE_MINUS_DST_COLOR
- GL_SRC_ALPHA
- GL_ONE_MINUS_SRC_ALPHA
- GL_DST_ALPHA
- GL_ONE_MINUS_DST_ALPHA
- GL_CONSTANT_COLOR
- GL_ONE_MINUS_CONSTANT_COLOR
- GL_CONSTANT_ALPHA
- GL_ONE_MINUS_CONSTANT_ALPHA
Qt5 + OpenGL
前幾天發現在Qt5裡,所有的fixed function pipeline都不能編譯了。稍微google了一下,才發現,原來Qt5所有precompile的安裝包,都是用ANGLE layer來實作OpenGL ES2,也就是你要寫的是OpenGL ES2,而不是OpenGL。所以一些fixed function pipeline的function,例如glBegin/glEnd都不能用了。
2013年3月8日 星期五
2013年3月7日 星期四
2013年3月3日 星期日
在Qt中,使用系統預設的圖示
QStyle定義了一些系統視窗相關的風格,像是圖示和gui的樣式。
qApp->style()->standardIcon(QStyle::SP_MediaVolumeMuted)
另外,也可以用
QStyleFactory::keys();列出可以建立的style,例如"Windows", "WindowsXP", "WindowsVista", "Fusion"
另外,也可以用
QStyleFactory::keys();列出可以建立的style,例如"Windows", "WindowsXP", "WindowsVista", "Fusion"
QStyleFactory::create(QString style);建立特殊的style,例如"Windows", "WindowsXP", "WindowsVista", "Fusion" 詳細清單
2013年3月2日 星期六
訂閱:
文章 (Atom)