当前位置: 首页>>代码示例>>C++>>正文


C++ KeyValue::getMember方法代码示例

本文整理汇总了C++中KeyValue::getMember方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValue::getMember方法的具体用法?C++ KeyValue::getMember怎么用?C++ KeyValue::getMember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KeyValue的用法示例。


在下文中一共展示了KeyValue::getMember方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initDriver


//.........这里部分代码省略.........
            const char *c_str = buffer.data;
            GLuint vertexShader = glCreateShader( GL_VERTEX_SHADER );
            glShaderSource( vertexShader, 1, &c_str, NULL );
            glCompileShader( vertexShader );
            shaders[name] = vertexShader;
            
            GLint status;
            glGetShaderiv( vertexShader, GL_COMPILE_STATUS, &status );
            
            if (status == GL_TRUE) {
                printf("Loaded vertex shader: %s (%d)\n", name, vertexShader);
            } else {
                char buffer[512];
                glGetShaderInfoLog( vertexShader, 512, NULL, buffer );
                
                printf("Error loading vertex shader: %s (%d)\n", name, vertexShader);
                printf("%s\n", buffer);
            }
        }
        
        delete file;
    }
    
    // Compile all the programs.
    for (DirectoryList::iterator i = list.begin(); i != list.end(); ++i) {
        char exten[10];
        util->getFileExtension(exten, (*i).c_str());
        if (strcmp(exten, ".kv") == 0) {
            char name[50];
            util->getFileName(name, (*i).c_str());
            util->getFileNameNoExtension(name, name);
            
            Buffer buffer;
            File *file = filesystem->open((*i).c_str());
            file->readBuffer(&buffer);
            
            KeyValue *kv = util->parseKeyValue(&buffer);
            
            GLuint shaderProgram = glCreateProgram();
            
            KeyValue *shadermembers = kv->getMember("shaders");
            
            if (shadermembers != NULL) {
                unsigned int b = 0;
                KeyValue *member = shadermembers->getMember(b);
                while ((member = shadermembers->getMember(b)) != NULL) {
                    glAttachShader( shaderProgram, shaders[member->getString()] );
                    b++;
                }
            }
            
            KeyValue *fragdatamembers = kv->getMember("fragdata");
            
            if (fragdatamembers != NULL) {
                unsigned int b = 0;
                KeyValue *member = fragdatamembers->getMember(b);
                while ((member = fragdatamembers->getMember(b)) != NULL) {
                    glBindFragDataLocation( shaderProgram, b, member->getString().c_str());
                    b++;
                }
            }
            
            glLinkProgram( shaderProgram );
            glUseProgram( shaderProgram );
            
            GLint posAttrib = glGetAttribLocation( shaderProgram, "position" );
            glEnableVertexAttribArray( posAttrib );
            glVertexAttribPointer( posAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0 );
            
            programs[name] = shaderProgram;
            
            printf("Loaded program: %s (%d)\n", name, shaderProgram);
            
            kv->release();
            file->release();
        }
        
    }
    
    glEnable(GL_TEXTURE_2D);
    glEnable(GL_BLEND);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LESS);
    glBlendEquation( GL_FUNC_ADD );
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    
    loadMaterial("disttex.tga");
    loadMaterial("8.tga");
    
    // load default textures
    ImageData white(1, 1);
    white.setPixel(0, 0, Color(255, 255, 255));
    loadMaterial("white", &white);
    
    ImageData black(1, 1);
    black.setPixel(0, 0, Color(0, 0, 0));
    loadMaterial("black", &black);
    
    glfwSetMouseButtonCallback(&MousePressedCallback);
}
开发者ID:qwook,项目名称:spine,代码行数:101,代码来源:graphics.cpp


注:本文中的KeyValue::getMember方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。