Exemple #1
0
void renderEnvironmentMap(int face) {
    // Always clear the frame buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    cur_scene = scene1;
    currentMesh_vec = &meshes_1;
    
    // use the shader associated with the Cathedral (shader 0)
    int shaderNum = 0;
    for (int i = 0; i < currentMesh_vec->size(); i++) {
        
        glUseProgram(shaders[shaderNum]->programID());
        
        environmentMatrixTransform(scene1, face);
        
        setMaterial(scene1, i, shaderNum);
        setTextures(i, shaderNum, true);
        setMeshData(i, shaderNum);
        
        // Draw the mesh
        if ((*currentMesh_vec)[i].mesh->mPrimitiveTypes == aiPrimitiveType_TRIANGLE) {
            glDrawElements(GL_TRIANGLES, 3*(*currentMesh_vec)[i].mesh->mNumFaces, GL_UNSIGNED_INT, &(*currentMesh_vec)[i].indexBuffer[0]);
        }
    }
}
Exemple #2
0
int main(int argc, char** arv)
{
    glutInit (&argc, arv);
    glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_STENCIL | GLUT_DEPTH );
    glutInitWindowPosition( 150, 150 );
    glutInitWindowSize( 800, 800 );
    glutCreateWindow( "Solar System" );
    glShadeModel(GL_SMOOTH);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    glEnable(GL_NORMALIZE);
    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);
    glClearColor(0, 0, 0, 0);
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    glGenTextures( 9, textures );
    unsigned char* pic1 = NULL;
    int w,h;
    setTextures(9);
    glutDisplayFunc(drawing);
    glutTimerFunc( 20, timer, 1 );
    glutKeyboardFunc( key );
    glutMainLoop();
    return 0;
}
optionMenu::optionMenu(float width, float height)
{
	minSliderX = 956; maxSliderX = 1462;

	mTimer = 0;
	mState = 4;
	mOptionMenuState = 1;
	setFonts();
	setTextures();

	slider01->setPosition(1400, 718);

	spriteControl->setPosition(745, 650);
	spriteVideo->setPosition(800, 750);
	spriteAudio->setPosition(800, 850);
	spriteBack->setPosition(1385, 515);

	selectedIndex = 0;

	mRects[0] = new sf::IntRect(sf::Vector2i(730, 650), sf::Vector2i(360, 75));
	mRects[1] = new sf::IntRect(sf::Vector2i(730, 750), sf::Vector2i(360, 75));
	mRects[2] = new sf::IntRect(sf::Vector2i(730, 850), sf::Vector2i(360, 75));
	mRects[3] = new sf::IntRect(sf::Vector2i(1375, 504), sf::Vector2i(113, 91));

}
startMenu::startMenu(float width, float height)
{
	highlightSprite01->setPosition(10, 235);
	mTimer = 0;
	mState = 3;
	setFonts();
	setTextures();

	spriteContinue->setPosition(689, 525);
	spriteNewgame->setPosition(689, 635);
	spriteOption->setPosition(689, 755);
	spriteCredits->setPosition(689, 875);
	spriteExit->setPosition(1770, 45);

	spriteSpinbg->setPosition(600, 0);

	selectedIndex = 0;

	mRects[3] = new sf::IntRect(sf::Vector2i(640, 510), sf::Vector2i(540, 100));
	mRects[0] = new sf::IntRect(sf::Vector2i(640, 630), sf::Vector2i(540, 100));
	mRects[1] = new sf::IntRect(sf::Vector2i(650, 750), sf::Vector2i(550, 100));
	mRects[2] = new sf::IntRect(sf::Vector2i(1750, 35), sf::Vector2i(115, 95));
	mRects[4] = new sf::IntRect(sf::Vector2i(650, 870), sf::Vector2i(550, 100));


}
Exemple #5
0
	Button::Button(sf::Window* window, float width, float height, std::string text,
		const sf::Texture* textureactive,
		const sf::Texture* textureinactive,
		const sf::Texture* texturehover)
	: SpriteWidget(window, width, height),
	  label(new Label(window)),
	  defaultfont(new sf::Font()),
	  state(ES_INACTIVE)
	{
		defaultfont->loadFromFile("./res/font/Knigqst.ttf");
		this->label->setFont(*defaultfont);
		this->label->setCharacterSize(25);
		this->label->setText(text);

		if(textureactive != NULL && textureinactive != NULL
			&& texturehover != NULL)
			setTextures(textureactive, textureinactive, texturehover);

		for(int i = 0; i < 3; ++i)
			textures[i] = 0;

		// Connect signals to slots
		this->signalleftmousebuttonpressed.connect(std::bind(&Button::leftMousebuttonPressedSlot, this));
		this->signalmouseentered.connect(std::bind(&Button::mouseEnteredSlot, this));
		this->signalclicked.connect(std::bind(&Button::clickedSlot, this));
		this->signalmouseleft.connect(std::bind(&Button::mouseLeftSlot, this));
	}
Exemple #6
0
void renderFrame() {
    // Always clear the frame buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    int shaderNum;
    
    // Cathedral scene (scene1, meshes_1, shader 0)
    cur_scene = scene1;
    currentMesh_vec = &meshes_1;
    shaderNum = 0;
    for (int i = 0; i < currentMesh_vec->size(); i++) {

        glUseProgram(shaders[shaderNum]->programID());
        
        setMatrices(cur_scene);
        
        setMaterial(cur_scene, i, shaderNum);
        setTextures(i, shaderNum, false);
        setMeshData(i, shaderNum);
        
        // Draw the mesh
        if ((*currentMesh_vec)[i].mesh->mPrimitiveTypes == aiPrimitiveType_TRIANGLE) {
            glDrawElements(GL_TRIANGLES, 3*(*currentMesh_vec)[i].mesh->mNumFaces, GL_UNSIGNED_INT, &(*currentMesh_vec)[i].indexBuffer[0]);
        }
    }
    
    // Statue scene (scene2, meshes_2, shader 1)
    cur_scene = scene2;
    currentMesh_vec = &meshes_2;
    shaderNum = 1;
    for (int i = 0; i < currentMesh_vec->size(); i++) {
        
        glUseProgram(shaders[shaderNum]->programID());
        
        setMatrices(cur_scene);
        
        setMaterial(cur_scene, i, shaderNum);
        setTextures(i, shaderNum, false);
        setMeshData(i, shaderNum);
        
        // Draw the mesh
        if ((*currentMesh_vec)[i].mesh->mPrimitiveTypes == aiPrimitiveType_TRIANGLE) {
            glDrawElements(GL_TRIANGLES, 3*(*currentMesh_vec)[i].mesh->mNumFaces, GL_UNSIGNED_INT, &(*currentMesh_vec)[i].indexBuffer[0]);
        }
    }
}
Exemple #7
0
bool SFLayer::init(void)
{
	if (!CNLayer::init())
	{
		CNLog("error");
		return false;
	}
	setTextures(NULL);
	return true;
}
Exemple #8
0
WinMenu::WinMenu(float width, float height)
{
	mTimer = 0;
	mState = 6;
	setFonts();
	setTextures();


	selectedIndex = 0;

	mRects[0] = new sf::IntRect(sf::Vector2i(500, 640), sf::Vector2i(550, 100));
	mRects[1] = new sf::IntRect(sf::Vector2i(500, 740), sf::Vector2i(550, 100));

}
void Button::setImages(Image* const TheImage, Vec2f Size)
{
    TextureObjChunkRefPtr TextureObjChunk(NULL);
    if(TheImage != NULL)
    {
        TextureObjChunk = TextureObjChunk::create();
        TextureObjChunk->setImage(TheImage);
        TextureObjChunk->setWrapS(GL_CLAMP_TO_EDGE);
        TextureObjChunk->setWrapT(GL_CLAMP_TO_EDGE);
        TextureObjChunk->setMinFilter(GL_LINEAR);
        TextureObjChunk->setMagFilter(GL_LINEAR);
        //TextureObjChunk->setEnvMode(GL_MODULATE);
    }
    setTextures(TextureObjChunk, Size);
}
Exemple #10
0
bool ImportedModel::load(string filename, vector<string> textureFiles)
{
	bool ret = false;

	const aiScene* scene = aiImportFile(filename.c_str(), aiProcess_GenSmoothNormals | aiProcess_Triangulate | aiProcess_CalcTangentSpace | aiProcess_FlipUVs);

	if (scene)
	{

		m_aabb.min = glm::vec3(INT_MAX);
		m_aabb.max = glm::vec3(INT_MIN);

//		cout << "Loading " << filename << endl;
		ret = initFromAiScene(scene, filename);

	}
	else
		cout << "Error parsing '" << filename.c_str() << "': '" << aiGetErrorString() << endl;

	setTextures(textureFiles);

	return ret;
}
Exemple #11
0
bool SFLayer::initWithDictionary(CCDictionary * pDict)
{
	if (!CNLayer::initWithDictionary(pDict))
	{
		CNLog("error");
		return false;
	}
	
	// load textures
	//     WARNING: For simplify reason, I hope you should never use it!
	CCArray * pTextures = CNDictionary::arrayForKey("Textures", pDict);
	setTextures(SFScene::loadTextures(pTextures));
	
	// add sub layers
	//     WARNING: For simplify reason, I hope you should never use it!
	CCArray * pLayers = CNDictionary::arrayForKey("Layers", pDict);
	addLayers(pLayers);
	
	// add sub sprites
	CCArray * pSprites = CNDictionary::arrayForKey("Sprites", pDict);
	addSprites(pSprites);
	
	return true;
}
Exemple #12
0
 TextureDataContainer::UpdateState TextureDataContainer::setTextures(const TextureDataContainer& textureEntries, bool force) {
     return setTextures(textureEntries._textures, force);
 }
Exemple #13
0
SFLayer::~SFLayer(void)
{
	setTextures(NULL);
}
Exemple #14
0
void renderNode(Shader *shader, aiScene const * scene, aiNode *node, bool doShadows)
{
    glMatrixMode(GL_MODELVIEW);

    glPushMatrix();
    aiMatrix4x4 m = node->mTransformation;
    m = m.Transpose();
    glMultMatrixf((float *)&m);

    if (shader == phongShader)
    {
        // store active texture to restore afterwards
        GLint activeTxtUnit;
        glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTxtUnit);

        glMatrixMode(GL_TEXTURE);
        glActiveTexture(GL_TEXTURE6);
        glPushMatrix();
        glMultMatrixf((float *)&m);

        glActiveTexture(activeTxtUnit);
    }

    for (int i = 0; i < node->mNumMeshes; i++)
    {
        int meshIndex = node->mMeshes[i];
        aiMesh *mesh = scene->mMeshes[meshIndex];

        if (mesh->mPrimitiveTypes != aiPrimitiveType_TRIANGLE)
            continue;

        if (shader == phongShader)
        {
            setMaterial(scene, mesh);
        }
        if (shader != simpleShader)
        {
            setTextures(shader, scene, mesh);
        }
        setMeshData(mesh, shader);

        // Draw the mesh
        std::map<aiMesh *, std::vector<unsigned>*>::iterator itr = indexBuffers.find(mesh);
        if (itr != indexBuffers.end())
        {
            std::vector<unsigned> indexBuffer = *itr->second;
            // Found an index buffer! Draw it
            glDrawElements(GL_TRIANGLES,  3*mesh->mNumFaces, GL_UNSIGNED_INT, &indexBuffer[0]);
        }
    }

    for (int i = 0; i < node->mNumChildren; i++)
    {
        aiNode *childNode = node->mChildren[i];
        renderNode(shader, scene, childNode, doShadows);
    }

    if (shader == phongShader)
    {
        // store active texture to restore afterwards
        GLint activeTxtUnit;
        glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTxtUnit);

        glMatrixMode(GL_TEXTURE);
        glActiveTexture(GL_TEXTURE6);
        glPopMatrix();

        glActiveTexture(activeTxtUnit);
    }

    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
}
Exemple #15
0
Volleyball::Volleyball()
{
    setTextures();
    addPlayers();
    addBalls();
}