ŏ Oni vO |
hLg̖ڎ |
ŏ Oni vO OpenWindow.java łB ͉ʂɔOp``vOłB sƈȉ̂悤ȉʂ\܂Bq L[ƏI܂B
ȉǂẴ\[XR[hĂ܂B
OpenWindow NXsȉAWindows Iy[eBOVXeŎs@łB ܂Aȉ̏KvłB
- Java 2 SDK CXg[Ă
- Oni Java ^C oni.jar -classpathŎsɓǂݍ܂悤ɂȂĂ
- Oni ̕tDLL(gl.dllAgrt.dll) fBNgPATHݒ肷铙ADLLǂݍ߂悤ɂȂĂ
Oni vO OpenWindow RpCɎsꍇ͈ȉ̂悤ȃR}hs܂B
> java oni.runtime.OniRuntime OpenWindowʏ Java vO̎sƈႢoni.runtime.OniRuntimeNXNA ̈ɎsNXn\ɂȂĂ܂B
import import oni.runtime.OniRuntime; import oni.runtime.Application; import oni.gfx.GLGraphics; import oni.gfx.GLConstants; import oni.gfx.PixelFormat; import oni.runtime.event.KeyListener; import oni.runtime.event.KeyEvent;ŏ Oni ʼnʂNXC|[gĂ܂B ŗpĂ Oni pbP[W͈ȉ̂悤ɂȂ܂B
Application C^tF[Xpublic class OpenWindow implements Application { private int width = 640; private int height = 480; public void oniMain(OniRuntime oniRuntime, String[] args) { ... } public void initGraphics(GLGraphics glGraphics) { ... } public void update(GLGraphics glGraphics) { ... } }Oni ŋNNX
oni.runtime.ApplicationC^tF[XȂĂ͂܂B ̃NX̖RXgN^newłKv܂Boni.runtime.ApplicationŎȂĂ͂Ȃ\bh 3 ܂B
oniMain(OniRuntime oniRuntime, String[] args): NꂽƂ1xĂяoinitGraphics(GLGraphics glGraphics):GLGraphics̏KvȂƂ(EBhEŏɕ\ꂽƂAtXN[ɐւƂA)Ăяoupdate(GLGraphics glGraphics): ʂɕ`悷^C~OŌĂяo
oniMain \bhpublic void oniMain(OniRuntime oniRuntime, String[] args) { oniRuntime.addKeyListener(new DemoKeyListener(oniRuntime)); oniRuntime.createWindow("your first KEEL program", width, height); oniRuntime.createGraphicsWithDefaultPixelFormat(); oniRuntime.run(); System.out.println("Never called."); }̃vOł͈ȉ̂ƂsĂ܂B
- L[̓Cxg
oni.runtime.event.KeyListenerIuWFNgݒ肷- EBhẼ^CgAʂ̃TCYݒ肷
- ftHg̃fBXvC̕`ݒ
oni.gfx.PixelFormatݒ肷
ApplicationNXNƍŏɂ̃\bhĂяo܂Boni.runtime.OniRuntime͉ʂァ御すNXナロに果れ合AOniRuntimeフイX^XoA KvワOniRuntimeCX^Xノ対Fン棚run\bhトべば果ワvOナはrun\bhトばれた轤サネ降フ碧は進゛とま
initGraphicsAupdate \bh`public void initGraphics(GLGraphics glGraphics) { glGraphics.glOrtho(0, width, 0, height, -1, 1); glGraphics.glScalef(1.0f, -1.0f, 1.0f); glGraphics.glTranslatef(0, -height, 0); } public void update(GLGraphics glGraphics) { glGraphics.glClear(GLConstants.GL_COLOR_BUFFER_BIT); drawTriangle(glGraphics); glGraphics.glFlush(); } public void quitRequested() { } private void drawTriangle(GLGraphics glGraphics) { int topY = height / 3; int bottomY = (height / 3) * 2; int centerX = width / 2; int leftX = width / 3; int rightX = (width / 3) * 2; glGraphics.glBegin(GLConstants.GL_TRIANGLES); glGraphics.glColor3f(1.0f, 1.0f, 1.0f); glGraphics.glVertex2i(leftX, bottomY); glGraphics.glVertex2i(rightX, bottomY); glGraphics.glVertex2i(centerX, topY); glGraphics.glEnd(); }フプOナ
initGraphics\bhł̓OtBbNX̍W̒`(0,0)A E(width,height)ƂEBhE̍WɂȂ悤ύXĂ܂Bupdate\bhł͉ʂNAĂAOp`ʂĂ܂B
initGraphicsAupdate\bhłoni.gfx.GLGraphicsIuWFNgn܂BGLGraphicsIuWFNgł OpenGL vO~OƓ悤ɃvO~O邱Ƃ\łB
quitRequested\bh͏IƂɌĂ郁\bhłB ł͉Ă܂B
KeyListener C^tF[X`class DemoKeyListener implements KeyListener { public DemoKeyListener(OniRuntime aOniRuntime) { oniRuntime = aOniRuntime; } public void keyTyped(KeyEvent event) { System.out.println(event); } public void keyPressed(KeyEvent event) { System.out.println(event); if (event.getKeyCode() == KeyEvent.VK_Q) { oniRuntime.disposeDisplay(); System.exit(0); } } public void keyReleased(KeyEvent event) { System.out.println(event); } private OniRuntime oniRuntime; }
oni.runtime.event.KeyListenerC^tF[XOniRuntimeCX^Xɓo^邱Ƃœ͂ꂽL[{[h̃Cxg邱Ƃ\łB ł͂ꂼ̃L[Cxgœnꂽoni.runtime.event.KeyEventIuWFNgWo͂ɏoĂ܂BăL[{[h'q'͂ꂽ ʂăvOI悤ɂĂ܂B
|
Copyright © 2001-2002 CyberStep, Inc. All Rights Reserved. |
Oni \tgEFA |