Page 2 of 2

Re: 3D Planets

Posted: Tue Jul 31, 2012 12:52 pm
by mickeyjm
Nixola wrote:Mickeyjm, that's exactly what I want to avoid. Canvas are fast and useful, it's not fair that some Windows users can't have them because Microsoft is dumb.
I mean get them to use love.graphcs.isSupported() then if it fails use ImageData otherwise, canvases

Re: 3D Planets

Posted: Tue Jul 31, 2012 6:00 pm
by T-Bone
I get 150-180 FPS on my quad core i5 (3,2 GHz) Ubuntu setup.

Re: 3D Planets

Posted: Tue Jul 31, 2012 11:05 pm
by Ref
mickeyjm wrote:
Nixola wrote:Mickeyjm, that's exactly what I want to avoid. Canvas are fast and useful, it's not fair that some Windows users can't have them because Microsoft is dumb.
I mean get them to use love.graphcs.isSupported() then if it fails use ImageData otherwise, canvases
Appreciate where you're coming from.
Still fighting my way through ImageData.
Can't figure out how to direct drawing primitives to an image without using canvases.
We don't seem to have an equivalent for:
love.grahpics.setCanvas( canvas ) - something like love.graphics.setImage( image )
Guess that would essentially involve a canvas anyway.
But, if you are only dealing with pre-drawn (loaded from disk) images, you can get along pretty well.
Still looking for pointers (help) and examples - just to see how other people do it.
Conversions between userdata, imagedata & images are still a pain.
For those that are interested this is all the farther I've managed to get:
(note: I haven't found a way to convert an image to imagedata - just have to load an image as imagedata.)

Code: Select all

gr = love.graphics
-- load a host image
    host = love.image.newImageData( 'buda.png' )
-- apply an effect to host image
    host:mapPixel( effect )
-- load image to be inserted into host
    insert = love.image.newImageData( 'Linux.png' )
-- insert imagedata into host
    host:paste(insert,10,10,0,0,40,40)
-- create a drawing surface (canvas)
    canvas = love.graphics.newCanvas( 20,20)
-- direct drawing to canvas
    gr.setCanvas( canvas )
        gr.setColor(255,55,255,255)
        gr.circle('fill',10,10,8)
        gr.setCanvas()
-- convert userdata (canvas) to imagedata
    data = canvas:getImageData( )
-- add converted canvas to host imagedata
    host:paste(data,30,30,0,0,20,20)
-- convert imagedata into an image
    composite = gr.newImage(host)
-- now ready to draw composite
    gr.setColorMode('replace')
    gr.draw(composite,100,100)
Anything I missed or are using incorrectly (seems to work)?
Edit:
You can also put a image into a canvas:

Code: Select all

canvas:renderTo( function() gr.draw( image ) end )

Re: 3D Planets

Posted: Wed Aug 01, 2012 5:07 pm
by Xgoff
Ref wrote:Can't figure out how to direct drawing primitives to an image without using canvases.
that's the thing... you can't. not unless you actually find/implement a software implementation of opengl. doing this with on a pixel-by-pixel basis through lua (if mapPixel and setPixel are involved) is going to be obscenely slow for just about any task you'd actually want to use canvases for anyway.

it may be possible to get some sort of canvas emulation with some horrific hodge-podge of scissoring, off-screen drawing, and cutting those areas out of screenshots (maybe, i've never used screenshots so i don't know if they always use the actual screen area or the scissor box)

Re: 3D Planets

Posted: Fri Aug 03, 2012 9:31 am
by retrotails
OK, so my real goal with this was to make a Pandemic clone. http://www.crazymonkeygames.com/Pandemic-2.html
You can mouse over countries and it'll tell you what they are. However, I need to use a shader to get it to function properly.
I need to send the GPU a black and white image, which is a different color for each country, and a table of how red each country is. Lets say the color of a pixel in the image I send is 0x30. That's the united states. Say the US is 50% infected. It should be turned 50% red.
How can I send a texture to a shader, and how can I get the color of a random pixel on the screen? Or do I have to send it a canvas of the entire rendered screen as a texture?

Re: 3D Planets

Posted: Sat Aug 04, 2012 4:23 am
by ishkabible
hold on...did I see pluto at the end there? I that the guys with degrees already went over this ;)

Re: 3D Planets

Posted: Sat Aug 04, 2012 7:08 pm
by Ponosna
Planet looks great. I'm really surprised that the details are made