[All Answered :D]Random Q's(optimization/cross-compatibility)

1.is it faster to use public variables from “subclasses” or get/set mutator/accessor methods to private variables?

2.is it faster to deal with the byte’s of an image to edit it or to use say the Graphics class?

3.Does OpenGL know not to render things that aren’t in sight?

4.How do you program for cross platform compatibility?
I read this about mac’s but don’t entirely get it:

[quote] Mac OS X
The Mac OS X port of Jogl, in particular the GL interface and its implementation, can be used either with the provided GLCanvas widget or with the Cocoa NSOpenGLView. In order to use it with Cocoa the following steps should be taken:
* Instantiate a net.java.games.jogl.impl.macosx.MacOSXGLImpl using the public constructor taking no arguments.
* Upon the first render of your application, or whenever the available OpenGL routines might have changed (because a window moved from one screen to another) call the publicly-accessible method MacOSXGLImpl.resetGLFunctionAvailability().
* Only use the GL instance when the OpenGL context from the NSOpenGLView is current.
[/quote]
What’s cocoa?

5.Do I have to reprogram the whole game to have a Mac version a Windows version and a Linux version?

6.Do different versions of java effect applets/applications a lot?

[quote]1.is it faster to use public variables from “subclasses” or get/set mutator/accessor methods to private variables?
[/quote]
Premature optimization is the root of all evil. I went through a phase like this and it made things much harder. Variable access will, 99% likely not be your slow-point and you’ll see no performance gain either way.

[quote]2.is it faster to deal with the byte’s of an image to edit it or to use say the Graphics class?
[/quote]
Dealing with the bytes has been faster in my experience, but it’s much more of a pain to use. When using Graphics, you have the nice methods to draw things and it can handle any type of image. When dealing with the actual data, you have to have ways of doing it handling all types of data and pixel formats.

Also, keep in mind that any changes to a BufferedImage will have to be sent to the graphics card, which is always a slower operation, too.

[quote]3.Does OpenGL know not to render things that aren’t in sight?
[/quote]
Yes, it gets clipped away so you don’t see it. But because you don’t see anything it’s best not to send it to the graphics card if you know its not showing. I’d look into “view frustum culling” to learn more.

[quote]4.How do you program for cross platform compatibility?
[/quote]
This I cannot answer so well, except to point out that whatever it is you’re reading, it’s very old. net.java.games.jogl is the old package name for JOGL before it became a official. You should not need to worry about choosing an NS or Cocoa implementation, jogl does this for you on Mac. These are just different windowing systems available on Mac.

[quote]5.Do I have to reprogram the whole game to have a Mac version a Windows version and a Linux version?
[/quote]
No, that’s the beauty of Java. It theoretically runs the same on the different platforms. I say theoretically because in rarer cases it doesn’t work that way. Program in such a way that each part is as separated as possible. If it turns out there’s a bug with some JVM or video card driver that you must support, you’ll have to change a small part of the code. You don’t want to change AI code to fix a bug with graphics.

[quote]6.Do different versions of java effect applets/applications a lot?
[/quote]
When you compile your code, the .class file has a minimum java version required to run it (e.g. if you compile with JDK 1.6, someone needs 1.6 to run it, too). Besides that, the newer java versions offer up syntactic changes with generics and annotations which won’t work on 1.4 or lower, and
they often improve performance.

I agree with lhkbob, you don’t need to do something special to support several operating system. Before thinking about low level optimizations, use both a spatial subdivision (trees, graphs, voxels, …) and a kind of view frustum culling. In my case, this is critical and this has greatly improved the frame rate.

wow lhkbob thanks for tackling all that haha.

here’s a couple more:

  1. Why do applets work on some browsers and not on others? is this in the HTML or in the .jar?

  2. Does mac/linux use different applet api?

  3. is jnlp more cross compatable then applets?

may be that the browser does not have java enabled

not that I am aware of, but I may be wrong.

You were right about ti being the java script enabled haha I can’t believe I didn’t check for that.
I just ran my applet on safari, IE, and fire-fox successfully.

Is there a cross-compatibility tutorial anywere for java(especially jogl)? because I can’t find anything about it anywhere… And I really want my Mac using friends to be able to run my little applet :(, and later things I make.

Do you understand what I meant?? you don’t need to do something special to support several operating systems
Of course, Linux and Mac don’t have a different API for applets.

When you use Java Webstart, you only have to add a single line in your JNLP file to load all necessary files as I did for TUER, watch my JNLP file if you don’t see what I mean. For applets, look at GL gears rewritten in Java on java.net, it is explained correctly.

thanks for baring with me everyone. I know I’m probably an annoying poster, but I’m just trying, and a year from now I may be worth net-working with haha. peace & love.

No you’re not annoying but please read our answers carefully. There are no stupid questions, it is better to ask a question than to do nothing.

don’t worry it took me longer to get 2D vectors.

now that was an intense thread :wink: