Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOAIImageTexture does not seem to be supported #42

Open
OliverHrdz opened this issue Jul 13, 2012 · 1 comment
Open

MOAIImageTexture does not seem to be supported #42

OliverHrdz opened this issue Jul 13, 2012 · 1 comment

Comments

@OliverHrdz
Copy link

With RapaNui, I'm not able to dynamically update a MOAIImageTexture object already bound to GPU memory from an input event handler. I display the texture with RNFactory.createImageFromMoaiImage () function, which accepts a MOAIImage object. MOAIImageTexture inherits from MOAIImage, so I expect that createImageFromMoaiImage () should work fine passed in a subclass of what it expects. This may be a bug somewhere, as MOAIImageTexture is something that has recently been added to MOAI. Thanks!

Code to reproduce:

require("rapanui-sdk/rapanui")

SCREEN_WIDTH = RNFactory.screen.width
SCREEN_HEIGHT = RNFactory.screen.height

print ( "hello" )
local background = RNFactory.createImage ( "images/background-blue.png" )
background:sendToBottom ()
print ( "displayed background" )

texture = MOAIImageTexture.new ()
texture:load ( "C:/dev/sdks/moai-sdk/samples/hello-moai/moai.png", MOAIImage.TRUECOLOR + MOAIImage.PREMULTIPLY_ALPHA )
print ( "loaded texture" )

-- demonstrate that we can modify the texture before rendering it
-- this draws a red line 50 pixels long diagonally from the top left
for i = 0,50 do
    texture:setRGBA ( i, i, 1, 0, 0, 1 )
end

image = RNFactory.createImageFromMoaiImage ( texture )
image.x = SCREEN_WIDTH/2
image.y = SCREEN_HEIGHT/2
print ( "displayed image from texture" )

function onTouchEvent ( event )
    if event.phase == "began" then
        print ( "touch begin" )

        -- this should draw a white line 128 pixels long diagonally from the top left
        for i = 0,127 do
            texture:setRGBA ( i, i, 1, 1, 1, 1 )
        end 
        texture:invalidate ()
    elseif event.phase == "ended" then
        print ( "touch end" )

        -- this should draw a blue line 128 pixels long diagonally from the top left
        for i = 0,127 do
            texture:setRGBA ( i, i, 0, 0, 1, 1 )
        end
        texture:invalidate ()
    end
end

local listenerId = RNListeners:addEventListener("touch", onTouchEvent)
@MattiaFortunati
Copy link
Collaborator

Hi,

MOAIImageTexture is something that has recently been added to MOAI.

Yes, I've labeled this as "new feature". We'll check on this.

Have a nice day,

Mattia

@ghost ghost assigned eljeko and MattiaFortunati Jul 30, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants