• Advertisement

Archived

This topic is now archived and is closed to further replies.

[java] Back Buffer Problems in Java 1.1

This topic is 6300 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Don''t ask me why but you have to do Component.addNotify() before Component.createImage() will work.

Share this post


Link to post
Share on other sites

  • Advertisement