第3章 OpenGL の基礎

Similar documents
第3章 OpenGL の基礎

untitled

libaux.dvi

( ) 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>

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 - > - > - > - >

演算増幅器

10 B 3. ( ) (3)

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

演算増幅器

#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 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

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

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

OpenGL Programming Course OpenGL Programming Course FAQ

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

沼津工業高等専門学校

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

2 : 2008/12/ /01/ G :

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

/*p7-1-1*/

C B

謗域・ュ逕ィppt

2 T ax 2 + 2bxy + cy 2 + dx + ey + f = 0 a + b + c > 0 a, b, c A xy ( ) ( ) ( ) ( ) u = u 0 + a cos θ, v = v 0 + b sin θ 0 θ 2π u = u 0 ± a

1) OOP 2) ( ) 3.2) printf Number3-2.cpp #include <stdio.h> class Number Number(); // ~Number(); // void setnumber(float n); float getnumber();

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()

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

第7章 レンダリング

OpenGL & GLUTの基本関数の説明

Kageyama (Kobe Univ.) / 36

第7章 レンダリング

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

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

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 level Level swtich ButtonPress ButtonRelease Expose Level

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

Microsoft PowerPoint - info_eng3_05ppt.pptx

Graphics Performance Tuning () Z 2

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

Microsoft PowerPoint - 04.pptx

x h = (b a)/n [x i, x i+1 ] = [a+i h, a+ (i + 1) h] A(x i ) A(x i ) = h 2 {f(x i) + f(x i+1 ) = h {f(a + i h) + f(a + (i + 1) h), (2) 2 a b n A(x i )

double float

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

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡

PowerPoint Presentation

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

WebGL X LR301 Kageyama (Kobe Univ.) Visualization / 45

<4D F736F F D B B83578B6594BB2D834A836F815B82D082C88C60202E646F63>

新版明解C言語 実践編

C言語によるアルゴリズムとデータ構造

II ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 D

イントロダクション

WebGL Safari WebGL WebGL Safari Kageyama (Kobe Univ.) / 5

ィ 07ィコ060909ィコィィィヲ , 0600ィェィ ィー02ィェィコ ィ ツィ 05ィケィェ04ィヲ ィコィョ0809 OpenGL. 00.: ィ ィ

Display 表示の初期化が CAVE 表示の初期化に置き換わり CAVE 用のプログラムに書き換えることが出来る 表 2 1 画面 (Windows LINUX IRIX) 用の OpenGL #include<stdio.h> #include<windows.h> #include<gl/g

XMPによる並列化実装2

Java演習(4) -- 変数と型 --

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1

WebGL References Kageyama (Kobe Univ.) Visualization *4 2 / 54

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裶²ó ¨¡ À©¸æ¹½Â¤¡§·«¤êÊÖ¤· ¨¡

ex01.dvi

r07.dvi

ohp07.dvi

Microsoft Word - C.....u.K...doc

SystemC言語概論

WinHPC ppt

Microsoft Word - mediaJikkenCG_no2_2007.doc


para02-2.dvi

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

slide5.pptx

卒 業 研 究 報 告.PDF

1 OpenGL OpenGL OpenGL OpenGL

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


Java updated

programmingII2019-v01

1.ppt

( CUDA CUDA CUDA CUDA ( NVIDIA CUDA I


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

A/B (2018/10/19) Ver kurino/2018/soft/soft.html A/B

5. p.1/37

C ( ) C ( ) C C C C C 1 Fortran Character*72 name Integer age Real income 3 1 C mandata mandata ( ) name age income mandata ( ) mandat

P06.ppt

program.dvi

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU

新・明解C言語 ポインタ完全攻略

(search: ) [1] ( ) 2 (linear search) (sequential search) 1

XcalableMP入門

解きながら学ぶJava入門編

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

07-二村幸孝・出口大輔.indd

Microsoft Word - mediaJikkenCG_no2_2012.doc

1 CUI CUI CUI 1.1 cout cin redirect.cpp #i n c l u d e <s t r i n g > 3 using namespace std ; 5 6 i n t main ( void ) 7 { 8 s t r i n g s ; 10 c

£Ã¥×¥í¥°¥é¥ß¥ó¥°(2018) - Âè11²ó – ½ÉÂꣲ¤Î²òÀ⡤±é½¬£² –

1 return main() { main main C 1 戻り値の型 関数名 引数 関数ブロックをあらわす中括弧 main() 関数の定義 int main(void){ printf("hello World!!\n"); return 0; 戻り値 1: main() 2.2 C main

ex01.dvi

(Eclipse\202\305\212w\202\324Java2\215\374.pdf)

Effective Android NDK Advanced Core Engineer

untitled

Transcription:

3 OpenGL April 11, 2017 1 / 28

3.1 ( ) OpenGL OpenGL 2 / 28

3.2 OpenGL OpenGL OpenGL (Open Graphics Library) Silicon Graphics, Inc. 2 3 API (Application Program Interface) [4] UNIX OS Windows Macintosh CAD CG 3 / 28

3.3 OpenGL GLUT (OpenGL Utility Toolkit) OpenGL 4 / 28

GLUT GUI Toolkit 5 / 28

3.4 program3 1.c #include <GL/glut.h> static void display(void); static void display(void) { } int main(int argc, char *argv[]) { glutinit(&argc, argv); glutcreatewindow(argv[0]); glutdisplayfunc(display); glutmainloop(); return 0; } 6 / 28

glutinit() #include <GL/glut.h> void glutinit(int *argc, char **argv); GLUT main. glutcreatewindow() #include <GL/glut.h> int glutcreatewindow(char *name);. name 7 / 28

glutdisplayfunc() #include <GL/glut.h> void glutdisplayfunc(void (*func)(void)); func. glutmainloop() #include <GL/glut.h> void glutmainloop(void);. 8 / 28

3.5 program3 2.c int main(int argc, char *argv[]) {... /* Window */ glutinitdisplaymode(glut_rgba); glutinitwindowsize(250, 250); glutinitwindowposition(100, 200); glutcreatewindow(argv[0]); /* */ glclearcolor(0.0, 0.0, 0.0, 0.0); } /* */ glutdisplayfunc(display);... 9 / 28

static void display(void) { glclear(gl_color_buffer_bit); glcolor3f(1.0, 1.0, 1.0); glbegin(gl_polygon); glvertex2f(0.5, 0.5); glvertex2f(-0.5, 0.5); glvertex2f(-0.5, -0.5); glvertex2f(0.5, -0.5); glend(); glflush(); } 10 / 28

glutinitdisplaymode() void glutinitdisplaymode(unsigned int mode); mode GLUT RGBA RGBA (,,, ) GLUT INDEX glutinitwindowsize() void glutinitwindowsize(int w, int h); ( 1, 1) 2 11 / 28

glutinitwindowposition() void glutinitwindowposition(int x, int y); glclearcolor() void glclearcolor(glclampf R, GLclampf G, GLclampf B, GLclampf A); R G B A,,, α GLclampf (float ) 0 1 (0, 0, 0) (1, 1, 1) 12 / 28

glclear() void glclear(glbitfield mask); mask ( ) GL COLOR BUFFER BIT GL DEPTH BUFFER BIT, glflush() void glflush(void); OpenGL 13 / 28

glbegin()... glend void glbegin(glnum mode);... void glend(void); mode 14 / 28

mode GL POINTS: GL LINES: GL LINE STRIP: GL LINE LOOP: v3 v0 v1 v2 v3 v0 v1 GL LINES GL LINE STRIP GL LINE LOOP v2 v3 v0 v1 v2 15 / 28

GL TRIANGLES / GL QUADS: 3 4 GL TRIANGLE STRIP / GL QUAD STRIP: GL TRIANGLE FAN: GL POLYGON: v5 v0 v3 v4 v2 v1 GL TRIANGLES v4 v3 v2 v0 v1 v4 v3 GL TRIANGLE STRIP v4 v3 v0 v2 v0 v2 v1 GL TRIANGLE FAN v1 GL POLYGON 16 / 28

void glvertex2f(glfloat x, GLfloat y) GLfloat (float ) 3, 4 (x,y,z), (x,y,z,w) glvertex3f (), glvertex4f () double glvertex?d(), int glvertex?i() void glvertex??v() void glcolor3f(glfloat r, GLfloat g, GLfloat b) r, g, b,, 0 1 r, g, b, a void glcolor4f( ) double glcolor?d( ), int glcolor?i( ) 17 / 28

3.6 program3 3.c void display(void) {... for(i=0; i<star_num; i++){ /* */ x = 2.0*random_num()-1.0; y = 2.0*random_num()-1.0; brightness = random_num(); size = STAR_SIZE*random_num(); /* 0.0 STAR_SIZE */ } /* */ draw_point(x, y, brightness, size); } glflush(); 18 / 28

rand int rand(void); 0 RAND MAX srand() rand() RAND MAX int 1.0 0 19 / 28

(anti-aliasing) /* */ glblendfunc(gl_src_alpha, GL_ONE_MINUS_SRC_ALPHA); glenable(gl_blend); /* ON */ /* */ glenable(gl_point_smooth); glhint(gl_point_smooth_hint, GL_NICEST); 20 / 28

glenable(gl POINT SMOOTH) glenable(gl LINE SMOOTH) glenable(gl POLYGON SMOOTH) glhint(gl POINT SMOOTH HINT, GL FASTEST); glhint(gl LINE SMOOTH HINT, GL FASTEST); glhint(gl POLYGON SMOOTH HINT, GL FASTEST); glhint(gl POINT SMOOTH HINT, GL NICEST); glhint(gl LINE SMOOTH HINT, GL NICEST); glhint(gl POLYGON SMOOTH HINT, GL NICEST); 21 / 28

3.7 program3 4.c length /= 2.0; /* */ if(length > 0.01){ draw_gasket(x0, y0, length); draw_gasket(mid_point(x0, x1), mid_point(y0, y1), length); draw_gasket(mid_point(x2, x0), mid_point(y2, y0), length); } 22 / 28

3.8 program3 5.c glutmousefunc(mouse); void mouse(int button, int state, int x, int y) { switch (button) { case GLUT_LEFT_BUTTON: printf("the left"); break; case GLUT_MIDDLE_BUTTON: printf("the middle"); break;... 23 / 28

program3 6.c case GLUT_LEFT_BUTTON: point[pointnum][0] = x; point[pointnum][1] = y; if (state == GLUT_UP) { /* */ glcolor3d(0.0, 0.0, 0.0); glbegin(gl_lines); glvertex2iv(point[pointnum - 1]); /* */ glvertex2iv(point[pointnum]); /* */ glend(); glflush(); void resize(int w, int h) 5 24 / 28

3.9.1 ( ) program3 2.c program3 3.c 3.1 25 / 28

3.1: 26 / 28

3.10 OpenGL OpenGL 1 OpenGL 2 3 API 2 OpenGL GLUT OpenGL GLUT 3 2 27 / 28

[1] Mark J. Kilgard. The OpenGL Utility Toolkit (GLUT) programming interface API version 3( ). http://opengl.jp/glut/index.html. [2],. OpenGL 3 CG., 2003. [3]. GLUT OpenGL. http://www.wakayama-u.ac.jp/ tokoi/opengl/libglut.html. [4] OpenGL. http://www.opengl.org/. 28 / 28