Example #1
0
void ShaderPass::checkError() {
    if(!shader_object) return;

    GLint compile_success;
    glGetShaderiv(shader_object, GL_COMPILE_STATUS, &compile_success);

    GLint info_log_length;
    glGetShaderiv(shader_object, GL_INFO_LOG_LENGTH, &info_log_length);

    const char* resource_desc = !parent->resource_name.empty() ? parent->resource_name.c_str() : "???";

    if(info_log_length > 1) {
        char info_log[info_log_length];

        glGetShaderInfoLog(shader_object, info_log_length, &info_log_length, info_log);

        std::string context;
        errorContext(info_log, context);

        if(!compile_success) {
            throw SDLAppException("%s shader '%s' failed to compile:\n%s\n%s",
                                  shader_object_desc.c_str(),
                                  resource_desc,
                                  info_log,
                                  context.c_str());



        }

        if(shadermanager.warnings) {
            warnLog("%s shader '%s':\n%s\n%s",
                            shader_object_desc.c_str(),
                            resource_desc,
                            info_log,
                            context.c_str());

        }

        return;
    }

    if(!compile_success) {
        throw SDLAppException("%s shader '%s' failed to compile",
                              shader_object_desc.c_str(),
                              resource_desc);
    }
}
CUAGDirectory* VRIAServerSolution::_OpenUAGDirectory( VError& outError)
{
	outError = VE_OK;

	CUAGDirectory *directory = nil;

	CUAGManager *uag = VComponentManager::RetainComponentOfType<CUAGManager>();
	if (uag != NULL)
	{
		if (testAssert(fDesignSolution != NULL))
		{
			StUseLogger logger;
			VMicrosecondsCounter usCounter;

			VProjectItem *dirItem = fDesignSolution->GetProjectItemFromTag( kUAGDirectoryTag);
			if (dirItem != NULL)
			{
				VFilePath directoryPath;
				dirItem->GetFilePath( directoryPath);
			
				usCounter.Start();
				logger.Log( fLoggerID, eL4JML_Information, L"Opening the users and groups directory");
				
				VFile file( directoryPath);
				directory = uag->RetainDirectory( file, FA_READ_WRITE, NULL, NULL, &outError);
			}

			if (directory == NULL && outError == VE_OK)
			{
				VFilePath solpath;
				fDesignSolution->GetSolutionFilePath(solpath);
				solpath.SetExtension(RIAFileKind::kDirectoryFileExtension);
				VFile defaultDirFile(solpath);
				directory = uag->RetainDirectory( defaultDirFile, FA_READ_WRITE, NULL, NULL, &outError, NULL, true);
			}

			if (directory != NULL && outError == VE_OK)
			{
				// Create an "admin" user if needed

				CUAGGroup *adminGroup = directory->RetainSpecialGroup( CUAGDirectory::AdminGroup);
				CUAGGroup *debuggerGroup = directory->RetainSpecialGroup( CUAGDirectory::DebuggerGroup);

				if ((adminGroup != NULL) && (debuggerGroup != NULL))
				{
					StErrorContextInstaller errorContext( VE_UAG_USERNAME_DOES_NOT_EXIST, VE_OK);

					CUAGUser *adminUser = directory->RetainUser( L"admin");
					
					if (adminUser == NULL)
						adminUser = directory->AddOneUser( L"admin", L"", L"", outError);

					if ((outError == VE_OK) && (adminUser != NULL))
					{
						VUUID adminUserID, userID;
						adminUser->GetID( adminUserID);
						
						CUAGUserVector users;
						adminGroup->RetainUsers( users);

						bool hasAdminUser = false;
						for (CUAGUserVector::iterator userIter = users.begin() ; (userIter != users.end()) && !hasAdminUser ; ++userIter)
						{
							(*userIter)->GetID( userID);
							hasAdminUser = (adminUserID == userID);
						}

						if (!hasAdminUser)
							outError = adminUser->PutIntoGroup( adminGroup);

						if (outError == VE_OK)
						{
							users.clear();
							debuggerGroup->RetainUsers( users);

							hasAdminUser = false;
							for (CUAGUserVector::iterator userIter = users.begin() ; (userIter != users.end()) && !hasAdminUser ; ++userIter)
							{
								(*userIter)->GetID( userID);
								hasAdminUser = (adminUserID == userID);
							}

							if (!hasAdminUser)
								outError = adminUser->PutIntoGroup( debuggerGroup);
						}
					}
					ReleaseRefCountable( &adminUser);
				}
				QuickReleaseRefCountable( adminGroup);
				QuickReleaseRefCountable( debuggerGroup);
			}

			if (directory != NULL && outError == VE_OK)
			{
				VString logMsg;
				logMsg.Printf( "Users and groups directory opened (duration: %i ms)", usCounter.Stop()/1000);
				logger.Log( fLoggerID, eL4JML_Information, logMsg);
			}
		}
		uag->Release();
	}
	else
	{
		outError = ThrowError( VE_RIA_UAG_COMPONENT_NOT_FOUND);
	}
	return directory;
}