Clouds::Clouds(Shader *shader, float radius, int rings, int sectors, glm::vec3 center) : SGeode() { this->shader = shader; this->radius = radius; this->rings = rings; this->sectors = sectors; this->center = center; setupCloud(); setUpBuffer(); setupUniformLoc(); createCloudPlane(); }
bool GridNode::init(std::string fileName) { if (!Node::init()) { return false; } //program program = new GLProgram; program->initWithFilenames("gridnode.vert", "gridnode.frag"); program->link(); program->updateUniforms(); _textureName = fileName; _textureID = Director::getInstance()->getTextureCache()->addImage(_textureName)->getName(); auto texture = Director::getInstance()->getTextureCache()->getTextureForKey(fileName); auto size = texture->getContentSize(); setContentSize(size); setUpBuffer( Vec2(0,0),Vec2(0,size.height), Vec2(size.width,size.height), Vec2(size.width,0), Color4B(155,0,0,255)); //vbo glGenBuffers(1, &_vbo); glBindBuffer(GL_ARRAY_BUFFER, _vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)* _bufferCapacity, _buffer, GL_STREAM_DRAW); // vertex glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); // color glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); // texcoord glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORD); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); auto touchListener = EventListenerTouchOneByOne::create(); touchListener->onTouchBegan = CC_CALLBACK_2(GridNode::onTouchbegan,this); touchListener->onTouchEnded = CC_CALLBACK_2(GridNode::onTouchEnded,this); _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); return true; }