OpenGL & GLUTの基本関数の説明

Similar documents
/*p7-1-1*/

untitled

libaux.dvi

#include <stdio.h> 2 #include <stdlib.h> 3 #include <GL/glut.h> 4 Program 1 (OpenGL GameSample001) 5 // 6 static bool KeyUpON = false; // 7 sta

2 2 GLUI 2 GLUI 2.1 GLUI GLUI OpenGL OpenGL glut OpenGL glut C++ Linux, Windows (Visual C++, gcc), Macintosh glut glut GUI glut GUI CG glmultmatrix()

1 1. Program 1 OpenCV (OpenCV Sample001) 1 /* 2 - > - > - >VC++ 3 ( ) 4 C:\opencv\build\include 5 ( ) 6 C:\opencv\build\x86\vc10\lib 7 - > - > - > - >

コンピュータグラフィックスS 演習資料

2 2 OpenGL ( ) OpenGL ( ) glclearcolor(glclampf red, GLclampf green, GLclampf

2 2 2 OpenGL (R,G,B,A) 2.1 OpenGL (x y) width height pixels void glreadpixels(glint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum t

第3章 OpenGL の基礎

謗域・ュ逕ィppt

第7章 レンダリング

2 2 OpenGL OpenGL OpenGL(Open Graphics Library) Silicon Graphics (SGI) 3D OpenGL SGI HP, SUN,

第7章 レンダリング

OpenGL Programming Course OpenGL Programming Course FAQ

3D グラフィックス処理の一般過程 1. 3D グラフィックス処理の一般過程

2 2 OpenGL ( ) 2 OpenGL ( ) glclearcolor(glclampf red, GLclampf green, GLclampf blu

2 3 OpenGL 2 OpenGL OpenGL(Open Graphics Library) Silicon Graphics (SGI) 3D OpenGL SGI HP, SUN, IBM UNIX Linux, FreeBSD PC UNIX Windows, Mac OS API PD

第3章 OpenGL の基礎

コンピュータグラフィックス特論Ⅱ

NB

Fair Curve and Surface Design System Using Tangent Control

コンピュータグラフィックス特論Ⅱ

manual.dvi

2 2 2 OpenGL (R,G,B,A) 2.1 OpenGL (x y) width height pixels void glreadpixels(glint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum t

( ) 1 1: 1 #include <s t d i o. h> 2 #include <GL/ g l u t. h> 3 #include <math. h> 4 #include <s t d l i b. h> 5 #include <time. h>

double rx[natom], ry[natom], rz[natom]; 原子の座標 速度 力 ポテンシャルエ double vx[natom], vy[natom], vz[natom]; ネルギーを受ける配列を準備 double fx[natom], fy[natom], fz[natom

謗域・ュ逕ィppt

謗域・ュ逕ィppt

DrawArrays DrawElements References Kageyama (Kobe Univ.) Visualization / 34

2 : 2008/12/ /01/ G :

演算増幅器

Microsoft PowerPoint - info_eng3_05ppt.pptx

演算増幅器

Kageyama (Kobe Univ.) / 36

TA TA TA abcdefgh abcdefgh C PC Wii bluetooth 2.2 Bluetooth USB Princeton PTM-UBT3S 1 1

コンピュータグラフィックスS 演習資料

Tekutama AR ~ 拡張現実感によるオーバーレイ表示と動作 ~ 情報物理研究室 渡部 修平 1

2 2 2 OpenGL Linux Linux Video for Linux(Video4Linux, v4l ) API Video4Linux USB IEEE1394 API Linux Video for Linux 2(Video4Linux2, v4l2 ) OpenCV API U

コンピュータグラフィックス特論Ⅱ

コンピュータグラフィックス特論Ⅱ

JAPLAシンポジウム資料 2009/12/5

コンピューターグラフィックスS

/* drawing function */ function_graph();// drawing graph glflush(); int main(int argc, char **argv ) glutinit( &argc, argv ); glutinitdisplaymode( GLU

JAPLA研究会資料 2010/4/24

19_OpenGLES.key

Microsoft Word - mediaJikkenCG_no2_2007.doc

PowerPoint Presentation

免許法認定公開講座: コンピュータグラフィックス

adv99_4.PDF

1 3 2 OpenGL 4 3 OpenGL 5 4 OpenGL 6 OpenGl : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 6 : : : : : : : : : : : : : : : : : : : : :

Microsoft Word - mediaJikkenCG_no2_2012.doc

Microsoft Word - ggbook.docx

10 B 3. ( ) (3)

準備 計算結果を可視化するために OpenGL を 利用する. 2

コンピューターグラフィックスS

JAPLA研究会資料 /6/15

$ ls -l $ ls -l -a $ ls -la $ ls -F $ ls <dirname> <dirname> $ cd <dirname> <dirname> $ cd $ pwd $ cat <filename> <filename> $ less <filename> <filena

3. OpenGL を利用するための準備作業 1) Tao Framework をダウンロードしてインストールする. Download から taoframework setup.exe をダウン

JAPLA研究会資料 2012/8/2

Microsoft Word - opengl講義資料2013.doc

Microsoft Word - opengl講義資料ha.doc

JAPLA研究会資料 2017/5/20

沼津工業高等専門学校

複雑系科学演習1 コンピュータグラフィックス

イントロダクション

j x j j j + 1 l j l j = x j+1 x j, n x n x 1 = n 1 l j j=1 H j j + 1 l j l j E

JAPLA研究会資料 2013/5/25

PowerPoint プレゼンテーション

Microsoft PowerPoint - 04.pptx


test_cylpyd


Kageyama (Kobe Univ.) Visualization / 32

human_sample.cpp 1 /** 2 *** キャラクタアニメーションのための人体モデルの表現 基本処理ライブラリ サンプルプログラム 3 *** Copyright (c) 2015-, Masaki OSHITA ( 4 *** Released

ゲームグラフィックス特論

JAPLA研究会資料 2010/1/23

Kageyama (Kobe Univ.) / 41

コンピュータグラフィクス論

コンピューターグラフィックスS

B.1 WebGL APIリファレンス この付録は WebGL JavaScript APIのすべての関数 その引数 戻り値を簡単にし API の概要を示す WebGLとOpenGL ES 2 APIの詳細は webgl/specs/

PowerPoint プレゼンテーション

イントロダクション

Presentation

WebGL OpenGL GLSL Kageyama (Kobe Univ.) Visualization / 57

コンピューターグラフィックスS

コンピュータグラフィックス特論Ⅱ

コンピュータグラフィクス論

C B

OpenGL GLSL References Kageyama (Kobe Univ.) Visualization / 58

1 level Level swtich ButtonPress ButtonRelease Expose Level

(300, 150) 120 getchar() HgBox(x, y, w, h) (x, y), w, h #include <stdio.h> #include <handy.h> int main(void) { int i; double w, h; } HgO

$ pwd /home1/t0/t0903 / / /home1/t0/t0903 / / /home1/t0/t0903 / /... ~ $ ls $ ls -a

1 OpenGL OpenGL OpenGL OpenGL

_openglcl


joho07-1.ppt

Graphics Performance Tuning () Z 2

(4) モデルの消去 mqodeletemodel( model ); (5) 終了処理 ( プログラム終了時にやってください ) mqocleanup(); 3. 使い方 (2) 連番ファイルを読み込んで表示する場合 (1) 初期化 (ARToolKit の場合,argInit() の後に使用 )


Transcription:

コンピュータグラフィックス S 演習資料 OpenGL & GLUT の基本関数の説明 1. OpenGL & GLUT 2. GLUT 2.1. GLUT void glutinit( int argc, char ** argv ); glut void glutinitdysplaymode( unsigned int mode ); mode void glutinitwindowsize( int width, int height ); GLUT void glutwindowposition( int x, int y ); GLUT int glutcreatewindow ( char * title ); GLUT title ID ID 1

void glutmainloop(); GLUT 2.2. void glutdisyplayfunc( void (*func)( void ) ); void glutreshapefunc( void (*func)( int width, int height ) ); void (*func)( int width, int height ); void glutidlefunc( void (*func)( void ) ); void glutmousefunc( void (*func)( int button, int state, int x, int y ) ); void (*func)( int button, int state, int x, int y ); button GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, GLUT_RIGHT_ BUTTON state GLUT_UP, GLUT_DOWN x,y void glutmotionfunc( void (*func)( int x, int y ) ); void glutpassivemotionfunc( void (*func)( int x, int y ) ); glutmotionfunc() glutpassivemotionfunc() 2

void glutkeyboardfunc( void (*func)( unsigned char key, int x, int y ) ); void (*func)( unsigned char key, int x, int y ); key GLUT_KEY_ LEFT, GLUT_KEY_RIGHT, GLUT_KEY_UP, GLUT_KEY_DOWN 2.3. void glutpostredisplay(); GLUT GLUT 2.4. GLUT void glutwirecube( GLdouble size ); void glutsolidcube( GLdouble size ); size glutwirecube() glutsolidcube() void glutwiresphere( GLdouble radius, GLdouble slices, GLdouble stacks ); void glutsolidsphere( GLdouble radius, GLdouble slices, GLdouble stacks ); size slices, stacks slices, stacks void glutwirecone( GLdouble radius, GLdouble height, GLdouble slices, GLdouble stacks ); void glutsolidcone( GLdouble radius, GLdouble height, GLdouble slices, GLdouble stacks ); radius, height slices, stacks glutsolidicosahedron(), glutsolidcone(), glutsolidcone(), glutsolidcone(), 3

glbegin() glend() 2.5. GLUT void glutbitmapcharacter( void * font, int character ); font GLUT_BITMAP_8_BY_13, GLUT_BIT MAP_9_BY_15, GLUT_BITMAP_TIMES_ROMAN_10, GLUT_BITMAP_TI MES_ROMAN_24, GLUT_BITMAP_HELVETICA_10, GLUT_BITMAP_HELVETICA_12, GLUT_BITM AP_HELVETICA_18 font void glrasterpos2i( GLint x, GLint y ); void glrasterpos2f( GLfloat x, GLfloat y ); void glrasterpos3i( GLint x, GLint y, GLint z ); void glrasterpos3i(glfloat x, GLfloat y, GLfloat z ); glvertex () int glutbitmapwidth ( void * font, int character ); glutbitmapcharacter() glutbitmapcharacter() 4

3. OpenGL OpenGL OpenGL gl glu OpenGL OpenGL Utility Library OpenGL glut GLUT OpenGL Utility Toolkit GLUT OpenGL GLUT PC GLUT OpenGL glvertex3f( x, y, z ), glvertex3d( x, y, z ) ( x, y, z ) float double double float 3.1. OpenGL OpenGL void glmatrixmode( GLenum mode ); mode GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE GL_MODELVIEW GL_PRO JECTION GL_TEXTURE 31 82 GL_MODELVIEW, GL_PROJECTION 3.1.1. void glloadidentity( void ); 5

void gltranslatef( GLfloat x, GLfloat y, GLfloat z ); void gltranslated( GLdouble x, GLdouble y, GLdouble z ); (x, y, z) void glrotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ); void glrotated(gldouble angle, GLdouble x, GLdouble y, GLdouble z ); (x, y, z) angle x x y y A = z z 1 1 A i A A 1,, An A A= A A A A 1 2 3 n void glulookat( GLdouble eye_x, GLdouble eye_y, GLdouble eye_z, GLdouble center_x, GLdouble center_y, GLdouble center_z, GLdouble up_x, GLdouble up_y, GLdouble up_z ); (eye_x, eye_y, eye_z) ( center_x, center_y, center_z ) ( up_x, up_y, up_z ) void glloadmatrixf( const GLfloat * m ); void glloadmatrixd( const GLdouble * m ); 16 m 16 m GLdouble m[4][4]; m[i][j] j 6

i i j void glmultmatrixf( const GLfloat * m ); void glmultmatrixd( const GLdouble * m ); 16 m glloadmatrixf(),glloadmatrixd() OpenGL glpushmatrix() glpopmatrix() void glpushmatrix ( void ); void glpopmatrix ( void ); glpushmatrix() glpopmatrix() glpopmatrix() glpushmatrix() glpopmatrix() glpushmatrix() 3.1.2. void glfrustum( GLdouble left, GLdouble right, GLdouble bottm, GLdouble top, GLdouble near, GLdouble far ); glfrustum() near 1 glfrustum() 1 glperspective() 7

glfrustum() gluperspective() void gluperspective( GLdouble fovy, GLdouble aspect, GLdouble near, GLdouble far ); glviewport() void glviewport( GLint x, GLint y, GLsizei width, GLsizei height ); reshape() glviewport() gluperspective() 45 glfrustum() gluperspective () glloadidentity() 1 glortho() void glortho( GLdouble left, GLdouble right, GLdouble bottm, GLdouble top, GLdouble near, GLdouble far ); 8

3.2. 3.2.1. void glclear( GLbitfield mask ); GL_COLOR_BUFF ER_BIT, GL_DEPTH_BUFFER_BIT, GL_ACCUM_BUFFER_BIT, GL_STENCIL_BUFFER_BIT GL_COLOR_BUFFER GL_DEPTH_BUFFER void glclearcolor( CLclampf red, GLclampf green, GLclampf blue, GLclamp alpha ); red, green, blue alpha 1.0 0 1 [0,1] 3.2.2. glbegin() glend() void glbegin( GLenum type ); type type GL_POINTS GL_LINES GL_TRIANGLES GL_POLYGON void glend(); GL_POINTS, GL_LINES, GL_TRIANGLES glbegin() glend() GL_TRIANGLES 3n n GL_POLYGON glbegin() glend() glbegin() glend() 9

void glcolor3f( GLfloat r, GLfloat g, GLfloat b ); void glcolor3d( GLdouble r, GLdouble g, GLdouble b ); ( r, g, b ) void glnormal3f( GLfloat nx, GLfloat ny, GLfloat zn ); void glnormal3d( GLdouble nx, GLdouble ny, GLdouble zn ); ( nx, ny, zn ) void glvertex3f( GLfloat x, GLfloat y, GLfloat z ); void glvertex3d( GLdouble x, GLdouble y, GLdouble z ); (x, y, z) 3f 3d float double glvertex2f(), glvertex4f() 3.3. OpenGL void glenable( GLenum capability ); capability GL_LIGHTING, GL_COLOR_MATERIAL, GL_DEPTH_TEST, GL_CULL_FACE 40 void gldisable( GLenum capability ); GL_LIGHTING, GL_COLOR_MA TERIAL, GL_DEPTH_TEST, GL_CULL_FACE 10

void glcullface( GLenum mode ); mode GL_FRONT, GL_BACK, GL_FRONT_AND_BACK 3.4. OpenGL void gllightf( GLenum light_no, GLenum pname, GLfloat param ); void gllighti( GLenum light_no, GLenum pname, GLint param ); void gllightfv( GLenum light_no, GLenum pname, GLfloat * param ); void gllightiv( GLenum light_no, GLenum pname, Glint * param ); light_no GL_LIGHT0, GL_LIGHT1,, GL_LIGHT7 pname GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_ POSITION, GL_SPOT_DIRECTION, GL_SPOT_DIRECTION, GL_SPOT_EXPONENT, GL_SPOT_C UTOFF, GL_CONSTANT_ATTENUATION, GL_LINEAR_ATTENUATION, GL_QUADRATIC_ATTENU ATION param GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR GL_POSITION x,y,z,w w 1.0 x,y,z w 0.0 x,y,z GL_SPOT_DIRECTION, GL_SPOT_EXPONENT, GL_SPOT_CUTOFF GL_CONSTANT_ATTENUATION, GL_LINEAR_ATTENUATION, GL_QUADRATIC_ATTENUATION RGB M { ln } { sn } s pecular_factor Color = L M + max, 0 L M + max, 0 L M ambient ambient diffuse diffuse specular specular n l s l L ambient, L diffuse, L specular M ambient, M diffuse, M specular, M specular_factor 11

Mambient, Mdiffuse glcolor3f() M specular, M specular_factor (1.0,1.0,1.0), 1.0 glmaterial() glenable() GL_LIGHTING GL_LIGHT0, GL_LIGHT1, gldisable() OpenGL 3.5. OpenGL glbegin() glend() glvertex() glvertex() void glvertexpointer( Glint size, GLenum type, GLsizei stride, const GLvoid * pointer ); size type GL_FLOAT, GL_DOUBLE, GL_INT stride pointer glvertexpointer() void glnormalpointer( GLenum type, GLsizei stride, const GLvoid * pointer ); void glcolor( Glint size, GLenum type, GLsizei stride, const GLvoid * pointer ); void gltexcoordpointer( Glint size, GLenum type, GLsizei stride, const GLvoid * pointer ); glvertexpointer() glnormalpointer() size void glenableclientstate( GLenum array_type ); void gldisableclientstate( GLenum array_type ); 12

or array_type GL_VERTEX_ARRAY, GL_NORMAL_ ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY void gldrawarrays( GLenum mode, GLint first, GLsizei count ); mode GL_POINTS GL_LINES GL_TRIANGLES GL_POLYGON glbegin() first, count void gldrawelements( GLenum mode, GLint count, GLenum type, void * indices ); mode gldrawarrays(), glbegin() count type GL_UNSIGNED_INT, GL_UNSIGNED_SHORT, GL_UNSIGNED_ BYTE indices glarrayelement( Glint no ); 3.6. glteximage2d() void glteximage2d( GLenum target, GLint level, GLenum int_format, GLsizei width, GLsizei height, GLsizei border, GLenum format, GLenum type, const GLvoid * pixels ); target GL_TEXTURE_2D level 0 13

int_format format width height border 0 format pixels RGB GL_RGB RGB GL_RGBA type pixels RGB 3 =24 GL_UNSIGNED_BYTE pixels format type OpenGL BMP, GIF, JPEG 24 BMP gltexparameteri() void gltexparameteri( GLenum target, GLenum pname, GLint param ); target pname param target param target GL_TEXTURE_MAG_FILTER GL_TEXTURE_MIN_FILTER pname GL_NEAREST GL_LINEAR target GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T pname GL_REPEATE 1 GL_CLAMP glenable( GL_TEXTURE_2D ) gldisable() void gltexenv( GLenum target, GLenum pname ); void gltexenvf( GLenum target, GLenum pname, GLfloat param ); void gltexenvfv( GLenum target, GLenum pname, GLfloat * param ); target GL_TEXTURE_ENV pname GL_DECAL, GL_REPLACE, GL_MODULATE, GL_BLEND GL_REPLACE GL_DECAL GL_REPLACE 14

GL_MODULATE GL_BLEND GL_MODULATE GL_BLEND void gltexcoord2f( GLfloat u, GLfloat v ); void gltexcoord2d( GLdouble u, GLdouble v ); (u, v) 0.0< u <1.0, 0.0< v <1.0 (u, v) glteximage2d () glbindtexture() glbindtexture() glbindtexture() 15