pixelploting fps in fullscreen ?q
i am makeing a class that allows me plot pixels to the screen,
shading polygons with my own algorithims.
What i want to know is
1.) what is the fastest way to do this in full screen mode ?
2.) and id like to know what framerates people have seen themselves
who have experimented with this already
[336 byte] By [
lightxxxa] at [2007-9-28 11:20:08]

how have you implemented the shading algorithm?
Are you directly manipulating the pixels of an images Raster,
or have you done it the correct way, and written a class (or classes) that implement the Paint & PaintContext interfaces? (ala TexturePaint, GradientPaint, etc etc)
Whether it is fullscreen or not makes no difference to the implementation. It is whether you are using BufferStrategy or not, that will limit the way inwhich you can do it. (as it is impossible to directly manipulate the Raster of a BufferStrategy's buffer[s])
as to framerate, any filling algorithm done in software will have relatively poor performance, it realy depends what you intend to do with it as to whether it is 2 slow or not.
1 Thing I have noticed though, when performing software operations on a hardware accelerated surface (like the 1s used by VolatileImage or BufferStrategy) the performance is abysmal (mainly because each pixel has to be read back from vram into main memory, the operation applied, and the pixel copied back again - incredibly inefficient :S)
When doing alot of software operations (basically anything that isn't a straight blit, or a BITMASK transparency) it is faster to perform the operation on an image stored in main memory, and then copy (drawImage) the image to vram in 1 go.
(an even simpler way, is to just use automatic images, and leave the caching of the image in vram upto the JVM)
.how have you implemented the shading algorithm?
.Are you directly manipulating the pixels of an images Raster,
.or have you done it the correct way, and written a class
.(or classes) that implement the Paint & PaintContext interfaces?
.(ala TexturePaint, GradientPaint, etc etc)
i dont know how to implement the paintcontext interface.
i based my first draft off the tinyptc for use in a applet
it's a zbuffer algorithm which basically does the following
makes two1 dimentional integer arrays color and depth
i pack the color bytes into the color integers
i pass the polygon data to the zbuffer class in a loop
the algorithim figures out if each pixel should be ploted in the polygon and what its color should be based on the texture which i also take out of images initially then put into texture arrays
diffuse,specular light and transparency stores it in the buffer array then uses
basically a modifyed tinyptc class to drop the array into the image then
supposedly blit it to the screen however its way slow.
in a application it crawls
i use a simultaneous breshams algorithim for u,v color intensity and position of the pixel ploting that i made up.
whats really bad is that i timed the algorithm that figures everything
out it only eats up 15 % to 30% of each frame and i havent even optimized that yetive tryed to optimize the bliting and it seems that its the problem
ill post some of the code below
applet snipet
public void start(){
Dimension size = getSize();
_width = size.width;_height = size.height;
if(startup == false){
initialize( _width , _height); startup = true;}
if(_thread == null){
_thread = new Thread(this," created_thread ");_thread.setPriority(Thread.MAX_PRIORITY);_thread.start();
}//eofif
}
public void stop(){
}
//public void run()
synchronized public void run(){
Dimension size = getSize();
_width = size.width;_height = size.height;
_model = new DirectColorModel(32,0x00FF0000,0x000FF00,0x000000FF,0);
_image = Toolkit.getDefaultToolkit().createImage(this);
Main(_width,_height);
}
public synchronized void update(Object pixels){
if (_consumer!=null){
_consumer.setPixels(0,0,_width,_height,_model,(int[])pixels,0,_width);// copy integer pixel data to image consumer
_consumer.imageComplete(ImageConsumer.SINGLEFRAMEDONE);// notify image consumer that the frame is done
}
paint();
}
private synchronized void paint(){
Graphics graphics = getGraphics();
graphics.drawImage(_image,0,0,_width,_height,null);
notifyAll();
}
public synchronized void addConsumer(ImageConsumer ic) {
}
public synchronized boolean isConsumer(ImageConsumer ic) {
return true;
}
public synchronized void removeConsumer(ImageConsumer ic) {
}
public void startProduction(ImageConsumer ic) {
addConsumer(ic);
_consumer = ic;
_consumer.setDimensions(_width,_height);
_consumer.setHints(_consumer.TOPDOWNLEFTRIGHT|_consumer.SINGLEPASS|_consumer.SINGLEFRAME);
_consumer.setColorModel(_model);
}
public void requestTopDownLeftRightResend(ImageConsumer ic) {
}
the application version is very bad i needed to use the awt to
so i modifyed it
and its actually just for a builder of patches to polygon meshes
so i didnt need it to be fast
public void init(){//init
addMouseMotionListener(this);
addMouseListener(this);
addKeyListener(this);
startout=false;
Dimension scrdim = getSize();w =scrdim.width;h = scrdim.height;
img = createImage (w , h);
screenbuffercolor= new int[w * h];
initialize(w,h);
start();
}
public void start(){//start
if(runner == null){
runner = new Thread(this);
runner.setPriority(Thread.MAX_PRIORITY);
runner.start();
}//eofif
}//eofstart
public void stop(){//stop
if(runner!=null){
runner=null;
running = false;
}//eofif
}
public void update(Graphics g){//update
paint(g);
}
synchronized public void paint(Graphics g){//paint
keyhit = false;mousehit = false;// reset the mouse hit and keyhit values
if(img != null)
g.drawImage(img,0,0,null);
notifyAll();
}
public void keyReleased(KeyEvent e){}
public void keyPressed(KeyEvent e){}
public void keyTyped(KeyEvent e){
keycheck =e.getKeyChar();
keyhit = true;
}
public void mouseClicked(MouseEvent me){
mouseCX = me.getX();
mouseCY = me.getY();
mousehit =true;
}
public void mouseEntered(MouseEvent me){}
public void mouseExited(MouseEvent me){}
public void mousePressed(MouseEvent me){}
public void mouseReleased(MouseEvent me){}
public void mouseDragged(MouseEvent me){}
public void mouseMoved(MouseEvent me){
mouseX = me.getX();
mouseY = me.getY();
}
//__RUN_
synchronized public void run(){
pen = img.getGraphics();
execute();
}// end run
