Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  int [] draw functions.  (Read 2755 times)
0 Members and 1 Guest are viewing this topic.
Offline Abuse

JGO Coder


Medals: 11


falling into the abyss of reality


« Posted 2003-09-30 18:09:30 »

Can any1 point me in the direction of an api that implements the common draw functions on an argb int []? (primitve rendering, image drawing etc etc)

The sort that would be used with tinyPTC.

I had a glance at OpenPTC, but it didn't appear immediately obvious if that was the intended use of the API.

Oh, 1.1 pls Wink (I know.. I know... i don't need the 'supporting dead APIs' lecture Roll Eyes)

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #1 - Posted 2003-10-09 05:35:53 »

You can create an image out of an array and render to it using Graphics (using MemoryImageSource, for example). Or is this not what you're looking for?
Offline Abuse

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #2 - Posted 2003-10-09 08:36:15 »

You can do that?!

I can't :-/

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
import java.awt.*;
import java.awt.image.*;
class Tests
{
   public static void main(String args[])
   {
      MemoryImageSource mis = new MemoryImageSource(640, 480, new int[640*480], 0, 640);
      Image img = Toolkit.getDefaultToolkit().createImage(mis);
      Graphics g= img.getGraphics();
   }
}



1  
2  
3  
Exception in thread "main" java.lang.IllegalAccessError: getGraphics() only valid for images created with createImage(w, h)
        at sun.awt.windows.WImage.getGraphics(WImage.java:27)
        at Tests.main(Tests.java:25)

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline tom
« Reply #3 - Posted 2003-10-09 17:31:22 »

With java.awt.image.PixelGrabber you can grab the pixels of an java.awt.Image.

So I guess you could:
1. create an Image with createImage(w, h)
2. grab the Graphics object of the image and draw on it
3. use PixelGrabber to get the data of the image

Haven't tested this though.

Offline Abuse

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #4 - Posted 2003-10-09 17:49:50 »

Quote
With java.awt.image.PixelGrabber you can grab the pixels of an java.awt.Image.

So I guess you could:
1. create an Image with createImage(w, h)
2. grab the Graphics object of the image and draw on it
3. use PixelGrabber to get the data of the image

Haven't tested this though.


I'm talkin realtime Wink

Resorting to pre-rendering primitives to an image, and blitting the image is just silly.

Without rewriting every single function in the Graphics class, i don't believe it is possible with the 1.1 core api.

Some1 must have already rewritten all the Graphics functions so they operate on an int [], and put it in a nice neat pixel [] based API? Huh

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline tom
« Reply #5 - Posted 2003-10-09 22:22:06 »

Quote
Some1 must have already rewritten all the Graphics functions so they operate on an int [], and put it in a nice neat pixel [] based API


This is sort of what we did at my last job. We made applet games, and we had our own library. We had a Pixels class with functions like drawImage, crop, fillRect etc. The drawImage functions supported add, sub, alphablending, scaling etc. We also had a Surface class that extended Pixels, with polygon rendering functions. Quite a nice lib actually. Unfortunatly the code is not mine to give away  Sad

Offline Abuse

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #6 - Posted 2003-10-09 22:35:55 »

Quote


This is sort of what we did at my last job. We made applet games, and we had our own library. We had a Pixels class with functions like drawImage, crop, fillRect etc. The drawImage functions supported add, sub, alphablending, scaling etc. We also had a Surface class that extended Pixels, with polygon rendering functions. Quite a nice lib actually. Unfortunatly the code is not mine to give away  Sad


yeah, I figured a library like that would have some commercial value Sad

I guess there are similar libraries floating around for C; an int [] is an int [] - right  Wink

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline nonnus29

Senior Member




Giving Java a second chance after ludumdare fiasco


« Reply #7 - Posted 2003-10-10 01:33:06 »

Oh, its possible; for more info - explore this link;

http://www.cfxweb.net/modules.php?name=Forums&file=viewtopic&t=51

you can find the cfxweb JACC (java applet coding contest) pages and some of them have the source code to the applets; there is some amazing stuff in there; including this snippet

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
// this is from Bloid's code

public MemoryImageSurface( int w, int h, Component parent )
  {
    this.parent = parent ;
    width = w ;
    height = h ;
    buffer = new int[ w * h ] ;
    source= new MemoryImageSource(w, h, model,buffer,0,w);
    source.setAnimated(true);
    image=parent.createImage(source);
     
  }

public Image getImage()  {
    source.newPixels();
    return image;
}


I have a mode7 applet on my site using something like the above;

http://www.geocities.com/nonnus29/mode7/mode7.htm


Quote
Some1 must have already rewritten all the Graphics functions so they operate on an int [], and put it in a nice neat pixel [] based API?


I actually started doing this recently using some of the JACC code; Bloids code already had blending and transparent blits and  I  added rotation, scaling and a mode7 function.  I want to add solid filled triangles and perspective correct tri's (I dont' care about n-gons).  It would all be open source of course; I basically just copy, paste, and modify other peoples code; the scaling, rotating and mode7 was origionally in C.
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #8 - Posted 2003-10-10 15:43:21 »

Can't you just draw to a BufferedImage?
Then access the WriteableRaster..

1  
2  
3  
4  
5  
6  
BufferedImage bi = new BufferedImage(320,240, BufferedImage.TYPE_INT_RGB);
WriteableRaster rast = bi.getRaster();
DataBuffer buf = rast.getDataBuffer();
assert buf.getDataType() == DataBuffer.TYPE_INT;
DataBufferInt bufi = (DataBufferInt) buf;
int [] pixelData = bufi.getData();

Offline Abuse

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #9 - Posted 2003-10-10 16:20:43 »

1.1 Wink

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #10 - Posted 2003-10-10 17:32:45 »

/me resists urge to lecture... (and promises himself to read more carefully next time Wink )

Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #11 - Posted 2003-10-11 05:30:10 »

I can. I just change the jdk code, recompile and voila =)

Sorry, forgot that you can't render to toolkit images..
Offline nonnus29

Senior Member




Giving Java a second chance after ludumdare fiasco


« Reply #12 - Posted 2003-10-13 01:16:11 »

Quote
I want to add solid filled triangles and perspective correct tri's (I dont' care about n-gons).  It would all be open source of course; I basically just copy, paste, and modify other peoples code; the scaling, rotating and mode7 was origionally in C.


I've been researching alot more about 3d software rendering; specifically clipping polygons to the view frustrum.  All of a sudden I care very DEEPLY about n-gons; they make clipping polys so much nicer.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

ctomni231 (33 views)
2014-07-18 06:55:21

Zero Volt (29 views)
2014-07-17 23:47:54

danieldean (24 views)
2014-07-17 23:41:23

MustardPeter (26 views)
2014-07-16 23:30:00

Cero (41 views)
2014-07-16 00:42:17

Riven (43 views)
2014-07-14 18:02:53

OpenGLShaders (31 views)
2014-07-14 16:23:47

Riven (30 views)
2014-07-14 11:51:35

quew8 (29 views)
2014-07-13 13:57:52

SHC (65 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!