Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - MichaelJPCT

Pages: 1 ... 16 17 [18]
256
Feedback / new way to develop with JPCT - Jython
« on: December 30, 2015, 03:13:01 pm »
i am more familiar with Python than with Java and after writing some java code i still think Python code is much faster to write, although Python runs much slower than Java. and for a beginner, the oppotunity to type in functions or change states when the program is running, then see the effects immediately (this is so called "interactive mode", as oppose to modify code -> compile -> test run) is a great help.
Jython is Python which runs on Java Virtual Machine, and it is possibly compatible with any Java libraries, so a JPCT game could be written mostly in Python code, although some parts should be written in Java or even C language to keep a high running performance.

now let's see how a JPCT program can be written with Jython.

to start up the program, create a shortcut such as start.bat.
-i means interactive mode, pause to let yourself read any error messages.
Code: [Select]
@c:\jythonpath\jython.exe -Djava.library.path=jar_path -i mygame.py
@pause

minimal example of a JPCT program, save as mygame.py
Code: [Select]
import sys,time; sys.path+=['jar_path','jar_path/jpct.jar','jar_path/lwjgl.jar','jar_path/lwjgl_util.jar']
from com.threed.jpct import *; from com.threed.jpct.util import *; from org.lwjgl.opengl import Display

fb=FrameBuffer(640,480,FrameBuffer.SAMPLINGMODE_NORMAL)
running=1
timeToSleep=0.01 # 0.01 second

def sleepSomeTime(): time.sleep(timeToSleep) # or calculate a value to make framerate constant

def GameLogic(): return
def pollKeyboard(): return

def mainLoop():
    global running
    while running:
        GameLogic(); fb.clear(); fb.update(); sleepSomeTime(); fb.display(); pollKeyboard()
        # if some key event: running=0
        if Display.isCloseRequested(): Display.destroy(); break

mainLoop()
if "some key event" happens and interactive mode is used, mainLoop stops and you can type in commands, such as change timeToSleep to 0.02, then call mainLoop again after changing running back to 1. this is an example of the benefit of interactive mode.

to import your own java class, put class files in jar_path or append another path to sys.path, then import YourJavaClass

if you know both Python language and Java, you may find this approach has some advantages.

257
Support / Re: techniques for displaying text
« on: December 29, 2015, 11:10:27 am »
many thanks, i'll look into it.

258
Support / Re: techniques for displaying text
« on: December 29, 2015, 07:30:30 am »
can i achieve multipass rendering of the same world (with different camera settings) or sequential rendering of multiple worlds in a specified order?

259
Support / techniques for displaying text
« on: December 28, 2015, 03:38:19 pm »
right now i am looking into text rendering. after some research i found several ways to put text onto screen:
1) texture blitting as the way jpct examples do
2) billboard object3D placed in front of camera
3) using overlay class of jpct
4) make rectangles to hold texture of each character and render these rectangles with ortho projection and depth-test off

i would like to know whether blitting is the fastest method (runtime performance) and whether the 4th method can be done in jpct - i need to manipulate opengl states manually such as calling glDisable, glMatrixMode at a specific time in the rendering process.

260
reproject2d3dws returns a direction vector, not a position in world space. project3d2d requires a position in world space as input.

261
thanks.
import org.lwjgl.opengl.Display works.
but import org.lwjgl.opengl.* has conflict with another "DisplayMode".
import org.lwjgl.opengl should be ideal but it doesn't work. i miss Python, i can write ogl=org.lwjgl.opengl; disp=ogl.Display in it!

262
i like to write something like:
Code: [Select]
import org.lwjgl.opengl;
class { method() { opengl.Display.setTitle("abc"); } }
but no matter what i tried:
import org.lwjgl;
import org.lwjgl.opengl.*
...
jave doens't compile.
do i have to write { org.lwjgl.opengl.Display.method(); } every time?

263
Support / Re: non standard window size and OPENGL renderer?
« on: December 27, 2015, 06:04:25 pm »
it helps. thank you.
right now i use JNA to call FindWindow & SetWindowLong in user32.dll in order to hide the decoration. so far the program seems working correctly.

264
Support / Re: non standard window size and OPENGL renderer?
« on: December 27, 2015, 05:11:50 am »
i tried adding the Canvas to Frame, also disabled software renderer, but still a new GL window showed up, i thought GL should render into the Canvas which was added into Frame.
i use Frame because i don't know how to manipulate the window created by FrameBuffer, for example change the style, size, position. and fullscreen mode is not good during development so i always prefer windowed mode. and java doesn't expose HWND so i can't even use DLL calls to change the window.
could you tell me how to create an opengl window without border and sized 1280x766? in pseudo code?

265
Support / non standard window size and OPENGL renderer?
« on: December 26, 2015, 04:02:52 pm »
hello i just started to try jpct the desktop version. so far i created a non fullscreen window with non standard size , but can't get OPENGL hardward renderer.
another problem is, if i set the window size to a standard size, the OPENGL renderer opens another window that i don't want.
how to setup the window correctly?

my current code is like this:

GraphicsEnvironment e=GraphicsEnvironment.getLocalGraphicsEnvironment();
gDevice=e.getDefaultScreenDevice(); GraphicsConfiguration gc=gDevice.getDefaultConfiguration();
gwin=new Frame(gc); gwin.setUndecorated(true); gwin.setIgnoreRepaint(true); gwin.setResizable(false);
gwin.pack(); Dimension d=new Dimension(1280,766); gwin.setSize(d);
gwin.setVisible(true); gfx=gwin.getGraphics();
gbuf=new FrameBuffer(1280,766,FrameBuffer.SAMPLINGMODE_NORMAL);
gbuf.enableRenderer(IRenderer.RENDERER_OPENGL); gbuf.optimizeBufferAccess();

and in the mainloop:
gbuf.clear(); gbuf.update(); gbuf.display(gfx);

note that i want the window to have no border/title, and sized 1280x766 (766=800-34, the height of taskbar)
in my experience at other 3D engine, non standard window size is achievable.
i am new to java and jpct, so can't find out what's wrong in my code. could someone help me? thanks.

266
Support / Re: for AIDE, where to put the downloaded files?
« on: April 05, 2013, 08:52:00 am »
i found out i need to add this in .classpath file <classpathentry kind="lib" path="xxx/xxx.jar"/>

it can be imported now.

developing on the device is slower but i can do it anywhere anytime, kind of fun.

267
Support / for AIDE, where to put the downloaded files?
« on: April 04, 2013, 05:46:46 pm »
hello. i'm new to java and android.
i'm trying to do some development on android device and AIDE seems good enough for me.
but the wiki of jpct only taught how to install for eclipse. can someone tell me how to install jpct for AIDE? thanks.

Pages: 1 ... 16 17 [18]