Tree PreBuild() { Tree haha = NULL; char temp; int size = sizeof(struct TreeNode); scanf("%c", &temp); if(temp != '#'){ haha = (Tree)malloc(size); haha -> Element = temp; haha -> Left = PreBuild(); haha -> Right = PreBuild(); } return haha; }
int main(void) { Tree T = PreBuild(); printf("PrePrint:\t"); PrePrint(T); printf("\n"); printf("InPrint:\t"); InPrint(T); printf("\n"); printf("InPrint_Iter:\t"); InPrint_Iterative(T); printf("\n"); printf("PostPrint:\t"); PostPrint(T); printf("\n"); printf("LevelPrint:\t"); LevelPrint(T); printf("\n"); ListDirectory(T); return 0; }
bool CRhGLShaderProgram::BuildProgram(const GLchar* VertexShader, const GLchar* FragmentShader) { // Shaders MUST consist of both a vertex AND a fragment shader in 2.0... if ( (VertexShader == NULL) || (FragmentShader == NULL) ) return false; PreBuild(); GLuint hVsh = BuildShader( VertexShader, GL_VERTEX_SHADER ); GLuint hFsh = BuildShader( FragmentShader, GL_FRAGMENT_SHADER ); if ( (hVsh == 0) || (hFsh == 0) ) return false; m_hProgram = glCreateProgram(); if ( m_hProgram == 0 ) return false; glAttachShader( m_hProgram, hVsh ); glAttachShader( m_hProgram, hFsh ); // These bindings are forced here so that mesh drawing can enable the // appropriate vertex array based on the same binding values. // Note: These must be done before we attempt to link the program... // Note2: Rhino supports multiple textures but for now we'll only // provide for a single set of texture coordinates. glBindAttribLocation( m_hProgram, ATTRIB_VERTEX, "rglVertex" ); glBindAttribLocation( m_hProgram, ATTRIB_NORMAL, "rglNormal" ); glBindAttribLocation( m_hProgram, ATTRIB_TEXCOORD0, "rglTexCoord0" ); glBindAttribLocation( m_hProgram, ATTRIB_COLOR, "rglColor" ); glLinkProgram( m_hProgram ); GLint Success; glGetProgramiv( m_hProgram, GL_LINK_STATUS, &Success ); if ( Success == GL_FALSE ) { #if defined(_DEBUG) GLint logLength; glGetProgramiv( m_hProgram, GL_INFO_LOG_LENGTH, &logLength ); if (logLength > 0) { GLchar *log = (GLchar *)malloc(logLength); glGetProgramInfoLog( m_hProgram, logLength, &logLength, log); std::cout << "Program link log:\n" << log; free(log); } #endif glDetachShader( m_hProgram, hVsh ); glDetachShader( m_hProgram, hFsh ); glDeleteProgram( m_hProgram ); m_hProgram = 0; } glDeleteShader( hVsh ); glDeleteShader( hFsh ); if ( m_hProgram == 0 ) return false; PostBuild(); return true; }