R0J0hound's Recent Forum Activity

  • QuaziGNRLnose

    Here's my current solution. It creates a simple webgl program that draws a white rectangle below a black one on a 1x2 canvas. It then reads the pixels and checks if the top pixel is black or not. With that it can know if the texture is flipped or not. This should only need to be run once.

    function isFlippedTexture()
    {
    	var canvas = document.createElement('canvas');
    	canvas.width = 1;
    	canvas.height = 2;
    	var gl = canvas.getContext("experimental-webgl");
    	gl.clearColor(1, 1, 1, 1);
    	gl.clear(gl.COLOR_BUFFER_BIT);
    
    	var prog = gl.createProgram();
    		
    	var vss = gl.createShader(gl.VERTEX_SHADER);
    	gl.shaderSource(vss, "attribute vec3 pos;void main() {gl_Position = vec4(pos, 1.0);}");
    	gl.compileShader(vss);
    	gl.attachShader(prog, vss);
    	
    	var fss = gl.createShader(gl.FRAGMENT_SHADER);
    	gl.shaderSource(fss, "void main() {gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);}");
    	gl.compileShader(fss);
    	gl.attachShader(prog, fss);
    	
    	gl.linkProgram(prog);
    	gl.useProgram(prog);
    
    	gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
    	gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 0, 1, -1, 0, -1, 0, 0,	1, 0, 0]), gl.STATIC_DRAW);
    	var attr = gl.getAttribLocation(prog, "pos");
    	gl.enableVertexAttribArray(attr);
    	gl.vertexAttribPointer(attr, 3, gl.FLOAT, false, 0, 0);
    	
    	gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
    	
    	var tex_small = gl.createTexture();
    	gl.bindTexture(gl.TEXTURE_2D, tex_small);
    	gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, gl.canvas);
    	gl.bindTexture(gl.TEXTURE_2D, null);
    	
    	var fbo = gl.createFramebuffer();
    	gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
    	gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex_small, 0);
    	
    	var pixels = new Uint8Array(1 * 2 * 4);
    	gl.readPixels( 0, 0, 1, 2, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
    	gl.bindFramebuffer(gl.FRAMEBUFFER, null);
    	gl.deleteTexture(tex_small);
    	
    	return pixels[0] == 0;
    }[/code:1t7nmz4j]
  • Prominent

    It's not as trivial to add support for as most of the other features added so far, but that's not really stopping it. It just may require a bit more time to do once I start implenting it.

  • TiAm

    I didn't update the download yet so the change in only in my export. So when you try the link and it shows a pixelated image it's no longer flipped for you? If so, then I think I found a fix for that part. Now I just need to figure out why it's not working at all at times.

    Anyways thanks for the testing. Hopefully I can fix the second issue over the next few days.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • TiAm

    Try this:

    http://tinyurl.com/neye756

    tap to paste the canvas.

    Does it flip?

  • Colludium

    You need to re-download the plugin. It uses an action I just added.

  • You can paste object's anywhere, including off-screen. The object you're pasting just needs to overlap the paster object.

    The exceptions currently are particles and tilemaps. They need to be onscreen to be able to be pasted.

  • Somebody

    The resolution can be set to anything from 1x1 up to the largest texture size your graphics card supports, whatever that may be. And yes you can do just that. In the example the canvas is copied to the screen object and a portion of that is pasted to the paster object which has a resolution of 32x32. So then if you saved Paster.imageUrl you'd get a 32x32 pixel image.

  • TiAm

    I appreciate testing it. I'm currently limited to only being able to use webgl in chrome 33 (probably should upgrade). Every other browser either on my laptop either never worked with webgl or somehow now won't work with webgl. I have another pc that I don't have access to atm that I'll test on if I need to.

    I did another tweak to do something that is used elsewhere in the plugins. Does it give better results?

  • QuaziGNRLnose

    So you only flip it in IE / FF? That's interesting since I needed to flip it in chrome, at least on my computer. Webgl support for my graphics card is dying off in the other browsers so I can only test in chrome currently. Unfortunately it appears to not be flipped on another users system across all browsers, so I'm at a loss atm. I'm thinking it possibly could be graphics card related? I'll let you know if I find any solution, since as of right now it has the same effect as what you're doing, drawing the quad inverted.

  • TiAm

    Well that's not very encouraging that it's mirrored and flipped, but you say it's the same across all the browsers IE, FF and Chrome with webgl on? I'm using chrome since that's the last browser that still supports my graphics card. What graphics card do you have? Maybe it's graphics card related (I have an Ati)

    If it's flipped or mirrored for anyone else let me know which browsers and graphics card if you could.

  • TiAm

    Re-download the c2addon, I added a "Load from canvas" action that copies the canvas to the paster's texture. The resulting resolution will be WindowWidth x WindowHeight. Not sure if it's faster, but you can do everything on the same tick you load.

    Somebody

    This may be useful for you for saving part of the window at any size image you want.

  • QuaziGNRLnose

    I found a solution for upside down texture loading that may be helpful to you. I'm using it in the case of loading a html5 canvas to a texture. I set it, load, then unset it so no other image loading will be affected.

    glw.gl.pixelStorei(glw.gl.UNPACK_FLIP_Y_WEBGL, true);

    this.texture = glw.loadTexture(canvas, false, this.runtime.linearSampling);

    glw.gl.pixelStorei(glw.gl.UNPACK_FLIP_Y_WEBGL, false);