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

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

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

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

第7章 レンダリング

第7章 レンダリング

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

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

/*p7-1-1*/

#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

libaux.dvi

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

第3章 OpenGL の基礎

OpenGL & GLUTの基本関数の説明

第3章 OpenGL の基礎

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

演算増幅器

untitled

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

PowerPoint Presentation

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

演算増幅器

謗域・ュ逕ィppt

2 : 2008/12/ /01/ G :

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

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

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

OpenGL Programming Course OpenGL Programming Course FAQ

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,

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

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

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

19_OpenGLES.key

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

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

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

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

1 level Level swtich ButtonPress ButtonRelease Expose Level

_openglcl

謗域・ュ逕ィppt

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

C B

manual.dvi

謗域・ュ逕ィppt

double float

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

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

Microsoft Word - opengl講義資料ha.doc

Kageyama (Kobe Univ.) / 36

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

Kageyama (Kobe Univ.) Visualization / 32

Condition DAQ condition condition 2 3 XML key value

Microsoft Word - mediaJikkenCG_no2_2012.doc

Microsoft Word - mediaJikkenCG_no2_2007.doc

Microsoft Word - opengl講義資料2013.doc

5. p.1/37

comment.dvi

JAPLA研究会資料 2010/4/24

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

Fair Curve and Surface Design System Using Tangent Control

C

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

Microsoft Word - ggbook.docx

P6dark P6dark µ-pic 2 µ-pic 2 3 µ-pic µ-pic µ-pic 3 µ-pic (10cm ) MPGC N3035-KA195 No. SN ASD (16ns[C]) (16nsC

adv99_4.PDF

tuat1.dvi

Kageyama (Kobe Univ.) / 41

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

CM-3G 周辺モジュール拡張技術文書 MS5607センサ(温度、気圧)

Graphics Performance Tuning () Z 2

プログラミング及び演習 第1回 講義概容・実行制御

273? C

untitled

Informatics 2014

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 )

slide5.pptx

沼津工業高等専門学校

ex01.dvi

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

ex01.dvi

イントロダクション

_TJ…X…g†[…fi_0216

TA tani/class/mech enshu/ X Window System GUI(Graphical User Interface) GUI (event driven) 2 Gtk

XMPによる並列化実装2

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

プログラミング及び演習 第1回 講義概容・実行制御

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

Microsoft PowerPoint - 04.pptx

r08.dvi

Informatics 2010.key

I 2 tutimura/ I 2 p.1/??

/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v

ohp08.dvi

TEOライブラリによる画像処理プログラミング入門

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

II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y

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

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

第5回お試しアカウント付き並列プログラミング講習会

Transcription:

1 22 (2) OpenGL+GUI(GLUI) 3DCG TA 2010 10 18 1 OpenGL OpenGL GUI GLUI 1.1 http://www.cyber.t.u-tokyo.ac.jp/~kuni/enshu2010/ 1.2 TA 1.3 2010/12/6( ) USB

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 type, GLvoid *pixels); format (RGBA ) type GL COLOR INDEX GL RGB GL RED GL GREEN GL BLUE GL ALPHA GL LUMINANCE GL LUMINANCE ALPHA GL STENCIL INDEX GL DEPTH COMPONENT 1 glreadpixels(),gldrawpixels() glrasterpos*() width height

2.1 OpenGL 3 GL UNSIGNED BYTE GL BYTE GL UNSIGNED SHORT GL SHORT GL UNSIGNED INT GL INT GL UNSIGNED BYTE 8 8 16 16 32 32 2 glreadpixels(),gldrawpixels() void gldrawpixels(glsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); void glrasterpos{234{sifd(type x, TYPE y, TYPE z, TYPE w); void glrasterpos{234{sifdv(type *coords); format type glreadpixels() glreadpixels() gldrawpixels() void glcopypixels(glint x, GLint y, GLsizei width, GLsizei height, GLenum buffer); buffer GL COLOR, GL STENCIL, GL DEPTH 1 4 fromat 2 3 glpixelstore*()

4 2 void glpixelstore{if(glenum pname TYPE param); GL UNPACK* gldrawpixels(),glteximage1d(),glteximage2d(),gltexsubimage1d(), gltexsubimage2d() GL PACK* glreadpixels(),glgetteximage() GL UNPACK SWAP BYTES, GL PACK SWAP BYTES GLboolean FALSE TRUEFALSE GL UNPACK LSB BYTES, GL PACK LSB BYTES GLboolean FALSE TRUEFALSE GL UNPACK ROW LENGTH, GL PACK ROW LENGTH GLint 0 GL UNPACK SKIP ROWS, GL PACK SKIP ROWS GLint 0 GL UNPACK SKIP PIXELS, GL PACK SKIP PIXELS GLint 0 GL UNPACK ALIGNMENT, GL PACK ALIGNMENT GLint 4 1,2,3,4 *ROW_LENGTH *SKIP_PIXELS ª æ œ *SKIP_ROWS æ œ 1 void glpixelzoom(glfloat zoom_x GLfloat zoom_y); (gldrawpixels(),glcopypixels()) x y zoom x zoom y 1.0 2.0 4

2.2 5 2.2 gldrawpixels() sample-image.c #include <GL/glut.h> #include <stdlib.h> #define checkimagewidth 64 #define checkimageheight 64 GLubyte checkimage[checkimageheight][checkimagewidth][3]; static GLdouble zoomfactor = 1.0; static GLint height; void makecheckimage(void) { int i, j, c; for (i = 0; i < checkimageheight; i++) { for (j = 0; j < checkimagewidth; j++) { c = ((((i&0x8)==0)^((j&0x8)==0)))*255; checkimage[i][j][0] = (GLubyte) c; checkimage[i][j][1] = (GLubyte) c; checkimage[i][j][2] = (GLubyte) c; void init(void) { glclearcolor (0.0, 0.0, 0.0, 0.0); glshademodel(gl_flat); makecheckimage(); glpixelstorei(gl_unpack_alignment, 1);

6 2 void display(void) { glclear(gl_color_buffer_bit); glrasterpos2i(0, 0); gldrawpixels(checkimagewidth, checkimageheight, GL_RGB, GL_UNSIGNED_BYTE, checkimage); glflush(); 2.3 Independent JPEG Group s software JPEG Linux (http://www.ijg.org/) JPEG JPEG OpenGL viewjpeg.c: OpenGL readjpeg.h, readjpeg.c: JPEG testimg.jpg: JPEG Makefile TARGET OBJS = viewjpeg = viewjpeg.o readjpeg.o CC = gcc CFLAGS = -g -Wall -O2 LIBS = -lglut -lglu -lgl -ljpeg TARGET:$(OBJS) $(CC) -o $(TARGET) $(OBJS) $(LIBS).c.o: $(CC) $(FLAGS) -c $< clean: rm -f *.o * $(TARGET)

7 3 OpenGL 6 A N J K H A 2 H E E J E L A @ A 2 5? A A I K H B =? A B > K E @ E C I K H B =? A B M = J H A A 3.1 3 0.0...1.0 gltexcoord() void gltexcoord{1,2,3,4{s,i,d,f(type coords); void gltexcoord{1,2,3,4{s,i,d,fv(type *coords); 3.2 (sample-checker.c) glteximage2d()

8 3 3 #include <GL/glut.h> #include <stdlib.h> /* Create checkerboard texture */ #define checkimagewidth 64 #define checkimageheight 64 GLubyte checkimage[checkimagewidth][checkimageheight][3]; void makecheckimage(void) { int i, j, c; for (i = 0; i < checkimagewidth; i++) { for (j = 0; j < checkimageheight; j++) { c = ((((i&0x8)==0)^((j&0x8)==0)))*255; checkimage[i][j][0] = (GLubyte) c; checkimage[i][j][1] = (GLubyte) c; checkimage[i][j][2] = (GLubyte) c; void myinit(void) { glclearcolor (0.0, 0.0, 0.0, 0.0); glenable(gl_depth_test); gldepthfunc(gl_less); makecheckimage(); glpixelstorei(gl_unpack_alignment, 1);

3.2 9 glteximage2d(gl_texture_2d, 0, 3, checkimagewidth, checkimageheight, 0, GL_RGB, GL_UNSIGNED_BYTE, &checkimage[0][0][0]); gltexparameterf(gl_texture_2d, GL_TEXTURE_WRAP_S, GL_CLAMP); gltexparameterf(gl_texture_2d, GL_TEXTURE_WRAP_T, GL_CLAMP); gltexparameterf(gl_texture_2d, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gltexparameterf(gl_texture_2d, GL_TEXTURE_MIN_FILTER, GL_LINEAR); gltexenvf(gl_texture_env, GL_TEXTURE_ENV_MODE, GL_DECAL); glenable(gl_texture_2d); glshademodel(gl_flat); void display(void) { glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glbegin(gl_quads); gltexcoord2f(0.0, 0.0); glvertex3f(-2.0, -1.0, 0.0); gltexcoord2f(0.0, 1.0); glvertex3f(-2.0, 1.0, 0.0); gltexcoord2f(1.0, 1.0); glvertex3f(0.0, 1.0, 0.0); gltexcoord2f(1.0, 0.0); glvertex3f(0.0, -1.0, 0.0); gltexcoord2f(0.0, 0.0); glvertex3f(1.0, -1.0, 0.0); gltexcoord2f(0.0, 1.0); glvertex3f(1.0, 1.0, 0.0); gltexcoord2f(1.0, 1.0); glvertex3f(2.41421, 1.0, -1.41421); gltexcoord2f(1.0, 0.0); glvertex3f(2.41421, -1.0, -1.41421); glend(); glutswapbuffers(); void myreshape(int w, int h) { glviewport(0, 0, w, h); glmatrixmode(gl_projection); glloadidentity(); gluperspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30.0); glmatrixmode(gl_modelview); glloadidentity(); gltranslatef(0.0, 0.0, -3.6);

10 3 int main(int argc, char** argv) { glutinit(&argc, argv); glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH); glutcreatewindow("checker"); myinit(); glutreshapefunc (myreshape); glutdisplayfunc(display); glutmainloop(); return 0; /* ANSI C requires main to return int. */ makecheckimage GLubyte (unsigned char) WIDTH HEIGHT 3 1 RGB 3 2 64 64 makecheckimage myinit glpixelstorei() image[ ] gltexparameteri, gltexparameterf GL TEXTURE MAG FILTER GL TEXTURE MIN FILTER (MAG) (MIN) GL LINEAR GL NEAREST GL TEXTURE WRAP S(T) s, t GL REPAET (GL CLAMP) 3 0.0..3.0 gltexenvf GL DECAL GL MODULATE

3.2 11 glteximage2d void glteximage2d(glenum target, GLint level, GLint format, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); target GL TEXTURE 2D GL PROXY TEXTURE 2D level 0 format (RGBA ) GL RGB GL RGBA width height OpenGL 2 1 2 4 8 16 32 64 128 256 64x64 1024x1024 border 0 format pixels RGB GL RGB PNG GL RGBA type pixels GL UNSIGNED BYTE width,height,pixel width,height 2 pixels ( image) display() glenable(gl TEXTURE 2D) gldisable(gl TEXTURE 2D)

12 3 3.3 OpenGL ( ) 1. 2. 3. 4. OpenGL void glgentextures(glsizei n, GLuint *texturenames); glgentextures() n texturenames void glbindtexture(glenum target, GLuint texturename); target GL TEXTURE 1D GL TEXTURE 2D texturename glteximage2d() 2 gltexsubimage2d()

3.3 13 void gltexsubimage2d( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); target GL TEXTURE 2D level 0 xoffset x yoffset y (0, 0) width height format type gldrawpixels() format type pixels gltexsubimage2d() glteximage2d() 2 2 n GLU gluscaleimage() int gluscaleimage( GLenum format, GLint widthin, GLint heightin, GLenum typein, const void * datain, GLint widthout, GLint heightout, GLenum typeout, void * dataout ); format widthin heightin typein datain widthout heightout typeout dataout

14 3 1 1. sampel-checker.c sample-texbind.c 2. JPEG viewjpeg.c, readjpeg.c USB USB USB 3. sample-image.c JPEG 4. glut- SolidTeapot 5. USB

15 4 GLUI 4.1 GLUI GLUI OpenGL OpenGL glut OpenGL glut C++ Linux, Windows (Visual C++, gcc), Macintosh glut glut GUI glut GUI CG glmultmatrix() glut glui glui 4 GLUI

16 4 GLUI 4.1.1 GLUI GLUI (Buttons) (Checkboxes) ON OFF (Radio Buttons) (Editable Text Boxes) (Spinners) (Listboxes) (Rotation Controls) (Translation Controls) 5 GLUI (Static Text) (Separators) Static Text (Columns)

4.1 GLUI 17 (Panels) (Rollouts) 5 6 7 glui 6 7 GLUI *glui = GLUI_Master.create_glui( "GLUI" ); GLUI *glui = GLUI_Master.create_glui_subwindow(main_window, glui->set_main_gfx_window( main_window ); GLUI_SUBWINDOW_BOTTOM);

18 4 GLUI GLUI SUBWINDOW BOTTOM GLUI SUBWINDOW TOP GLUI SUBWINDOW LEFT 4.2 glut GLUI teapot UI #include <stdio.h> #include <math.h> #include <GL/glut.h> void display(void) { glclear(gl_color_buffer_bit); glutwireteapot(1.5); glutswapbuffers(); glutpostredisplay(); int main(int argc, char *argv[]) { glutinit(&argc, argv); glutinitdisplaymode(glut_rgba GLUT_DOUBLE); glutcreatewindow(argv[0]); glutdisplayfunc(display); glclearcolor(0.0, 0.0, 1.0, 0.0); glutmainloop(); return 0; GLUI #include <stdio.h> #include <math.h> #include <GL/glut.h> #include <glui.h>

4.2 glut GLUI 19 /*--- ---*/ float rotate[16] = { 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 ; void display(void) { glclear(gl_color_buffer_bit); /*--- ---*/ glpushmatrix(); glmultmatrixf( rotate ); glutwireteapot(1.5); glpopmatrix(); /*--- ---*/ glutswapbuffers(); glutpostredisplay(); /*=== ===*/ void gluicallback(int num) { exit(0); /*=== ===*/ int main(int argc, char *argv[]) { glutinit(&argc, argv); glutinitdisplaymode(glut_rgba GLUT_DOUBLE); glutcreatewindow(argv[0]); glutdisplayfunc(display); glclearcolor(0.0, 0.0, 1.0, 0.0);

20 4 GLUI /*---GLUI initialize---*/ GLUI *glui = GLUI_Master.create_glui("control"); /*---GLUI ---*/ GLUI_Rotation *view_rot= new GLUI_Rotation(glui, "Rotation",rotate); /*===GLUI ===*/ new GLUI_Button(glui, "Exit", 0, gluicallback); glutmainloop(); return 0; 8 GLUI teapot UI 4.3 GLUI GLUI glui-2.36.tgz example example1.cpp, example2.cpp, example3.cpp, example4.cpp, example5.cpp example6.cpp bin tar xvzf glui-2.36.tgz cd glui-2.36 make

4.3 GLUI 21 2 1. sample glui.cpp sample glui teapot.cpp Makefile Teapot glutwireteapot glutsolidteapot 2. exmple5 2 Teapot Teapot 3. UI ( )

22 4 GLUI 3 GLUI solar system ex.tar.gz C++ ( 1. plant view main.cpp 2. orbit view main.cpp a Day rate b 9 3.1 10 3.1 11 3.1 12 3.2

4.3 GLUI 23 13 3.2 ( ) 14 3.2 ( ) 15 3.2 ( )