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

演算増幅器

10 B 3. ( ) (3)

演算増幅器

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

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,

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

OpenGL Programming Course OpenGL Programming Course FAQ

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

沼津工業高等専門学校

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

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

2 : 2008/12/ /01/ G :

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

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

#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

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

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

Kageyama (Kobe Univ.) / 36

第7章 レンダリング

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

第7章 レンダリング

謗域・ュ逕ィppt

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

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

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

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

/*p7-1-1*/

C B

OpenGL & GLUTの基本関数の説明

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

Graphics Performance Tuning () Z 2

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

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

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

<4D F736F F D B B83578B6594BB2D834A836F815B82D082C88C60202E646F63>

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

PowerPoint Presentation

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

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

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

XMPによる並列化実装2

( CUDA CUDA CUDA CUDA ( NVIDIA CUDA I

WinHPC ppt


ex01.dvi

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

para02-2.dvi

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

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


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


Microsoft Word - mediaJikkenCG_no2_2007.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

r07.dvi

1.ppt

ohp07.dvi

program.dvi

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

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

Effective Android NDK Advanced Core Engineer

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

2 1 Web Java Android Java 1.2 6) Java Java 7) 6) Java Java (Swing, JavaFX) (JDBC) 7) OS 1.3 Java Java

XcalableMP入門

joho07-1.ppt

MPI usage

P06.ppt

新版明解C言語 実践編

Microsoft Word - mediaJikkenCG_no2_2012.doc

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

PowerPoint Presentation

SystemC言語概論

5. p.1/37

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

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

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

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

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

C C UNIX C ( ) 4 1 HTML 1

3.1 stdio.h iostream List.2 using namespace std C printf ( ) %d %f %s %d C++ cout cout List.2 Hello World! cout << float a = 1.2f; int b = 3; cout <<

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

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

/* sansu1.c */ #include <stdio.h> main() { int a, b, c; /* a, b, c */ a = 200; b = 1300; /* a 200 */ /* b 200 */ c = a + b; /* a b c */ }

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

卒 業 研 究 報 告.PDF

1 OpenGL OpenGL OpenGL OpenGL

1 1.1 (VR) [1] * * /3/5 1

1 C STL(1) C C C libc C C C++ STL(Standard Template Library ) libc libc C++ C STL libc STL iostream Algorithm libc STL string vector l

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

±é½¬£²¡§£Í£Ð£É½éÊâ

& & a a * * ptr p int a ; int *a ; int a ; int a int *a

Transcription:

3 OpenGL April 20, 2012 1 / 23

31 ( ) OpenGL OpenGL 2 / 23

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

33 OpenGL GLUT (OpenGL Utility Toolkit) OpenGL GLUT GUI Toolkit 4 / 23

34 program3 1c #include <GL/gluth> 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; } 5 / 23

34 (cnt) glutinit() #include <GL/gluth> void glutinit(int *argc, char **argv); GLUT main glutcreatewindow() #include <GL/gluth> int glutcreatewindow(char *name); name 6 / 23

34 (cnt) glutdisplayfunc() #include <GL/gluth> void glutdisplayfunc(void (*func)(void)); func glutmainloop() #include <GL/gluth> void glutmainloop(void); 7 / 23

35 program3 2c int main(int argc, char *argv[]) { /* Window */ glutinitdisplaymode(glut_rgba); glutinitwindowsize(250, 250); glutinitwindowposition(100, 200); glutcreatewindow(argv[0]); /* */ glclearcolor(00, 00, 00, 00); } /* */ glutdisplayfunc(display); 8 / 23

35 (cnt) static void display(void) { glclear(gl_color_buffer_bit); glcolor3f(10, 10, 10); glbegin(gl_polygon); glvertex2f(05, 05); glvertex2f(-05, 05); glvertex2f(-05, -05); glvertex2f(05, -05); glend(); glflush(); } 9 / 23

35 (cnt) glutinitdisplaymode() void glutinitdisplaymode(unsigned int mode); mode GLUT RGBA RGBA (,,, ) GLUT INDEX glutinitwindowsize() void glutinitwindowsize(int w, int h); ( 1, 1) 2 10 / 23

35 (cnt) 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) 11 / 23

35 (cnt) glclear() void glclear(glbitfield mask); mask ( ) GL COLOR BUFFER BIT GL DEPTH BUFFER BIT, glflush() void glflush(void); OpenGL 12 / 23

35 (cnt) glbegin() glend void glbegin(glnum mode); void glend(void); mode 13 / 23

35 (cnt) mode GL POINTS: GL LINES: GL LINE STRIP: GL LINE LOOP: v0 v0 v0 v2 v2 v2 v3 v3 v3 v1 v1 v1 GL LINES GL LINE STRIP GL LINE LOOP 14 / 23

35 (cnt) GL TRIANGLES / GL QUADS: 3 4 GL TRIANGLE STRIP / GL QUAD STRIP: GL TRIANGLE FAN: GL POLYGON: v0 v1 v3 v2 v5 v4 GL TRIANGLES v4 v3 v0 v2 v1 v4 v3 GL TRIANGLE STRIP v4 v3 v0 v2 v0 v2 v1 GL TRIANGLE FAN v1 GL POLYGON 15 / 23

35 (cnt) 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( ) 16 / 23

36 program3 3c void display(void) { for(i=0; i<star_num; i++){ /* */ x = 20*random_num()-10; y = 20*random_num()-10; brightness = random_num(); size = STAR_SIZE*random_num(); /* 00 STAR_SIZE */ } /* */ draw_point(x, y, brightness, size); } glflush(); 17 / 23

36 (cnt) rand int rand(void); 0 RAND MAX srand() rand() RAND MAX int 10 0 18 / 23

36 (cnt) (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); 19 / 23

36 (cnt) 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); 20 / 23

37 program3 4c length /= 20; /* */ if(length > 001){ 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); } 21 / 23

38 OpenGL OpenGL 1 OpenGL 2 3 API 2 OpenGL GLUT OpenGL GLUT 3 2 22 / 23

[1] Mark J Kilgard The OpenGL Utility Toolkit (GLUT) programming interface API version 3( ) http://opengljp/glut/indexhtml [2], OpenGL 3 CG, 2003 [3] GLUT OpenGL http://wwwwakayama-uacjp/ tokoi/opengl/libgluthtml [4] OpenGL http://wwwopenglorg/ 23 / 23