Question about getting composition width and height.

FFGL, OSC, GLSL. If you like abbreviations, this is the forum for you
Post Reply
hive8
Posts: 331
Joined: Sat Jan 22, 2011 22:42
Location: Los Angeles

Question about getting composition width and height.

Post by hive8 »

What i am planning to do is draw the texture in the composition window.
My texture size is 3840 x 540, composition window size is 1920 x 1080
With the current code i can move the texture only in the 3840 x 540 tex coordinates.

How would i go around so i can move the texture in the composition window size

Code: Select all

DWORD H8_FFGLProWrap::DrawTex(ProcessOpenGLStruct* pGL)
{
   
  //start out by just filling our output with the input texture
  if (pGL->numInputTextures<1 || pGL->inputTextures[0]==NULL)
  {
    //no input? just clear
    glClearColor(0.f,0.f,0.f,0.f);
    glClear(GL_COLOR_BUFFER_BIT);
  }
  else
  {
    FFGLTextureStruct &Texture = *(pGL->inputTextures[0]);

	//bind the texture handle
    glBindTexture(GL_TEXTURE_2D, Texture.Handle);

    //enable texturemapping
    glEnable(GL_TEXTURE_2D);
    
    //get the max s,t that correspond to the 
    //width,height of the used portion of the allocated texture space
    FFGLTexCoords maxCoords = GetMaxGLTexCoords(Texture);
    
		DrawTopTex(&maxCoords);
   
 	 //unbind the texture
    glBindTexture(GL_TEXTURE_2D, 0);

    //disable texturemapping
    glDisable(GL_TEXTURE_2D);
  }

	return FF_SUCCESS;
}

void H8_FFGLProWrap::DrawTopTex(FFGLTexCoords *maxCoords)
{
    glTranslatef(-0.5f, 0.0f, 0.0f);
   
	//loop to clone the texture
	    glPushMatrix();
    	
		glBegin(GL_QUADS);
		//lower left
		glTexCoord2d(0.0, 0.0);
		glVertex2f(-1,-1);
		//upper left
		glTexCoord2d(0.0, maxCoords->t);
		glVertex2f(-1,1);
		//upper right
		glTexCoord2d(maxCoords->s, maxCoords->t);
		glVertex2f(1,1);
		//lower right
		glTexCoord2d(maxCoords->s, 0.0);
		glVertex2f(1,-1);
		glEnd();
	
		glPopMatrix();	
	glLoadIdentity(); 
}


HIVE 8 | Quantum Laser | http://www.hive8.com

Joris
Posts: 5186
Joined: Fri May 22, 2009 11:38

Re: Question about getting composition width and height.

Post by Joris »

This is not something that can be done in a plugin.

A plugin is only aware of the size of the texture it is provided. It has no concept or knowledge of the composition it is placed in, because this hasn't happened yet when the plugins renders. Since a FFGL host does not necessarily have a composition render level, there is nothing in the API to get this info either.

But you can apply an effect on a clip or layer after transformation (https://resolume.com/manual/en/r4/effects#render_order). Flipping the render order will first scale the texture to the layer size ( or comp size when layer width and height are disabled ), and then place the original video texture in the middle of this larger texture.

Any effects applied after this will then take the full texture width and height into account, so your plugin will also receive the comp width and height as max texture coords.

This is actually how all plugins work. You can see it happen by for instance applying a kaleidscope effect on a smaller video in a bigger composition. Before flipping render order, it will only appear on the video area, after flipping it will fill the screen.

hive8
Posts: 331
Joined: Sat Jan 22, 2011 22:42
Location: Los Angeles

Re: Question about getting composition width and height.

Post by hive8 »

Thank you for the reply that help me to finish it.
HIVE 8 | Quantum Laser | http://www.hive8.com

Post Reply