linux, framebuffer, no X, swing

When running a Java/Swing application on Linux, using X, I'm experiencing poor performance. This is partly caused by X. I'm therefore wondering if there is a possibility to directly use the video memory.

With java NIO you can map a file into a buffer and write directly to this buffer. You can force Swing to paint in this buffer.

Mapping to a normal file works, but mapping to /dev/fb0 fails. The size of this device file is 0.

Is there anybody who has tried the same thing? Or is there someone who runs a Java/Swing appication on Linux without X in some other way ?

Test program:

import java.nio.*;

import java.nio.channels.*;

import java.io.*;

publicclass MemoryMapTest{

static String filename;

public MemoryMapTest(){

RandomAccessFile memFile;

try{

memFile =new RandomAccessFile(filename,"rw");

FileChannel fileChannel = memFile.getChannel();

try{

MappedByteBuffer buffer = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, 800);

for (int i = 0; i < 800; i++){

byte val = (byte)(255 - i);

buffer.put(i, val);

}

}catch (IOException ex){

ex.printStackTrace();

}

try{

fileChannel.close();

memFile.close();

}catch (IOException ex){

ex.printStackTrace();

}

}catch (FileNotFoundException ex){

ex.printStackTrace();

}

}

publicstaticvoid main(String argv[]){

if (argv.length > 0){

filename = argv[0];

}else{

filename ="memfile";

}

new MemoryMapTest();

}

}

[3107 byte] By [jacqa] at [2007-10-2 18:04:27]
# 1
I believe that there is a java command line switch which tells Swing to use OpenGL acceleration. That may solve your problem.
klana001a at 2007-7-13 19:23:43 > top of Java-index,Other Topics,Java Game Development...