[java] Back Buffer Problems in Java 1.1

Started by
3 comments, last by Stiby 23 years, 6 months ago
Hi all, First a bit about me, I am a professional multimedia developer who programs in C++ and ASM and currently making the move to Java so my first steps is to get to grips with graphics in Java so I have set myself two tasks one of which is to recreate my simple 3D FlightSim demo over to java in the next week my second challenge is to recreate DOOM or Part of in Java using my ASM/C++ experience to translate and reshape the DOOM engine to a totally OO engine over the next month and a half whilst on training so I will be needing your guys help to achive this goal. My first problem is back buffering in a "Frame" as I find that the code that works for an Applet "createImage( int, int )" dosn''t work in a Buffer it just returns a NULL pointer. What I am ultimatly after is a buffer of some kind that I can adjust and blit similar to DirectX buffers were I can get the surface pointer and render to directly and no ned to re-create the surface to blit the adjustments("g.drawImage(buffer, 0, 0)" or similar). Also working double buffering in a Frame. If you can help it would be most apriciated. Phill Phillip Stiby BSc(HONS) I program therefore cant spell!
StibyI program therefore cant spell!
Advertisement
well if i were you i''d use the PixelGrabber to get @ my image source, parse to int[]. Then i could just assume a large array as a buffer and use some of those tryed & tested 86 Asm method logic to wing it through.
createImage won''t work unless you set the content up.
Rather than use AWT you may want to look into Java 2D which provides better mechanisms for buffering. In the next version Java 2D will even be accelerated on the Windows platform (by hooking into DirectX).

Here is the link to the Java 2D FAQ on Sun''s Javasoft site.

http://www.javasoft.com/products/java-media/2D/forDevelopers/java2dfaq.html

The downside is that your applet will not function in most browsers with out the user having first installed the Java 2 Browser plug-in. If you are planning on eventually building your graphics programs as Java applications this won''t be a problem (as you can distribute the Java Runtime 2.0 with your app). If your goal is to distribute your graphics programs via browser then you will be stuck with AWT.
Stiby -

You will want to look at the Toolkit class in your Java documentation. In your frame you can do something like this:


Frame f = new Frame();
Toolkit tk = f.getToolkit();
tk.createImage(...);


There are lots of methods to return an image in there... just choose the appropriate one...

-Nate
Don''t ask me why but you have to do Component.addNotify() before Component.createImage() will work.

This topic is closed to new replies.

Advertisement