Exemple #1
0
bool OpenGLApp::checkForErrors(){
	int error = glGetError();
	if (error != GL_NO_ERROR){
		if (error        ==    GL_INVALID_ENUM){
			outputDebugString("GL_INVALID_ENUM");
		} else if (error ==    GL_INVALID_VALUE){
			outputDebugString("GL_INVALID_VALUE");
		} else if (error ==    GL_INVALID_OPERATION){
			outputDebugString("GL_INVALID_OPERATION");
		} else if (error ==    GL_STACK_OVERFLOW){
			outputDebugString("GL_STACK_OVERFLOW");
		} else if (error ==    GL_STACK_UNDERFLOW){
			outputDebugString("GL_STACK_UNDERFLOW");
		} else if (error ==    GL_OUT_OF_MEMORY){
			outputDebugString("GL_OUT_OF_MEMORY");
		} else if (error == GL_INVALID_FRAMEBUFFER_OPERATION){
			outputDebugString("GL_INVALID_FRAMEBUFFER_OPERATION");
		} else {
			outputDebugString("Unrecognized OpenGL error");
		}

		return true;
	}

	return false;
}
void Logger::writeToLog (const String& message)
{
    if (currentLogger != nullptr)
        currentLogger->logMessage (message);
    else
        outputDebugString (message);
}
void D3D10App::exitAPI(){
	delete renderer;

	deleteBuffers();

	if (swapChain){
		// Reset display mode to default
		if (fullscreen) swapChain->SetFullscreenState(false, NULL);
		swapChain->Release();
	}

	if (device){
		ULONG count = device->Release();
#ifdef _DEBUG
		if (count){
			char str[512];
			sprintf(str, "There are %d unreleased references left on the D3D device!\n", count);
			outputDebugString(str);
		}
#endif
		device = NULL;
	}

	DestroyWindow(hwnd);
}
Exemple #4
0
	void WriteStopLogString( FILE *traceOut )
	{
#if defined(_WIN32)// && defined(_DEBUG)
        if(IsDebugOutEnabled())
		    outputDebugString(
                NULL,
                c_STOP_LOG_FILE_STR, 
                getpid(),
			    GetCurrentTimeString( TF_PRINT_MILLISECONDS ).c_str());
#endif
		// записываем строчку открытия log файла
#ifndef __unix__
		fwprintf( traceOut, c_STOP_LOG_FILE_STR, 
#else
		KLSTD_USES_CONVERSION;
		fprintf( traceOut, KLSTD_W2CA(c_STOP_LOG_FILE_STR), 
#endif
#ifdef N_PLAT_NLM
                        0,  
#else
			getpid(),
#endif
            GetCurrentTimeString( TF_PRINT_MILLISECONDS ).c_str() );	
		fflush( traceOut );
	}
void Renderer::apply(){

#ifdef DEBUG
	if (!wasReset){
		outputDebugString("Warning: reset() not called before apply()");
	}
	wasReset = false;
#endif


	if (selectedShader != DONTCARE){
		changeShader(selectedShader);
		applyConstants();
	}

/*	for (uint i = 0; i < nImageUnits; i++){
		if (selectedTextures[i] != DONTCARE) changeTexture(i, selectedTextures[i]);
	}*/
	applyTextures();

/*	for (uint i = 0; i < MAX_SAMPLERSTATE; i++){
		if (selectedSamplerStates[i] != DONTCARE) changeSamplerState(i, selectedSamplerStates[i]);
	}*/
	applySamplerStates();

	changeVertexFormat(selectedVertexFormat);
	for (uint i = 0; i < MAX_VERTEXSTREAM; i++){
		if (selectedVertexBuffers[i] != DONTCARE){
			changeVertexBuffer(i, selectedVertexBuffers[i], selectedOffsets[i]);
		}
	}
	if (selectedIndexBuffer != DONTCARE) changeIndexBuffer(selectedIndexBuffer);

	if (selectedDepthState != DONTCARE){
		changeDepthState(selectedDepthState, selectedStencilRef);
	}
	if (selectedBlendState != DONTCARE){
		changeBlendState(selectedBlendState, selectedSampleMask);
	}
	if (selectedRasterizerState != DONTCARE) changeRasterizerState(selectedRasterizerState);

//	reset();
}
int DebuggerEngine::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QThread::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: successfulAttach(); break;
        case 1: outputDebugString((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 2: outputToConsole((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 3: debuggerError((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 4: processCreated(); break;
        case 5: breakpointSignal((*reinterpret_cast< Breakpoint*(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 6;
    }
    return _id;
}
Exemple #7
0
	void WriteStartLogString( FILE *traceOut )
	{
#if defined(_WIN32)// && defined(_DEBUG)
        if(IsDebugOutEnabled())
		    outputDebugString(
                    NULL,
                    c_START_LOG_FILE_STR, 
                    getpid(),
			        GetCurrentTimeString( TF_PRINT_MILLISECONDS ).c_str());
#endif
		// записываем строчку открытия log файла
#ifndef __unix__
		fwprintf( traceOut, c_START_LOG_FILE_STR, 
#else
                KLSTD_USES_CONVERSION; 
		fprintf( traceOut,KLSTD_W2CA(c_START_LOG_FILE_STR), 
#endif
#ifdef N_PLAT_NLM
                        0,  
#else
			getpid(),
#endif
			GetCurrentTimeString( TF_PRINT_MILLISECONDS ).c_str() );	



    std::wstring wstrOsName, wstrOsVer;

    GetSystemVersionInfo(wstrOsName, wstrOsVer);

    fprintf(traceOut, "System:\t %ls\nVersion:\t%ls\n\n", wstrOsName.c_str(), wstrOsVer.c_str());





		fflush( traceOut );
	}
Exemple #8
0
void MainWindow::startSWG() {
    QStringList arguments;

    QSettings settings;
    QString folder = settings.value("swg_folder").toString();
    bool multiple = settings.value("multiple_instances").toBool();
    ConfigParser* parser = new ConfigParser();
    GameProcess* process = new GameProcess(parser, NULL);

    parser->connect(parser, SIGNAL(errorSignal(QString)), process, SLOT(outputDebugString(QString)));

    try {
        if (parser->loadFile(folder, "swgemu.cfg") != 0) {
            QMessageBox::warning(this, "Warning", "There was an issue parsing the swg config files! To restore them run full scan!");
        }
    } catch (...) {
        QMessageBox::warning(this, "Warning", "There was an issue parsing the swg config files! To restore them run full scan!");
    }

    QVector<ConfigValue> loginServerAddresses = parser->getConfigValues("ClientGame", "loginServerAddress0");
    QVector<ConfigValue> loginServerPorts = parser->getConfigValues("ClientGame", "loginServerPort0");

    if (loginServerAddresses.size() > 1) {
        QString warningString;
        QTextStream stream(&warningString);

        stream << "You have several login server addresses defined in the following swg config files: ";

        for (int i = 0; i < loginServerAddresses.size(); ++i) {
            const ConfigValue val = loginServerAddresses.at(i);

            stream << val.fileName << " ";
        }

        stream << " client will use the value: " << parser->getStringConfigValue("ClientGame", "loginServerAddress0");

        QMessageBox::warning(this, "Warning", warningString);
    }

    if (loginServerPorts.size() > 1) {
        QString warningString;
        QTextStream stream(&warningString);

        stream << "You have several login server ports defined in the following swg config files: ";

        for (int i = 0; i < loginServerPorts.size(); ++i) {
            const ConfigValue val = loginServerPorts.at(i);

            stream << val.fileName << " ";
        }

        stream << " client will use the value: " << parser->getStringConfigValue("ClientGame", "loginServerPort0");

        QMessageBox::warning(this, "Warning", warningString);
    }

    LoginServer* server = loginServers->getServer(ui->comboBox_login->currentText());

    QString loginAddress = parser->getStringConfigValue("ClientGame", "loginServerAddress0", "loginServerAddress0");
    QString port = parser->getStringConfigValue("ClientGame", "loginServerAddress0", "loginServerPort0");

    if (loginAddress != server->getHost() || port != QString::number(server->getPort())) {
#ifdef Q_OS_WIN32
        QFile loginFile(folder + "\\swgemu_login.cfg");
#else
        QFile loginFile(folder + "/swgemu_login.cfg");
#endif

        if (loginFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
            QTextStream stream(&loginFile);
            stream << "[ClientGame]" << endl;
            stream << "loginServerAddress0=" << server->getHost() << endl;
            stream << "loginServerPort0=" << server->getPort();

            loginFile.close();
        } else {
            QMessageBox::warning(this, "Error", "Could not write swgemu_login.cfg!");
        }
    }
/*
    arguments.append("--");
    arguments.append("-s");
    arguments.append("ClientGame");
    arguments.append("cameraFarPlane=4096");
*/
/*
    arguments.append("--");
    arguments.append("-s");
    arguments.append("SharedFoundation");
    arguments.append("minFrameRate=60");
*/
  //  QFile executable()
/*
    arguments.append("--");
    arguments.append("-s");
    arguments.append("ClientTerrain");
    arguments.append("dynamicNearFloraDistance=128");

    arguments.append("--");
    arguments.append("-s");
    arguments.append("ClientTerrain");
    arguments.append("staticNonCollidableFloraDistance=2048");

    arguments.append("--");
    arguments.append("-s");
    arguments.append("ClientProceduralTerrainAppearance_LevelOfDetail");
    arguments.append("forceHighThreshold=40");

    arguments.append("--");
    arguments.append("-s");
    arguments.append("ClientProceduralTerrainAppearance_LevelOfDetail");
    arguments.append("threshold=40");

    arguments.append("--");
    arguments.append("-s");
    arguments.append("ClientProceduralTerrainAppearance_LevelOfDetail");
    arguments.append("heightBiasMax=4096");
*/
    //ClientProceduralTerrainAppearance_LevelOfDetail.heightBiasMax



    //ClientGame.cameraFarPlane

    /*ClientProceduralTerrainAppearance_LevelOfDetail.threshold*/


    /*ClientProceduralTerrainAppearance_LevelOfDetail.forceHighThreshold*/


    arguments.append("--");
    arguments.append("-s");
    arguments.append("ClientGame");

    if (server != NULL)
        arguments.append("loginServerAddress0=" + server->getHost());
    else
        arguments.append("loginServerAddress0=" + LoginServers::defaultLoginAddress);

    if (server == NULL)
        arguments.append("loginServerPort0=" + QString::number(LoginServers::defaultLoginPort));
    else
        arguments.append("loginServerPort0=" + QString::number(server->getPort()));

    arguments.append("-s");
    arguments.append("Station");
    arguments.append("gameFeatures=34929");

    if (multiple) {
        if (parser->hasConfigValue("SwgClient", "allowMultipleInstances")) {
            bool val = parser->getBooleanConfigValue("SwgClient", "allowMultipleInstances");

            if (!val) {
                QMessageBox::warning(this, "Warning", "You selected the multiple instances option but you have set it to false in the swg config files!");
            }
        }

        arguments.append("-s");
        arguments.append("SwgClient");
        arguments.append("allowMultipleInstances=true");
    }

    qDebug() << "start swg with arguments " << arguments;

    connect(process, SIGNAL(processFinished(GameProcess*,int)), this, SLOT(gameProcessFinished(GameProcess*,int)));

    ui->tabWidget->addTab(process, "Process " + QString::number(++gameProcessesCount));
    gameProcesses.append(process);
    QTabBar* bar = ui->tabWidget->tabBar();
    int tabIndex = ui->tabWidget->indexOf(process);
    bar->setTabTextColor(tabIndex, Qt::green);
    bar->setTabIcon(tabIndex, QIcon(":/img/tab.svg"));

    //process->show();
    bool startResult = process->start(folder, gameExecutable, arguments);

    if (startResult) {
        //showMinimized();
        if (settings.value("minimize_after_start", false).toBool()) {
            systemTrayIcon->show();

            QTimer::singleShot(0, this, SLOT(hide()));
        }
    }
}
ShaderID Renderer::addShader(const char *fileName, const char **attributeNames, const int nAttributes, const char *extra, const StreamDesc *streamOut, const uint nElements, const uint flags){
	FILE *file = fopen(fileName, "rb");
	ShaderID res = SHADER_NONE;

	if (file == NULL){
		ErrorMsg(String("Couldn't load \"") + fileName + "\"");
	} else {
#ifdef DEBUG
		char str[66];
		str[0] = '\n';
		memset(str + 1, '-', sizeof(str) - 2);
		str[sizeof(str) - 1] = '\0';
		size_t lfn = strlen(fileName);
		size_t start = (sizeof(str) - lfn) / 2;

		str[start - 1]   = '[';
		str[start + lfn] = ']';
		strncpy(str + start, fileName, lfn);
		outputDebugString(str);
#endif

		// Find file size
		fseek(file, 0, SEEK_END);
		int length = ftell(file);
		fseek(file, 0, SEEK_SET);

		char *shaderText = new char[length + 1];
		fread(shaderText, length, 1, file);
		fclose(file);
		shaderText[length] = '\0';

		char *vs = strstr(shaderText, "[Vertex shader]");
		char *gs = strstr(shaderText, "[Geometry shader]");
		char *fs = strstr(shaderText, "[Fragment shader]");

		char *header = (shaderText[0] != '[')? shaderText : NULL;

		int vsLine = 0;
		if (vs != NULL){
			*vs = '\0';
			vs += 15;
			while (*vs == '\r' || *vs == '\n') vs++;

			char *str = shaderText;
			while (str < vs){
                if (*str == '\n') vsLine++;
				str++;
			}
		}

		int gsLine = 0;
		if (gs != NULL){
			*gs = '\0';
			gs += 17;
			while (*gs == '\r' || *gs == '\n') gs++;

			char *str = shaderText;
			while (str < gs){
                if (*str == '\n') gsLine++;
				str++;
			}
		}

		int fsLine = 0;
		if (fs != NULL){
			*fs = '\0';
			fs += 17;
			while (*fs == '\r' || *fs == '\n') fs++;

			char *str = shaderText;
			while (str < fs){
                if (*str == '\n') fsLine++;
				str++;
			}
		}

		res = addShader(vs, gs, fs, vsLine, gsLine, fsLine, header, extra, streamOut, nElements, fileName, attributeNames, nAttributes, flags);
		delete shaderText;
	}
	return res;
}