Coder Social home page Coder Social logo

ofxcubemap's Introduction

ofxCubeMap

Addon for working with Cube Maps in openFrameworks

Usage:

To load some images into a cubemap:

	myCubeMap.loadImages( "Cubemaps/SummerScene/cubescene_rt.jpg",
					      "Cubemaps/SummerScene/cubescene_lf.jpg",						 
					      "Cubemaps/SummerScene/cubescene_up.jpg",
					      "Cubemaps/SummerScene/cubescene_dn.jpg",
					      "Cubemaps/SummerScene/cubescene_fr.jpg",
					      "Cubemaps/SummerScene/cubescene_bk.jpg" );

Then to draw it:

	myCubeMap.bind();
		myCubeMap.drawSkybox( 800 );
	myCubeMap.unbind();

It can also be drawn using the supplied shader doing something like:

myCubeMap.bind();

	cubeMapShader.begin();
	cubeMapShader.setUniform1i("EnvMap", 0);

		myCubeMap.drawSkybox( 800 );

	cubeMapShader.end();

myCubeMap.unbind();

To initialise an FBO based cubemap that you can draw into:

myFboCubeMap.initEmptyTextures( 512 );

To draw into it in 2D, this will clear each face to black and draw a line from one corner to the other

for( int i = 0; i < 6; i++ )
{
	myFboCubeMap.beginDrawingInto2D( GL_TEXTURE_CUBE_MAP_POSITIVE_X + i );

		ofClear(0,0,0);

		ofLine(0,0, myFboCubeMap.getWidth(), myFboCubeMap.getHeight() );
		ofLine(myFboCubeMap.getWidth(), 0, 0, myFboCubeMap.getHeight() );

	myFboCubeMap.endDrawingInto2D();
}

If you want to draw your 3D scene into it, you can place it in the scene:

myFboCubeMap.setPosition( 0.0f, 40.0f, 0.0f );

And then you can draw the 3D scene into it like so:

for( int i = 0; i < 6; i++ )
{
	myFboCubeMap.beginDrawingInto3D( GL_TEXTURE_CUBE_MAP_POSITIVE_X + i );

		ofClear(0,0,0);
		drawScene();

	myFboCubeMap.endDrawingInto3D();
}

Examples coming when I get a chance.

ofxcubemap's People

Contributors

andreasmuller avatar

Watchers

Elie Zananiri avatar Golan Levin avatar James George avatar Lars Berg avatar Reza Ali avatar Dan Moore avatar Neil Mendoza avatar James Cloos avatar Jonathan Minard avatar Omer Shapira avatar Surya Mattu avatar Gal Sasson avatar R. Luke DuBois avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.