blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 3
264
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
85
| license_type
stringclasses 2
values | repo_name
stringlengths 5
140
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 905
values | visit_date
timestamp[us]date 2015-08-09 11:21:18
2023-09-06 10:45:07
| revision_date
timestamp[us]date 1997-09-14 05:04:47
2023-09-17 19:19:19
| committer_date
timestamp[us]date 1997-09-14 05:04:47
2023-09-06 06:22:19
| github_id
int64 3.89k
681M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us]date 2012-06-07 00:51:45
2023-09-14 21:58:39
⌀ | gha_created_at
timestamp[us]date 2008-03-27 23:40:48
2023-08-21 23:17:38
⌀ | gha_language
stringclasses 141
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
10.4M
| extension
stringclasses 115
values | content
stringlengths 3
10.4M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
158
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5fcd8a3374ec9f569544647bc616d1c212277e25 | 313bb78d5b0ee1935099fd693ecd1016f65abb9d | /source/SetTransparency/SetTransparency.cpp | c096259ce5d9af235d05419d78e0c2645015eed0 | [] | no_license | kaida-kaida/settransparency | 915acef6c100d129a6c3b7428b0bb67de299efa9 | 18f11b2e24dad3e642c70c109c9a2ccadbcdf838 | refs/heads/master | 2021-01-11T14:12:18.549999 | 2014-03-29T09:11:59 | 2014-03-29T09:11:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,301 | cpp | // SetTransparency.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "SetTransparency.h"
#include <string>
using namespace std;
HWND hWnd_main = NULL;
DWORD g_pid = 0;
BYTE g_alpha = 0;
wstring g_app_title = wstring(L"");
wregex g_pattern_title;
BOOL CALLBACK EnumWindowsProc(
_In_ HWND hwnd,
_In_ LPARAM lParam
)
{
DWORD pid;
DWORD result;
result = GetWindowThreadProcessId(hwnd, &pid);
// Match PID
if (pid == g_pid)
{
hWnd_main = hwnd;
wchar_t buffer[MAXBYTE] = {0};
GetWindowTextW(hwnd, buffer, MAXBYTE);
wstring titleStr = wstring(buffer);
// Match main window title
if (regex_match(titleStr, g_pattern_title))
{
//MessageBox(NULL, _T("OK"), _T("OK"), MB_OK);
if (IsWindow(hwnd))
{
LONG winLong = GetWindowLong(hwnd, GWL_EXSTYLE);
winLong |= WS_EX_LAYERED;
SetWindowLong(hwnd, GWL_EXSTYLE, winLong);
SetLayeredWindowAttributes(hwnd, 0, g_alpha, LWA_ALPHA);
}
}
}
return TRUE;
}
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPTSTR lpCmdLine,
_In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
wstring parametersStr = wstring(lpCmdLine);
wstring parPid = wstring(L"");
wstring parAlpha = wstring(L"");
wstring parAppTitle = wstring(L"");
// Parser the input as 3 parameters
wregex par_pattern(L"(\\S+)\\s+(\\S+)\\s+(.*)", regex_constants::ECMAScript);
if (regex_match(parametersStr, par_pattern))
{
parPid = regex_replace(parametersStr, par_pattern, wstring(L"$1"));
parAlpha = regex_replace(parametersStr, par_pattern, wstring(L"$2"));
parAppTitle = regex_replace(parametersStr, par_pattern, wstring(L"$3"));
}
if ( (!parPid.empty()) && (!parAlpha.empty()) && (!parAppTitle.empty()) )
{
//MessageBox(NULL, _T("OK"), _T("OK"), MB_OK);
g_pid = stoul(parPid, nullptr);
g_alpha = static_cast<BYTE>(stoul(parAlpha, nullptr));
g_app_title = parAppTitle;
g_pattern_title = wregex(wstring(L".*") + g_app_title + wstring(L".*"), regex_constants::ECMAScript);
// Validate the process
if (OpenProcess(PROCESS_QUERY_INFORMATION, 0, g_pid) != NULL)
{
EnumWindows(EnumWindowsProc, NULL);
}
}
return 0;
}
| [
"[email protected]"
] | |
0d9d25ccb823f77f2bdb6a009d150bc47c03325c | c0c025007b7732bc3ca309b834b2e3e210276577 | /sample/accounting_Beta2/homepage_1.h | afa14947c21c282433b463e9a411adaf536814c2 | [] | no_license | gukurhgodp31/CSharpHomework | 1d936814604084a521141f93cbfe8a4272cee7a4 | 6e5ff3787a3c992e2574acd3a9c1aad5457474a4 | refs/heads/master | 2023-04-19T19:32:42.746660 | 2021-04-13T02:57:28 | 2021-04-13T02:57:28 | 365,220,500 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 674 | h | #ifndef HOMEPAGE_1_H
#define HOMEPAGE_1_H
#include <QDialog>
#include <QtCharts>
using namespace QtCharts;
namespace Ui {
class Homepage_1;
}
class Homepage_1 : public QDialog
{
Q_OBJECT
public:
explicit Homepage_1(QWidget *parent = 0);
~Homepage_1();
QString income;
QString output;
QString remain;
QChart *progressDonut(double budget);
int password;
void list();
private slots:
void on_setBtn_clicked();
void on_pushButton_clicked();
void showProgressDonut();
void on_pushButton_3_clicked();
void change2AcountStatement();
void change2Chart();
private:
Ui::Homepage_1 *ui;
};
#endif // HOMEPAGE_1_H
| [
"[email protected]"
] | |
0ae5dd53148517d2642eae6cf5f0b9a370f6c33c | aab49f04e01a3f248ce5adb0d65088bc921fb380 | /1.Introduction-to-Programming-Practice/week-10/55-reverse-array-elements.cpp | b12bfb9011615133fbdfa02852393bee1b206284 | [] | no_license | gyokkoo/Introduction-to-Programming-FMI-2017 | bb8983c159cf802cf3b9b533e503a3dceaf24b4a | 6a467f894991d69c6a06cd36309b600d46e91a93 | refs/heads/master | 2023-06-14T10:27:10.622804 | 2021-07-07T16:37:41 | 2021-07-07T16:37:41 | 107,156,320 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,197 | cpp | /**
*
* Solution to exercises
* Introduction to programming course
* Faculty of Mathematics and Informatics of Sofia University
* Winter semester 2017/2018
*
* @author Gyokan Syuleymanov
* @idnumber 62117
* @task 55
* @compiler GCC
*
* Assignment:
* Да се състави програма, чрез която предварително въведени N
* естествени числа от интервала [0..5000] в едномерен масив се
* разменят местата на елементите му в обратен ред.
* Пример: 1,2,4,3,5,6,7 Изход: 7,6,5,3,4,2,1
*/
#include <iostream>
using namespace std;
const int MAX_SIZE = 1000;
int main()
{
int arr[MAX_SIZE];
int n = 0, tempElement = 0;
cout << "Enter N, and N integer numbers" << endl;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> arr[i];
}
// Reverse elements
for (int i = 0; i < n / 2; i++)
{
tempElement = arr[i];
arr[i] = arr[n - i - 1];
arr[n - i - 1] = tempElement;
}
// Print array
for (int i = 0; i < n; i++)
{
cout << arr[i] << " ";
}
cout << endl;
return 0;
}
| [
"[email protected]"
] | |
c50ff5c02374ef42c44345bceadfbb580319f541 | f413bf20ddbfd37c171385cf095a39392fcb4867 | /Source/Rendering/Misc/vaZoomTool.h | 3eb09ff25ce044c62a61f447c15377d0c59c40a8 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | NewKidHere/XeGTAO | be44d3c0db9688958c7088f28113d585f25c5e58 | 65b387cd2fa7dd14b1382807a6be9750ea305376 | refs/heads/master | 2023-08-13T19:32:51.044319 | 2021-09-20T17:07:18 | 2021-09-20T17:07:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,329 | h | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016-2021, Intel Corporation
//
// SPDX-License-Identifier: MIT
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Author(s): Filip Strugar ([email protected])
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "Core/vaCoreIncludes.h"
#include "Core/vaUI.h"
#include "Rendering/vaRenderingIncludes.h"
namespace Vanilla
{
class vaInputMouseBase;
class vaZoomTool : public Vanilla::vaRenderingModule, public vaUIPanel
{
public:
struct Settings
{
bool Enabled = false;
int ZoomFactor = 4;
vaVector2i BoxPos = vaVector2i( 400, 300 );
vaVector2i BoxSize = vaVector2i( 128, 96 );
Settings( ) { }
};
protected:
shared_ptr<vaTexture> m_edgesTexture;
Settings m_settings;
vaTypedConstantBufferWrapper<ZoomToolShaderConstants>
m_constantsBuffer;
vaAutoRMI<vaComputeShader> m_CSZoomToolFloat;
vaAutoRMI<vaComputeShader> m_CSZoomToolUnorm;
public:
vaZoomTool( const vaRenderingModuleParams & params );
~vaZoomTool( );
public:
Settings & Settings( ) { return m_settings; }
void HandleMouseInputs( vaInputMouseBase & mouseInput );
virtual void Draw( vaRenderDeviceContext & renderContext, shared_ptr<vaTexture> colorInOut ); // colorInOut is not a const reference for a reason (can change if it's the current RT)
protected:
virtual void UpdateConstants( vaRenderDeviceContext & renderContext );
private:
virtual void UIPanelTickAlways( vaApplicationBase & application ) override;
virtual void UIPanelTick( vaApplicationBase & application ) override;
};
}
| [
"[email protected]"
] | |
94dfa9a8b39db13f3e95f76815789cf77d194269 | 1dbf007249acad6038d2aaa1751cbde7e7842c53 | /cdn/src/v2/model/RequestLimitRules.cpp | ad5a3fbf48542d500a7708f0f3e57ed8c94a3aba | [] | permissive | huaweicloud/huaweicloud-sdk-cpp-v3 | 24fc8d93c922598376bdb7d009e12378dff5dd20 | 71674f4afbb0cd5950f880ec516cfabcde71afe4 | refs/heads/master | 2023-08-04T19:37:47.187698 | 2023-08-03T08:25:43 | 2023-08-03T08:25:43 | 324,328,641 | 11 | 10 | Apache-2.0 | 2021-06-24T07:25:26 | 2020-12-25T09:11:43 | C++ | UTF-8 | C++ | false | false | 6,745 | cpp |
#include "huaweicloud/cdn/v2/model/RequestLimitRules.h"
namespace HuaweiCloud {
namespace Sdk {
namespace Cdn {
namespace V2 {
namespace Model {
RequestLimitRules::RequestLimitRules()
{
status_ = "";
statusIsSet_ = false;
priority_ = 0;
priorityIsSet_ = false;
matchType_ = "";
matchTypeIsSet_ = false;
matchValue_ = "";
matchValueIsSet_ = false;
type_ = "";
typeIsSet_ = false;
limitRateAfter_ = 0L;
limitRateAfterIsSet_ = false;
limitRateValue_ = 0;
limitRateValueIsSet_ = false;
}
RequestLimitRules::~RequestLimitRules() = default;
void RequestLimitRules::validate()
{
}
web::json::value RequestLimitRules::toJson() const
{
web::json::value val = web::json::value::object();
if(statusIsSet_) {
val[utility::conversions::to_string_t("status")] = ModelBase::toJson(status_);
}
if(priorityIsSet_) {
val[utility::conversions::to_string_t("priority")] = ModelBase::toJson(priority_);
}
if(matchTypeIsSet_) {
val[utility::conversions::to_string_t("match_type")] = ModelBase::toJson(matchType_);
}
if(matchValueIsSet_) {
val[utility::conversions::to_string_t("match_value")] = ModelBase::toJson(matchValue_);
}
if(typeIsSet_) {
val[utility::conversions::to_string_t("type")] = ModelBase::toJson(type_);
}
if(limitRateAfterIsSet_) {
val[utility::conversions::to_string_t("limit_rate_after")] = ModelBase::toJson(limitRateAfter_);
}
if(limitRateValueIsSet_) {
val[utility::conversions::to_string_t("limit_rate_value")] = ModelBase::toJson(limitRateValue_);
}
return val;
}
bool RequestLimitRules::fromJson(const web::json::value& val)
{
bool ok = true;
if(val.has_field(utility::conversions::to_string_t("status"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("status"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setStatus(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("priority"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("priority"));
if(!fieldValue.is_null())
{
int32_t refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setPriority(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("match_type"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("match_type"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setMatchType(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("match_value"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("match_value"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setMatchValue(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("type"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("type"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setType(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("limit_rate_after"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("limit_rate_after"));
if(!fieldValue.is_null())
{
int64_t refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setLimitRateAfter(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("limit_rate_value"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("limit_rate_value"));
if(!fieldValue.is_null())
{
int32_t refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setLimitRateValue(refVal);
}
}
return ok;
}
std::string RequestLimitRules::getStatus() const
{
return status_;
}
void RequestLimitRules::setStatus(const std::string& value)
{
status_ = value;
statusIsSet_ = true;
}
bool RequestLimitRules::statusIsSet() const
{
return statusIsSet_;
}
void RequestLimitRules::unsetstatus()
{
statusIsSet_ = false;
}
int32_t RequestLimitRules::getPriority() const
{
return priority_;
}
void RequestLimitRules::setPriority(int32_t value)
{
priority_ = value;
priorityIsSet_ = true;
}
bool RequestLimitRules::priorityIsSet() const
{
return priorityIsSet_;
}
void RequestLimitRules::unsetpriority()
{
priorityIsSet_ = false;
}
std::string RequestLimitRules::getMatchType() const
{
return matchType_;
}
void RequestLimitRules::setMatchType(const std::string& value)
{
matchType_ = value;
matchTypeIsSet_ = true;
}
bool RequestLimitRules::matchTypeIsSet() const
{
return matchTypeIsSet_;
}
void RequestLimitRules::unsetmatchType()
{
matchTypeIsSet_ = false;
}
std::string RequestLimitRules::getMatchValue() const
{
return matchValue_;
}
void RequestLimitRules::setMatchValue(const std::string& value)
{
matchValue_ = value;
matchValueIsSet_ = true;
}
bool RequestLimitRules::matchValueIsSet() const
{
return matchValueIsSet_;
}
void RequestLimitRules::unsetmatchValue()
{
matchValueIsSet_ = false;
}
std::string RequestLimitRules::getType() const
{
return type_;
}
void RequestLimitRules::setType(const std::string& value)
{
type_ = value;
typeIsSet_ = true;
}
bool RequestLimitRules::typeIsSet() const
{
return typeIsSet_;
}
void RequestLimitRules::unsettype()
{
typeIsSet_ = false;
}
int64_t RequestLimitRules::getLimitRateAfter() const
{
return limitRateAfter_;
}
void RequestLimitRules::setLimitRateAfter(int64_t value)
{
limitRateAfter_ = value;
limitRateAfterIsSet_ = true;
}
bool RequestLimitRules::limitRateAfterIsSet() const
{
return limitRateAfterIsSet_;
}
void RequestLimitRules::unsetlimitRateAfter()
{
limitRateAfterIsSet_ = false;
}
int32_t RequestLimitRules::getLimitRateValue() const
{
return limitRateValue_;
}
void RequestLimitRules::setLimitRateValue(int32_t value)
{
limitRateValue_ = value;
limitRateValueIsSet_ = true;
}
bool RequestLimitRules::limitRateValueIsSet() const
{
return limitRateValueIsSet_;
}
void RequestLimitRules::unsetlimitRateValue()
{
limitRateValueIsSet_ = false;
}
}
}
}
}
}
| [
"[email protected]"
] | |
912f25fab5805c732460a1c894012b9d8e4b0240 | d1e88b853c50997dbc16dca812fe9b0e04bbf759 | /myserver.h | 3a0242657c1aba49af67392c4501c923f2f9f2ca | [] | no_license | HelloAWorld/myserverclient | ba64690880b4fffb30b1b9de56ed433683ff573c | c639b5716fd6750a5ec16e06cc70be794e92b94d | refs/heads/master | 2021-01-05T13:21:58.686315 | 2020-02-17T06:32:26 | 2020-02-17T06:32:26 | 241,034,281 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 406 | h | #ifndef __MY_SERVER_H__
#define __MY_SERVER_H__
#include "sys/epoll.h"
#include "sys/socket.h"
#include "sys/types.h"
#include "mysocket.h"
#include <map>
class CMyServer
{
public:
CMyServer();
int create_server(int port);
int epoll_bind();
int start_loop();
int handle(int fd);
int end_loop();
private:
int m_ep_fd;
CMySocket m_serversocket;
std::map<int, CMySocket *> m_mapClients;
};
#endif
| [
"[email protected]"
] | |
b43ceb5a62ae838017fbcf328f14a1469fd9bc74 | d62a7af792a62892e39a13e4d5eecc045172f5f6 | /Source/Player.cpp | 8f8e251c1b169117e0a4ef987988ed7b114b2236 | [] | no_license | MasterSofter/LunarLander | 2317985d1c12b2b664f283836bda07b85fa86d8e | d675b34767ee4747ffad8cd3ecf092455f8a5ef1 | refs/heads/master | 2020-04-23T11:18:14.174369 | 2019-02-17T14:37:09 | 2019-02-17T14:37:09 | 171,132,065 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,930 | cpp | #include "Player.h"
#include "CommandQueue.h"
#include "LunarModuleNode.h"
#include <SFML/Network/Packet.hpp>
#include <map>
#include <string>
#include <algorithm>
using namespace std::placeholders;
struct ThrustOn
{
ThrustOn(double t) {thrust = t;}
void operator() (LunarModuleNode& lunarModule, sf::Time) const {
if(!lunarModule.hasLanded())
lunarModule.setThrust(lunarModule.maxThrust() * thrust);
}
double thrust;
};
struct ThrustPlus
{
ThrustPlus(double val) { delta = val; }
void operator() (LunarModuleNode& lunarModule, sf::Time) const {
if(!lunarModule.hasLanded())
lunarModule.setThrust(lunarModule.getThrust() + lunarModule.maxThrust() * delta);
}
double delta;
};
struct TorqueRightOn
{
void operator() (LunarModuleNode& lunarModule, sf::Time) const {
if(!lunarModule.hasLanded())
lunarModule.setTorque(-1);
}
};
struct TorqueLeftOn
{
void operator() (LunarModuleNode& lunarModule, sf::Time) const {
if(!lunarModule.hasLanded())
lunarModule.setTorque(1);
}
};
struct TorqueOff
{
void operator() (LunarModuleNode& lunarModule, sf::Time) const {
lunarModule.setTorque(0);
}
};
Player::Player(const KeyBinding* binding)
: _keyBindingPtr(binding),
_currentMissionStatus(MissionRunning)
{
initializeActions();
}
void Player::handleEvent(const sf::Event& event, CommandQueue& commands)
{
// Event
if (event.type == sf::Event::KeyPressed || event.type == sf::Event::KeyReleased)
{
Action action;
if (_keyBindingPtr && _keyBindingPtr->checkAction(event, action))
commands.push(_actionBinding[action]);
}
}
void Player::handleRealtimeInput(CommandQueue& commands)
{
// Lookup all actions and push corresponding commands to queue
std::vector<Action> activeActions = _keyBindingPtr->getRealtimeActions();
for(auto& action : activeActions)
commands.push(_actionBinding[action]);
}
void Player::setMissionStatus(MissionStatus status)
{
_currentMissionStatus = status;
}
void Player::initializeActions()
{
_actionBinding[PlayerAction::ThrustOn].action = derivedAction<LunarModuleNode>(ThrustOn(1.f));
_actionBinding[PlayerAction::ThrustOff].action = derivedAction<LunarModuleNode>(ThrustOn(0.f));
_actionBinding[PlayerAction::ThrustHalf].action = derivedAction<LunarModuleNode>(ThrustOn(0.5f));
_actionBinding[PlayerAction::ThrustPlus].action = derivedAction<LunarModuleNode>(ThrustPlus(0.1f));
_actionBinding[PlayerAction::ThrustMinus].action = derivedAction<LunarModuleNode>(ThrustPlus(-0.1f));
_actionBinding[PlayerAction::TorqueRithtOn].action = derivedAction<LunarModuleNode>(TorqueRightOn());
_actionBinding[PlayerAction::TorqueLeftOn].action = derivedAction<LunarModuleNode>(TorqueLeftOn());
_actionBinding[PlayerAction::TorqueOff].action = derivedAction<LunarModuleNode>(TorqueOff());
for(auto it = _actionBinding.begin(); it != _actionBinding.end(); ++it)
it->second.category = Category::Type::SceneLunarModule;
}
| [
"[email protected]"
] | |
bc8917997920f1de0f1bcc31a59181d0cb1ff8a8 | 1cc1b1a94493e6962cad12f1f89e584bf0311e8f | /RemoveDuplicatesFromSortedArray.cpp | fe8aedd190f5d7f8560f1d394cd1939845df75d0 | [] | no_license | LeonXJ/leonleetcode | 26c138f8cdc46c974ae4912039949eddbc3a46aa | 42be6485cc586b1f13b08ef0f938762d3f05f009 | refs/heads/master | 2016-09-16T02:26:53.063483 | 2013-09-10T09:02:09 | 2013-09-10T09:02:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 507 | cpp | int removeDuplicates(int A[], int n) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(!A || n==0){
return 0;
}
if(n==1){
return 1;
}
int iFirst = 0;
int iSecond = 1;
for(iSecond = 1; iSecond<n; ++iSecond){
if(A[iFirst] != A[iSecond]){
++iFirst;
A[iFirst] = A[iSecond];
}
}
return iFirst+1;
}
| [
"[email protected]"
] | |
40babb99421c5d116731e63df88d877e99bd4615 | 877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a | /app/src/main/cpp/dir521/dir522/dir572/dir2774/file3555.cpp | 06c1721f12a02022b063356031f7b4244d01c1db | [] | no_license | tgeng/HugeProject | 829c3bdfb7cbaf57727c41263212d4a67e3eb93d | 4488d3b765e8827636ce5e878baacdf388710ef2 | refs/heads/master | 2022-08-21T16:58:54.161627 | 2020-05-28T01:54:03 | 2020-05-28T01:54:03 | 267,468,475 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 111 | cpp | #ifndef file3555
#error "macro file3555 must be defined"
#endif
static const char* file3555String = "file3555"; | [
"[email protected]"
] | |
830a3d97f42f7ab793fca58619b7547f82cf69ce | 9fb71ba51dd38af8c22bbe06fb4dc460c8c0d7df | /src/Density/check_density_continuity_at_mt.hpp | 56a68123a0a579bcdcee8a501b015b564bc1c350 | [
"BSD-2-Clause"
] | permissive | ckae95/SIRIUS | 15e279fb24220bf10ebce0fd2a9630cdc3e2ac67 | ecb7edb4f19577c85b0cec82aa6a0d5374ee1f33 | refs/heads/master | 2021-04-09T15:50:43.754267 | 2018-03-16T15:50:06 | 2018-03-16T15:50:06 | 125,530,189 | 0 | 0 | BSD-2-Clause | 2018-03-16T14:50:45 | 2018-03-16T14:50:45 | null | UTF-8 | C++ | false | false | 1,399 | hpp | //inline void Density::check_density_continuity_at_mt()
//{
// // generate plane-wave coefficients of the potential in the interstitial region
// ctx_.fft().input(&rho_->f_it<global>(0));
// ctx_.fft().transform(-1);
// ctx_.fft().output(ctx_.num_gvec(), ctx_.fft_index(), &rho_->f_pw(0));
//
// SHT sht(ctx_.lmax_rho());
//
// double diff = 0.0;
// for (int ia = 0; ia < ctx_.num_atoms(); ia++)
// {
// for (int itp = 0; itp < sht.num_points(); itp++)
// {
// double vc[3];
// for (int x = 0; x < 3; x++) vc[x] = sht.coord(x, itp) * ctx_.atom(ia)->mt_radius();
//
// double val_it = 0.0;
// for (int ig = 0; ig < ctx_.num_gvec(); ig++)
// {
// double vgc[3];
// ctx_.get_coordinates<cartesian, reciprocal>(ctx_.gvec(ig), vgc);
// val_it += real(rho_->f_pw(ig) * exp(double_complex(0.0, Utils::scalar_product(vc, vgc))));
// }
//
// double val_mt = 0.0;
// for (int lm = 0; lm < ctx_.lmmax_rho(); lm++)
// val_mt += rho_->f_rlm(lm, ctx_.atom(ia)->num_mt_points() - 1, ia) * sht.rlm_backward(lm, itp);
//
// diff += fabs(val_it - val_mt);
// }
// }
// printf("Total and average charge difference at MT boundary : %.12f %.12f\n", diff, diff / ctx_.num_atoms() / sht.num_points());
//}
| [
"[email protected]"
] | |
680a27dddaede7283ef210ef8bce1467960ee86f | cf8ddfc720bf6451c4ef4fa01684327431db1919 | /SDK/ARKSurvivalEvolved_DinoEntry_Jerboa_functions.cpp | 6e33f470e9da02901395399d064de25ec9a6d74b | [
"MIT"
] | permissive | git-Charlie/ARK-SDK | 75337684b11e7b9f668da1f15e8054052a3b600f | c38ca9925309516b2093ad8c3a70ed9489e1d573 | refs/heads/master | 2023-06-20T06:30:33.550123 | 2021-07-11T13:41:45 | 2021-07-11T13:41:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,005 | cpp | // ARKSurvivalEvolved (329.9) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "ARKSurvivalEvolved_DinoEntry_Jerboa_parameters.hpp"
namespace sdk
{
//---------------------------------------------------------------------------
//Functions
//---------------------------------------------------------------------------
// Function DinoEntry_Jerboa.DinoEntry_Jerboa_C.ExecuteUbergraph_DinoEntry_Jerboa
// ()
// Parameters:
// int EntryPoint (Parm, ZeroConstructor, IsPlainOldData)
void UDinoEntry_Jerboa_C::ExecuteUbergraph_DinoEntry_Jerboa(int EntryPoint)
{
static auto fn = UObject::FindObject<UFunction>("Function DinoEntry_Jerboa.DinoEntry_Jerboa_C.ExecuteUbergraph_DinoEntry_Jerboa");
UDinoEntry_Jerboa_C_ExecuteUbergraph_DinoEntry_Jerboa_Params params;
params.EntryPoint = EntryPoint;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"[email protected]"
] | |
3ebf58a2eb5123b34b297ac3e961c3be9a52da96 | 7fd5e6156d6a42b305809f474659f641450cea81 | /glog/base/commandlineflags.h | 3ecc7729c68d73ca2cba9633f7277c53e747be26 | [] | no_license | imos/icfpc2015 | 5509b6cfc060108c9e5df8093c5bc5421c8480ea | e998055c0456c258aa86e8379180fad153878769 | refs/heads/master | 2020-04-11T04:30:08.777739 | 2015-08-10T11:53:12 | 2015-08-10T11:53:12 | 40,011,767 | 8 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,986 | h | // Copyright (c) 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---
// This file is a compatibility layer that defines Google's version of
// command line flags that are used for configuration.
//
// We put flags into their own namespace. It is purposefully
// named in an opaque way that people should have trouble typing
// directly. The idea is that DEFINE puts the flag in the weird
// namespace, and DECLARE imports the flag from there into the
// current namespace. The net result is to force people to use
// DECLARE to get access to a flag, rather than saying
// extern bool FLAGS_logtostderr;
// or some such instead. We want this so we can put extra
// functionality (like sanity-checking) in DECLARE if we want,
// and make sure it is picked up everywhere.
//
// We also put the type of the variable in the namespace, so that
// people can't DECLARE_int32 something that they DEFINE_bool'd
// elsewhere.
#ifndef BASE_COMMANDLINEFLAGS_H__
#define BASE_COMMANDLINEFLAGS_H__
#include "glog/config.h"
#include <string>
#include <string.h> // for memchr
#include <stdlib.h> // for getenv
#ifdef HAVE_LIB_GFLAGS
#include "gflags/gflags.h"
#else
#include "glog/logging.h"
#define DECLARE_VARIABLE(type, shorttype, name, tn) \
namespace fL##shorttype { \
extern GOOGLE_GLOG_DLL_DECL type FLAGS_##name; \
} \
using fL##shorttype::FLAGS_##name
#define DEFINE_VARIABLE(type, shorttype, name, value, meaning, tn) \
namespace fL##shorttype { \
GOOGLE_GLOG_DLL_DECL type FLAGS_##name(value); \
char FLAGS_no##name; \
} \
using fL##shorttype::FLAGS_##name
// bool specialization
#define DECLARE_bool(name) \
DECLARE_VARIABLE(bool, B, name, bool)
#define DEFINE_bool(name, value, meaning) \
DEFINE_VARIABLE(bool, B, name, value, meaning, bool)
// int32 specialization
#define DECLARE_int32(name) \
DECLARE_VARIABLE(GOOGLE_NAMESPACE::int32, I, name, int32)
#define DEFINE_int32(name, value, meaning) \
DEFINE_VARIABLE(GOOGLE_NAMESPACE::int32, I, name, value, meaning, int32)
// Special case for string, because we have to specify the namespace
// std::string, which doesn't play nicely with our FLAG__namespace hackery.
#define DECLARE_string(name) \
namespace fLS { \
extern GOOGLE_GLOG_DLL_DECL std::string& FLAGS_##name; \
} \
using fLS::FLAGS_##name
#define DEFINE_string(name, value, meaning) \
namespace fLS { \
std::string FLAGS_##name##_buf(value); \
GOOGLE_GLOG_DLL_DECL std::string& FLAGS_##name = FLAGS_##name##_buf; \
char FLAGS_no##name; \
} \
using fLS::FLAGS_##name
#endif // HAVE_LIB_GFLAGS
// Define GLOG_DEFINE_* using DEFINE_* . By using these macros, we
// have GLOG_* environ variables even if we have gflags installed.
//
// If both an environment variable and a flag are specified, the value
// specified by a flag wins. E.g., if GLOG_v=0 and --v=1, the
// verbosity will be 1, not 0.
#define GLOG_DEFINE_bool(name, value, meaning) \
DEFINE_bool(name, EnvToBool("GLOG_" #name, value), meaning)
#define GLOG_DEFINE_int32(name, value, meaning) \
DEFINE_int32(name, EnvToInt("GLOG_" #name, value), meaning)
#define GLOG_DEFINE_string(name, value, meaning) \
DEFINE_string(name, EnvToString("GLOG_" #name, value), meaning)
// These macros (could be functions, but I don't want to bother with a .cc
// file), make it easier to initialize flags from the environment.
#define EnvToString(envname, dflt) \
(!getenv(envname) ? (dflt) : getenv(envname))
#define EnvToBool(envname, dflt) \
(!getenv(envname) ? (dflt) : memchr("tTyY1\0", getenv(envname)[0], 6) != NULL)
#define EnvToInt(envname, dflt) \
(!getenv(envname) ? (dflt) : strtol(getenv(envname), NULL, 10))
#endif // BASE_COMMANDLINEFLAGS_H__
| [
"[email protected]"
] | |
ebba2782c33c6c8860e1510abfd8958ce08021ff | 7744436f65e0e66d336d60656776d9de3b70e56c | /windows_internals/processassignments/createthreadterminate.cpp | ee4ecabdfadde4b4e578a764544fccf95394a0e2 | [] | no_license | paruchurimadhurima/NCR-INTERN | e91082888e80c1d0983828c6ce434eac5654020c | 2471c98e152a0ec13a2cdfc97268726f039a454b | refs/heads/master | 2021-01-13T21:07:17.418646 | 2020-03-20T12:56:25 | 2020-03-20T12:56:25 | 242,494,608 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 999 | cpp | #include<Windows.h>
#include<iostream>
#include<tchar.h>
using namespace std;
/*
DWORD WINAPI ThreadFun(LPVOID Str)
{
cout << "Hi" << endl;
return 0;
}
int _tmain(int argc, WCHAR* argv[], WCHAR* env[])
{
HANDLE CreateThreadHandle;
LPVOID Str = NULL;
CreateThreadHandle = CreateThread(NULL,//security attributes thread is not inherited if null
0,//stack size for thread if 0 it uses size of executable
ThreadFun,//call back function
Str,//parameter to function
0,//creation flag
NULL);//thread id
if (CreateThreadHandle == NULL)
{
cout << "creation of thread failed due to error (" << GetLastError() << ")" << endl;
}
LPDWORD retval = (LPDWORD)WaitForSingleObject(CreateThreadHandle, INFINITE);
//cout << TerminateThread(CreateThreadHandle, GetExitCodeThread(CreateThreadHandle, retval)) << endl;
CloseHandle(CreateThreadHandle);
cout << TerminateThread(CreateThreadHandle, GetExitCodeThread(CreateThreadHandle, retval)) << endl;
//close the handle after use
return 0;
}*/ | [
"INSERT_YOUR_EMAIL"
] | INSERT_YOUR_EMAIL |
1ceab5827a70adf5b7d563c94fe057ac2172b4fe | 297497957c531d81ba286bc91253fbbb78b4d8be | /third_party/aom/test/decode_api_test.cc | 57df634644d1965efbb0dbb1664fd5aba603b5dc | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
] | permissive | marco-c/gecko-dev-comments-removed | 7a9dd34045b07e6b22f0c636c0a836b9e639f9d3 | 61942784fb157763e65608e5a29b3729b0aa66fa | refs/heads/master | 2023-08-09T18:55:25.895853 | 2023-08-01T00:40:39 | 2023-08-01T00:40:39 | 211,297,481 | 0 | 0 | NOASSERTION | 2019-09-29T01:27:49 | 2019-09-27T10:44:24 | C++ | UTF-8 | C++ | false | false | 1,495 | cc |
#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
#include "config/aom_config.h"
#include "test/util.h"
#include "aom/aomdx.h"
#include "aom/aom_decoder.h"
namespace {
TEST(DecodeAPI, InvalidParams) {
static const aom_codec_iface_t *kCodecs[] = {
#if CONFIG_AV1_DECODER
aom_codec_av1_dx(),
#endif
};
uint8_t buf[1] = { 0 };
aom_codec_ctx_t dec;
EXPECT_EQ(AOM_CODEC_INVALID_PARAM, aom_codec_dec_init(NULL, NULL, NULL, 0));
EXPECT_EQ(AOM_CODEC_INVALID_PARAM, aom_codec_dec_init(&dec, NULL, NULL, 0));
EXPECT_EQ(AOM_CODEC_INVALID_PARAM, aom_codec_decode(NULL, NULL, 0, NULL));
EXPECT_EQ(AOM_CODEC_INVALID_PARAM, aom_codec_decode(NULL, buf, 0, NULL));
EXPECT_EQ(AOM_CODEC_INVALID_PARAM,
aom_codec_decode(NULL, buf, NELEMENTS(buf), NULL));
EXPECT_EQ(AOM_CODEC_INVALID_PARAM,
aom_codec_decode(NULL, NULL, NELEMENTS(buf), NULL));
EXPECT_EQ(AOM_CODEC_INVALID_PARAM, aom_codec_destroy(NULL));
EXPECT_TRUE(aom_codec_error(NULL) != NULL);
for (int i = 0; i < NELEMENTS(kCodecs); ++i) {
EXPECT_EQ(AOM_CODEC_INVALID_PARAM,
aom_codec_dec_init(NULL, kCodecs[i], NULL, 0));
EXPECT_EQ(AOM_CODEC_OK, aom_codec_dec_init(&dec, kCodecs[i], NULL, 0));
EXPECT_EQ(AOM_CODEC_INVALID_PARAM,
aom_codec_decode(&dec, NULL, NELEMENTS(buf), NULL));
EXPECT_EQ(AOM_CODEC_INVALID_PARAM, aom_codec_decode(&dec, buf, 0, NULL));
EXPECT_EQ(AOM_CODEC_OK, aom_codec_destroy(&dec));
}
}
}
| [
"[email protected]"
] | |
af96e325aebb10caaa5f6792c3c70083c482d0c4 | d0c44dd3da2ef8c0ff835982a437946cbf4d2940 | /cmake-build-debug/programs_tiling/function13917/function13917_schedule_5/function13917_schedule_5_wrapper.cpp | bbdfb7a81e8dfba072c621377844fce107301b0c | [] | no_license | IsraMekki/tiramisu_code_generator | 8b3f1d63cff62ba9f5242c019058d5a3119184a3 | 5a259d8e244af452e5301126683fa4320c2047a3 | refs/heads/master | 2020-04-29T17:27:57.987172 | 2019-04-23T16:50:32 | 2019-04-23T16:50:32 | 176,297,755 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 926 | cpp | #include "Halide.h"
#include "function13917_schedule_5_wrapper.h"
#include "tiramisu/utils.h"
#include <cstdlib>
#include <iostream>
#include <time.h>
#include <fstream>
#include <chrono>
#define MAX_RAND 200
int main(int, char **){
Halide::Buffer<int32_t> buf00(524288, 128);
Halide::Buffer<int32_t> buf0(524288, 128);
init_buffer(buf0, (int32_t)0);
auto t1 = std::chrono::high_resolution_clock::now();
function13917_schedule_5(buf00.raw_buffer(), buf0.raw_buffer());
auto t2 = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = t2 - t1;
std::ofstream exec_times_file;
exec_times_file.open("../data/programs/function13917/function13917_schedule_5/exec_times.txt", std::ios_base::app);
if (exec_times_file.is_open()){
exec_times_file << diff.count() * 1000000 << "us" <<std::endl;
exec_times_file.close();
}
return 0;
} | [
"[email protected]"
] | |
044ddf326c99fbde0b07b84766db3134f65aaf8a | dfe01ef79596f1c9f12c6ba6fe46d703369054fe | /renderdoc/driver/d3d12/d3d12_stringise.cpp | 551cbb9f29db2bedac8daadf5e8bc03127c2a40e | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | galek/renderdoc | 330b209da7618e38df595e8d3c5ac5f9e5734853 | 39d31e880d9d8997372f0121bec8950e9b4e4442 | refs/heads/master | 2021-11-25T06:15:53.681934 | 2021-10-28T09:49:15 | 2021-10-28T10:24:46 | 40,795,914 | 0 | 0 | null | 2015-08-16T02:17:03 | 2015-08-16T02:17:03 | null | UTF-8 | C++ | false | false | 47,799 | cpp | /******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2019-2021 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
#include "d3d12_common.h"
#include "d3d12_resources.h"
template <>
rdcstr DoStringise(const D3D12Chunk &el)
{
RDCCOMPILE_ASSERT((uint32_t)D3D12Chunk::Max == 1114, "Chunks changed without updating names");
BEGIN_ENUM_STRINGISE(D3D12Chunk)
{
STRINGISE_ENUM_CLASS_NAMED(SetName, "ID3D12Resource::SetName");
STRINGISE_ENUM_CLASS_NAMED(PushMarker, "ID3D12GraphicsCommandList::BeginEvent");
STRINGISE_ENUM_CLASS_NAMED(SetMarker, "ID3D12GraphicsCommandList::SetMarker");
STRINGISE_ENUM_CLASS_NAMED(PopMarker, "ID3D12GraphicsCommandList::EndEvent");
STRINGISE_ENUM_CLASS_NAMED(SetShaderDebugPath, "Internal::SetShaderDebugPath");
STRINGISE_ENUM_CLASS_NAMED(CreateSwapBuffer, "IDXGISwapChain::GetBuffer");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateCommandQueue, "ID3D12Device::CreateCommandQueue");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateCommandAllocator,
"ID3D12Device::CreateCommandAllocator");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateCommandList, "ID3D12Device::CreateCommandList");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateGraphicsPipeline,
"ID3D12Device::CreateGraphicsPipeline");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateComputePipeline, "ID3D12Device::CreateComputePipeline");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateDescriptorHeap, "ID3D12Device::CreateDescriptorHeap");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateRootSignature, "ID3D12Device::CreateRootSignature");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateCommandSignature,
"ID3D12Device::CreateCommandSignature");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateHeap, "ID3D12Device::CreateHeap");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateCommittedResource,
"ID3D12Device::CreateCommittedResource");
STRINGISE_ENUM_CLASS_NAMED(Device_CreatePlacedResource, "ID3D12Device::CreatePlacedResource");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateQueryHeap, "ID3D12Device::CreateQueryHeap");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateFence, "ID3D12Device::CreateFence");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateReservedResource,
"ID3D12Device::CreateReservedResource");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateConstantBufferView,
"ID3D12Device::CreateConstantBufferView");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateShaderResourceView,
"ID3D12Device::CreateShaderResourceView");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateUnorderedAccessView,
"ID3D12Device::CreateUnorderedAccessView");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateRenderTargetView,
"ID3D12Device::CreateRenderTargetView");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateDepthStencilView,
"ID3D12Device::CreateDepthStencilView");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateSampler, "ID3D12Device::CreateSampler");
STRINGISE_ENUM_CLASS_NAMED(Device_CopyDescriptors, "ID3D12Device::CopyDescriptors");
STRINGISE_ENUM_CLASS_NAMED(Device_CopyDescriptorsSimple, "ID3D12Device::CopyDescriptorsSimple");
STRINGISE_ENUM_CLASS_NAMED(Device_OpenSharedHandle, "ID3D12Device::OpenSharedHandle");
STRINGISE_ENUM_CLASS_NAMED(Queue_ExecuteCommandLists,
"ID3D12CommandQueue::ExecuteCommandLists");
STRINGISE_ENUM_CLASS_NAMED(Queue_Signal, "ID3D12CommandQueue::Signal");
STRINGISE_ENUM_CLASS_NAMED(Queue_Wait, "ID3D12CommandQueue::Wait");
STRINGISE_ENUM_CLASS_NAMED(Queue_UpdateTileMappings, "ID3D12CommandQueue::UpdateTileMappings");
STRINGISE_ENUM_CLASS_NAMED(Queue_CopyTileMappings, "ID3D12CommandQueue::CopyTileMappings");
STRINGISE_ENUM_CLASS_NAMED(List_Close, "ID3D12GraphicsCommandList::Close");
STRINGISE_ENUM_CLASS_NAMED(List_Reset, "ID3D12GraphicsCommandList::Reset");
STRINGISE_ENUM_CLASS_NAMED(List_ResourceBarrier, "ID3D12GraphicsCommandList::ResourceBarrier");
STRINGISE_ENUM_CLASS_NAMED(List_BeginQuery, "ID3D12GraphicsCommandList::BeginQuery");
STRINGISE_ENUM_CLASS_NAMED(List_EndQuery, "ID3D12GraphicsCommandList::EndQuery");
STRINGISE_ENUM_CLASS_NAMED(List_ResolveQueryData,
"ID3D12GraphicsCommandList::ResolveQueryData");
STRINGISE_ENUM_CLASS_NAMED(List_SetPredication, "ID3D12GraphicsCommandList::SetPredication");
STRINGISE_ENUM_CLASS_NAMED(List_DrawIndexedInstanced,
"ID3D12GraphicsCommandList::DrawIndexedInstanced");
STRINGISE_ENUM_CLASS_NAMED(List_DrawInstanced, "ID3D12GraphicsCommandList::DrawInstanced");
STRINGISE_ENUM_CLASS_NAMED(List_Dispatch, "ID3D12GraphicsCommandList::Dispatch");
STRINGISE_ENUM_CLASS_NAMED(List_ExecuteIndirect, "ID3D12GraphicsCommandList::ExecuteIndirect");
STRINGISE_ENUM_CLASS_NAMED(List_ExecuteBundle, "ID3D12GraphicsCommandList::ExecuteBundle");
STRINGISE_ENUM_CLASS_NAMED(List_CopyBufferRegion,
"ID3D12GraphicsCommandList::CopyBufferRegion");
STRINGISE_ENUM_CLASS_NAMED(List_CopyTextureRegion,
"ID3D12GraphicsCommandList::CopyTextureRegion");
STRINGISE_ENUM_CLASS_NAMED(List_CopyResource, "ID3D12GraphicsCommandList::CopyResource");
STRINGISE_ENUM_CLASS_NAMED(List_ResolveSubresource,
"ID3D12GraphicsCommandList::ResolveSubresource");
STRINGISE_ENUM_CLASS_NAMED(List_ClearRenderTargetView,
"ID3D12GraphicsCommandList::ClearRenderTargetView");
STRINGISE_ENUM_CLASS_NAMED(List_ClearDepthStencilView,
"ID3D12GraphicsCommandList::ClearDepthStencilView");
STRINGISE_ENUM_CLASS_NAMED(List_ClearUnorderedAccessViewUint,
"ID3D12GraphicsCommandList::ClearUnorderedAccessViewUint");
STRINGISE_ENUM_CLASS_NAMED(List_ClearUnorderedAccessViewFloat,
"ID3D12GraphicsCommandList::ClearUnorderedAccessViewFloat");
STRINGISE_ENUM_CLASS_NAMED(List_DiscardResource, "ID3D12GraphicsCommandList::DiscardResource");
STRINGISE_ENUM_CLASS_NAMED(List_IASetPrimitiveTopology,
"ID3D12GraphicsCommandList::IASetPrimitiveTopology");
STRINGISE_ENUM_CLASS_NAMED(List_IASetIndexBuffer,
"ID3D12GraphicsCommandList::IASetIndexBuffer");
STRINGISE_ENUM_CLASS_NAMED(List_IASetVertexBuffers,
"ID3D12GraphicsCommandList::IASetVertexBuffers");
STRINGISE_ENUM_CLASS_NAMED(List_SOSetTargets, "ID3D12GraphicsCommandList::SOSetTargets");
STRINGISE_ENUM_CLASS_NAMED(List_RSSetViewports, "ID3D12GraphicsCommandList::RSSetViewports");
STRINGISE_ENUM_CLASS_NAMED(List_RSSetScissorRects,
"ID3D12GraphicsCommandList::RSSetScissorRects");
STRINGISE_ENUM_CLASS_NAMED(List_SetPipelineState,
"ID3D12GraphicsCommandList::SetPipelineState");
STRINGISE_ENUM_CLASS_NAMED(List_SetDescriptorHeaps,
"ID3D12GraphicsCommandList::SetDescriptorHeaps");
STRINGISE_ENUM_CLASS_NAMED(List_OMSetRenderTargets,
"ID3D12GraphicsCommandList::OMSetRenderTargets");
STRINGISE_ENUM_CLASS_NAMED(List_OMSetStencilRef, "ID3D12GraphicsCommandList::OMSetStencilRef");
STRINGISE_ENUM_CLASS_NAMED(List_OMSetBlendFactor,
"ID3D12GraphicsCommandList::OMSetBlendFactor");
STRINGISE_ENUM_CLASS_NAMED(List_SetGraphicsRootDescriptorTable,
"ID3D12GraphicsCommandList::SetGraphicsRootDescriptorTable");
STRINGISE_ENUM_CLASS_NAMED(List_SetGraphicsRootSignature,
"ID3D12GraphicsCommandList::SetGraphicsRootSignature");
STRINGISE_ENUM_CLASS_NAMED(List_SetGraphicsRoot32BitConstant,
"ID3D12GraphicsCommandList::SetGraphicsRoot32BitConstant");
STRINGISE_ENUM_CLASS_NAMED(List_SetGraphicsRoot32BitConstants,
"ID3D12GraphicsCommandList::SetGraphicsRoot32BitConstants");
STRINGISE_ENUM_CLASS_NAMED(List_SetGraphicsRootConstantBufferView,
"ID3D12GraphicsCommandList::SetGraphicsRootConstantBufferView");
STRINGISE_ENUM_CLASS_NAMED(List_SetGraphicsRootShaderResourceView,
"ID3D12GraphicsCommandList::SetGraphicsRootShaderResourceView");
STRINGISE_ENUM_CLASS_NAMED(List_SetGraphicsRootUnorderedAccessView,
"ID3D12GraphicsCommandList::SetGraphicsRootUnorderedAccessView");
STRINGISE_ENUM_CLASS_NAMED(List_SetComputeRootDescriptorTable,
"ID3D12GraphicsCommandList::SetComputeRootDescriptorTable");
STRINGISE_ENUM_CLASS_NAMED(List_SetComputeRootSignature,
"ID3D12GraphicsCommandList::SetComputeRootSignature");
STRINGISE_ENUM_CLASS_NAMED(List_SetComputeRoot32BitConstant,
"ID3D12GraphicsCommandList::SetComputeRoot32BitConstant");
STRINGISE_ENUM_CLASS_NAMED(List_SetComputeRoot32BitConstants,
"ID3D12GraphicsCommandList::SetComputeRoot32BitConstants");
STRINGISE_ENUM_CLASS_NAMED(List_SetComputeRootConstantBufferView,
"ID3D12GraphicsCommandList::SetComputeRootConstantBufferView");
STRINGISE_ENUM_CLASS_NAMED(List_SetComputeRootShaderResourceView,
"ID3D12GraphicsCommandList::SetComputeRootShaderResourceView");
STRINGISE_ENUM_CLASS_NAMED(List_SetComputeRootUnorderedAccessView,
"ID3D12GraphicsCommandList::SetComputeRootUnorderedAccessView");
STRINGISE_ENUM_CLASS_NAMED(List_CopyTiles, "ID3D12GraphicsCommandList::CopyTiles");
STRINGISE_ENUM_CLASS_NAMED(Resource_Unmap, "ID3D12Resource::Unmap");
STRINGISE_ENUM_CLASS_NAMED(Resource_WriteToSubresource, "ID3D12Resource::WriteToSubresource");
STRINGISE_ENUM_CLASS_NAMED(List_IndirectSubCommand, "Indirect Sub-command");
STRINGISE_ENUM_CLASS_NAMED(Queue_BeginEvent, "ID3D12CommandQueue::BeginEvent");
STRINGISE_ENUM_CLASS_NAMED(Queue_SetMarker, "ID3D12CommandQueue::SetMarker");
STRINGISE_ENUM_CLASS_NAMED(Queue_EndEvent, "ID3D12CommandQueue::EndEvent");
STRINGISE_ENUM_CLASS_NAMED(Device_CreatePipelineState, "ID3D12Device2::CreatePipelineState");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateHeapFromAddress,
"ID3D12Device3::OpenExistingHeapFromAddress");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateHeapFromFileMapping,
"ID3D12Device3::OpenExistingHeapFromFileMapping");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateCommandList1, "ID3D12Device4::CreateCommandList1");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateCommittedResource1,
"ID3D12Device4::CreateCommittedResource1");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateHeap1, "ID3D12Device4::CreateHeap1");
STRINGISE_ENUM_CLASS_NAMED(List_AtomicCopyBufferUINT,
"ID3D12GraphicsCommandList1::AtomicCopyBufferUINT");
STRINGISE_ENUM_CLASS_NAMED(List_AtomicCopyBufferUINT64,
"ID3D12GraphicsCommandList1::AtomicCopyBufferUINT64");
STRINGISE_ENUM_CLASS_NAMED(List_OMSetDepthBounds,
"ID3D12GraphicsCommandList1::OMSetDepthBounds");
STRINGISE_ENUM_CLASS_NAMED(List_ResolveSubresourceRegion,
"ID3D12GraphicsCommandList1::ResolveSubresourceRegion");
STRINGISE_ENUM_CLASS_NAMED(List_SetSamplePositions,
"ID3D12GraphicsCommandList1::SetSamplePositions");
STRINGISE_ENUM_CLASS_NAMED(List_SetViewInstanceMask,
"ID3D12GraphicsCommandList1::SetViewInstanceMask");
STRINGISE_ENUM_CLASS_NAMED(List_WriteBufferImmediate,
"ID3D12GraphicsCommandList2::WriteBufferImmediate");
STRINGISE_ENUM_CLASS_NAMED(List_BeginRenderPass, "ID3D12GraphicsCommandList4::BeginRenderPass");
STRINGISE_ENUM_CLASS_NAMED(List_EndRenderPass, "ID3D12GraphicsCommandList4::EndRenderPass");
STRINGISE_ENUM_CLASS_NAMED(List_RSSetShadingRate,
"ID3D12GraphicsCommandList5::RSSetShadingRate");
STRINGISE_ENUM_CLASS_NAMED(List_RSSetShadingRateImage,
"ID3D12GraphicsCommandList5::RSSetShadingRateImage");
STRINGISE_ENUM_CLASS_NAMED(Device_ExternalDXGIResource, "External DXGI Resource import");
STRINGISE_ENUM_CLASS_NAMED(Swapchain_Present, "IDXGISwapChain::Present");
STRINGISE_ENUM_CLASS_NAMED(List_ClearState, "ID3D12GraphicsCommandList::ClearState");
STRINGISE_ENUM_CLASS_NAMED(CompatDevice_CreateSharedResource,
"ID3D12CompatibilityDevice::CreateSharedResource");
STRINGISE_ENUM_CLASS_NAMED(CompatDevice_CreateSharedHeap,
"ID3D12CompatibilityDevice::CreateSharedHeap");
STRINGISE_ENUM_CLASS_NAMED(SetShaderExtUAV, "Vendor Extension: Set magic shader UAV slot");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateCommittedResource2,
"ID3D12Device8::CreateCommittedResource2");
STRINGISE_ENUM_CLASS_NAMED(Device_CreatePlacedResource1,
"ID3D12Device8::CreatePlacedResource1");
STRINGISE_ENUM_CLASS_NAMED(Device_CreateCommandQueue1, "ID3D12Device9::CreateCommandQueue1");
STRINGISE_ENUM_CLASS_NAMED(CoherentMapWrite, "Internal::Coherent Mapped Memory Write");
STRINGISE_ENUM_CLASS_NAMED(Max, "Max Chunk");
}
END_ENUM_STRINGISE()
}
template <>
rdcstr DoStringise(const D3D12DescriptorType &el)
{
if((uint32_t)el < (uint32_t)D3D12DescriptorType::CBV)
return "Sampler";
BEGIN_ENUM_STRINGISE(D3D12DescriptorType);
{
STRINGISE_ENUM_CLASS_NAMED(CBV, "CBV");
STRINGISE_ENUM_CLASS_NAMED(SRV, "SRV");
STRINGISE_ENUM_CLASS_NAMED(UAV, "UAV");
STRINGISE_ENUM_CLASS_NAMED(RTV, "RTV");
STRINGISE_ENUM_CLASS_NAMED(DSV, "DSV");
STRINGISE_ENUM_CLASS_NAMED(Undefined, "Undefined");
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12ResourceType &el)
{
BEGIN_ENUM_STRINGISE(D3D12ResourceType);
{
STRINGISE_ENUM_NAMED(Resource_Device, "Device");
STRINGISE_ENUM_NAMED(Resource_Unknown, "Unknown");
STRINGISE_ENUM_NAMED(Resource_CommandAllocator, "Command Allocator");
STRINGISE_ENUM_NAMED(Resource_CommandQueue, "Command Queue");
STRINGISE_ENUM_NAMED(Resource_CommandSignature, "Command Signature");
STRINGISE_ENUM_NAMED(Resource_DescriptorHeap, "Descriptor Heap");
STRINGISE_ENUM_NAMED(Resource_Fence, "Fence");
STRINGISE_ENUM_NAMED(Resource_Heap, "Heap");
STRINGISE_ENUM_NAMED(Resource_PipelineState, "Pipeline State");
STRINGISE_ENUM_NAMED(Resource_QueryHeap, "Query Heap");
STRINGISE_ENUM_NAMED(Resource_Resource, "Resource");
STRINGISE_ENUM_NAMED(Resource_GraphicsCommandList, "Graphics CommandList");
STRINGISE_ENUM_NAMED(Resource_RootSignature, "Root Signature");
STRINGISE_ENUM_NAMED(Resource_PipelineLibrary, "Pipeline Library");
STRINGISE_ENUM_NAMED(Resource_ProtectedResourceSession, "Protected Resource Session");
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_HEAP_TYPE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_HEAP_TYPE);
{
STRINGISE_ENUM(D3D12_HEAP_TYPE_DEFAULT)
STRINGISE_ENUM(D3D12_HEAP_TYPE_UPLOAD)
STRINGISE_ENUM(D3D12_HEAP_TYPE_READBACK)
STRINGISE_ENUM(D3D12_HEAP_TYPE_CUSTOM)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_CPU_PAGE_PROPERTY &el)
{
BEGIN_ENUM_STRINGISE(D3D12_CPU_PAGE_PROPERTY);
{
STRINGISE_ENUM(D3D12_CPU_PAGE_PROPERTY_UNKNOWN)
STRINGISE_ENUM(D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE)
STRINGISE_ENUM(D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE)
STRINGISE_ENUM(D3D12_CPU_PAGE_PROPERTY_WRITE_BACK)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_MEMORY_POOL &el)
{
BEGIN_ENUM_STRINGISE(D3D12_MEMORY_POOL);
{
STRINGISE_ENUM(D3D12_MEMORY_POOL_UNKNOWN)
STRINGISE_ENUM(D3D12_MEMORY_POOL_L0)
STRINGISE_ENUM(D3D12_MEMORY_POOL_L1)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_QUERY_HEAP_TYPE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_QUERY_HEAP_TYPE);
{
STRINGISE_ENUM(D3D12_QUERY_HEAP_TYPE_OCCLUSION)
STRINGISE_ENUM(D3D12_QUERY_HEAP_TYPE_TIMESTAMP)
STRINGISE_ENUM(D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS)
STRINGISE_ENUM(D3D12_QUERY_HEAP_TYPE_SO_STATISTICS)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_QUERY_TYPE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_QUERY_TYPE);
{
STRINGISE_ENUM(D3D12_QUERY_TYPE_OCCLUSION)
STRINGISE_ENUM(D3D12_QUERY_TYPE_BINARY_OCCLUSION)
STRINGISE_ENUM(D3D12_QUERY_TYPE_TIMESTAMP)
STRINGISE_ENUM(D3D12_QUERY_TYPE_PIPELINE_STATISTICS)
STRINGISE_ENUM(D3D12_QUERY_TYPE_SO_STATISTICS_STREAM0)
STRINGISE_ENUM(D3D12_QUERY_TYPE_SO_STATISTICS_STREAM1)
STRINGISE_ENUM(D3D12_QUERY_TYPE_SO_STATISTICS_STREAM2)
STRINGISE_ENUM(D3D12_QUERY_TYPE_SO_STATISTICS_STREAM3)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_PREDICATION_OP &el)
{
BEGIN_ENUM_STRINGISE(D3D12_PREDICATION_OP);
{
STRINGISE_ENUM(D3D12_PREDICATION_OP_EQUAL_ZERO)
STRINGISE_ENUM(D3D12_PREDICATION_OP_NOT_EQUAL_ZERO)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_DESCRIPTOR_HEAP_TYPE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_DESCRIPTOR_HEAP_TYPE);
{
STRINGISE_ENUM(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)
STRINGISE_ENUM(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER)
STRINGISE_ENUM(D3D12_DESCRIPTOR_HEAP_TYPE_RTV)
STRINGISE_ENUM(D3D12_DESCRIPTOR_HEAP_TYPE_DSV)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_RESOURCE_BARRIER_TYPE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_RESOURCE_BARRIER_TYPE);
{
STRINGISE_ENUM(D3D12_RESOURCE_BARRIER_TYPE_TRANSITION)
STRINGISE_ENUM(D3D12_RESOURCE_BARRIER_TYPE_ALIASING)
STRINGISE_ENUM(D3D12_RESOURCE_BARRIER_TYPE_UAV)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_SRV_DIMENSION &el)
{
BEGIN_ENUM_STRINGISE(D3D12_SRV_DIMENSION);
{
STRINGISE_ENUM(D3D12_SRV_DIMENSION_UNKNOWN)
STRINGISE_ENUM(D3D12_SRV_DIMENSION_BUFFER)
STRINGISE_ENUM(D3D12_SRV_DIMENSION_TEXTURE1D)
STRINGISE_ENUM(D3D12_SRV_DIMENSION_TEXTURE1DARRAY)
STRINGISE_ENUM(D3D12_SRV_DIMENSION_TEXTURE2D)
STRINGISE_ENUM(D3D12_SRV_DIMENSION_TEXTURE2DARRAY)
STRINGISE_ENUM(D3D12_SRV_DIMENSION_TEXTURE2DMS)
STRINGISE_ENUM(D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY)
STRINGISE_ENUM(D3D12_SRV_DIMENSION_TEXTURE3D)
STRINGISE_ENUM(D3D12_SRV_DIMENSION_TEXTURECUBE)
STRINGISE_ENUM(D3D12_SRV_DIMENSION_TEXTURECUBEARRAY)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_RTV_DIMENSION &el)
{
BEGIN_ENUM_STRINGISE(D3D12_RTV_DIMENSION);
{
STRINGISE_ENUM(D3D12_RTV_DIMENSION_UNKNOWN)
STRINGISE_ENUM(D3D12_RTV_DIMENSION_BUFFER)
STRINGISE_ENUM(D3D12_RTV_DIMENSION_TEXTURE1D)
STRINGISE_ENUM(D3D12_RTV_DIMENSION_TEXTURE1DARRAY)
STRINGISE_ENUM(D3D12_RTV_DIMENSION_TEXTURE2D)
STRINGISE_ENUM(D3D12_RTV_DIMENSION_TEXTURE2DARRAY)
STRINGISE_ENUM(D3D12_RTV_DIMENSION_TEXTURE2DMS)
STRINGISE_ENUM(D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY)
STRINGISE_ENUM(D3D12_RTV_DIMENSION_TEXTURE3D)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_UAV_DIMENSION &el)
{
BEGIN_ENUM_STRINGISE(D3D12_UAV_DIMENSION);
{
STRINGISE_ENUM(D3D12_UAV_DIMENSION_BUFFER)
STRINGISE_ENUM(D3D12_UAV_DIMENSION_TEXTURE1D)
STRINGISE_ENUM(D3D12_UAV_DIMENSION_TEXTURE1DARRAY)
STRINGISE_ENUM(D3D12_UAV_DIMENSION_TEXTURE2D)
STRINGISE_ENUM(D3D12_UAV_DIMENSION_TEXTURE2DARRAY)
STRINGISE_ENUM(D3D12_UAV_DIMENSION_TEXTURE3D)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_DSV_DIMENSION &el)
{
BEGIN_ENUM_STRINGISE(D3D12_DSV_DIMENSION);
{
STRINGISE_ENUM(D3D12_DSV_DIMENSION_UNKNOWN)
STRINGISE_ENUM(D3D12_DSV_DIMENSION_TEXTURE1D)
STRINGISE_ENUM(D3D12_DSV_DIMENSION_TEXTURE1DARRAY)
STRINGISE_ENUM(D3D12_DSV_DIMENSION_TEXTURE2D)
STRINGISE_ENUM(D3D12_DSV_DIMENSION_TEXTURE2DARRAY)
STRINGISE_ENUM(D3D12_DSV_DIMENSION_TEXTURE2DMS)
STRINGISE_ENUM(D3D12_DSV_DIMENSION_TEXTURE2DMSARRAY)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_FILTER &el)
{
BEGIN_ENUM_STRINGISE(D3D12_FILTER);
{
STRINGISE_ENUM(D3D12_FILTER_MIN_MAG_MIP_POINT);
STRINGISE_ENUM(D3D12_FILTER_MIN_MAG_POINT_MIP_LINEAR);
STRINGISE_ENUM(D3D12_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT);
STRINGISE_ENUM(D3D12_FILTER_MIN_POINT_MAG_MIP_LINEAR);
STRINGISE_ENUM(D3D12_FILTER_MIN_LINEAR_MAG_MIP_POINT);
STRINGISE_ENUM(D3D12_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR);
STRINGISE_ENUM(D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT);
STRINGISE_ENUM(D3D12_FILTER_MIN_MAG_MIP_LINEAR);
STRINGISE_ENUM(D3D12_FILTER_ANISOTROPIC);
STRINGISE_ENUM(D3D12_FILTER_COMPARISON_MIN_MAG_MIP_POINT);
STRINGISE_ENUM(D3D12_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR);
STRINGISE_ENUM(D3D12_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT);
STRINGISE_ENUM(D3D12_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR);
STRINGISE_ENUM(D3D12_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT);
STRINGISE_ENUM(D3D12_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR);
STRINGISE_ENUM(D3D12_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT);
STRINGISE_ENUM(D3D12_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR);
STRINGISE_ENUM(D3D12_FILTER_COMPARISON_ANISOTROPIC);
STRINGISE_ENUM(D3D12_FILTER_MINIMUM_MIN_MAG_MIP_POINT);
STRINGISE_ENUM(D3D12_FILTER_MINIMUM_MIN_MAG_POINT_MIP_LINEAR);
STRINGISE_ENUM(D3D12_FILTER_MINIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT);
STRINGISE_ENUM(D3D12_FILTER_MINIMUM_MIN_POINT_MAG_MIP_LINEAR);
STRINGISE_ENUM(D3D12_FILTER_MINIMUM_MIN_LINEAR_MAG_MIP_POINT);
STRINGISE_ENUM(D3D12_FILTER_MINIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR);
STRINGISE_ENUM(D3D12_FILTER_MINIMUM_MIN_MAG_LINEAR_MIP_POINT);
STRINGISE_ENUM(D3D12_FILTER_MINIMUM_MIN_MAG_MIP_LINEAR);
STRINGISE_ENUM(D3D12_FILTER_MINIMUM_ANISOTROPIC);
STRINGISE_ENUM(D3D12_FILTER_MAXIMUM_MIN_MAG_MIP_POINT);
STRINGISE_ENUM(D3D12_FILTER_MAXIMUM_MIN_MAG_POINT_MIP_LINEAR);
STRINGISE_ENUM(D3D12_FILTER_MAXIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT);
STRINGISE_ENUM(D3D12_FILTER_MAXIMUM_MIN_POINT_MAG_MIP_LINEAR);
STRINGISE_ENUM(D3D12_FILTER_MAXIMUM_MIN_LINEAR_MAG_MIP_POINT);
STRINGISE_ENUM(D3D12_FILTER_MAXIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR);
STRINGISE_ENUM(D3D12_FILTER_MAXIMUM_MIN_MAG_LINEAR_MIP_POINT);
STRINGISE_ENUM(D3D12_FILTER_MAXIMUM_MIN_MAG_MIP_LINEAR);
STRINGISE_ENUM(D3D12_FILTER_MAXIMUM_ANISOTROPIC);
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_TEXTURE_ADDRESS_MODE &el)
{
// possible for unused fields via 0-initialisation
if((int)el == 0)
return "--";
BEGIN_ENUM_STRINGISE(D3D12_TEXTURE_ADDRESS_MODE);
{
STRINGISE_ENUM(D3D12_TEXTURE_ADDRESS_MODE_WRAP);
STRINGISE_ENUM(D3D12_TEXTURE_ADDRESS_MODE_MIRROR);
STRINGISE_ENUM(D3D12_TEXTURE_ADDRESS_MODE_CLAMP);
STRINGISE_ENUM(D3D12_TEXTURE_ADDRESS_MODE_BORDER);
STRINGISE_ENUM(D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE);
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_BLEND &el)
{
// possible for unused fields via 0-initialisation
if((int)el == 0)
return "--";
BEGIN_ENUM_STRINGISE(D3D12_BLEND);
{
STRINGISE_ENUM(D3D12_BLEND_ZERO);
STRINGISE_ENUM(D3D12_BLEND_ONE);
STRINGISE_ENUM(D3D12_BLEND_SRC_COLOR);
STRINGISE_ENUM(D3D12_BLEND_INV_SRC_COLOR);
STRINGISE_ENUM(D3D12_BLEND_SRC_ALPHA);
STRINGISE_ENUM(D3D12_BLEND_INV_SRC_ALPHA);
STRINGISE_ENUM(D3D12_BLEND_DEST_ALPHA);
STRINGISE_ENUM(D3D12_BLEND_INV_DEST_ALPHA);
STRINGISE_ENUM(D3D12_BLEND_DEST_COLOR);
STRINGISE_ENUM(D3D12_BLEND_INV_DEST_COLOR);
STRINGISE_ENUM(D3D12_BLEND_SRC_ALPHA_SAT);
STRINGISE_ENUM(D3D12_BLEND_BLEND_FACTOR);
STRINGISE_ENUM(D3D12_BLEND_INV_BLEND_FACTOR);
STRINGISE_ENUM(D3D12_BLEND_SRC1_COLOR);
STRINGISE_ENUM(D3D12_BLEND_INV_SRC1_COLOR);
STRINGISE_ENUM(D3D12_BLEND_SRC1_ALPHA);
STRINGISE_ENUM(D3D12_BLEND_INV_SRC1_ALPHA);
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_BLEND_OP &el)
{
// possible for unused fields via 0-initialisation
if((int)el == 0)
return "--";
BEGIN_ENUM_STRINGISE(D3D12_BLEND_OP);
{
STRINGISE_ENUM(D3D12_BLEND_OP_ADD);
STRINGISE_ENUM(D3D12_BLEND_OP_SUBTRACT);
STRINGISE_ENUM(D3D12_BLEND_OP_REV_SUBTRACT);
STRINGISE_ENUM(D3D12_BLEND_OP_MIN);
STRINGISE_ENUM(D3D12_BLEND_OP_MAX);
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_LOGIC_OP &el)
{
BEGIN_ENUM_STRINGISE(D3D12_LOGIC_OP);
{
STRINGISE_ENUM(D3D12_LOGIC_OP_CLEAR);
STRINGISE_ENUM(D3D12_LOGIC_OP_SET);
STRINGISE_ENUM(D3D12_LOGIC_OP_COPY);
STRINGISE_ENUM(D3D12_LOGIC_OP_COPY_INVERTED);
STRINGISE_ENUM(D3D12_LOGIC_OP_NOOP);
STRINGISE_ENUM(D3D12_LOGIC_OP_INVERT);
STRINGISE_ENUM(D3D12_LOGIC_OP_AND);
STRINGISE_ENUM(D3D12_LOGIC_OP_NAND);
STRINGISE_ENUM(D3D12_LOGIC_OP_OR);
STRINGISE_ENUM(D3D12_LOGIC_OP_NOR);
STRINGISE_ENUM(D3D12_LOGIC_OP_XOR);
STRINGISE_ENUM(D3D12_LOGIC_OP_EQUIV);
STRINGISE_ENUM(D3D12_LOGIC_OP_AND_REVERSE);
STRINGISE_ENUM(D3D12_LOGIC_OP_AND_INVERTED);
STRINGISE_ENUM(D3D12_LOGIC_OP_OR_REVERSE);
STRINGISE_ENUM(D3D12_LOGIC_OP_OR_INVERTED);
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_FILL_MODE &el)
{
// possible for unused fields via 0-initialisation
if((int)el == 0)
return "--";
BEGIN_ENUM_STRINGISE(D3D12_FILL_MODE);
{
STRINGISE_ENUM(D3D12_FILL_MODE_WIREFRAME);
STRINGISE_ENUM(D3D12_FILL_MODE_SOLID);
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_CULL_MODE &el)
{
// possible for unused fields via 0-initialisation
if((int)el == 0)
return "--";
BEGIN_ENUM_STRINGISE(D3D12_CULL_MODE);
{
STRINGISE_ENUM(D3D12_CULL_MODE_NONE);
STRINGISE_ENUM(D3D12_CULL_MODE_FRONT);
STRINGISE_ENUM(D3D12_CULL_MODE_BACK);
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_CONSERVATIVE_RASTERIZATION_MODE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_CONSERVATIVE_RASTERIZATION_MODE);
{
STRINGISE_ENUM(D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF)
STRINGISE_ENUM(D3D12_CONSERVATIVE_RASTERIZATION_MODE_ON)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_COMPARISON_FUNC &el)
{
// possible for unused fields via 0-initialisation
if((int)el == 0)
return "--";
BEGIN_ENUM_STRINGISE(D3D12_COMPARISON_FUNC);
{
STRINGISE_ENUM(D3D12_COMPARISON_FUNC_NEVER);
STRINGISE_ENUM(D3D12_COMPARISON_FUNC_LESS);
STRINGISE_ENUM(D3D12_COMPARISON_FUNC_EQUAL);
STRINGISE_ENUM(D3D12_COMPARISON_FUNC_LESS_EQUAL);
STRINGISE_ENUM(D3D12_COMPARISON_FUNC_GREATER);
STRINGISE_ENUM(D3D12_COMPARISON_FUNC_NOT_EQUAL);
STRINGISE_ENUM(D3D12_COMPARISON_FUNC_GREATER_EQUAL);
STRINGISE_ENUM(D3D12_COMPARISON_FUNC_ALWAYS);
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_DEPTH_WRITE_MASK &el)
{
BEGIN_ENUM_STRINGISE(D3D12_DEPTH_WRITE_MASK);
{
STRINGISE_ENUM(D3D12_DEPTH_WRITE_MASK_ZERO)
STRINGISE_ENUM(D3D12_DEPTH_WRITE_MASK_ALL)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_STENCIL_OP &el)
{
// possible for unused fields via 0-initialisation
if((int)el == 0)
return "--";
BEGIN_ENUM_STRINGISE(D3D12_STENCIL_OP);
{
STRINGISE_ENUM(D3D12_STENCIL_OP_KEEP);
STRINGISE_ENUM(D3D12_STENCIL_OP_ZERO);
STRINGISE_ENUM(D3D12_STENCIL_OP_REPLACE);
STRINGISE_ENUM(D3D12_STENCIL_OP_INCR_SAT);
STRINGISE_ENUM(D3D12_STENCIL_OP_DECR_SAT);
STRINGISE_ENUM(D3D12_STENCIL_OP_INVERT);
STRINGISE_ENUM(D3D12_STENCIL_OP_INCR);
STRINGISE_ENUM(D3D12_STENCIL_OP_DECR);
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_INPUT_CLASSIFICATION &el)
{
BEGIN_ENUM_STRINGISE(D3D12_INPUT_CLASSIFICATION);
{
STRINGISE_ENUM(D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA)
STRINGISE_ENUM(D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_INDEX_BUFFER_STRIP_CUT_VALUE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE);
{
STRINGISE_ENUM(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_DISABLED)
STRINGISE_ENUM(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFF)
STRINGISE_ENUM(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFFFFFF)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_PRIMITIVE_TOPOLOGY_TYPE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_PRIMITIVE_TOPOLOGY_TYPE);
{
STRINGISE_ENUM(D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED)
STRINGISE_ENUM(D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT)
STRINGISE_ENUM(D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE)
STRINGISE_ENUM(D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE)
STRINGISE_ENUM(D3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCH)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_INDIRECT_ARGUMENT_TYPE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_INDIRECT_ARGUMENT_TYPE);
{
STRINGISE_ENUM(D3D12_INDIRECT_ARGUMENT_TYPE_DRAW)
STRINGISE_ENUM(D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED)
STRINGISE_ENUM(D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH)
STRINGISE_ENUM(D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW)
STRINGISE_ENUM(D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW)
STRINGISE_ENUM(D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT)
STRINGISE_ENUM(D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW)
STRINGISE_ENUM(D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW)
STRINGISE_ENUM(D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_COMMAND_LIST_TYPE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_COMMAND_LIST_TYPE);
{
STRINGISE_ENUM(D3D12_COMMAND_LIST_TYPE_DIRECT)
STRINGISE_ENUM(D3D12_COMMAND_LIST_TYPE_BUNDLE)
STRINGISE_ENUM(D3D12_COMMAND_LIST_TYPE_COMPUTE)
STRINGISE_ENUM(D3D12_COMMAND_LIST_TYPE_COPY)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_TEXTURE_COPY_TYPE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_TEXTURE_COPY_TYPE);
{
STRINGISE_ENUM(D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX)
STRINGISE_ENUM(D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_RESOURCE_DIMENSION &el)
{
BEGIN_ENUM_STRINGISE(D3D12_RESOURCE_DIMENSION);
{
STRINGISE_ENUM(D3D12_RESOURCE_DIMENSION_UNKNOWN)
STRINGISE_ENUM(D3D12_RESOURCE_DIMENSION_BUFFER)
STRINGISE_ENUM(D3D12_RESOURCE_DIMENSION_TEXTURE1D)
STRINGISE_ENUM(D3D12_RESOURCE_DIMENSION_TEXTURE2D)
STRINGISE_ENUM(D3D12_RESOURCE_DIMENSION_TEXTURE3D)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_TEXTURE_LAYOUT &el)
{
BEGIN_ENUM_STRINGISE(D3D12_TEXTURE_LAYOUT);
{
STRINGISE_ENUM(D3D12_TEXTURE_LAYOUT_UNKNOWN)
STRINGISE_ENUM(D3D12_TEXTURE_LAYOUT_ROW_MAJOR)
STRINGISE_ENUM(D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE)
STRINGISE_ENUM(D3D12_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_TILED_RESOURCES_TIER &el)
{
BEGIN_ENUM_STRINGISE(D3D12_TILED_RESOURCES_TIER);
{
STRINGISE_ENUM(D3D12_TILED_RESOURCES_TIER_NOT_SUPPORTED)
STRINGISE_ENUM(D3D12_TILED_RESOURCES_TIER_1)
STRINGISE_ENUM(D3D12_TILED_RESOURCES_TIER_2)
STRINGISE_ENUM(D3D12_TILED_RESOURCES_TIER_3)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_RESOLVE_MODE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_RESOLVE_MODE);
{
STRINGISE_ENUM(D3D12_RESOLVE_MODE_AVERAGE)
STRINGISE_ENUM(D3D12_RESOLVE_MODE_DECOMPRESS)
STRINGISE_ENUM(D3D12_RESOLVE_MODE_MAX)
STRINGISE_ENUM(D3D12_RESOLVE_MODE_MIN)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_WRITEBUFFERIMMEDIATE_MODE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_WRITEBUFFERIMMEDIATE_MODE);
{
STRINGISE_ENUM(D3D12_WRITEBUFFERIMMEDIATE_MODE_DEFAULT)
STRINGISE_ENUM(D3D12_WRITEBUFFERIMMEDIATE_MODE_MARKER_IN)
STRINGISE_ENUM(D3D12_WRITEBUFFERIMMEDIATE_MODE_MARKER_OUT)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE);
{
STRINGISE_ENUM(D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_DISCARD)
STRINGISE_ENUM(D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE)
STRINGISE_ENUM(D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR)
STRINGISE_ENUM(D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_NO_ACCESS)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_RENDER_PASS_ENDING_ACCESS_TYPE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_RENDER_PASS_ENDING_ACCESS_TYPE);
{
STRINGISE_ENUM(D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_DISCARD)
STRINGISE_ENUM(D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE)
STRINGISE_ENUM(D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE)
STRINGISE_ENUM(D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_NO_ACCESS)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_SHADING_RATE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_SHADING_RATE);
{
STRINGISE_ENUM(D3D12_SHADING_RATE_1X1)
STRINGISE_ENUM(D3D12_SHADING_RATE_1X2)
STRINGISE_ENUM(D3D12_SHADING_RATE_2X1)
STRINGISE_ENUM(D3D12_SHADING_RATE_2X2)
STRINGISE_ENUM(D3D12_SHADING_RATE_2X4)
STRINGISE_ENUM(D3D12_SHADING_RATE_4X2)
STRINGISE_ENUM(D3D12_SHADING_RATE_4X4)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_SHADING_RATE_COMBINER &el)
{
BEGIN_ENUM_STRINGISE(D3D12_SHADING_RATE_COMBINER);
{
STRINGISE_ENUM(D3D12_SHADING_RATE_COMBINER_PASSTHROUGH)
STRINGISE_ENUM(D3D12_SHADING_RATE_COMBINER_OVERRIDE)
STRINGISE_ENUM(D3D12_SHADING_RATE_COMBINER_MIN)
STRINGISE_ENUM(D3D12_SHADING_RATE_COMBINER_MAX)
STRINGISE_ENUM(D3D12_SHADING_RATE_COMBINER_SUM)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_ROOT_PARAMETER_TYPE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_ROOT_PARAMETER_TYPE);
{
STRINGISE_ENUM(D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE)
STRINGISE_ENUM(D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS)
STRINGISE_ENUM(D3D12_ROOT_PARAMETER_TYPE_CBV)
STRINGISE_ENUM(D3D12_ROOT_PARAMETER_TYPE_SRV)
STRINGISE_ENUM(D3D12_ROOT_PARAMETER_TYPE_UAV)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_SHADER_VISIBILITY &el)
{
BEGIN_ENUM_STRINGISE(D3D12_SHADER_VISIBILITY);
{
STRINGISE_ENUM(D3D12_SHADER_VISIBILITY_ALL)
STRINGISE_ENUM(D3D12_SHADER_VISIBILITY_VERTEX)
STRINGISE_ENUM(D3D12_SHADER_VISIBILITY_HULL)
STRINGISE_ENUM(D3D12_SHADER_VISIBILITY_DOMAIN)
STRINGISE_ENUM(D3D12_SHADER_VISIBILITY_GEOMETRY)
STRINGISE_ENUM(D3D12_SHADER_VISIBILITY_PIXEL)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_STATIC_BORDER_COLOR &el)
{
BEGIN_ENUM_STRINGISE(D3D12_STATIC_BORDER_COLOR);
{
STRINGISE_ENUM(D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK)
STRINGISE_ENUM(D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK)
STRINGISE_ENUM(D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_DESCRIPTOR_RANGE_TYPE &el)
{
BEGIN_ENUM_STRINGISE(D3D12_DESCRIPTOR_RANGE_TYPE);
{
STRINGISE_ENUM(D3D12_DESCRIPTOR_RANGE_TYPE_SRV)
STRINGISE_ENUM(D3D12_DESCRIPTOR_RANGE_TYPE_UAV)
STRINGISE_ENUM(D3D12_DESCRIPTOR_RANGE_TYPE_CBV)
STRINGISE_ENUM(D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER)
}
END_ENUM_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_CLEAR_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_CLEAR_FLAGS);
{
STRINGISE_BITFIELD_BIT(D3D12_CLEAR_FLAG_DEPTH);
STRINGISE_BITFIELD_BIT(D3D12_CLEAR_FLAG_STENCIL);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_BUFFER_SRV_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_BUFFER_SRV_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_BUFFER_SRV_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_BUFFER_SRV_FLAG_RAW);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_DSV_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_DSV_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_DSV_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_DSV_FLAG_READ_ONLY_DEPTH);
STRINGISE_BITFIELD_BIT(D3D12_DSV_FLAG_READ_ONLY_STENCIL);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_BUFFER_UAV_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_BUFFER_UAV_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_BUFFER_UAV_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_BUFFER_UAV_FLAG_RAW);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_HEAP_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_HEAP_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_HEAP_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_HEAP_FLAG_SHARED);
STRINGISE_BITFIELD_BIT(D3D12_HEAP_FLAG_DENY_BUFFERS);
STRINGISE_BITFIELD_BIT(D3D12_HEAP_FLAG_ALLOW_DISPLAY);
STRINGISE_BITFIELD_BIT(D3D12_HEAP_FLAG_SHARED_CROSS_ADAPTER);
STRINGISE_BITFIELD_BIT(D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES);
STRINGISE_BITFIELD_BIT(D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES);
STRINGISE_BITFIELD_BIT(D3D12_HEAP_FLAG_HARDWARE_PROTECTED);
STRINGISE_BITFIELD_BIT(D3D12_HEAP_FLAG_ALLOW_WRITE_WATCH);
STRINGISE_BITFIELD_BIT(D3D12_HEAP_FLAG_ALLOW_SHADER_ATOMICS);
STRINGISE_BITFIELD_BIT(D3D12_HEAP_FLAG_CREATE_NOT_RESIDENT);
STRINGISE_BITFIELD_BIT(D3D12_HEAP_FLAG_CREATE_NOT_ZEROED);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_FENCE_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_FENCE_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_FENCE_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_FENCE_FLAG_SHARED);
STRINGISE_BITFIELD_BIT(D3D12_FENCE_FLAG_SHARED_CROSS_ADAPTER);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_DESCRIPTOR_HEAP_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_DESCRIPTOR_HEAP_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_DESCRIPTOR_HEAP_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_RESOURCE_BARRIER_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_RESOURCE_BARRIER_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_RESOURCE_BARRIER_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_BARRIER_FLAG_BEGIN_ONLY);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_BARRIER_FLAG_END_ONLY);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_RESOURCE_STATES &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_RESOURCE_STATES);
{
STRINGISE_BITFIELD_VALUE(D3D12_RESOURCE_STATE_COMMON);
STRINGISE_BITFIELD_VALUE(D3D12_RESOURCE_STATE_GENERIC_READ);
STRINGISE_BITFIELD_VALUE(D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_INDEX_BUFFER);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_RENDER_TARGET);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_DEPTH_WRITE);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_DEPTH_READ);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_STREAM_OUT);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_COPY_DEST);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_COPY_SOURCE);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_RESOLVE_DEST);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_RESOLVE_SOURCE);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_SHADING_RATE_SOURCE);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_VIDEO_DECODE_READ);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_VIDEO_PROCESS_READ);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_VIDEO_PROCESS_WRITE);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_VIDEO_ENCODE_READ);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_STATE_VIDEO_ENCODE_WRITE);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_PIPELINE_STATE_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_PIPELINE_STATE_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_PIPELINE_STATE_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_PIPELINE_STATE_FLAG_TOOL_DEBUG);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_RESOURCE_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_RESOURCE_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_RESOURCE_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER);
STRINGISE_BITFIELD_BIT(D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_COMMAND_QUEUE_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_COMMAND_QUEUE_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_COMMAND_QUEUE_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_COMMAND_QUEUE_FLAG_DISABLE_GPU_TIMEOUT);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_TILE_COPY_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_TILE_COPY_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_TILE_COPY_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_TILE_COPY_FLAG_NO_HAZARD);
STRINGISE_BITFIELD_BIT(D3D12_TILE_COPY_FLAG_LINEAR_BUFFER_TO_SWIZZLED_TILED_RESOURCE);
STRINGISE_BITFIELD_BIT(D3D12_TILE_COPY_FLAG_SWIZZLED_TILED_RESOURCE_TO_LINEAR_BUFFER);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_TILE_MAPPING_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_TILE_MAPPING_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_TILE_MAPPING_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_TILE_MAPPING_FLAG_NO_HAZARD);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_TILE_RANGE_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_TILE_RANGE_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_TILE_RANGE_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_TILE_RANGE_FLAG_NULL);
STRINGISE_BITFIELD_BIT(D3D12_TILE_RANGE_FLAG_SKIP);
STRINGISE_BITFIELD_BIT(D3D12_TILE_RANGE_FLAG_REUSE_SINGLE_TILE);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_COLOR_WRITE_ENABLE &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_COLOR_WRITE_ENABLE);
{
STRINGISE_BITFIELD_VALUE(D3D12_COLOR_WRITE_ENABLE_ALL);
STRINGISE_BITFIELD_BIT(D3D12_COLOR_WRITE_ENABLE_RED);
STRINGISE_BITFIELD_BIT(D3D12_COLOR_WRITE_ENABLE_GREEN);
STRINGISE_BITFIELD_BIT(D3D12_COLOR_WRITE_ENABLE_BLUE);
STRINGISE_BITFIELD_BIT(D3D12_COLOR_WRITE_ENABLE_ALPHA);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_VIEW_INSTANCING_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_VIEW_INSTANCING_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_VIEW_INSTANCING_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_VIEW_INSTANCING_FLAG_ENABLE_VIEW_INSTANCE_MASKING);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_COMMAND_LIST_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_COMMAND_LIST_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_COMMAND_LIST_FLAG_NONE);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_RENDER_PASS_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_RENDER_PASS_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_RENDER_PASS_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_RENDER_PASS_FLAG_ALLOW_UAV_WRITES);
STRINGISE_BITFIELD_BIT(D3D12_RENDER_PASS_FLAG_SUSPENDING_PASS);
STRINGISE_BITFIELD_BIT(D3D12_RENDER_PASS_FLAG_RESUMING_PASS);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_ROOT_SIGNATURE_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_ROOT_SIGNATURE_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_ROOT_SIGNATURE_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT);
STRINGISE_BITFIELD_BIT(D3D12_ROOT_SIGNATURE_FLAG_DENY_VERTEX_SHADER_ROOT_ACCESS);
STRINGISE_BITFIELD_BIT(D3D12_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS);
STRINGISE_BITFIELD_BIT(D3D12_ROOT_SIGNATURE_FLAG_DENY_DOMAIN_SHADER_ROOT_ACCESS);
STRINGISE_BITFIELD_BIT(D3D12_ROOT_SIGNATURE_FLAG_DENY_GEOMETRY_SHADER_ROOT_ACCESS);
STRINGISE_BITFIELD_BIT(D3D12_ROOT_SIGNATURE_FLAG_DENY_PIXEL_SHADER_ROOT_ACCESS);
STRINGISE_BITFIELD_BIT(D3D12_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT);
STRINGISE_BITFIELD_BIT(D3D12_ROOT_SIGNATURE_FLAG_LOCAL_ROOT_SIGNATURE);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_ROOT_DESCRIPTOR_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_ROOT_DESCRIPTOR_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_ROOT_DESCRIPTOR_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_ROOT_DESCRIPTOR_FLAG_DATA_VOLATILE);
STRINGISE_BITFIELD_BIT(D3D12_ROOT_DESCRIPTOR_FLAG_DATA_STATIC_WHILE_SET_AT_EXECUTE);
STRINGISE_BITFIELD_BIT(D3D12_ROOT_DESCRIPTOR_FLAG_DATA_STATIC);
}
END_BITFIELD_STRINGISE();
}
template <>
rdcstr DoStringise(const D3D12_DESCRIPTOR_RANGE_FLAGS &el)
{
BEGIN_BITFIELD_STRINGISE(D3D12_DESCRIPTOR_RANGE_FLAGS);
{
STRINGISE_BITFIELD_VALUE(D3D12_DESCRIPTOR_RANGE_FLAG_NONE);
STRINGISE_BITFIELD_BIT(D3D12_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_VOLATILE);
STRINGISE_BITFIELD_BIT(D3D12_DESCRIPTOR_RANGE_FLAG_DATA_VOLATILE);
STRINGISE_BITFIELD_BIT(D3D12_DESCRIPTOR_RANGE_FLAG_DATA_STATIC_WHILE_SET_AT_EXECUTE);
STRINGISE_BITFIELD_BIT(D3D12_DESCRIPTOR_RANGE_FLAG_DATA_STATIC);
STRINGISE_BITFIELD_BIT(
D3D12_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS);
}
END_BITFIELD_STRINGISE();
}
| [
"[email protected]"
] | |
801577cd4a6c19e42b10e1fd52b7b22452a8d337 | b11b2b488d94ae20f58cfe40bae0987c32b5945e | /LEMOS-2.3.x/tutorials/mesh/movingBlockRBF/constant/turbulenceProperties | 692307c1ebe81f02be4787b6ad6407e7c379394c | [] | no_license | jamesjguthrie/mayerTestCase | 93dbd9230e16a0f061cec97c7ddf6cb5303e1c95 | 9279ad56b62efa1507ff8b1bcd96e3ce2daceb56 | refs/heads/master | 2021-03-30T18:20:33.641846 | 2019-06-25T12:55:07 | 2019-06-25T12:55:07 | 26,530,210 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 900 | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.2.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType laminar;
// ************************************************************************* //
| [
"[email protected]"
] | ||
3b20e4b211effe0ad62ebeac288a5bcae65d6f96 | 97aab27d4410969e589ae408b2724d0faa5039e2 | /SDK/EXES/INSTALL VISUAL 6 SDK/INPUT/6.0_980820/MSDN/VCPP/SMPL/MSDN98/98VSa/1036/SAMPLES/VC98/atl/atltangram/atltangramcanvas/atltangramcanvasimpl.cpp | af476458b2e304cfdabcd3209eb21ff29537eefb | [] | no_license | FutureWang123/dreamcast-docs | 82e4226cb1915f8772418373d5cb517713f858e2 | 58027aeb669a80aa783a6d2cdcd2d161fd50d359 | refs/heads/master | 2021-10-26T00:04:25.414629 | 2018-08-10T21:20:37 | 2018-08-10T21:20:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,297 | cpp | // AtlTangramCanvasImpl.cpp : Implementation of CAtlTangramCanvas
//
// This is a part of the Active Template Library.
// Copyright (C) 1996-1998 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Active Template Library Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Active Template Library product.
#include "stdafx.h"
#include "ATLTangramCanvas.h"
#include "AtlTangramCanvasImpl.h"
/////////////////////////////////////////////////////////////////////////////
// CAtlTangramCanvas
//
///////////////////////////////////////////////////////////
//
// Initialize
//
HRESULT CAtlTangramCanvas::Initialize(HWND hWnd, long cx, long cy)
{
// Hard coded to 8 bits per pixel.
int ibitcount = 8 ;
// Preconditions.
if ( hWnd == NULL || !::IsWindow(hWnd) || cx <= 0 || cy <= 0)
{
// Definsive code.
ASSERT(hWnd != NULL) ;
ASSERT(::IsWindow(hWnd)) ;
ASSERT(cx > 0);
ASSERT(cy > 0);
return E_INVALIDARG ;
}
// Cache a copy of the window handle.
m_hWnd = hWnd ;
// Destroy parts of objects if we are recreating it.
if ((m_hdc != NULL) || (m_hbmp != NULL))
{
// destroy() ;
}
// Save size for drawing later.
m_sizeDIB.cx = cx ;
m_sizeDIB.cy = cy ;
// Create a BITMAPINFOHEADER structure to describe the DIB
BITMAPINFOHEADER BIH ;
int iSize = sizeof(BITMAPINFOHEADER) ;
memset(&BIH, 0, iSize);
// Fill in the header info.
BIH.biSize = iSize;
BIH.biWidth = cx;
BIH.biHeight = cy;
BIH.biPlanes = 1;
BIH.biBitCount = ibitcount;
BIH.biCompression = BI_RGB;
// Create a new DC.
m_hdc = ::CreateCompatibleDC(NULL) ;
// Create the DIB section.
m_hbmp = CreateDIBSection( m_hdc,
(BITMAPINFO*)&BIH,
DIB_PAL_COLORS,
&m_pBits,
NULL,
0);
ASSERT(m_hbmp);
ASSERT(m_pBits);
// Select the new bitmap into the buffer DC
if (m_hbmp)
{
m_hbmOld = (HBITMAP)::SelectObject( m_hdc,
m_hbmp);
}
return S_OK ;
}
///////////////////////////////////////////////////////////
//
// Transfer the dib section to a DC.
// Called in response to paint and draw messages.
//
HRESULT CAtlTangramCanvas::Paint(HDC hdcDest, RECT rectUpdate)
{
// Preconditions
if ( hdcDest == NULL)
{
ASSERT(hdcDest != NULL) ;
return E_INVALIDARG ;
}
// Select in a palette if we have one.
HPALETTE hPalOld = NULL;
if (m_hPal)
{
hPalOld = ::SelectPalette(hdcDest, (HPALETTE)m_hPal, 0);
::RealizePalette(hdcDest);
}
// If the rectangle is empty or null, repaint the entire area.
RECT rect, rectNull ;
::SetRectEmpty(&rectNull) ;
::CopyRect(&rect, &rectUpdate) ;
if (::EqualRect(&rect, &rectNull) || ::IsRectEmpty(&rect))
{
// Note: you do not need to select the palette into
// the memory DC because the DIB section is using palette
// index values not colors
::BitBlt(hdcDest, 0, 0,
m_sizeDIB.cx, m_sizeDIB.cy,
m_hdc,
0,0,
SRCCOPY);
}
else
{
// Just repaint the updated area.
::BitBlt(hdcDest,
rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top,
m_hdc,
rect.left, rect.top,
SRCCOPY);
}
// We are done with the palette
if (hPalOld)
{
::SelectPalette(hdcDest, hPalOld, 0);
}
return S_OK ;
}
///////////////////////////////////////////////////////////
//
// Update
//
HRESULT CAtlTangramCanvas::Update(RECT rectUpdate)
{
HDC hdcDest = ::GetDC(m_hWnd) ;
Paint(hdcDest, rectUpdate) ;
::ReleaseDC(m_hWnd, hdcDest);
return S_OK ;
}
///////////////////////////////////////////////////////////
//
// GetHDC
//
HRESULT CAtlTangramCanvas::GetHDC(HDC* phdc)
{
// Pre conditions.
if (!IsValidAddress(phdc, sizeof(HDC), TRUE))
{
ASSERT(0) ;
return E_FAIL ;
}
// Return device context.
*phdc = m_hdc ;
return S_OK ;
}
///////////////////////////////////////////////////////////
//
// Set the color table in the DIB section.
//
HRESULT __stdcall CAtlTangramCanvas::SetPalette(HPALETTE hPal)
{
if (hPal == NULL)
{
ASSERT(hPal != NULL);
return E_INVALIDARG ;
}
// Keep a copy of the palette around for painting.
m_hPal = hPal ;
// get the colors from the palette
int iColors = 0;
::GetObject(hPal, sizeof(iColors), &iColors) ;
ASSERT(iColors > 0);
PALETTEENTRY* pPE = new PALETTEENTRY[iColors];
::GetPaletteEntries(hPal, 0, iColors, pPE);
// Build a table of RGBQUADS
RGBQUAD* pRGB = new RGBQUAD[iColors];
ASSERT(pRGB);
for (int i = 0; i < iColors; i++) {
pRGB[i].rgbRed = pPE[i].peRed;
pRGB[i].rgbGreen = pPE[i].peGreen;
pRGB[i].rgbBlue = pPE[i].peBlue;
pRGB[i].rgbReserved = 0;
}
::SetDIBColorTable(m_hdc,
0, iColors,
pRGB);
delete [] pRGB;
delete [] pPE;
return S_OK ;
}
///////////////////////////////////////////////////////////
//
// Called when the main window gets a QueryNewPalette or a
// PaletteChanged message.
//
HRESULT __stdcall CAtlTangramCanvas::OnQueryNewPalette(HWND hWndReceived)
{
if (hWndReceived == NULL)
{
return E_FAIL ;
}
if (m_hPal)
{
HDC hdc = ::GetDC(hWndReceived) ;
::SelectPalette(hdc, m_hPal, FALSE) ;
UINT u = ::RealizePalette(hdc) ;
::ReleaseDC(hWndReceived, hdc) ;
if (u != 0)
{
::InvalidateRect(hWndReceived, NULL, TRUE) ;
}
}
return S_OK ;
} | [
"[email protected]"
] | |
5264cc54bca04f7c04401d8af196c0b133a29883 | da74ee93fd07d0f66f0a102b194b75e456948a95 | /problemset-new/011/01105-filling-bookcase-shelves/tiankonguse.cpp | 07e48eaeaf7eca38eb38f41d1c5c81120cc05b8b | [] | no_license | L65430/leetcode-solutions | c01a0199d017e89c63c41da22671d5cec2456834 | 8d3f9c04fdc1273c03d9893b8f4e1a45a6aef59f | refs/heads/master | 2020-06-13T10:35:59.220331 | 2019-06-30T13:11:07 | 2019-06-30T13:11:07 | 194,629,079 | 1 | 0 | null | 2019-07-01T08:13:36 | 2019-07-01T08:13:36 | null | UTF-8 | C++ | false | false | 1,538 | cpp | /*************************************************************************
> File Name: filling-bookcase-shelves.cpp
> Author: tiankonguse
> Mail: [email protected]
> Created Time: 2019年06月30日 11:37:47
> link:
> No: 1105. Filling Bookcase Shelves
> Contest: https://leetcode.com/contest/weekly-contest-143
************************************************************************/
#include "../../../include/base.h"
class Solution {
public:
int minHeightShelves(vector<vector<int>>& books, int shelf_width) {
vector<int> dp(books.size()+1, 1000*1000);
dp[0] = 0;
for(int i=1;i<=books.size(); i++){
auto& b = books[i-1];
int w = b[0];
int h = b[1];
dp[i] = dp[i-1] + h;
for(int j=i-1;j>0;j--){
w += books[j-1][0];
h = max(h, books[j-1][1]);
if(w > shelf_width)break;
dp[i] = min(dp[i], dp[j-1] + h);
}
}
return dp[books.size()];
}
};
/*
//ListNode* root = vecToList({1,2,3,4});
// vecToTree({});
// std::reverse(a.begin(),a.end());
//int dir[4][2] = {{0,1},{0,-1},{1,0},{-1,0}};
*/
int main() {
#define CLASS Solution
#define FUNCTION smallestRepunitDivByK
int first;
int second;
int expectAns;
first = 113;
second = 1;
expectAns = -1;
TEST_SMP1(CLASS, FUNCTION, expectAns, first);
//TEST_SMP2(Solution, FUNCTION, expectAns, first, second);
return 0;
}
| [
"[email protected]"
] | |
3d75180851068227cf8199ae4dc3e6e68cfc9304 | 408a6a47509db59838a45d362707ffe6d2967a70 | /Classes/GameOver.cpp | 4d28e2c16ffb00c84449f7382cbee3caf90a2efa | [] | no_license | DanicaMeng/RabbitRun | 87d511645b90d9129d026b636adcb3e1b8854dd8 | 97892a01876186a2e69ff9776c70bdf2ea10f9bd | refs/heads/master | 2021-05-15T21:14:05.028696 | 2018-10-19T04:08:30 | 2018-10-19T04:08:30 | 27,667,757 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,388 | cpp | #include "GameOver.h"
#include "Global.h"
#include "GameScene.h"
#include "DataM.h"
GameOver::GameOver()
{
}
GameOver::~GameOver()
{
}
bool GameOver::init()
{
if ( !CCLayerColor::initWithColor(ccc4(0, 0, 0, 200)) )
{
return false;
}
DataM::getInstance()->saveHighScore();
CCLabelTTF *title = CCLabelTTF::create("Game Over", FONT_NAME, 90);
title->setPosition(ccp(SCREEN_CX, SCREEN_HEIGHT - 100));
this->addChild(title);
char s[128];
sprintf(s, "High Score: %d", DataM::getInstance()->getHighScore());
CCLabelTTF *highScore = CCLabelTTF::create(s, FONT_NAME, 80);
highScore->setAnchorPoint(ccp(0.5f, 0.5f));
highScore->setPosition(ccp(SCREEN_CX, SCREEN_HEIGHT - 250));
highScore->setColor(ccc3(255,245, 0));
this->addChild(highScore);
sprintf(s, "Score: %d", DataM::getInstance()->getScore());
CCLabelTTF *scoreShow = CCLabelTTF::create(s, FONT_NAME, 80);
scoreShow->setAnchorPoint(ccp(0.5f, 0.5f));
scoreShow->setPosition(ccp(SCREEN_CX, SCREEN_HEIGHT - 380));
scoreShow->setColor(ccc3(255,245, 0));
this->addChild(scoreShow);
CCSprite *_eagle_catch = CCSprite::createWithSpriteFrameName("eagle_dive_left.png");
_eagle_catch->setPosition(ccp(275, SCREEN_HEIGHT - 260));
_eagle_catch->setScale(0.9f);
this->addChild(_eagle_catch,1);
CCSprite *_rabbit_catched = CCSprite::create("rabbit_catched.png");
_rabbit_catched->setPosition(ccp(220, SCREEN_HEIGHT - 350));
_rabbit_catched->setScale(0.25f);
this->addChild(_rabbit_catched,2);
CCMenuItemFont::setFontName(FONT_NAME);
CCMenuItemFont::setFontSize(50);
CCMenuItemFont *restartGame = CCMenuItemFont::create("Replay", this, menu_selector(GameOver::restartGame));
restartGame->setColor(ccc3(0, 255,51));
restartGame->setPositionX(-70);
CCMenuItemFont *exitGame = CCMenuItemFont::create("Exit", this, menu_selector(GameOver::exitGame));
exitGame->setColor(ccc3(255, 0, 0));
exitGame->setPositionX(130);
CCMenu *menu = CCMenu::create(exitGame, restartGame, NULL);
menu->setPositionY(220);
menu->setTouchPriority(-201);
this->addChild(menu);
this->setTouchPriority(-200);
this->setTouchMode(kCCTouchesOneByOne);
this->setTouchEnabled(true);
return true;
}
void GameOver::restartGame(CCObject* sender)
{
this->removeFromParent();
g_gameScene->restartGame();
}
void GameOver::exitGame(CCObject* sender)
{
DataM::purge();
CCDirector::sharedDirector()->end();
} | [
"[email protected]"
] | |
df0c6e86829ad53b3d1fef0a6fb5f33d2f5b147e | ab45de67f367fe254e8b4cae5f0f9e52cecaac78 | /kozDX/PixelShader.cpp | 1446b5d28f176d24c9f7eb77edaa2ecda5ba8f36 | [] | no_license | kozonoyuki/kozDX | 3e23ebc157fcf33fdc9c8e6f2f226737ade6ae97 | 96cf89d7be0c3c35d1c973ccbca83a1936ae12b4 | refs/heads/master | 2021-03-24T12:27:56.238957 | 2015-05-09T13:30:42 | 2015-05-09T13:30:42 | 27,296,073 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,442 | cpp | /**
* @file PixelShader.cpp
* @brief ピクセルシェーダをラップ
* @author kozonoyuki
* @date 11/29に書き始め
*/
#include "stdafx.h"
#include "PixelShader.h"
#include "Utility.h"
koz::PixelShader::PixelShader()
{
// デフォルト設定
m_EntryName = "PS";
m_ShaderVersion = "ps_4_0";
}
koz::PixelShader::~PixelShader()
{
}
HRESULT koz::PixelShader::Create(CComPtr<ID3D11Device> pDevice, std::string ShaderPath)
{
HRESULT hr = S_OK;
ID3D11PixelShader* pPixelShader = nullptr;
ID3DBlob* pBlob = nullptr;
hr = CompileShaderFromFile(StringToWcstring(ShaderPath), m_EntryName.c_str(), m_ShaderVersion.c_str(), &pBlob);
if (FAILED(hr))
{
MessageBox(nullptr, L"ピクセルシェーダをコンパイルできませんでした。", L"Error", MB_OK);
return hr;
}
hr = pDevice->CreatePixelShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), nullptr, &pPixelShader);
if (FAILED(hr))
{
MessageBox(nullptr, L"ピクセルシェーダを作成することができませんでした。", L"Error", MB_OK);
return hr;
}
m_PixelShader.Attach(pPixelShader);
return hr;
}
void koz::PixelShader::SetEntryName(std::string EntryName)
{
m_EntryName = EntryName;
}
void koz::PixelShader::SetShaderVersion(std::string ShaderVersion)
{
m_ShaderVersion = ShaderVersion;
}
void koz::PixelShader::Set(CComPtr<ID3D11DeviceContext> pDeviceContext)
{
pDeviceContext->PSSetShader(m_PixelShader, nullptr, 0);
} | [
"[email protected]"
] | |
87eaf8f12389f7542c70948771ffab1d763bc27a | eea72893d7360d41901705ee4237d7d2af33c492 | /src/rich/CsRCLikeAll05.cc | 924c25c1d0de1869811e688242f2f6edc65ba442 | [] | no_license | lsilvamiguel/Coral.Efficiencies.r14327 | 5488fca306a55a7688d11b1979be528ac39fc433 | 37be8cc4e3e5869680af35b45f3d9a749f01e50a | refs/heads/master | 2021-01-19T07:22:59.525828 | 2017-04-07T11:56:42 | 2017-04-07T11:56:42 | 87,541,002 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 37,720 | cc | /*!
\File CsRCLikeAll05.cc
\----------------------------
\brief CsRCLikeAll05 class implementation.
\author Paolo Schiavon
\version 1.0
\date May 2004
*/
#include <iostream>
#include <ostream>
#include <cstdio>
#include <iomanip>
#include "CsOpt.h"
#include "CsHist.h"
#include "CsHistograms.h"
//------------------------------
#include "CsRCLikeAll.h"
#include "CsRCLikeAll05.h"
#include "CsRCParticle.h"
#include "CsRCCluster.h"
#include "CsRCEventPartPhotons.h"
#include "CsRCPartPhotons.h"
#include "CsRCPhoton.h"
#include "CsRCHistos.h"
#include "CsRCRecConst.h"
#include "CsRCExeKeys.h"
#include "CsErrLog.h"
#include "CsRCMirrors.h"
#include "CsRCDetectors.h"
#include "CsRCUty.h"
//------------------------------
using namespace std;
using namespace CLHEP;
//===========================================================================
CsRCLikeAll05::CsRCLikeAll05( const CsRCPartPhotons* papho ):
//-------------------------------------------------------------
CsRCLikeAll() {
pPartPhot_ = papho;
}
//===========================================================================
CsRCLikeAll05::~CsRCLikeAll05() {}
//----------------------------------
extern "C" {
float prob_( const float&, const int& );
float erf_( const float& );
}
//===========================================================================
double CsRCLikeAll05::normSignal( const double theIpo ) {
//---------------------------------------------------------
//- compute Signal normalization for Likelihood
// -------------------------------------------
//- Paolo - May 2004
// Rev. January 2005
// Rev. May 2006
CsRCRecConst* cons = CsRCRecConst::Instance();
static const double TwoPI = cons->TwoPI();
static const double Drad = 360./ TwoPI;
int sz = pPartPhot_->lPhotons().size();
static const bool exeFrac = true;
//static const bool exeFrac = false;
//@@--------------------------------
CsRCHistos& hist = CsRCHistos::Ref();
int level = hist.levelBk();
bool doHist = false;
if ( level >= 2 ) doHist = true;
double xh, yh, wh;
bool testHist = true;
//@@--------------------
static int kOffHi = cons->kOffHi();
static CsHist1D *hRC0011 = NULL;
static CsHist1D *hRC0012 = NULL;
static CsHist1D *hRC0013 = NULL;
static bool firstCall = true;
if( firstCall ) {
firstCall = false;
std::cout << " Useful Photons ";
if( exeFrac ) std::cout << "ON";
else std::cout << "OFF";
std::cout << std::endl;
if ( testHist ) {
CsHistograms::SetCurrentPath("/RICH");
stringstream Title;
stringstream hNtest1;
stringstream hNtest2;
stringstream hNtest3;
Title << "d-nPhotExp";
hNtest1 << kOffHi + 11;
hRC0011 = new CsHist1D( hNtest1.str(), Title.str(), 100, -50., 50. );
Title << "nPhotExpP-K/sqP";
hNtest2 << kOffHi + 12;
hRC0012 = new CsHist1D( hNtest2.str(), Title.str(), 200, -0.01, 0.19);
Title << "nPhotExpP-K/sqP";
hNtest3 << kOffHi + 13;
hRC0013 = new CsHist1D( hNtest3.str(), Title.str(), 100, -50., 50. );
CsHistograms::SetCurrentPath("/");
}
}
//dump_ = true;
dump_ = false;
//useOldCode_ = true;
useOldCode_ = false;
//@@-------------------
xHole_ = 100.;
yHole_ = 60.;
rPipe_ = 50.;
//@@-------------
bool splitPatt = false;
bool newPF = false;
static int kEventC = -1;
int kEvent = CsRichOne::Instance()->kEvent();
static const CsRCPartPhotons* pPartPhotC = NULL;
if( kEvent != kEventC || pPartPhotC != pPartPhot_ ) {
newPF = true;
std::list<int> lSelCats = pPartPhot_->lSelCats();
std::list<int>::iterator isc = lSelCats.begin();
//for( isc=lSelCats.begin(); isc!=lSelCats.end(); isc++ )
//std::cout << (*isc) << " ";
//std::cout << std::endl;
int iCast = (*isc);
if( iCast > 7 ) splitPatt = false;
else {
for( isc=lSelCats.begin(); isc!=lSelCats.end(); isc++ ) {
if( (*isc) > 7 ) { splitPatt = true; break; }
}
}
splitPatt_ = splitPatt;
// ----------------------
if( dump_ )
std::cout << "CsRCLikeAll05 : === new partPhoton " << sz << std::endl;
}
kEventC = kEvent;
pPartPhotC = pPartPhot_;
CsRCPartPhotons* papho = const_cast<CsRCPartPhotons*>(pPartPhot_);
static float nPhotEx = 0.;
//- Compute expected number of Signal photons :
// -------------------------------------------
double theIrad = theIpo / 1000.;
float pathLen = pPartPhot_->pPart()->pathLen();
//nPhotEx = cons->nZero() * pathLen/10. * theIrad*theIrad;
nPhotEx = papho->nPhotExpct( theIpo );
double nPhotExS = 0.;
nPhotExS = papho->nPhotExpctCat( theIpo );
//-------------------------------------------
if( testHist ) {
if( pPartPhot_->likeONLY() ) {
xh = nPhotExS - nPhotEx;
if( hRC0011 ) hRC0011->Fill( xh );
// ---------------------------------
xh = nPhotExS - sz;
if( hRC0013 ) hRC0013->Fill( xh );
// ---------------------------------
static double nPhotExP;
if( pPartPhot_->pionONLY() ) nPhotExP = nPhotEx;
static double nPhotExK;
if( pPartPhot_->kaonONLY() && nPhotExP > 0. ) {
nPhotExK = nPhotEx;
//std::cout << "CsRCLikeAll05 " << nPhotExP << " " << nPhotExK
//<< " " << sqrt( nPhotExP ) << " "
//<< papho->pPart()->mom() << std::endl;
xh = ( nPhotExP - nPhotExK ) / sqrt( nPhotExP );
if( hRC0012 ) hRC0012->Fill( xh );
// ---------------------------------
}
}
}
//std::cout << "CsRCLikeAll05 " << nPhotEx << " " << nPhotExS << std::endl;
nPhotEx_ = nPhotEx;
// ------------------
static float fracUse = 0.;
//- Compute average photon survival prob. :
// ---------------------------------------
fracUse = 1.;
fracUsePhiSet_ = false;
if( exeFrac ) {
if( dump_ )
std::cout << "CsRCLikeAll05 : == exeFrac " << sz << std::endl;
int kDetPart = pPartPhot_->kDetPart();
Hep3Vector vPoPhot0e = pPartPhot_->pPart()->vPosEmP();
Hep3Vector vDcPart0e = pPartPhot_->pPart()->vDirIn();
CsRCMirrors *mirr = CsRCMirrors::Instance();
CsRCDetectors *dets = CsRCDetectors::Instance();
std::list<CsRCMirrorNom*> lMirrNom = mirr->lMirrNom();
std::list<CsRCMirrorNom*>::iterator in = lMirrNom.begin();
std::list<CsRCPhotonDet*> lPhoDet = dets->lPhoDet();
std::list<CsRCPhotonDet*>::iterator id = lPhoDet.begin();
// if( id == NULL || in == NULL ) return 0.;
if( id == lPhoDet.end() || in == lMirrNom.end() ) return 0.;
//--- inverse rotation
int kDetClu = kDetPart;
if( useOldCode_ ) {
if( kDetClu == 0 ) id++; // ???
if( kDetClu == 1 ) in++;
} else {
if( kDetClu == 1 ) { in++; id++; }
}
Hep3Vector vPoC0( (*in)->vC0() );
vPoC0 += mirr->vCorPoPa0();
float RR = mirr->RRv( kDetClu );
Hep3Vector vDcPartW = pPartPhot_->vDcPartW()[kDetClu];
Hep3Vector vPoPaMirr0 = pPartPhot_->pPart()->vPoPaMir0()[kDetPart];
//std::cout << vPoPaMirr0.x() << " " << vPoPaMirr0.y() << std::endl;
//std::cout << sqrt(pow(vPoPaMirr0.x(),2)+pow(vPoPaMirr0.y(),2))
// << std::endl;
double thePhot = theIpo / 1000.;
int nStepL = 10;
//@@-----------------
int nStepL2 = nStepL/2;
double dPath = pathLen / float( nStepL );
int nStepP = 36;
//@@-----------------
double dPhi = 360. / float( nStepP );
dPhi_ = dPhi;
int nTot = 0;
int nGood = 0;
//--- loop on photon angle Phi (to Y axis) :
for( int stepp=0; stepp<nStepP; stepp++ ) {
double phiPhot0 = pPartPhot_->lPhotons().front()->phiA() / Drad;
double phiPhot = 0.;
int nTotl = 0;
int nGoodl = 0;
//----- loop on photon position along part path :
for( int stepl=-nStepL2; stepl<=nStepL2; stepl++ ) {
Hep3Vector vPoPhot0 = vPoPhot0e + float( stepl )*dPath * vDcPart0e;
if( useOldCode_ ) phiPhot = (float( stepp ) * dPhi) / Drad;
else phiPhot = phiPhot0 + (float( stepp ) * dPhi) / Drad;
double tga, tgb;
tga = tan( thePhot ) * cos( phiPhot );
tgb = tan( thePhot ) * sin( phiPhot );
Hep3Vector vDcPhotWw( tga, tgb, 1.);
vDcPhotWw = vDcPhotWw.unit();
double theP, phiP;
Hep3Vector vDcPhotW = CsRCUty::Instance()->
rotfbcc( -1., vDcPartW, vDcPhotWw, theP, phiP );
// ----------------------------------------------
HepVector vrot( 3, 0 );
vrot[0] = vDcPhotW.x();
vrot[1] = vDcPhotW.y();
vrot[2] = vDcPhotW.z();
HepVector vPhot = (*id)->rotMatrix() * vrot;
Hep3Vector vDcPhot0( vPhot[0], vPhot[1], vPhot[2] );
Hep3Vector vPhotMirr0 =
mirr->vImpMir( vPoPhot0, vDcPhot0, vPoC0, RR );
// ----------------------------------------------
bool Hole = false;
double elips = pow( vPhotMirr0.x()/xHole_, 2 ) +
pow( vPhotMirr0.y()/yHole_, 2 ) - 1.;
if( elips < 0. ) Hole = true;
//Hole = false;
bool Pipe = false;
double xx = vPhotMirr0.x() - vPoPhot0.x();
double yy = vPhotMirr0.y() - vPoPhot0.y();
double mm = yy / xx;
double qq = sqrt( xx*xx + yy*yy );
//double rr = fabs( (vPoPhot0.y() * xx - vPoPhot0.x() * yy) / qq );
//double pp = vPhotMirr0.x()*vPhotMirr0.x() +
// vPhotMirr0.y()*vPhotMirr0.y();
double ssp, ssm;
if( vPoPhot0.x()*vPoPhot0.x() + vPoPhot0.y()*vPoPhot0.y()
< rPipe_*rPipe_ ) Pipe = true;
else if( vPhotMirr0.x()*vPhotMirr0.x()
+ vPhotMirr0.y()*vPhotMirr0.y()
< rPipe_*rPipe_ ) Pipe = true;
else if( fabs( (vPoPhot0.y()* xx - vPoPhot0.x()* yy)/ qq )
< rPipe_ ) {
//ssp = vPoPhot0.x() + vPoPhot0.y() * mm;
//ssm = vPhotMirr0.x() + vPhotMirr0.y() * mm;
//if( (ssp < 0. && ssm > 0.) || (ssm < 0. && ssp > 0.) )
//Pipe = true;
double aa = tga*tga + tgb*tgb;
double bb = tga*vPoPhot0.x() + tgb*vPoPhot0.y();
double cc = vPoPhot0.x()*vPoPhot0.x() + vPoPhot0.y()*vPoPhot0.y()
- rPipe_*rPipe_;
double delta = bb*bb - aa*cc;
if( delta > 0. ) {
double zp1 = ( -bb + sqrt( delta )) / aa;
double zp2 = ( -bb - sqrt( delta )) / aa;
if( !(vPoPhot0.z() > zp1 && vPoPhot0.z() > zp2) ) Pipe = true;
}
}
//Pipe = false;
nTotl++;
if( !Hole && !Pipe ) nGoodl++;
nTot++;
if( !Hole && !Pipe ) nGood++;
//std::cout << true << Hole << " " << Pipe << " " << rr << " "
//<< vPoPhot0.x() << " " << xPhotMirr0 << " " << mm << " "
//<< ssp << " " << ssm << std::endl;
}
//cout << stepp << " " << nGoodl << " " << nTotl << endl;
if( nTotl == 0 ) nTotl = 1;
fracUsePhi_[stepp] = float( nGoodl ) / float( nTotl );
// -----------------------------------------------------
//^fracUsePhiSet_ = true;
// ---------------------
}
fracUsePhiSet_ = true;
// ---------------------
//cout << "------ " << nGood << " " << nTot << endl;
if( nTot == 0 ) nTot = 1;
fracUse = float( nGood ) / float( nTot );
// ----------------------------------------
//std::cout << "05All-N " << nPhotEx << " " << fracUse << std::endl;
}
fracUse_ = fracUse;
// ------------------
papho->setFracUse( fracUse );
if( dump_ ) {
static float fracUseS;
if( newPF ) {
fracUseS = fracUse;
std::cout << setprecision(4);
std::cout << "CsRCLikeAll05 : fracUseS " << fracUse << std::endl;
std::cout << setprecision(2);
} else {
if( fracUse != fracUseS ) {
std::cout << setprecision(4);
std::cout << "CsRCLikeAll05 : ... fracUse " << fracUse << std::endl;
std::cout << setprecision(2);
}
}
}
//- Histograms :
// ------------
if( doHist ) {
xh = nPhotEx;
yh = fracUse;
if( hist.hRC1510 ) hist.hRC1510->Fill( xh, yh );
// -----------------------------------------------
Hep3Vector vPoPart0 = pPartPhot_->pPart()->vPosIn();
double rr0 = sqrt( pow( vPoPart0.x(), 2 ) + pow( vPoPart0.y(), 2 ) );
Hep3Vector vDcPart0 = pPartPhot_->pPart()->vDirIn();
double the0 = acos( vDcPart0.z() ) * 1000.;
xh = the0;
yh = rr0;
wh = fracUse;
if( hist.hRC1514 ) hist.hRC1514->Fill( xh, yh, wh );
// ---------------------------------------------------
xh = the0;
yh = rr0;
if( hist.hRC1515 ) hist.hRC1515->Fill( xh, yh );
// -----------------------------------------------
if( fracUse == 0. ) {
if( hist.hRC1624 ) hist.hRC1624->Fill( xh, yh );
// -----------------------------------------------
}
if( fracUse == 1. ) {
if( hist.hRC1625 ) hist.hRC1625->Fill( xh, yh );
// -----------------------------------------------
}
}
if( exeFrac ) nPhotEx *= fracUse;
//----------------------------------
//std::cout << theIpo << " " << pPartPhot_
// << " " << fracUse << " " << nPhotEx << std::endl;
double normS = nPhotEx;
if( theIpo <= 0. ) normS = 0.;
if( doHist ) {
xh = normS;
if( hist.hRC1577 ) hist.hRC1577->Fill( xh );
// -------------------------------------------
}
return normS;
}
//===========================================================================
double CsRCLikeAll05::normBackgr( const double theIpo ) {
//---------------------------------------------------------
//- compute Background normalization for Likelihood
// -----------------------------------------------
// NOT used - to be CHECKED!
//- Paolo - May 2004
// Rev. May 2006
// TO BE CHECKED!
CsRCRecConst* cons = CsRCRecConst::Instance();
static const double TwoPI = cons->TwoPI();
int sz = pPartPhot_->lPhotons().size();
static const float focLen = pPartPhot_->pPart()->pMirPart()->RR() / 2.;
//static const bool exeInt = false;
static const bool exeInt = true;
//@@--------------------------------
CsRCHistos& hist = CsRCHistos::Ref();
int level = hist.levelBk();
bool doHist = false;
if ( level >= 2 ) doHist = true;
double xh, yh, wh;
static bool firstCall = true;
if( firstCall ) {
firstCall = false;
std::cout << " Back Int ";
if( exeInt ) std::cout << "ON";
else std::cout << "OFF";
}
//- Compute Background integral :
//-------------------------------
double normB = 0.;
static const double theMax = 70./ 1000.;
static const int nThe = 23;
static const int nPhi = 24;
//@@--------------------------
//^long double backInt = 0.;
//^long double backIntS = 0.;
static long double backInt = 0.;
static long double backIntS = 0.;
static int kEventC = -1;
int kEvent = CsRichOne::Instance()->kEvent();
static const CsRCPartPhotons* pPartPhotC = NULL;
if( exeInt ) {
if( kEvent != kEventC || pPartPhotC != pPartPhot_ ) {
if( dump_ )
std::cout << "CsRCLikeAll05 : exeInt " << sz << std::endl;
backInt = 0.;
double dThe = theMax / float( nThe );
double dPhi = TwoPI / float( nPhi );
//std::cout << " " << dThe << " " << dPhi << std::endl;
std::list<CsRCPhoton*> lPhotons = pPartPhot_->lPhotons();
CsRCCluster clu( *(lPhotons.front()->ptToClu()) );
int kDetPart = pPartPhot_->kDetPart();
double xPade = pPartPhot_->pPart()->vPade()[kDetPart].x();
double yPade = pPartPhot_->pPart()->vPade()[kDetPart].y();
//std::cout << " " << xPade << " " << yPade << std::endl;
int iPhot = 0;
for( int kThe=0; kThe<nThe; kThe++ ) {
for( int kPhi=0; kPhi<nPhi; kPhi++ ) {
double the = kThe*dThe + dThe/2.;
double phi = kPhi*dPhi + dPhi/2.;
double xClu = xPade + focLen*the * cos( phi );
double yClu = yPade + focLen*the * sin( phi );
clu.setX( xClu );
clu.setY( yClu );
double backWgt = 0.;
if( clu.getBackWgt( backWgt ) ) {
backInt += backWgt * focLen*the * focLen*dThe * dPhi;
// ----------------------------------------------------
//std::cout << "BackInt" << " " << backWgt << " "
// << iPhot << " "
// << the << " " << phi << " " << xClu << " "
// << yClu <<std::endl;
iPhot++;
}
}
}
//backInt /= (TwoPI/2. * theMax*theMax);
//std::cout << "BackInt = " << backInt << " " << iPhot << " "
// << lPhotons.size() << std::endl;
backIntS = 0.;
if( splitPatt_ ) {
std::vector<double> vySplitLLim;
vySplitLLim = pPartPhot_->vySplitLLim();
if( vySplitLLim.size() < 2 ) {
vySplitLLim.clear();
vySplitLLim.push_back( 0. );
vySplitLLim.push_back( 0. );
}
int jDetPart = 1 - kDetPart;
xPade = pPartPhot_->pPart()->vPade()[jDetPart].x();
yPade = pPartPhot_->pPart()->vPade()[jDetPart].y();
int sign = 1 - 2 * jDetPart;
int jPhot = 0;
for( int kThe=0; kThe<nThe; kThe++ ) {
for( int kPhi=0; kPhi<nPhi; kPhi++ ) {
double the = kThe*dThe + dThe/2.;
double phi = kPhi*dPhi + dPhi/2.;
double xClu = xPade + focLen*the * cos( phi );
double yClu = yPade + focLen*the * sin( phi );
if( (yClu - vySplitLLim[jDetPart])* sign > 0. ) {
//std::cout << jDetPart << " " << yClu << " "
//<< vySplitLLim[jDetPart] << std::endl;
clu.setX( xClu );
clu.setY( yClu );
double backWgt = 0;
if( clu.getBackWgt( backWgt ) ) {
backIntS += backWgt * focLen*the * focLen*dThe * dPhi;
// -----------------------------------------------------
//std::cout << "BackIntS" << " " << backWgt << " " << iPhot
//<< " " << the << " " << phi << " " << xClu << " "
//<< yClu <<std::endl;
jPhot++;
}
}
}
}
}
//std::cout << "BackInt " << backInt << " " << backIntS
// << " " << lPhotons.size() << " " << splitPatt_ << std::endl;
//----- Histograms :
// ------------
if( doHist ) {
xh = backInt;
yh = backIntS;
if( hist.hRC1511 ) hist.hRC1511->Fill( xh, yh );
// -----------------------------------------------
int kDetPart = pPartPhot_->pPart()->kDetPart();
float ddpdet = pPartPhot_->pPart()->ddPaDet()[kDetPart];
xh = ddpdet;
yh = backInt;
if( kDetPart == 0 ) {
if( hist.hRC1518 ) hist.hRC1518->Fill( xh, yh );
// -----------------------------------------------
}
if( kDetPart == 1 ) {
if( hist.hRC1519 ) hist.hRC1519->Fill( xh, yh );
// -----------------------------------------------
}
}
}
kEventC = kEvent;
pPartPhotC = pPartPhot_;
normB = backInt + backIntS;
// --------------------------
}
else normB = 1.;
// ----------
normB_ = normB;
// --------------
if( doHist ) {
xh = normB;
if( hist.hRC1578 ) hist.hRC1578->Fill( xh );
// -------------------------------------------
}
return normB;
}
//===========================================================================
double CsRCLikeAll05::likeSignal( const CsRCPhoton* pPhot,
//----------------------------------------------------------
const double theIpo ) {
//- compute Signal value for Likelihood
// -----------------------------------
//- Paolo - May 2004
// Rev. May 2006
//if( theIpo < 50. ) return 0.;
CsRCRecConst* cons = CsRCRecConst::Instance();
static const double TwoPI = cons->TwoPI();
static const double sq2pi = sqrt( TwoPI );
static const double Drad = 360./ TwoPI;
int sz = pPartPhot_->lPhotons().size();
CsRCDetectors *dets = CsRCDetectors::Instance();
//static const float pipeLen = dets->zExitWind() - dets->zEntrWind();
CsRCHistos& hist = CsRCHistos::Ref();
int level = hist.levelBk();
bool doHist = false;
if ( level >= 2 ) doHist = true;
double xh, yh, wh;
static const bool exeSpl = false;
//@@--------------------------------
static const bool exeSig = true;
//static const bool exeSig = false;
//@@-------------------------------
static bool firstCall = true;
if( firstCall ) {
firstCall = false;
std::cout << " Signal Spl ";
if( exeSpl ) std::cout << "ON";
else std::cout << "OFF";
std::cout << " Signal Corr ";
if( exeSig ) std::cout << "ON";
else std::cout << "OFF";
std::cout << std::endl;
}
//- Compute Signal term :
// ---------------------
double thePhot = pPhot->the();
double sigPhot = pPhot->sigmaPhoPid( pPartPhot_ );
double signal = 0.;
if( sigPhot > 0.) {
double qSw = (thePhot - fabs( theIpo )) / sigPhot;
signal = exp( - 0.5* qSw*qSw ) / (sigPhot*sq2pi);
//-----------------------------------------------------------
}
//signal *= 1./ (TwoPI*theIpo); // test int
//signal *= thePhot / (TwoPI*theIpo);
//signal *= thePhot / theIpo;
//@@----------------------------------
static int kDetPart = 0;
static float nPhotEx = 0.;
static std::vector<double> vySplitLLim;
static std::vector<double> cosphi0;
static const float focLen = pPartPhot_->pPart()->pMirPart()->RR() / 2.;
int kDetClu = pPhot->kDetClu();
static CsRCPhoton* pPhotF = NULL;
pPhotF = pPartPhot_->lPhotons().front();
double theIrad = theIpo / 1000.;
if( pPhot == pPhotF ) {
kDetPart = pPartPhot_->kDetPart();
vySplitLLim = pPartPhot_->vySplitLLim();
if( vySplitLLim.size() < 2 ) {
vySplitLLim.clear();
vySplitLLim.push_back( 0. );
vySplitLLim.push_back( 0. );
}
nPhotEx = nPhotEx_;
// ------------------
if( splitPatt_ ) {
cosphi0.clear();
for( int kDet=0; kDet<2; kDet++ ) {
//double rOnDet = theIrad * ( pPartPhot_->pPart()->vPade()[kDet] -
// pPartPhot_->vPoPaMirW()[kDet] ).mag();
double rOnDet = (theIrad + 0.003) * focLen;
double yPade = pPartPhot_->pPart()->vPade()[kDet].y();
double dd = fabs( yPade - vySplitLLim[kDet] );
double cos = 1.;
if( rOnDet > 0. ) cos = fabs( dd / rOnDet );
//cout << rOnDet << " " << cos << endl;
if( cos > 1. ) cos = 1.;
cosphi0.push_back( cos );
}
}
//std::cout << "----- " << splitPatt_
// << " " << cosphi0[0] << " " << cosphi0[1]
// << " " << vySplitLLim[0] << " " << vySplitLLim[1]
// << " " << theIpo << std::endl;
}
//- Split rings effect (do NOT use) :
// ---------------------------------
float normSpl = 1.;
if( exeSpl ) {
double cosphi = 0.;
if( splitPatt_ && cosphi0[kDetClu] < 1. ) {
double xc = pPhot->ptToClu()->xc();
double yc = pPhot->ptToClu()->yc();
double xPade = pPartPhot_->pPart()->vPade()[kDetClu].x();
double yPade = pPartPhot_->pPart()->vPade()[kDetClu].y();
double tanphi = 0.;
//std::cout << "--- " << dd << " " << rOnDet << std::endl;
//std::cout << xc << " " << yc << " "
// << xPade << " " << yPade << " " << dd << std::endl;
int sign = 1 - 2 * kDetPart;
if( kDetClu == kDetPart ) {
if( ( yc - vySplitLLim[kDetClu] )* sign < 0. ) {
if((yc - yPade) > 0.) tanphi = (xc - xPade) / (yc - yPade);
cosphi = 1./ sqrt( 1.+ tanphi*tanphi );
if( cosphi > cosphi0[kDetClu] ) normSpl = cosphi0[kDetClu]/cosphi;
// ---------------------------------
//else normSpl = 0.;
}
//std::cout << kDetClu << " " << cosphi << " " << cosphi0[kDetClu]
// << " " << normSpl << std::endl;
}
tanphi = 0.;
if( kDetClu != kDetPart ) {
normSpl = 0.;
// ------------
//if( ( yc - vySplitLLim[kDetClu] )* sign < 0. ) {
if( ( yc - vySplitLLim[kDetClu] )* sign > 0. ) {
if((yc - yPade) > 0.) tanphi = (xc - xPade) / (yc - yPade);
cosphi = 1./ sqrt( 1.+ tanphi*tanphi );
if( cosphi > cosphi0[kDetClu] )
normSpl = 1.- cosphi0[kDetClu]/cosphi;
// -------------------------------------
else normSpl = 0.;
// ------------
}
//std::cout << kDetClu << " " << cosphi << " " << cosphi0[kDetClu]
// << " " << normSpl << std::endl;
}
}
}
//- Photon survival prob. :
// -----------------------
float probSig = 1.;
if( exeSig ) {
if( useOldCode_ ) fracUsePhiSet_ = false;
if( fracUsePhiSet_ ) {
if( dump_ )
if( pPhot == pPartPhot_->lPhotons().front() )
std::cout << "CsRCLikeAll05 : (Sig) " << sz << std::endl;
double phiPhot0 = pPartPhot_->lPhotons().front()->phiA();
double phiPhot = pPhot->phiA();
double diffPhi = phiPhot - phiPhot0;
if( diffPhi < 0. ) diffPhi = diffPhi + 360.;
if( diffPhi > 360. ) diffPhi = diffPhi - 360.;
//std::cout << "05All-S " << phiPhot << " " << phiPhot0 << " "
// << diffPhi << " " << dPhi_ << std::endl;
int kFrac = int( diffPhi / dPhi_ );
if( kFrac < 0 ) kFrac = 0;
if( kFrac > 35 ) kFrac = 35;
probSig = fracUsePhi_[kFrac];
// ----------------------------
//std::cout << "05All-S " << nPhotEx << " " << probSig << std::endl;
} else {
if( dump_ )
if( pPhot == pPartPhot_->lPhotons().front() )
std::cout << "CsRCLikeAll05 : exeSig " << sz << std::endl;
CsRCMirrors *mirr = CsRCMirrors::Instance();
float RR = mirr->RRv( kDetClu );
Hep3Vector vPoPhot0e = pPartPhot_->pPart()->vPosEmP();
Hep3Vector vDcPart0e = pPartPhot_->pPart()->vDirEmP();
double phiPhot = pPhot->phiA() / Drad;
thePhot = theIpo / 1000.;
//------------------------------
list<CsRCMirrorNom*> lMirrNom = mirr->lMirrNom();
list<CsRCMirrorNom*>::iterator in = lMirrNom.begin();
list<CsRCPhotonDet*> lPhoDet = dets->lPhoDet();
list<CsRCPhotonDet*>::iterator id = lPhoDet.begin();
// if( id == NULL || in == NULL ) return 0.;
if( id == lPhoDet.end() || in == lMirrNom.end() ) return 0.;
//----- inverse rotation
if( useOldCode_ ) {
if( kDetClu == 0 ) id++; // ???
if( kDetClu == 1 ) in++;
} else if( kDetClu == 1 ) { in++; id++; }
Hep3Vector vPoC0( (*in)->vC0() );
vPoC0 += mirr->vCorPoPa0();
Hep3Vector vDcPartW = pPartPhot_->vDcPartW()[kDetClu];
double tga, tgb;
tga = tan( thePhot ) * cos( phiPhot );
tgb = tan( thePhot ) * sin( phiPhot );
Hep3Vector vDcPhotWw( tga, tgb, 1.);
vDcPhotWw = vDcPhotWw.unit();
double theP, phiP;
Hep3Vector vDcPhotW = CsRCUty::Instance()->
rotfbcc( -1., vDcPartW, vDcPhotWw, theP, phiP );
// -----------------------------------------------
HepVector vrot( 3, 0 );
vrot[0] = vDcPhotW.x();
vrot[1] = vDcPhotW.y();
vrot[2] = vDcPhotW.z();
HepVector vPhot = (*id)->rotMatrix() * vrot;
Hep3Vector vDcPhot0( vPhot[0], vPhot[1], vPhot[2] );
//std::cout << vDcPhotWw << " " << vDcPhotW << " " << vDcPhot0
// <<std::endl;
double pathLen = pPartPhot_->pPart()->pathLen();
int nStep = 10;
double dPath = pathLen / float( nStep );
//----- in MRS
int nTot = 0;
int nGood = 0;
//----- loop on photon position along part path :
for( int step=-nStep/2; step<=nStep/2; step++ ) {
Hep3Vector vPoPhot0 = vPoPhot0e + float( step )*dPath * vDcPart0e;
//std::cout << vPoPhot0e << " " << vPoPhot0 << std::endl;
Hep3Vector vPhotMirr0 =
mirr->vImpMir( vPoPhot0, vDcPhot0, vPoC0, RR );
// ----------------------------------------------
bool Hole = false;
double elips = pow( vPhotMirr0.x()/xHole_, 2 ) +
pow( vPhotMirr0.y()/yHole_, 2 ) - 1.;
if( elips < 0. ) Hole = true;
//Hole = false;
bool Pipe = false;
double xx = vPhotMirr0.x() - vPoPhot0.x();
if( xx == 0.) continue;
double yy = vPhotMirr0.y() - vPoPhot0.y();
double mm = yy / xx;
double qq = sqrt( xx*xx + yy*yy );
//double rr = fabs( (vPoPhot0.y() * xx - vPoPhot0.x() * yy) / qq );
//double pp = vPhotMirr0.x()*vPhotMirr0.x() +
// vPhotMirr0.y()*vPhotMirr0.y();
double ssp, ssm;
if( vPoPhot0.x()*vPoPhot0.x() + vPoPhot0.y()*vPoPhot0.y()
< rPipe_*rPipe_ ) Pipe = true;
else if( vPhotMirr0.x()*vPhotMirr0.x()
+ vPhotMirr0.y()*vPhotMirr0.y()
< rPipe_*rPipe_ ) Pipe = true;
else if( fabs( (vPoPhot0.y()* xx - vPoPhot0.x()* yy)/ qq )
< rPipe_) {
//ssp = vPoPhot0.x() + vPoPhot0.y() * mm;
//ssm = vPhotMirr0.x() + vPhotMirr0.y() * mm;
//if( (ssp < 0. && ssm > 0.) || (ssm < 0. && ssp > 0.) )
//Pipe = true;
double aa = tga*tga + tgb*tgb;
double bb = tga*vPoPhot0.x() + tgb*vPoPhot0.y();
double cc = vPoPhot0.x()*vPoPhot0.x() + vPoPhot0.y()*vPoPhot0.y()
- rPipe_*rPipe_;
double delta = bb*bb - aa*cc;
if( delta > 0. ) {
double zp1 = ( -bb + sqrt( delta )) / aa;
double zp2 = ( -bb - sqrt( delta )) / aa;
if( !(vPoPhot0.z() > zp1 && vPoPhot0.z() > zp2) ) Pipe = true;
}
}
//Pipe = false;
nTot++;
if( !Hole && !Pipe ) nGood++;
//std::cout << Hole << " " << Pipe << std::endl;
}
if( nTot == 0 ) nTot = 1;
probSig = float( nGood ) / float( nTot );
// ----------------------------------------
//std::cout << "05All-S " << nPhotEx << " " << probSig << std::endl;
//std::cout << nPhotEx << " " << normSpl << " " << probSig
// << std::endl;
//std::cout << std::endl;
}
}
signal *= nPhotEx;
//-------------------
if( exeSpl ) signal *= normSpl;
//--------------------------------
if( exeSig ) signal *= probSig;
//--------------------------------
//- Histogramms :
// -------------
if( doHist ) {
xh = nPhotEx;
yh = probSig;
if( hist.hRC1512 ) hist.hRC1512->Fill( xh, yh );
// -----------------------------------------------
Hep3Vector vPoPart0 = pPartPhot_->pPart()->vPosIn();
double rr0 = sqrt( pow( vPoPart0.x(), 2 ) + pow( vPoPart0.y(), 2 ) );
Hep3Vector vDcPart0 = pPartPhot_->pPart()->vDirIn();
double the0 = acos( vDcPart0.z() ) * 1000.;
xh = the0;
yh = rr0;
wh = probSig;
if( hist.hRC1516 ) hist.hRC1516->Fill( xh, yh, wh );
// ---------------------------------------------------
xh = the0;
yh = rr0;
if( hist.hRC1517 ) hist.hRC1517->Fill( xh, yh );
// -----------------------------------------------
if( probSig == 0. ) {
if( hist.hRC1626 ) hist.hRC1626->Fill( xh, yh );
// -----------------------------------------------
}
if( probSig == 1. ) {
if( hist.hRC1627 ) hist.hRC1627->Fill( xh, yh );
// -----------------------------------------------
}
xh = normSpl;
yh = -1.;
if( kDetPart == 0 ) {
if( kDetClu == kDetPart ) yh = 0.5;
if( kDetClu != kDetPart ) yh = 1.5;
}
if( kDetPart == 1 ) {
if( kDetClu == kDetPart ) yh = 2.5;
if( kDetClu != kDetPart ) yh = 3.5;
}
if( hist.hRC1513 ) hist.hRC1513->Fill( xh, yh );
// -----------------------------------------------
if( cosphi0.size() >= 2 ) {
xh = cosphi0[kDetPart];
yh = 4.5;
if( hist.hRC1513 ) hist.hRC1513->Fill( xh, yh );
// -----------------------------------------------
}
if( pPartPhot_->likeONLY() ) {
xh = signal;
if( pPhot->isPMT() ) if( hist.hRC1574 ) hist.hRC1574->Fill( xh );
// -------------------------------------------
if( pPhot->isAPV() ) if( hist.hRC1575 ) hist.hRC1575->Fill( xh );
// -------------------------------------------
}
}
if( theIpo <= 0. ) signal = 0.;
return signal;
}
//===========================================================================
double CsRCLikeAll05::likeBackgr( const CsRCPhoton* pPhot,
//----------------------------------------------------------
const double theIpo ) {
//- compute Background value for Likelihood
// ---------------------------------------
//- Paolo - May 2004
// Rev. May 2006
//if( theIpo < 50. ) return 0.;
static const float focLen = pPartPhot_->pPart()->pMirPart()->RR() / 2.;
static const float factor = focLen/1000. * focLen/1000.;
int sz = pPartPhot_->lPhotons().size();
static bool firstCall = true;
if( firstCall ) {
firstCall = false;
}
CsRCHistos& hist = CsRCHistos::Ref();
int level = hist.levelBk();
bool doHist = false;
if ( level >= 2 ) doHist = true;
double xh, yh, wh;
//- Warning : kPhot is NOT sequential!
int kPhot = pPhot->kPhot();
double thePhot = pPhot->the();
//- from back-para-... .new-vector74 background map
// ---------------------------
//static const double backWgtMin = 0.0002;
static const double backWgtMin = 0.00001;
//@@----------------------------------------
static const CsRCPartPhotons* pPartPhotP = NULL;
if( kPhot >= 1000 ) {
if( pPartPhotP != pPartPhot_ ) {
std::cout << " RICHONE, CsRCLikeAll05::likeBackgr : "
<< " BUFFER Overflow! " << kPhot << " "
<< pPartPhot_->lPhotons().size() << std::endl;
}
pPartPhotP = pPartPhot_;
return backWgtMin;
// ------------------
}
double backgr = 0.;
double backWgt = 0.;
static int kEventC = -1;
static CsRCPartPhotons* pPartPhotC = NULL;
static CsRCPhoton* pPhotC = NULL;
static int kPhotC = -1;
int kEvent = CsRichOne::Instance()->kEvent();
//- Warning : pPartPhot can be the same for two conseq. events!
// also pPhot suspicious
if( kEvent != kEventC || pPartPhot_ != pPartPhotC ) {
phoBackSet_ = false;
pPhotC = const_cast<CsRCPhoton*>(pPhot);
kPhotC = kPhot;
//std::cout << "CsRCLikeAll05 : --- zeroPF " << std::endl;
} else {
if( kPhot == kPhotC ) {
phoBackSet_ = true;
//std::cout << "CsRCLikeAll05 : zeroF " << std::endl;
}
}
if( useOldCode_ ) phoBackSet_ = false;
if( phoBackSet_ ) {
if( dump_ ) if( kPhot == kPhotC )
std::cout << "CsRCLikeAll05 : (Back) " << sz << std::endl;
backgr = phoBack_[kPhot];
// ------------------------
} else {
if( dump_ ) if( kPhot == kPhotC )
std::cout << "CsRCLikeAll05 : = exeBack " << sz << std::endl;
backgr = backWgtMin;
if( pPhot->ptToClu()->getBackWgt( backWgt ) ) {
// ---------------------------------------
if( backWgt < backWgtMin ) backWgt = backWgtMin;
backgr = factor * backWgt * thePhot; // (3300/1000)**2
//backgr = factor * backWgt * thePhot/1000.;
// -----------------------------------
if( !useOldCode_ ) phoBack_[kPhot] = backgr;
}
else {
backWgt = backWgtMin;
backgr = factor * backWgt * thePhot;
if( !useOldCode_ ) phoBack_[kPhot] = backgr;
std::cout << " RICHONE, CsRCLikeAll05::likeBackgr() : "
<< "MINIMUM background assignment! - Ev. "
<< kEvent << " Phot. " << kPhot << std::endl;
}
}
kEventC = kEvent;
pPartPhotC = const_cast<CsRCPartPhotons*>(pPartPhot_);
//if( backgr == 0.) {
//if( pPartPhot_->likeONLY() ) {
//std::cout << setprecision( 12 ) << "LAll05 ";
//std::cout << kPhot << " "
// << log(backgr) << " " << backWgt << " " << thePhot << std::endl;
//}
//}
float normSpl = 1.;
// ------------------
//- Histograms :
// ------------
if( doHist ) {
int kDetPart = pPartPhot_->kDetPart();
int kDetClu = pPhot->kDetClu();
xh = normSpl;
yh = 10.5;
if( kDetPart == 0 ) {
if( kDetClu == kDetPart ) yh = 5.5;
if( kDetClu != kDetPart ) yh = 6.5;
}
if( kDetPart == 1 ) {
if( kDetClu == kDetPart ) yh = 7.5;
if( kDetClu != kDetPart ) yh = 8.5;
}
if( hist.hRC1513 ) hist.hRC1513->Fill( xh, yh );
// -----------------------------------------------
if( backgr > 0. ) {
xh = pPhot->ptToClu()->xc();
yh = pPhot->ptToClu()->yc();
wh = backgr;
if( hist.hRC1530 ) hist.hRC1530->Fill( xh, yh, wh );
// ---------------------------------------------------
if( hist.hRC1540 ) hist.hRC1540->Fill( xh, yh );
// -----------------------------------------------
}
if( pPartPhot_->likeONLY() ) {
xh = backgr;
if( pPhot->isPMT() ) if( hist.hRC1576 ) hist.hRC1576->Fill( xh );
// -------------------------------------------
if( pPhot->isAPV() ) if( hist.hRC1579 ) hist.hRC1579->Fill( xh );
// -------------------------------------------
}
}
return backgr;
}
//===========================================================================
double CsRCLikeAll05::getRingBackground( const double theReco ) {
//-----------------------------------------------------------------
//- Paolo - May 2004
//- NOT IMPLEMENTED !
CsRCRecConst * cons = CsRCRecConst::Instance();
static bool firstCall = true;
if( firstCall ) {
firstCall = false;
}
double corrBack = 0.;
return corrBack;
}
| [
"[email protected]"
] | |
3ebf22a746c60d25d144c770b282cebdf6e8f1ec | 76be06b529203553c26366904bd1bc8fce167048 | /testPierrot/test_courbure_gaussienne/tp1/build-starterLight-Desktop-Debug/ui_dialoghistogramme.h | eb5420f05668257ffb12aab6c41546d089529db3 | [] | no_license | jjzhang166/PFE_Livewire | 824393dab6a6c712ef38b95480b705f51490fb07 | decbeeef7d70a4e2b3bf1e39840aeaef3095f264 | refs/heads/master | 2022-04-12T12:07:42.104463 | 2020-03-26T23:23:42 | 2020-03-26T23:23:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,350 | h | /********************************************************************************
** Form generated from reading UI file 'dialoghistogramme.ui'
**
** Created by: Qt User Interface Compiler version 5.9.5
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_DIALOGHISTOGRAMME_H
#define UI_DIALOGHISTOGRAMME_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QDialog>
#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QVBoxLayout>
#include "QtCharts"
QT_BEGIN_NAMESPACE
class Ui_DialogHistogramme
{
public:
QVBoxLayout *verticalLayout;
QChartView *_myQChartView;
QDialogButtonBox *buttonBox;
void setupUi(QDialog *DialogHistogramme)
{
if (DialogHistogramme->objectName().isEmpty())
DialogHistogramme->setObjectName(QStringLiteral("DialogHistogramme"));
DialogHistogramme->resize(624, 367);
verticalLayout = new QVBoxLayout(DialogHistogramme);
verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
_myQChartView = new QChartView(DialogHistogramme);
_myQChartView->setObjectName(QStringLiteral("_myQChartView"));
verticalLayout->addWidget(_myQChartView);
buttonBox = new QDialogButtonBox(DialogHistogramme);
buttonBox->setObjectName(QStringLiteral("buttonBox"));
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Close);
verticalLayout->addWidget(buttonBox);
retranslateUi(DialogHistogramme);
QObject::connect(buttonBox, SIGNAL(accepted()), DialogHistogramme, SLOT(accept()));
QObject::connect(buttonBox, SIGNAL(rejected()), DialogHistogramme, SLOT(reject()));
QMetaObject::connectSlotsByName(DialogHistogramme);
} // setupUi
void retranslateUi(QDialog *DialogHistogramme)
{
DialogHistogramme->setWindowTitle(QApplication::translate("DialogHistogramme", "Dialog", Q_NULLPTR));
} // retranslateUi
};
namespace Ui {
class DialogHistogramme: public Ui_DialogHistogramme {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_DIALOGHISTOGRAMME_H
| [
"[email protected]"
] | |
404ac6bb71782c5e2a0c8395ac9995cae9f90903 | 9da42e04bdaebdf0193a78749a80c4e7bf76a6cc | /third_party/gecko-2/win32/include/nsIURIRefObject.h | 65aa1424aabdd0a75bf16b806f1ef2cb1298fb74 | [
"Apache-2.0"
] | permissive | bwp/SeleniumWebDriver | 9d49e6069881845e9c23fb5211a7e1b8959e2dcf | 58221fbe59fcbbde9d9a033a95d45d576b422747 | refs/heads/master | 2021-01-22T21:32:50.541163 | 2012-11-09T16:19:48 | 2012-11-09T16:19:48 | 6,602,097 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,439 | h | /*
* DO NOT EDIT. THIS FILE IS GENERATED FROM e:/builds/moz2_slave/rel-2.0-xr-w32-bld/build/editor/idl/nsIURIRefObject.idl
*/
#ifndef __gen_nsIURIRefObject_h__
#define __gen_nsIURIRefObject_h__
#ifndef __gen_nsISupports_h__
#include "nsISupports.h"
#endif
#ifndef __gen_domstubs_h__
#include "domstubs.h"
#endif
/* For IDL files that don't want to include root IDL files. */
#ifndef NS_NO_VTABLE
#define NS_NO_VTABLE
#endif
class nsIDOMNode; /* forward declaration */
/* starting interface: nsIURIRefObject */
#define NS_IURIREFOBJECT_IID_STR "2226927e-1dd2-11b2-b57f-faab47288563"
#define NS_IURIREFOBJECT_IID \
{0x2226927e, 0x1dd2, 0x11b2, \
{ 0xb5, 0x7f, 0xfa, 0xab, 0x47, 0x28, 0x85, 0x63 }}
/** A class which can represent any node which points to an
* external URI, e.g. <a>, <img>, <script> etc,
* and has the capability to rewrite URLs to be
* relative or absolute.
* Used by the editor but not dependant on it.
*/
class NS_NO_VTABLE NS_SCRIPTABLE nsIURIRefObject : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IURIREFOBJECT_IID)
/* attribute nsIDOMNode node; */
NS_SCRIPTABLE NS_IMETHOD GetNode(nsIDOMNode **aNode) = 0;
NS_SCRIPTABLE NS_IMETHOD SetNode(nsIDOMNode *aNode) = 0;
/**
* Go back to the beginning of the attribute list.
*/
/* void Reset (); */
NS_SCRIPTABLE NS_IMETHOD Reset(void) = 0;
/**
* Return the next rewritable URI.
*/
/* DOMString GetNextURI (); */
NS_SCRIPTABLE NS_IMETHOD GetNextURI(nsAString & _retval NS_OUTPARAM) = 0;
/**
* Go back to the beginning of the attribute list
*
* @param aOldPat Old pattern to be replaced, e.g. file:///a/b/
* @param aNewPat New pattern to be replaced, e.g. http://mypage.aol.com/
* @param aMakeRel Rewrite links as relative vs. absolute
*/
/* void RewriteAllURIs (in DOMString aOldPat, in DOMString aNewPat, in boolean aMakeRel); */
NS_SCRIPTABLE NS_IMETHOD RewriteAllURIs(const nsAString & aOldPat, const nsAString & aNewPat, PRBool aMakeRel) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIURIRefObject, NS_IURIREFOBJECT_IID)
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSIURIREFOBJECT \
NS_SCRIPTABLE NS_IMETHOD GetNode(nsIDOMNode **aNode); \
NS_SCRIPTABLE NS_IMETHOD SetNode(nsIDOMNode *aNode); \
NS_SCRIPTABLE NS_IMETHOD Reset(void); \
NS_SCRIPTABLE NS_IMETHOD GetNextURI(nsAString & _retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD RewriteAllURIs(const nsAString & aOldPat, const nsAString & aNewPat, PRBool aMakeRel);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_NSIURIREFOBJECT(_to) \
NS_SCRIPTABLE NS_IMETHOD GetNode(nsIDOMNode **aNode) { return _to GetNode(aNode); } \
NS_SCRIPTABLE NS_IMETHOD SetNode(nsIDOMNode *aNode) { return _to SetNode(aNode); } \
NS_SCRIPTABLE NS_IMETHOD Reset(void) { return _to Reset(); } \
NS_SCRIPTABLE NS_IMETHOD GetNextURI(nsAString & _retval NS_OUTPARAM) { return _to GetNextURI(_retval); } \
NS_SCRIPTABLE NS_IMETHOD RewriteAllURIs(const nsAString & aOldPat, const nsAString & aNewPat, PRBool aMakeRel) { return _to RewriteAllURIs(aOldPat, aNewPat, aMakeRel); }
/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
#define NS_FORWARD_SAFE_NSIURIREFOBJECT(_to) \
NS_SCRIPTABLE NS_IMETHOD GetNode(nsIDOMNode **aNode) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetNode(aNode); } \
NS_SCRIPTABLE NS_IMETHOD SetNode(nsIDOMNode *aNode) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetNode(aNode); } \
NS_SCRIPTABLE NS_IMETHOD Reset(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Reset(); } \
NS_SCRIPTABLE NS_IMETHOD GetNextURI(nsAString & _retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetNextURI(_retval); } \
NS_SCRIPTABLE NS_IMETHOD RewriteAllURIs(const nsAString & aOldPat, const nsAString & aNewPat, PRBool aMakeRel) { return !_to ? NS_ERROR_NULL_POINTER : _to->RewriteAllURIs(aOldPat, aNewPat, aMakeRel); }
#if 0
/* Use the code below as a template for the implementation class for this interface. */
/* Header file */
class nsURIRefObject : public nsIURIRefObject
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIURIREFOBJECT
nsURIRefObject();
private:
~nsURIRefObject();
protected:
/* additional members */
};
/* Implementation file */
NS_IMPL_ISUPPORTS1(nsURIRefObject, nsIURIRefObject)
nsURIRefObject::nsURIRefObject()
{
/* member initializers and constructor code */
}
nsURIRefObject::~nsURIRefObject()
{
/* destructor code */
}
/* attribute nsIDOMNode node; */
NS_IMETHODIMP nsURIRefObject::GetNode(nsIDOMNode **aNode)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsURIRefObject::SetNode(nsIDOMNode *aNode)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void Reset (); */
NS_IMETHODIMP nsURIRefObject::Reset()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* DOMString GetNextURI (); */
NS_IMETHODIMP nsURIRefObject::GetNextURI(nsAString & _retval NS_OUTPARAM)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void RewriteAllURIs (in DOMString aOldPat, in DOMString aNewPat, in boolean aMakeRel); */
NS_IMETHODIMP nsURIRefObject::RewriteAllURIs(const nsAString & aOldPat, const nsAString & aNewPat, PRBool aMakeRel)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* End of implementation class template. */
#endif
#endif /* __gen_nsIURIRefObject_h__ */
| [
"[email protected]"
] | |
ab830abee4785755c7a55b61756618cb16fb6a41 | 32e43c3cce09f4659035644e70a4e2e88b021c15 | /abc178/d.cpp | e5892337b4511934136fab5f03956b3792268644 | [] | no_license | sp4ghet/comp | 22c7453bcd4aff56970f3ee465e0c66ca0ab697f | 222911d45ab513c88d5450919d8c803cb0f7da1c | refs/heads/master | 2020-12-04T15:59:34.368399 | 2020-09-19T15:00:31 | 2020-09-19T15:00:31 | 231,827,088 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,281 | cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }
template <typename T>
void view(const std::vector<T> &v)
{
for (const auto &e : v)
{
std::cout << e << " ";
}
std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
for (const auto &v : vv)
{
view(v);
}
}
#pragma endregion
#pragma region mod
const int p = 1e9 + 7; //10^9 + 7
struct mint
{
ll x;
mint(ll xx = 0) : x(xx % p) {}
mint &operator+=(const mint a)
{
if ((x += a.x) >= p)
x -= p;
return *this;
}
mint &operator-=(const mint a)
{
if ((x += p - a.x) >= p)
x -= p;
return *this;
}
mint &operator*=(const mint a)
{
(x *= a.x) %= p;
return *this;
}
mint operator+(const mint a) const
{
mint res(*this);
return res += a;
}
mint operator-(const mint a) const
{
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const
{
mint res(*this);
return res *= a;
}
mint pow(ll t) const
{
mint r = 1;
mint a = *this;
while (true)
{
if (t & 1)
{
r *= a;
}
t >>= 1;
if (t == 0)
break;
a *= a;
}
return r;
}
mint inv() const
{
return pow(p - 2);
}
mint &operator/=(const mint a)
{
return (*this) *= a.inv();
}
};
istream &operator>>(istream &is, mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
struct comb
{
vector<mint> fact, invs;
comb(int n) : fact(n + 1), invs(n + 1)
{
assert(n < p);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
invs[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
invs[i - 1] = invs[i] * i;
}
mint operator()(int n, int k)
{
if (k < 0 || k > n)
return 0;
return fact[n] * invs[n - k] * invs[k];
}
};
#pragma endregion
mint dp[2005][2005];
mint f(int x, int k)
{
if (dp[x][k].x != -1)
{
return dp[x][k];
}
if (k == 1 && x >= 3)
{
return 1;
}
mint ret = 0;
for (int j = 3; (k - 1) * 3 + j <= x; j++)
{
ret += f(x - j, k - 1);
}
return dp[x][k] = ret;
}
int main()
{
int s;
cin >> s;
int maxlen = s / 3;
mint ans = 0;
rep(i, 2005) rep(j, 2005) dp[i][j].x = -1;
for (int i = 1; i <= maxlen; i++)
{
ans += f(s, i);
}
cout << ans << endl;
return 0;
} | [
"[email protected]"
] | |
fa204b67b49e4516fe5369b789ce0f62d26d26e6 | 9bf5f43c9adc4a7fdfe4a6c03e805a9623685171 | /SpaceRacer/Source/Asteroid.h | a1eeacfd73fab669c0ea3a130b917c44a9d8beaf | [] | no_license | caioteixeira/SpaceRacer | 8e4ba58c072139e91c9a5949b4c85a143ff6fdaf | ae31ba5203975f316b1a1bdddbf2b13318af62e0 | refs/heads/master | 2016-08-11T18:51:37.601961 | 2015-10-29T21:27:27 | 2015-10-29T21:27:27 | 45,133,433 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 292 | h | #pragma once
#include "Actor.h"
#include "AudioComponent.h"
class Asteroid : public Actor
{
DECL_ACTOR(Asteroid, Actor);
public:
Asteroid(Game & game);
AudioComponentPtr GetAudio(){ return mAudio; };
private:
AudioComponentPtr mAudio;
SoundPtr mExplosionSound;
};
DECL_PTR(Asteroid); | [
"[email protected]"
] | |
717225bc6ea0788e5edf5b5496536221e1f40c44 | cf2b77f1e27736862d349509dee8374c787b050d | /sloeber.ino.cpp | 8b2609ab016d60a275f37d5ec63661a217e5c93d | [] | no_license | eziya/ESP8266_GxEPD_TEST | 55e9fa18fa0be1557e61e8f21e71956d5a1d51d5 | 6b7b168af456ffc62ae30b9313c8556ff76024a7 | refs/heads/master | 2020-03-31T17:29:58.782077 | 2018-10-22T13:17:18 | 2018-10-22T13:17:18 | 152,425,327 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 930 | cpp | #ifdef __IN_ECLIPSE__
//This is a automatic generated file
//Please do not modify this file
//If you touch this file your change will be overwritten during the next build
//This file has been generated on 2018-10-11 20:14:33
#include "Arduino.h"
#include "Arduino.h"
#include <GxEPD.h>
#include <GxGDEP015OC1/GxGDEP015OC1.h>
#include <GxIO/GxIO_SPI/GxIO_SPI.h>
#include <GxIO/GxIO.h>
#include <Fonts/DSDIGIT9pt7b.h>
#include <Fonts/DSDIGIT12pt7b.h>
#include <Fonts/DSDIGIT18pt7b.h>
#include <Fonts/DSDIGIT24pt7b.h>
#include <Fonts/DSDIGIT30pt7b.h>
#include <GxGDEP015OC1/BitmapExamples.h>
#include "ImageData.h"
void setup() ;
void loop() ;
void showBitmapExample() ;
void showBoat() ;
void showFont(const char name[], const GFXfont* font) ;
void drawCornerTest() ;
void showBlackBoxCallback(uint32_t v) ;
void showValueBoxCallback(const uint32_t v) ;
void showPartialUpdatePaged() ;
#include "ESP8266_GxEPD_TEST.ino"
#endif
| [
"[email protected]"
] | |
b8d63402eefbadd26950c0e9090c4dde86a82e1d | bc2a6e1f41ced330c04c199d0e13f7f8b82bd6ef | /src/halibs/examples/src/button.cpp | cb3b3d2acff34c3d9c4a794b9cb7070c0efea9bc | [] | no_license | SoCXin/MEGA328P | 372187c044c402ae90c3c3192b4d90f8ea996f3e | 321166c6f287e441d0ae906ecfddc5d3cff706f2 | refs/heads/master | 2023-04-27T02:10:27.492148 | 2021-05-18T07:51:01 | 2021-05-18T07:51:01 | 157,304,433 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 804 | cpp | /**
* \file examples/applications/button.cpp
* \brief Example for usage of Button and Led (very simple)
*
* This file is part of avr-halib. See COPYING for copyright details.
*/
#include "platform.h"
#include "avr-halib/drivers/ext/button.h"
#include "avr-halib/drivers/ext/led.h"
using avr_halib::drivers::ext::Button;
using avr_halib::drivers::ext::Led;
int main()
{
Button< platform::Button0 > button0;
Led < platform::Led0 > led0;
Led < platform::Led1 > led1;
Led < platform::Led2 > led2;
while (1)
{
if(button0.isPressed())
{
led0.set(1);
led1.set(1);
led2.set(1);
}
else
{
led0.set(0);
led1.set(0);
led2.set(0);
}
}
}
| [
"[email protected]"
] | |
a408ce3b8abc1ee03017a76d9db859ce29ec48b5 | 1afec7d1d3099138b5afe5fd73dfd3d24ff4eb15 | /src/wallet/transaction.cpp | 0c72293af4bc8870f456e50415b643b1eaedf021 | [
"MIT"
] | permissive | republic-productions/finalcoin | 5c7c6b0734178fe22db63f0946ec555f59e8d0eb | 7c0f335ded1e5c662034c822ca2c474b8e62778f | refs/heads/main | 2023-09-04T17:04:32.683667 | 2021-10-14T17:45:22 | 2021-10-14T17:45:22 | 417,209,088 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 723 | cpp | // Copyright (c) 2021 The Finalcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <wallet/transaction.h>
bool CWalletTx::IsEquivalentTo(const CWalletTx& _tx) const
{
CMutableTransaction tx1 {*this->tx};
CMutableTransaction tx2 {*_tx.tx};
for (auto& txin : tx1.vin) txin.scriptSig = CScript();
for (auto& txin : tx2.vin) txin.scriptSig = CScript();
return CTransaction(tx1) == CTransaction(tx2);
}
bool CWalletTx::InMempool() const
{
return fInMempool;
}
int64_t CWalletTx::GetTxTime() const
{
int64_t n = nTimeSmart;
return n ? n : nTimeReceived;
}
| [
"[email protected]"
] | |
a2987ea72ba13b851be2b6fab3aad64df7f82e95 | c01229900ffcc6aeb98c3d49f1ef63d699a2f12b | /include/game_renderer.hpp | ea9a15d8ce73a1b9ec21f6b12906185b63eca890 | [
"MIT"
] | permissive | rosskidson/nestris_x86 | 32dda38de2e1acbe786dc842d40bf9131fb1c25e | ce5085436ff2c04f8f760c2d88469f77794dd6c3 | refs/heads/master | 2023-03-11T19:20:30.225094 | 2021-01-10T21:29:08 | 2021-01-10T21:29:08 | 325,801,988 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,563 | hpp | #pragma once
#include <memory>
#include <set>
#include "assets.hpp"
#include "das.hpp"
#include "drawers/pixel_drawing_interface.hpp"
#include "game_states.hpp"
#include "key_defines.hpp"
#include "statistics.hpp"
#include "tetromino.hpp"
namespace nestris_x86 {
class GameRenderer {
public:
GameRenderer(std::unique_ptr<PixelDrawingInterface> &&drawer,
const std::shared_ptr<SpriteProvider> &sprite_provider,
const std::string &sprites_path);
void renderGameState(const GameState<> &state, const Statistics &stats,
const bool render_controls, const bool render_das_bar,
const StatisticsMode &statistics_mode, const KeyEvents &key_events,
const Das &das_processor);
void renderPaused() const;
void doTetrisFlash(const int &line_clear_frame_number) const;
void startNewGame();
private:
template <typename GridContainer>
void renderGrid(const int x_start, const int y_start, const GridContainer &grid, const int level,
const int x_spacing = 8, const int y_spacing = 8, const int color = 1) const {
for (int i = 0; i < grid.size(); ++i) {
for (int j = 0; j < grid[i].size(); ++j) {
if (grid[i][j] == 0) {
continue;
}
drawer_->drawSprite(x_start + i * x_spacing, y_start + j * y_spacing,
getBlockSprite(level, grid[i][j] * color));
}
}
}
olc::Sprite *getBlockSprite(const int level, const int color) const;
void renderNesStatsics(const GameState<> &state, const Statistics &statistics);
void renderTreyVisionStatistics(const GameState<> &state, const Statistics &statistics);
void renderBackground();
void renderText(const GameState<> &state, const Statistics &stats) const;
void renderNextTetromino(const Tetromino &next_tetromino, const int level) const;
void renderDasBar(const int das_counter, const Das &das_processor,
const PixelDrawingInterface::Coords &das_box_pos) const;
void renderControls(const GameState<> &state, const KeyEvents &key_events,
const PixelDrawingInterface::Coords &control_position) const;
void renderEntryDelay(const bool delay_entry,
const PixelDrawingInterface::Coords &position) const;
std::unique_ptr<PixelDrawingInterface> drawer_;
std::shared_ptr<SpriteProvider> sprite_provider_;
std::vector<std::vector<std::unique_ptr<olc::Sprite>>> block_sprites_;
bool background_rendered_;
};
} // namespace nestris_x86
| [
"[email protected]"
] | |
569110132e9afc7fc23df8574a02307f52c0e3df | f875f2ff25629091b2f234140891f407ef537608 | /aws-cpp-sdk-location/include/aws/location/model/CreateMapResult.h | 705bd7378c4303e9f4cef861873bce9204da20ce | [
"MIT",
"Apache-2.0",
"JSON"
] | permissive | Adam9911/aws-sdk-cpp | 39f0c057c25053929aec41ef8de81a9664c1a616 | da78cc54da7de3894af2742316cec2814832b3c1 | refs/heads/main | 2023-06-03T10:25:53.887456 | 2021-05-15T14:49:26 | 2021-05-15T14:49:26 | 367,572,100 | 0 | 0 | Apache-2.0 | 2021-05-15T07:52:14 | 2021-05-15T07:52:13 | null | UTF-8 | C++ | false | false | 6,255 | h | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/location/LocationService_EXPORTS.h>
#include <aws/core/utils/DateTime.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <utility>
namespace Aws
{
template<typename RESULT_TYPE>
class AmazonWebServiceResult;
namespace Utils
{
namespace Json
{
class JsonValue;
} // namespace Json
} // namespace Utils
namespace LocationService
{
namespace Model
{
class AWS_LOCATIONSERVICE_API CreateMapResult
{
public:
CreateMapResult();
CreateMapResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);
CreateMapResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);
/**
* <p>The timestamp for when the map resource was created in <a
* href="https://www.iso.org/iso-8601-date-and-time-format.html">ISO 8601</a>
* format: <code>YYYY-MM-DDThh:mm:ss.sssZ</code>.</p>
*/
inline const Aws::Utils::DateTime& GetCreateTime() const{ return m_createTime; }
/**
* <p>The timestamp for when the map resource was created in <a
* href="https://www.iso.org/iso-8601-date-and-time-format.html">ISO 8601</a>
* format: <code>YYYY-MM-DDThh:mm:ss.sssZ</code>.</p>
*/
inline void SetCreateTime(const Aws::Utils::DateTime& value) { m_createTime = value; }
/**
* <p>The timestamp for when the map resource was created in <a
* href="https://www.iso.org/iso-8601-date-and-time-format.html">ISO 8601</a>
* format: <code>YYYY-MM-DDThh:mm:ss.sssZ</code>.</p>
*/
inline void SetCreateTime(Aws::Utils::DateTime&& value) { m_createTime = std::move(value); }
/**
* <p>The timestamp for when the map resource was created in <a
* href="https://www.iso.org/iso-8601-date-and-time-format.html">ISO 8601</a>
* format: <code>YYYY-MM-DDThh:mm:ss.sssZ</code>.</p>
*/
inline CreateMapResult& WithCreateTime(const Aws::Utils::DateTime& value) { SetCreateTime(value); return *this;}
/**
* <p>The timestamp for when the map resource was created in <a
* href="https://www.iso.org/iso-8601-date-and-time-format.html">ISO 8601</a>
* format: <code>YYYY-MM-DDThh:mm:ss.sssZ</code>.</p>
*/
inline CreateMapResult& WithCreateTime(Aws::Utils::DateTime&& value) { SetCreateTime(std::move(value)); return *this;}
/**
* <p>The Amazon Resource Name (ARN) for the map resource. Used when you need to
* specify a resource across all AWS.</p> <ul> <li> <p>Format example:
* <code>arn:partition:service:region:account-id:resource-type:resource-id</code>
* </p> </li> </ul>
*/
inline const Aws::String& GetMapArn() const{ return m_mapArn; }
/**
* <p>The Amazon Resource Name (ARN) for the map resource. Used when you need to
* specify a resource across all AWS.</p> <ul> <li> <p>Format example:
* <code>arn:partition:service:region:account-id:resource-type:resource-id</code>
* </p> </li> </ul>
*/
inline void SetMapArn(const Aws::String& value) { m_mapArn = value; }
/**
* <p>The Amazon Resource Name (ARN) for the map resource. Used when you need to
* specify a resource across all AWS.</p> <ul> <li> <p>Format example:
* <code>arn:partition:service:region:account-id:resource-type:resource-id</code>
* </p> </li> </ul>
*/
inline void SetMapArn(Aws::String&& value) { m_mapArn = std::move(value); }
/**
* <p>The Amazon Resource Name (ARN) for the map resource. Used when you need to
* specify a resource across all AWS.</p> <ul> <li> <p>Format example:
* <code>arn:partition:service:region:account-id:resource-type:resource-id</code>
* </p> </li> </ul>
*/
inline void SetMapArn(const char* value) { m_mapArn.assign(value); }
/**
* <p>The Amazon Resource Name (ARN) for the map resource. Used when you need to
* specify a resource across all AWS.</p> <ul> <li> <p>Format example:
* <code>arn:partition:service:region:account-id:resource-type:resource-id</code>
* </p> </li> </ul>
*/
inline CreateMapResult& WithMapArn(const Aws::String& value) { SetMapArn(value); return *this;}
/**
* <p>The Amazon Resource Name (ARN) for the map resource. Used when you need to
* specify a resource across all AWS.</p> <ul> <li> <p>Format example:
* <code>arn:partition:service:region:account-id:resource-type:resource-id</code>
* </p> </li> </ul>
*/
inline CreateMapResult& WithMapArn(Aws::String&& value) { SetMapArn(std::move(value)); return *this;}
/**
* <p>The Amazon Resource Name (ARN) for the map resource. Used when you need to
* specify a resource across all AWS.</p> <ul> <li> <p>Format example:
* <code>arn:partition:service:region:account-id:resource-type:resource-id</code>
* </p> </li> </ul>
*/
inline CreateMapResult& WithMapArn(const char* value) { SetMapArn(value); return *this;}
/**
* <p>The name of the map resource.</p>
*/
inline const Aws::String& GetMapName() const{ return m_mapName; }
/**
* <p>The name of the map resource.</p>
*/
inline void SetMapName(const Aws::String& value) { m_mapName = value; }
/**
* <p>The name of the map resource.</p>
*/
inline void SetMapName(Aws::String&& value) { m_mapName = std::move(value); }
/**
* <p>The name of the map resource.</p>
*/
inline void SetMapName(const char* value) { m_mapName.assign(value); }
/**
* <p>The name of the map resource.</p>
*/
inline CreateMapResult& WithMapName(const Aws::String& value) { SetMapName(value); return *this;}
/**
* <p>The name of the map resource.</p>
*/
inline CreateMapResult& WithMapName(Aws::String&& value) { SetMapName(std::move(value)); return *this;}
/**
* <p>The name of the map resource.</p>
*/
inline CreateMapResult& WithMapName(const char* value) { SetMapName(value); return *this;}
private:
Aws::Utils::DateTime m_createTime;
Aws::String m_mapArn;
Aws::String m_mapName;
};
} // namespace Model
} // namespace LocationService
} // namespace Aws
| [
"[email protected]"
] | |
4e377a17082231d429b0fcee09527701b936e4f2 | 5e1ae0c5e8f26339759b43e6627771edcf7d16ce | /art/compiler/dex/vreg_analysis.cc | 7e1e7e184732d4a0a04cb2dfa453cc6975729e00 | [
"NCSA",
"Apache-2.0"
] | permissive | guoyanjun0313/cb40_6735 | d303eec21051633ee52230704a1dfd0f3c579cc0 | fc5aa800555da17f2c2c3f75f95f772ff67b40c0 | refs/heads/master | 2022-12-28T16:44:38.678552 | 2018-04-18T03:00:31 | 2018-04-18T03:00:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,959 | cc | /*
* Copyright (C) 2014 MediaTek Inc.
* Modification based on code covered by the mentioned copyright
* and/or permission notice(s).
*/
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "compiler_internals.h"
#include "dex/dataflow_iterator-inl.h"
namespace art {
bool MIRGraph::SetFp(int index, bool is_fp) {
bool change = false;
if (is_fp && !reg_location_[index].fp) {
reg_location_[index].fp = true;
reg_location_[index].defined = true;
change = true;
}
return change;
}
bool MIRGraph::SetFp(int index) {
bool change = false;
if (!reg_location_[index].fp) {
reg_location_[index].fp = true;
reg_location_[index].defined = true;
change = true;
}
return change;
}
bool MIRGraph::SetCore(int index, bool is_core) {
bool change = false;
if (is_core && !reg_location_[index].defined) {
reg_location_[index].core = true;
reg_location_[index].defined = true;
change = true;
}
return change;
}
bool MIRGraph::SetCore(int index) {
bool change = false;
if (!reg_location_[index].defined) {
reg_location_[index].core = true;
reg_location_[index].defined = true;
change = true;
}
return change;
}
bool MIRGraph::SetRef(int index, bool is_ref) {
bool change = false;
if (is_ref && !reg_location_[index].defined) {
reg_location_[index].ref = true;
reg_location_[index].defined = true;
change = true;
}
return change;
}
bool MIRGraph::SetRef(int index) {
bool change = false;
if (!reg_location_[index].defined) {
reg_location_[index].ref = true;
reg_location_[index].defined = true;
change = true;
}
return change;
}
bool MIRGraph::SetWide(int index, bool is_wide) {
bool change = false;
if (is_wide && !reg_location_[index].wide) {
reg_location_[index].wide = true;
change = true;
}
return change;
}
bool MIRGraph::SetWide(int index) {
bool change = false;
if (!reg_location_[index].wide) {
reg_location_[index].wide = true;
change = true;
}
return change;
}
bool MIRGraph::SetHigh(int index, bool is_high) {
bool change = false;
if (is_high && !reg_location_[index].high_word) {
reg_location_[index].high_word = true;
change = true;
}
return change;
}
bool MIRGraph::SetHigh(int index) {
bool change = false;
if (!reg_location_[index].high_word) {
reg_location_[index].high_word = true;
change = true;
}
return change;
}
/*
* Infer types and sizes. We don't need to track change on sizes,
* as it doesn't propagate. We're guaranteed at least one pass through
* the cfg.
*/
bool MIRGraph::InferTypeAndSize(BasicBlock* bb, MIR* mir, bool changed) {
SSARepresentation *ssa_rep = mir->ssa_rep;
/*
* The dex bytecode definition does not explicitly outlaw the definition of the same
* virtual register to be used in both a 32-bit and 64-bit pair context. However, dx
* does not generate this pattern (at least recently). Further, in the next revision of
* dex, we will forbid this. To support the few cases in the wild, detect this pattern
* and punt to the interpreter.
*/
bool type_mismatch = false;
if (ssa_rep) {
uint64_t attrs = GetDataFlowAttributes(mir);
const int* uses = ssa_rep->uses;
const int* defs = ssa_rep->defs;
// Handle defs
if (attrs & DF_DA) {
if (attrs & DF_CORE_A) {
changed |= SetCore(defs[0]);
}
if (attrs & DF_REF_A) {
changed |= SetRef(defs[0]);
}
if (attrs & DF_A_WIDE) {
reg_location_[defs[0]].wide = true;
reg_location_[defs[1]].wide = true;
reg_location_[defs[1]].high_word = true;
DCHECK_EQ(SRegToVReg(defs[0])+1,
SRegToVReg(defs[1]));
}
}
// Handles uses
int next = 0;
if (attrs & DF_UA) {
if (attrs & DF_CORE_A) {
changed |= SetCore(uses[next]);
}
if (attrs & DF_REF_A) {
changed |= SetRef(uses[next]);
}
if (attrs & DF_A_WIDE) {
reg_location_[uses[next]].wide = true;
reg_location_[uses[next + 1]].wide = true;
reg_location_[uses[next + 1]].high_word = true;
DCHECK_EQ(SRegToVReg(uses[next])+1,
SRegToVReg(uses[next + 1]));
next += 2;
} else {
type_mismatch |= reg_location_[uses[next]].wide;
next++;
}
}
if (attrs & DF_UB) {
if (attrs & DF_CORE_B) {
changed |= SetCore(uses[next]);
}
if (attrs & DF_REF_B) {
changed |= SetRef(uses[next]);
}
if (attrs & DF_B_WIDE) {
reg_location_[uses[next]].wide = true;
reg_location_[uses[next + 1]].wide = true;
reg_location_[uses[next + 1]].high_word = true;
DCHECK_EQ(SRegToVReg(uses[next])+1,
SRegToVReg(uses[next + 1]));
next += 2;
} else {
type_mismatch |= reg_location_[uses[next]].wide;
next++;
}
}
if (attrs & DF_UC) {
if (attrs & DF_CORE_C) {
changed |= SetCore(uses[next]);
}
if (attrs & DF_REF_C) {
changed |= SetRef(uses[next]);
}
if (attrs & DF_C_WIDE) {
reg_location_[uses[next]].wide = true;
reg_location_[uses[next + 1]].wide = true;
reg_location_[uses[next + 1]].high_word = true;
DCHECK_EQ(SRegToVReg(uses[next])+1,
SRegToVReg(uses[next + 1]));
} else {
type_mismatch |= reg_location_[uses[next]].wide;
}
}
// Special-case return handling
if ((mir->dalvikInsn.opcode == Instruction::RETURN) ||
(mir->dalvikInsn.opcode == Instruction::RETURN_WIDE) ||
(mir->dalvikInsn.opcode == Instruction::RETURN_OBJECT)) {
switch (cu_->shorty[0]) {
case 'I':
type_mismatch |= reg_location_[uses[0]].wide;
changed |= SetCore(uses[0]);
break;
case 'J':
changed |= SetCore(uses[0]);
changed |= SetCore(uses[1]);
reg_location_[uses[0]].wide = true;
reg_location_[uses[1]].wide = true;
reg_location_[uses[1]].high_word = true;
break;
case 'F':
type_mismatch |= reg_location_[uses[0]].wide;
changed |= SetFp(uses[0]);
break;
case 'D':
changed |= SetFp(uses[0]);
changed |= SetFp(uses[1]);
reg_location_[uses[0]].wide = true;
reg_location_[uses[1]].wide = true;
reg_location_[uses[1]].high_word = true;
break;
case 'L':
type_mismatch |= reg_location_[uses[0]].wide;
changed |= SetRef(uses[0]);
break;
default: break;
}
}
// Special-case handling for format 35c/3rc invokes
Instruction::Code opcode = mir->dalvikInsn.opcode;
int flags = MIR::DecodedInstruction::IsPseudoMirOp(opcode) ?
0 : Instruction::FlagsOf(mir->dalvikInsn.opcode);
if ((flags & Instruction::kInvoke) &&
(attrs & (DF_FORMAT_35C | DF_FORMAT_3RC))) {
DCHECK_EQ(next, 0);
int target_idx = mir->dalvikInsn.vB;
const char* shorty = GetShortyFromTargetIdx(target_idx);
// Handle result type if floating point
if ((shorty[0] == 'F') || (shorty[0] == 'D')) {
MIR* move_result_mir = FindMoveResult(bb, mir);
// Result might not be used at all, so no move-result
if (move_result_mir && (move_result_mir->dalvikInsn.opcode !=
Instruction::MOVE_RESULT_OBJECT)) {
SSARepresentation* tgt_rep = move_result_mir->ssa_rep;
DCHECK(tgt_rep != NULL);
tgt_rep->fp_def[0] = true;
changed |= SetFp(tgt_rep->defs[0]);
if (shorty[0] == 'D') {
tgt_rep->fp_def[1] = true;
changed |= SetFp(tgt_rep->defs[1]);
}
}
}
int num_uses = mir->dalvikInsn.vA;
// If this is a non-static invoke, mark implicit "this"
if (((mir->dalvikInsn.opcode != Instruction::INVOKE_STATIC) &&
(mir->dalvikInsn.opcode != Instruction::INVOKE_STATIC_RANGE))) {
reg_location_[uses[next]].defined = true;
reg_location_[uses[next]].ref = true;
type_mismatch |= reg_location_[uses[next]].wide;
next++;
}
uint32_t cpos = 1;
if (strlen(shorty) > 1) {
for (int i = next; i < num_uses;) {
DCHECK_LT(cpos, strlen(shorty));
switch (shorty[cpos++]) {
case 'D':
ssa_rep->fp_use[i] = true;
ssa_rep->fp_use[i+1] = true;
reg_location_[uses[i]].wide = true;
reg_location_[uses[i+1]].wide = true;
reg_location_[uses[i+1]].high_word = true;
DCHECK_EQ(SRegToVReg(uses[i])+1, SRegToVReg(uses[i+1]));
i++;
break;
case 'J':
reg_location_[uses[i]].wide = true;
reg_location_[uses[i+1]].wide = true;
reg_location_[uses[i+1]].high_word = true;
DCHECK_EQ(SRegToVReg(uses[i])+1, SRegToVReg(uses[i+1]));
changed |= SetCore(uses[i]);
i++;
break;
case 'F':
type_mismatch |= reg_location_[uses[i]].wide;
ssa_rep->fp_use[i] = true;
break;
case 'L':
type_mismatch |= reg_location_[uses[i]].wide;
changed |= SetRef(uses[i]);
break;
default:
type_mismatch |= reg_location_[uses[i]].wide;
changed |= SetCore(uses[i]);
break;
}
i++;
}
}
}
for (int i = 0; ssa_rep->fp_use && i< ssa_rep->num_uses; i++) {
if (ssa_rep->fp_use[i]) {
changed |= SetFp(uses[i]);
}
}
for (int i = 0; ssa_rep->fp_def && i< ssa_rep->num_defs; i++) {
if (ssa_rep->fp_def[i]) {
changed |= SetFp(defs[i]);
}
}
// Special-case handling for moves & Phi
if (attrs & (DF_IS_MOVE | DF_NULL_TRANSFER_N)) {
/*
* If any of our inputs or outputs is defined, set all.
* Some ugliness related to Phi nodes and wide values.
* The Phi set will include all low words or all high
* words, so we have to treat them specially.
*/
bool is_phi = (static_cast<int>(mir->dalvikInsn.opcode) == kMirOpPhi);
RegLocation rl_temp = reg_location_[defs[0]];
bool defined_fp = rl_temp.defined && rl_temp.fp;
bool defined_core = rl_temp.defined && rl_temp.core;
bool defined_ref = rl_temp.defined && rl_temp.ref;
bool is_wide = rl_temp.wide || ((attrs & DF_A_WIDE) != 0);
bool is_high = is_phi && rl_temp.wide && rl_temp.high_word;
for (int i = 0; i < ssa_rep->num_uses; i++) {
rl_temp = reg_location_[uses[i]];
defined_fp |= rl_temp.defined && rl_temp.fp;
defined_core |= rl_temp.defined && rl_temp.core;
defined_ref |= rl_temp.defined && rl_temp.ref;
is_wide |= rl_temp.wide;
is_high |= is_phi && rl_temp.wide && rl_temp.high_word;
}
/*
* We don't normally expect to see a Dalvik register definition used both as a
* floating point and core value, though technically it could happen with constants.
* Until we have proper typing, detect this situation and disable register promotion
* (which relies on the distinction between core a fp usages).
*/
if ((defined_fp && (defined_core | defined_ref)) &&
((cu_->disable_opt & (1 << kPromoteRegs)) == 0)) {
LOG(WARNING) << PrettyMethod(cu_->method_idx, *cu_->dex_file)
<< " op at block " << bb->id
<< " has both fp and core/ref uses for same def.";
cu_->disable_opt |= (1 << kPromoteRegs);
}
changed |= SetFp(defs[0], defined_fp);
changed |= SetCore(defs[0], defined_core);
changed |= SetRef(defs[0], defined_ref);
changed |= SetWide(defs[0], is_wide);
changed |= SetHigh(defs[0], is_high);
if (attrs & DF_A_WIDE) {
changed |= SetWide(defs[1]);
changed |= SetHigh(defs[1]);
}
for (int i = 0; i < ssa_rep->num_uses; i++) {
changed |= SetFp(uses[i], defined_fp);
changed |= SetCore(uses[i], defined_core);
changed |= SetRef(uses[i], defined_ref);
changed |= SetWide(uses[i], is_wide);
changed |= SetHigh(uses[i], is_high);
}
if (attrs & DF_A_WIDE) {
DCHECK_EQ(ssa_rep->num_uses, 2);
changed |= SetWide(uses[1]);
changed |= SetHigh(uses[1]);
}
}
}
if (type_mismatch) {
LOG(WARNING) << "Deprecated dex type mismatch, interpreting "
<< PrettyMethod(cu_->method_idx, *cu_->dex_file);
LOG(INFO) << "@ 0x" << std::hex << mir->offset;
SetPuntToInterpreter(true);
}
return changed;
}
static const char* storage_name[] = {" Frame ", "PhysReg", " Spill "};
void MIRGraph::DumpRegLocTable(RegLocation* table, int count) {
// FIXME: Quick-specific. Move to Quick (and make a generic version for MIRGraph?
Mir2Lir* cg = static_cast<Mir2Lir*>(cu_->cg.get());
if (cg != NULL) {
for (int i = 0; i < count; i++) {
LOG(INFO) << StringPrintf("Loc[%02d] : %s, %c %c %c %c %c %c 0x%04x S%d",
table[i].orig_sreg, storage_name[table[i].location],
table[i].wide ? 'W' : 'N', table[i].defined ? 'D' : 'U',
table[i].fp ? 'F' : table[i].ref ? 'R' :'C',
table[i].is_const ? 'c' : 'n',
table[i].high_word ? 'H' : 'L', table[i].home ? 'h' : 't',
table[i].reg.GetRawBits(),
table[i].s_reg_low);
}
} else {
// Either pre-regalloc or Portable.
for (int i = 0; i < count; i++) {
LOG(INFO) << StringPrintf("Loc[%02d] : %s, %c %c %c %c %c %c S%d",
table[i].orig_sreg, storage_name[table[i].location],
table[i].wide ? 'W' : 'N', table[i].defined ? 'D' : 'U',
table[i].fp ? 'F' : table[i].ref ? 'R' :'C',
table[i].is_const ? 'c' : 'n',
table[i].high_word ? 'H' : 'L', table[i].home ? 'h' : 't',
table[i].s_reg_low);
}
}
}
// FIXME - will likely need to revisit all uses of this.
static const RegLocation fresh_loc = {kLocDalvikFrame, 0, 0, 0, 0, 0, 0, 0, 0,
RegStorage(), INVALID_SREG, INVALID_SREG};
void MIRGraph::InitRegLocations() {
/* Allocate the location map */
int max_regs = GetNumSSARegs() + GetMaxPossibleCompilerTemps();
RegLocation* loc = static_cast<RegLocation*>(arena_->Alloc(max_regs * sizeof(*loc),
kArenaAllocRegAlloc));
for (int i = 0; i < GetNumSSARegs(); i++) {
loc[i] = fresh_loc;
loc[i].s_reg_low = i;
loc[i].is_const = is_constant_v_->IsBitSet(i);
loc[i].wide = false;
}
/* Patch up the locations for the compiler temps */
GrowableArray<CompilerTemp*>::Iterator iter(&compiler_temps_);
for (CompilerTemp* ct = iter.Next(); ct != NULL; ct = iter.Next()) {
loc[ct->s_reg_low].location = kLocCompilerTemp;
loc[ct->s_reg_low].defined = true;
}
/* Treat Method* as a normal reference */
loc[GetMethodSReg()].ref = true;
reg_location_ = loc;
int num_regs = cu_->num_dalvik_registers;
/* Add types of incoming arguments based on signature */
int num_ins = cu_->num_ins;
if (num_ins > 0) {
int s_reg = num_regs - num_ins;
if ((cu_->access_flags & kAccStatic) == 0) {
// For non-static, skip past "this"
reg_location_[s_reg].defined = true;
reg_location_[s_reg].ref = true;
s_reg++;
}
const char* shorty = cu_->shorty;
int shorty_len = strlen(shorty);
for (int i = 1; i < shorty_len; i++) {
switch (shorty[i]) {
case 'D':
reg_location_[s_reg].wide = true;
reg_location_[s_reg+1].high_word = true;
reg_location_[s_reg+1].fp = true;
DCHECK_EQ(SRegToVReg(s_reg)+1, SRegToVReg(s_reg+1));
reg_location_[s_reg].fp = true;
reg_location_[s_reg].defined = true;
s_reg++;
break;
case 'J':
reg_location_[s_reg].wide = true;
reg_location_[s_reg+1].high_word = true;
DCHECK_EQ(SRegToVReg(s_reg)+1, SRegToVReg(s_reg+1));
reg_location_[s_reg].core = true;
reg_location_[s_reg].defined = true;
s_reg++;
break;
case 'F':
reg_location_[s_reg].fp = true;
reg_location_[s_reg].defined = true;
break;
case 'L':
reg_location_[s_reg].ref = true;
reg_location_[s_reg].defined = true;
break;
default:
reg_location_[s_reg].core = true;
reg_location_[s_reg].defined = true;
break;
}
s_reg++;
}
}
}
/*
* Set the s_reg_low field to refer to the pre-SSA name of the
* base Dalvik virtual register. Once we add a better register
* allocator, remove this remapping.
*/
#ifdef MTK_ART_COMMON
__attribute__((weak))
#endif
void MIRGraph::RemapRegLocations() {
for (int i = 0; i < GetNumSSARegs(); i++) {
if (reg_location_[i].location != kLocCompilerTemp) {
int orig_sreg = reg_location_[i].s_reg_low;
reg_location_[i].orig_sreg = orig_sreg;
reg_location_[i].s_reg_low = SRegToVReg(orig_sreg);
}
}
}
} // namespace art
| [
"[email protected]"
] | |
bc4c8f3a546de62475be2017bc85e432dd816b27 | 1c444bdf16632d78a3801a7fe6b35c054c4cddde | /include/bds/bedrock/actor/goal/VexRandomMoveGoal.h | d24911fa64bd88afd1df55fa91e697de3ec96fec | [] | no_license | maksym-pasichnyk/symbols | 962a082bf6a692563402c87eb25e268e7e712c25 | 7673aa52391ce93540f0e65081f16cd11c2aa606 | refs/heads/master | 2022-04-11T03:17:18.078103 | 2020-03-15T11:30:36 | 2020-03-15T11:30:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 579 | h | #pragma once
#include <string>
#include "Goal.h"
class VexRandomMoveGoal : public Goal {
public:
~VexRandomMoveGoal(); // _ZN17VexRandomMoveGoalD2Ev
virtual bool canUse(); // _ZN17VexRandomMoveGoal6canUseEv
virtual bool canContinueToUse(); // _ZN17VexRandomMoveGoal16canContinueToUseEv
virtual void tick(); // _ZN17VexRandomMoveGoal4tickEv
virtual void appendDebugInfo(std::string &)const; // _ZNK17VexRandomMoveGoal15appendDebugInfoERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
VexRandomMoveGoal(Mob &); // _ZN17VexRandomMoveGoalC2ER3Mob
};
| [
"[email protected]"
] | |
d040830a7beec156aaf73d0f9c192e1de5f0d9a4 | 17ccc1c1b2558ddf605621360ce7abe41595a0dc | /qprog/libs/cppitertools/test/test_permutations.cpp | 68fa24f9ac2ec264369e5b541a6489d6eff71aa6 | [
"BSD-2-Clause"
] | permissive | yoyonel/bablib | 43da5684eff58e78a79ce82e931a072e9addef0f | 89c532386160a5a23fd6f42b3b3bb8974a0d4005 | refs/heads/master | 2020-12-24T14:27:10.565023 | 2016-01-16T17:14:12 | 2016-01-16T17:14:12 | 37,137,759 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,599 | cpp | #include <permutations.hpp>
#include "helpers.hpp"
#include <vector>
#include <string>
#include <iterator>
#include "catch.hpp"
using iter::permutations;
using IntPermSet = std::multiset<std::vector<int>>;
TEST_CASE("permutations: basic test, 3 element sequence", "[permutations]") {
const std::vector<int> ns = {1, 7, 9};
auto p = permutations(ns);
IntPermSet v;
for (auto&& st : p) {
v.emplace(std::begin(st), std::end(st));
}
const IntPermSet vc = {
{1, 7, 9}, {1, 9, 7}, {7, 1, 9}, {7, 9, 1}, {9, 1, 7}, {9, 7, 1}};
REQUIRE(v == vc);
}
TEST_CASE(
"permutations: empty sequence has one empy permutation", "[permutations]") {
const std::vector<int> ns{};
auto p = permutations(ns);
auto it = std::begin(p);
REQUIRE((*it).empty());
it++;
REQUIRE(it == std::end(p));
}
TEST_CASE("permutations: iterators can be compared", "[permutations]") {
const std::vector<int> ns = {1, 2};
auto p = permutations(ns);
auto it = std::begin(p);
REQUIRE(it == std::begin(p));
REQUIRE_FALSE(it != std::begin(p));
REQUIRE(it != std::end(p));
REQUIRE_FALSE(it == std::end(p));
++it;
REQUIRE_FALSE(it == std::begin(p));
REQUIRE(it != std::begin(p));
REQUIRE_FALSE(it == std::end(p));
REQUIRE(it != std::end(p));
++it;
REQUIRE(it == std::end(p));
REQUIRE_FALSE(it != std::end(p));
}
TEST_CASE("permutations: binds to lvalues, moves rvalues", "[permutations]") {
itertest::BasicIterable<int> bi{1, 2};
SECTION("binds to lvalues") {
permutations(bi);
REQUIRE_FALSE(bi.was_moved_from());
}
SECTION("moves rvalues") {
permutations(std::move(bi));
REQUIRE(bi.was_moved_from());
}
}
namespace itertest {
bool operator<(const SolidInt& lhs, const SolidInt& rhs) {
return lhs.getint() < rhs.getint();
}
}
TEST_CASE("permutations doesn't move or copy elements of iterable",
"[permutations]") {
constexpr itertest::SolidInt arr[] = {{1}, {0}, {2}};
for (auto&& st : permutations(arr)) {
(void)st;
}
}
TEST_CASE("permutations: iterator meets requirements", "[permutations]") {
std::string s{"abc"};
auto c = permutations(s);
REQUIRE(itertest::IsIterator<decltype(std::begin(c))>::value);
auto&& row = *std::begin(c);
REQUIRE(itertest::IsIterator<decltype(std::begin(row))>::value);
}
template <typename T>
using ImpT = decltype(permutations(std::declval<T>()));
TEST_CASE("permutations: has correct ctor and assign ops", "[permutations]") {
REQUIRE(itertest::IsMoveConstructibleOnly<ImpT<std::string&>>::value);
REQUIRE(itertest::IsMoveConstructibleOnly<ImpT<std::string>>::value);
}
| [
"[email protected]"
] | |
abf3b128710657840c24495304b977e7a476d28a | bedc7ba29919fe77b96338096a33c548cc4a3f44 | /histogram.h | b07e6be546ec7ee27d6bb35ca5552d43615cfca8 | [] | no_license | MavrinaAA/cs_laba03 | 4f9fa5dded123b13dfda8f60e5e4b2a3d5071c8c | 508a4db751fc1c8c23d1535764a1281b97ddcfb7 | refs/heads/main | 2023-05-14T00:37:45.800633 | 2021-05-19T16:13:16 | 2021-05-19T16:13:16 | 361,726,563 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 287 | h | #pragma once
#include <vector>
#include <iostream>
using namespace std;
void
find_minmax(const vector<double>& numbers, double& min, double& max);
vector<size_t>
make_histogram (const vector<double>& numbers,size_t bin_count);
void
show_histogram_text (const vector<size_t>& bins);
| [
"[email protected]"
] | |
ae455cb1e165ab0e17c5639542f038a425767bbd | 7efc72aa1cf4667f759a7a89d015143b5f8456e9 | /src/learn/01/camera_class.cpp | 6e9e29e9b76afc5fdfbc12d32c38b9c15f2eea6e | [] | no_license | ORZaaa/openGL | ebe88120ec4c4a04e491dd4197bcc59055f80d9a | d8bd29f8d8cf3b943c48903a3ee0c2e0536e4583 | refs/heads/master | 2020-05-20T07:12:07.090639 | 2019-05-07T17:03:13 | 2019-05-07T17:03:13 | 185,444,031 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,946 | cpp | ///**
//*┌──────────────────────────────────────────────────────────────┐
//*│ Info:
//*│ Author: Carl
//*│ Version: 1.0
//*│ Creat Time: 19.04.21
//*└──────────────────────────────────────────────────────────────┘
//*/
//
//#include <glad/glad.h>
//#include <GLFW/glfw3.h>
//#define STB_IMAGE_IMPLEMENTATION
//#include <stb_image.h>
//
//#include <glm/glm.hpp>
//#include <glm/gtc/matrix_transform.hpp>
//#include <glm/gtc/type_ptr.hpp>
//
//#include <shader_m.h>
//#include <camera.h>
//
//#include <iostream>
//
//void framebuffer_size_callback(GLFWwindow* window, int width, int height);
//void mouse_callback(GLFWwindow* window, double xpos, double ypos);
//void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
//void processInput(GLFWwindow *window);
//
//// settings
//const unsigned int SCR_WIDTH = 800;
//const unsigned int SCR_HEIGHT = 600;
//
//// camera
//Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
//float lastX = SCR_WIDTH / 2.0f;
//float lastY = SCR_HEIGHT / 2.0f;
//bool firstMouse = true;
//
//// timing
//float deltaTime = 0.0f; // time between current frame and last frame
//float lastFrame = 0.0f;
//
//int main()
//{
// /**
// * init GLFW window
// */
// glfwInit();
//
// // Choose openGL Version
// glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
// glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
//
// // Choose openGL Model: core
// glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
//
//#ifdef __APPLE__
// glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // uncomment this statement to fix compilation on OS X
//#endif
//
// /**
// * create window
// */
// GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL);
// if (window == NULL)
// {
// std::cout << "Failed to create GLFW window" << std::endl;
// glfwTerminate();
// return -1;
// }
// glfwMakeContextCurrent(window);
// glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
// glfwSetCursorPosCallback(window, mouse_callback);
// glfwSetScrollCallback(window, scroll_callback);
//
// // tell GLFW to capture our mouse
// glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
//
// /**
// * init GLAD
// */
// if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
// {
// std::cout << "Failed to initialize GLAD" << std::endl;
// return -1;
// }
//
// //------------------------------------------------
// /**
// * Enable GL_DEPTH_TEST
// */
// glEnable(GL_DEPTH_TEST);
//
//
// //-----------------------------------------------------------
// /**
// * build shader
// */
// Shader ourShader("shaders/learn/1.getting_started/7.4.camera.vs", "shaders/learn/1.getting_started/7.4.camera.fs");
//
//
// //---------------------------------------------
// /**
// * Vertex data
// */
// float vertices[] = {
// -0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
// 0.5f, -0.5f, -0.5f, 1.0f, 0.0f,
// 0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
// 0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
// -0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
// -0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
//
// -0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
// 0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
// 0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
// 0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
// -0.5f, 0.5f, 0.5f, 0.0f, 1.0f,
// -0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
//
// -0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
// -0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
// -0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
// -0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
// -0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
// -0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
//
// 0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
// 0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
// 0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
// 0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
// 0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
// 0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
//
// -0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
// 0.5f, -0.5f, -0.5f, 1.0f, 1.0f,
// 0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
// 0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
// -0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
// -0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
//
// -0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
// 0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
// 0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
// 0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
// -0.5f, 0.5f, 0.5f, 0.0f, 0.0f,
// -0.5f, 0.5f, -0.5f, 0.0f, 1.0f
// };
// // world space positions of our cubes
// glm::vec3 cubePositions[] = {
// glm::vec3(0.0f, 0.0f, 0.0f),
// glm::vec3(2.0f, 5.0f, -15.0f),
// glm::vec3(-1.5f, -2.2f, -2.5f),
// glm::vec3(-3.8f, -2.0f, -12.3f),
// glm::vec3(2.4f, -0.4f, -3.5f),
// glm::vec3(-1.7f, 3.0f, -7.5f),
// glm::vec3(1.3f, -2.0f, -2.5f),
// glm::vec3(1.5f, 2.0f, -2.5f),
// glm::vec3(1.5f, 0.2f, -1.5f),
// glm::vec3(-1.3f, 1.0f, -1.5f)
// };
// unsigned int VBO, VAO;
// glGenVertexArrays(1, &VAO);
// glGenBuffers(1, &VBO);
//
// glBindVertexArray(VAO);
//
// glBindBuffer(GL_ARRAY_BUFFER, VBO);
// glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
//
// // position attribute
// glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)0);
// glEnableVertexAttribArray(0);
// // texture coord attribute
// glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3 * sizeof(float)));
// glEnableVertexAttribArray(1);
//
//
// //--------------------------------
// /**
// * load and create a texture
// */
// unsigned int texture1, texture2;
// // texture 1
// // ---------
// glGenTextures(1, &texture1);
// glBindTexture(GL_TEXTURE_2D, texture1);
// // set the texture wrapping parameters
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
// // set texture filtering parameters
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// // load image, create texture and generate mipmaps
// int width, height, nrChannels;
// stbi_set_flip_vertically_on_load(true); // tell stb_image.h to flip loaded texture's on the y-axis.
// unsigned char *data = stbi_load("resources/learn/textures/container.jpg", &width, &height, &nrChannels, 0);
// if (data)
// {
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
// glGenerateMipmap(GL_TEXTURE_2D);
// }
// else
// {
// std::cout << "Failed to load texture" << std::endl;
// }
// stbi_image_free(data);
// // texture 2
// // ---------
// glGenTextures(1, &texture2);
// glBindTexture(GL_TEXTURE_2D, texture2);
// // set the texture wrapping parameters
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
// // set texture filtering parameters
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// // load image, create texture and generate mipmaps
// data = stbi_load("resources/learn/textures/awesomeface.png", &width, &height, &nrChannels, 0);
// if (data)
// {
// // note that the awesomeface.png has transparency and thus an alpha channel, so make sure to tell OpenGL the data type is of GL_RGBA
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
// glGenerateMipmap(GL_TEXTURE_2D);
// }
// else
// {
// std::cout << "Failed to load texture" << std::endl;
// }
// stbi_image_free(data);
//
// // tell opengl for each sampler to which texture unit it belongs to (only has to be done once)
// // -------------------------------------------------------------------------------------------
// ourShader.use();
// ourShader.setInt("texture1", 0);
// ourShader.setInt("texture2", 1);
//
//
// //-------------------------------------
// /**
// * render loop
// */
// while (!glfwWindowShouldClose(window))
// {
// // per-frame time logic
// // --------------------
// float currentFrame = glfwGetTime();
// deltaTime = currentFrame - lastFrame;
// lastFrame = currentFrame;
//
// // input
// // -----
// processInput(window);
//
// // render
// // ------
// glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//
// // bind textures on corresponding texture units
// glActiveTexture(GL_TEXTURE0);
// glBindTexture(GL_TEXTURE_2D, texture1);
// glActiveTexture(GL_TEXTURE1);
// glBindTexture(GL_TEXTURE_2D, texture2);
//
// // activate shader
// ourShader.use();
//
// // pass projection matrix to shader (note that in this case it could change every frame)
// glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
// ourShader.setMat4("projection", projection);
//
// // camera/view transformation
// glm::mat4 view = camera.GetViewMatrix();
// ourShader.setMat4("view", view);
//
// // render boxes
// glBindVertexArray(VAO);
// for (unsigned int i = 0; i < 10; i++)
// {
// // calculate the model matrix for each object and pass it to shader before drawing
// glm::mat4 model = glm::mat4(1.0f); // make sure to initialize matrix to identity matrix first
// model = glm::translate(model, cubePositions[i]);
// float angle = 20.0f * i;
// model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f));
// ourShader.setMat4("model", model);
//
// glDrawArrays(GL_TRIANGLES, 0, 36);
// }
//
// // glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
// // -------------------------------------------------------------------------------
// glfwSwapBuffers(window);
// glfwPollEvents();
// }
//
// // optional: de-allocate all resources once they've outlived their purpose:
// // ------------------------------------------------------------------------
// glDeleteVertexArrays(1, &VAO);
// glDeleteBuffers(1, &VBO);
//
// // glfw: terminate, clearing all previously allocated GLFW resources.
// // ------------------------------------------------------------------
// glfwTerminate();
// return 0;
//}
//
///**
// * process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly
// */
//void processInput(GLFWwindow *window)
//{
// if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
// glfwSetWindowShouldClose(window, true);
//
// if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
// camera.ProcessKeyboard(FORWARD, deltaTime);
// if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
// camera.ProcessKeyboard(BACKWARD, deltaTime);
// if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
// camera.ProcessKeyboard(LEFT, deltaTime);
// if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
// camera.ProcessKeyboard(RIGHT, deltaTime);
//}
//
///**
// * process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly
// */
//void framebuffer_size_callback(GLFWwindow* window, int width, int height)
//{
// // make sure the viewport matches the new window dimensions; note that width and
// // height will be significantly larger than specified on retina displays.
// glViewport(0, 0, width, height);
//}
//
//
///**
// * glfw: whenever the mouse moves, this callback is called
// */
//void mouse_callback(GLFWwindow* window, double xpos, double ypos)
//{
// if (firstMouse)
// {
// lastX = xpos;
// lastY = ypos;
// firstMouse = false;
// }
//
// float xoffset = xpos - lastX;
// float yoffset = lastY - ypos; // reversed since y-coordinates go from bottom to top
//
// lastX = xpos;
// lastY = ypos;
//
// camera.ProcessMouseMovement(xoffset, yoffset);
//}
//
///**
// * glfw: whenever the mouse scroll wheel scrolls, this callback is called
// */
//void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
//{
// camera.ProcessMouseScroll(yoffset);
//}
| [
"[email protected]"
] | |
ce64adb1d02aabc44817038c17d655e5a16ee42d | 250dd2597d72cf7b7c109909ea5b33b151e42af2 | /src/stdio/zstdio.h | 7805f6f7ea1d723de24598fb0db5a032324153a5 | [] | no_license | goddanao/php-czmq-legacy | 83d5ab582ebc69df891e4d77a99c2fc460efa3b6 | 3ae0a16008462f868007f7cb9c1f8145110f154a | refs/heads/master | 2021-01-22T15:49:59.766391 | 2016-03-16T12:17:45 | 2016-03-16T12:17:45 | 29,911,347 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,808 | h | #pragma once
#include "../common.h"
class ZStdIn : public ZHandle, public Php::Base {
public:
ZStdIn() : ZHandle(STDIN_FILENO, false, "fd"), Php::Base() { }
Php::Value recv(Php::Parameters ¶m){
Php::Value result;
result.reserve(4096);
int num_read = read(get_fd(), (void *) result.rawValue(), 4096);
result.reserve(num_read);
return result;
}
Php::Value send(Php::Parameters ¶m) {
const char *pointer = param[0].rawValue();
return (write(get_fd(), pointer, param[0].size()) == param[0].size());
}
static Php::Class<ZStdIn> php_register() {
Php::Class<ZStdIn> o("ZStdIn");
o.method("recv", &ZStdIn::recv);
o.method("send", &ZStdIn::send, {
Php::ByVal("data", Php::Type::String, true)
});
// IZDescriptor intf support
ZHandle::register_izdescriptor((Php::Class<ZStdIn> *) &o);
return o;
}
};
class ZStdOut : public ZHandle, public Php::Base {
public:
ZStdOut() : ZHandle(STDOUT_FILENO, false, "fd"), Php::Base() { }
Php::Value recv(Php::Parameters ¶m){
Php::Value result;
result.reserve(4096);
int num_read = read(get_fd(), (void *) result.rawValue(), 4096);
result.reserve(num_read);
return result;
}
Php::Value send(Php::Parameters ¶m) {
const char *pointer = param[0].rawValue();
return (write(get_fd(), pointer, param[0].size()) == param[0].size());
}
static Php::Class<ZStdOut> php_register() {
Php::Class<ZStdOut> o("ZStdOut");
o.method("recv", &ZStdOut::recv);
o.method("send", &ZStdOut::send, {
Php::ByVal("data", Php::Type::String, true)
});
// IZDescriptor intf support
ZHandle::register_izdescriptor((Php::Class<ZStdOut> *) &o);
return o;
}
};
class ZStdErr : public ZHandle, public Php::Base {
public:
ZStdErr() : ZHandle(STDERR_FILENO, false, "fd"), Php::Base() { }
Php::Value recv(Php::Parameters ¶m){
Php::Value result;
result.reserve(4096);
int num_read = read(get_fd(), (void *) result.rawValue(), 4096);
result.reserve(num_read);
return result;
}
Php::Value send(Php::Parameters ¶m) {
const char *pointer = param[0].rawValue();
return (write(get_fd(), pointer, param[0].size()) == param[0].size());
}
static Php::Class<ZStdErr> php_register() {
Php::Class<ZStdErr> o("ZStdErr");
o.method("recv", &ZStdErr::recv);
o.method("send", &ZStdErr::send, {
Php::ByVal("data", Php::Type::String, true)
});
// IZDescriptor intf support
ZHandle::register_izdescriptor((Php::Class<ZStdErr> *) &o);
return o;
}
}; | [
"[email protected]"
] | |
e86e27dc8a89248c0be024d02651d70af14a07c6 | 4369050c1694b57db3c6f4417a0824978af97062 | /src/SDL2/Entities/Texture.cpp | f6869b1078e0226a3f7ce41e1f05e73d691377b5 | [] | no_license | Serdok/GoldenPhoenix | 18c6c87440bab6cd94f0a2ba79173150630d2c30 | 927519c80038f452f626a9e4d19c64fa95156772 | refs/heads/master | 2021-05-20T23:09:12.889371 | 2019-05-06T17:26:12 | 2019-05-06T17:26:12 | 252,445,809 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,851 | cpp | //
// Created by serdok on 09/03/19.
//
#include "Texture.h"
Texture::Texture( const std::string& imagefile, bool fullscreen )
: _fullscreen( fullscreen )
{
// Load the image
_texture = AssetsManager::GetInstance()->GetTexture( imagefile );
// Fetch image size
SDL_QueryTexture( _texture, nullptr, nullptr, &_width, &_height );
_dest.w = _width;
_dest.h = _height;
}
Texture::Texture( const std::string& imagefile, int x, int y, int width, int height, bool fullscreen )
: _clipped( true ), _fullscreen( fullscreen )
{
// Load the image
_texture = AssetsManager::GetInstance()->GetTexture( imagefile );
// Set image sizes
_dest.w = _width = width;
_dest.h = _height = height;
// Set clip size
_clip = { x, y, width, height };
}
Texture::Texture( const std::string& text, const std::string& font, int size, const SDL_Color& color, bool fullscreen )
: _fullscreen( fullscreen )
{
// Convert message to texture
_texture = AssetsManager::GetInstance()->GetMessage( text, font, size, color );
// Fetch texture size
SDL_QueryTexture( _texture, nullptr, nullptr, &_width, &_height );
_dest.w = _width;
_dest.h = _height;
}
Texture::~Texture()
{
_texture = nullptr;
}
int Texture::GetWidth() const
{
return _width;
}
int Texture::GetHeight() const
{
return _height;
}
void Texture::SetAlpha( unsigned char alpha )
{
SDL_SetTextureAlphaMod( _texture, alpha );
}
void Texture::SetBlendingMode( SDL_BlendMode mode )
{
SDL_SetTextureBlendMode( _texture, mode );
}
void Texture::Update()
{
// Overridden in derived classes
}
void Texture::Render()
{
// Calculate destination coordinates. Image will be rendered from its center point
Vector2f position = GetPosition();
Vector2f scale = GetScale();
_dest.x = (int) ( position.x - _width*scale.x*0.5f );
_dest.y = (int) ( position.y - _height*scale.y*0.5f );
_dest.w = (int) ( _width*scale.x );
_dest.h = (int) ( _height*scale.y );
// Load texture in renderer
Graphics::GetInstance()->DrawTexture( _texture, ( _clipped ? &_clip : nullptr ), ( _fullscreen ? nullptr : &_dest ),
GetRotation() );
}
void Texture::Render( SDL_RendererFlip flip )
{
// Calculate destination coordinates. Image will be rendered from its center point
Vector2f position = GetPosition();
Vector2f scale = GetScale();
_dest.x = (int) ( position.x - _width*scale.x*0.5f );
_dest.y = (int) ( position.y - _height*scale.y*0.5f );
_dest.w = (int) ( _width*scale.x );
_dest.h = (int) ( _height*scale.y );
// Load texture in renderer
Graphics::GetInstance()->DrawTexture( _texture, ( _clipped ? &_clip : nullptr ), ( _fullscreen ? nullptr : &_dest ),
GetRotation(), flip );
} | [
"[email protected]"
] | |
ff4c5a831aefa332c98efdd64b07becbb2a25a04 | 498dab3961bd056615ebcca32f5b5d89122d5efe | /external/glm/gtc/noise.hpp | b4a33bb60b3d6c6c257fff68cc416d29a8a00121 | [
"MIT"
] | permissive | andy-thomason/Vookoo | 3ee6b24e798afcca0d228ff5444b5e7577f8369a | d24318c9bf9dbbd38c596353bd7f9eacbab0e862 | refs/heads/master | 2023-08-29T06:35:01.669135 | 2022-06-15T18:47:30 | 2022-06-20T14:59:56 | 52,352,579 | 551 | 66 | MIT | 2022-08-08T12:36:18 | 2016-02-23T11:00:22 | C++ | UTF-8 | C++ | false | false | 1,508 | hpp | /// @ref gtc_noise
/// @file glm/gtc/noise.hpp
///
/// @see core (dependence)
///
/// @defgroup gtc_noise GLM_GTC_noise
/// @ingroup gtc
///
/// Include <glm/gtc/noise.hpp> to use the features of this extension.
///
/// Defines 2D, 3D and 4D procedural noise functions
/// Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise":
/// https://github.com/ashima/webgl-noise
/// Following Stefan Gustavson's paper "Simplex noise demystified":
/// http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
#pragma once
// Dependencies
#include "../detail/setup.hpp"
#include "../detail/qualifier.hpp"
#include "../detail/_noise.hpp"
#include "../geometric.hpp"
#include "../common.hpp"
#include "../vector_relational.hpp"
#include "../vec2.hpp"
#include "../vec3.hpp"
#include "../vec4.hpp"
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTC_noise extension included")
#endif
namespace glm
{
/// @addtogroup gtc_noise
/// @{
/// Classic perlin noise.
/// @see gtc_noise
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL T perlin(
vec<L, T, Q> const& p);
/// Periodic perlin noise.
/// @see gtc_noise
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL T perlin(
vec<L, T, Q> const& p,
vec<L, T, Q> const& rep);
/// Simplex noise.
/// @see gtc_noise
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL T simplex(
vec<L, T, Q> const& p);
/// @}
}//namespace glm
#include "noise.inl"
| [
"[email protected]"
] | |
c6cdc7a9e9d4a08e960cdf8b02fa3c139f7d5ef2 | 4ac1e916a5c376d687ad868b218bd95074f5fa12 | /r7q2/src/MinhaEmpresa.cpp | 5e849e783fb6dfdf5d5f31a3a0c15ee99e0f3f78 | [] | no_license | henriqueeraraujo/roteiro7 | 87abba2243590190c1dfdf825e318f99bedd261c | ab9ee4fe9896ae98756eb7ebbb3efea645c64229 | refs/heads/master | 2021-07-13T17:52:52.170028 | 2017-10-19T12:48:15 | 2017-10-19T12:48:15 | 104,886,962 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 723 | cpp | #include "MinhaEmpresa.h"
MinhaEmpresa::MinhaEmpresa(){
f1=Funcionario();
c1=Consultor();
}
void MinhaEmpresa::menu(){
cout<<"\n**********\tMENU\t**********\n";
cout<<"0 - Sair\n";
cout<<"1 - Mostrar dados do Funcionario\n";
cout<<"2 - Alterar nome do Funcionario\n";
cout<<"3 - Alterar matricula do funcionario\n";
cout<<"4 - alterar salario do funcionario\n";
cout<<"5 - Mostrar dados do Consultor\n";
cout<<"6 - Alterar nome do Consultor\n";
cout<<"7 - Alterar matricula do Consultor\n";
cout<<"8 - alterar salario do Consultor\n";
cout<<"9 - alterar percentual de aumento de salario do consultor\n";
cout<<"--> ";
}
MinhaEmpresa::~MinhaEmpresa()
{
//dtor
}
| [
"[email protected]"
] | |
023ee51ece6a36f5a6e84b6d5b8e17f0d25e88d7 | f9ff7e219c50aa6961846bde39deb0418f58fb8f | /usami-ray/include/usami/ray/bsdf/bsdf_geometry.h | e360d1d6318022ba279afd572238b5214951ebdd | [] | no_license | daiyousei-qz/Usami | a46073b86fc02d04756678992d1c6748d12e3e67 | dfdbb463818302462a881c9cc077c258716f3027 | refs/heads/master | 2023-03-15T07:27:44.678096 | 2021-03-10T20:58:28 | 2021-03-10T20:58:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,018 | h | #pragma once
#include "usami/math/math.h"
namespace usami::ray
{
// calculation of Bsdf instance would be done in local coordinate
// where scattering normal vector is mapped to kBsdfNormal
constexpr Vec3f kBsdfNormal = Vec3f{0.f, 0.f, 1.f};
// create transform from **world coordinate** to **bsdf local coordinate**
// TODO: this transform only support non-polarized bsdf
// TODO: generate inverse matrix, too
inline Matrix4 CreateBsdfCoordTransform(Vec3f n)
{
if (n.x != 0 || n.y != 0)
{
Vec3f nz = n.Normalize();
Vec3f nx = Vec3f{n.y, -n.x, 0.f}.Normalize();
Vec3f ny = Cross(n, nx);
return Matrix4::ChangeBasis3D(nx, ny, nz, 0.f);
}
else
{
Vec3f nz = n.Normalize();
Vec3f nx = Vec3f{n.z > 0 ? 1.f : -1.f, 0.f, 0.f};
Vec3f ny = Vec3f{0.f, 1.f, 0.f};
return Matrix4::ChangeBasis3D(nx, ny, nz, 0.f);
}
}
inline bool SameHemisphere(const Vec3f& wo, const Vec3f& wi) noexcept
{
return wo.z * wi.z > 0;
}
inline float CosTheta(const Vec3f& w) noexcept
{
return w.z;
}
inline float Cos2Theta(const Vec3f& w) noexcept
{
return w.z * w.z;
}
inline float AbsCosTheta(const Vec3f& w) noexcept
{
return Abs(w.z);
}
inline float Sin2Theta(const Vec3f& w) noexcept
{
return Max(0.f, 1.f - Cos2Theta(w));
}
inline float SinTheta(const Vec3f& w) noexcept
{
return Sqrt(Sin2Theta(w));
}
inline float TanTheta(const Vec3f& w) noexcept
{
return SinTheta(w) / CosTheta(w);
}
inline float Tan2Theta(const Vec3f& w) noexcept
{
return Sin2Theta(w) / Cos2Theta(w);
}
// assume SameHemiSphere(wo, n)
inline Vec3f ReflectRay(const Vec3f& wo, const Vec3f& n) noexcept
{
auto h = Dot(wo, n);
return -wo + 2 * h * n;
}
// assume n = +-kBsdfNormal
inline Vec3f ReflectRayQuick(const Vec3f& wo) noexcept
{
return Vec3f{-wo.x, -wo.y, wo.z};
}
// assume SameHemiSphere(wo, n)
// eta = etaI / etaT, i.e. inverse of refractive index
inline bool RefractRay(const Vec3f& wo, const Vec3f& n, float eta, Vec3f& refracted) noexcept
{
float cosThetaI = Dot(n, wo);
float sin2ThetaI = Max(0.f, 1.f - cosThetaI * cosThetaI);
float sin2ThetaT = eta * eta * sin2ThetaI;
if (sin2ThetaT > 1)
{
return false;
}
float cosThetaT = Sqrt(1.f - sin2ThetaT);
refracted = -eta * wo + (eta * cosThetaI - cosThetaT) * n;
return true;
}
// eta = etaI / etaT
inline constexpr float Schlick(float cos_theta, float eta) noexcept
{
auto r0 = (eta - 1) / (eta + 1);
r0 = r0 * r0;
auto root = 1 - cos_theta;
auto root2 = root * root;
return r0 + (1 - r0) * root2 * root;
}
} // namespace usami::ray
| [
"[email protected]"
] | |
f1a81e9fbf3ade6db8db2a1f89f0d9230ff01978 | e92a0b984f0798ef2bba9ad4199b431b4f5eb946 | /2009/simulateur/src/pc/usb.cpp | ab8de296ac8a15d4d13f1712525ad3a4de6990ea | [] | no_license | AdamdbUT/mac-gyver | c09c1892080bf77c25cb4ca2a7ebaf7be3459032 | 32de5c0989710ccd671d46e0babb602e51bf8ff9 | refs/heads/master | 2021-01-23T15:53:19.383860 | 2010-06-21T13:33:38 | 2010-06-21T13:33:38 | 42,737,082 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 110 | cpp | #include "../common/simul.h"
#ifdef SIMULATION
#include "usb_simul.cpp"
#else
#include "usb_real.cpp"
#endif
| [
"[email protected]"
] | |
9895f0174edeb0068030dbf0d4f52dac00b3e37d | 4ede9fb3478e7e4f3697a1996d9f961a5a1afda7 | /day03/ChineseChessTest/widget.h | 403bee74deb0adde3290c757e25e8f536a49ba29 | [
"MIT"
] | permissive | lvzl20/QtTest1 | b9ec6caf89bd94b92e2ca757f2ba45778bbf4703 | b5df4f93530763b3aeada3499b1b4695c49c0c04 | refs/heads/main | 2023-05-15T22:58:56.489823 | 2021-06-19T15:36:22 | 2021-06-19T15:36:22 | 372,178,626 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,095 | h | #ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QLabel>
#include "chess.h"
QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = nullptr);
~Widget();
protected:
// 绘图事件
void paintEvent(QPaintEvent *) override;
// 鼠标按下,移动事件
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent*)override;
private:
void init(); // 初始化棋子
bool getChess(int x, int y, int flag); // 在没有选择棋子的情况下,flag = 0得到当前坐标下的棋子传给curSelectChess,当前坐标不在棋子范围则返回false
// flag = 1 得到目标区域的棋子,如果目标区域没有棋子则返回false
// flag = 2 代表仅判断是否有棋子
bool moveTo(int x, int y); // 已经选择了棋子的情况下,将棋子移动, 返回true代表棋子移动一次
// 不同类型的棋子移动, 返回值为是否成功移动
bool moveArmyTo(int,int,bool);
bool movePaoTo(int,int,bool);
bool moveCarTo(int,int,bool);
bool moveHorseTo(int,int,bool);
bool moveXiangTo(int,int,bool);
bool moveShiTo(int,int,bool);
bool moveMasteTo(int,int,bool);
bool done(); // 判断是否游戏结束
// bool isWillDie();// 判断是否被将军
int areaBlong(int logicY); // 传入逻辑y值(单位为棋盘的格子)判断当前所在红方还是黑方区域
void reUpdate(); // 更新棋盘
//signals:
// void mysignal();
private:
Ui::Widget *ui;
QPoint point;
// 棋子大小 即 格子大小
int ChessSize;
int oldLogicX; // 记录棋子移动前的位置,用于显示光标
int oldLogicY;
int curToGo; // 当前行棋的是哪一方
// 32个棋子
Chess chess[32];
QLabel* label[32];
Chess* curSelectChess; // 当前点击的棋子
Chess* curToChess; // 将要覆盖掉的棋子
};
#endif // WIDGET_H
| [
"[email protected]"
] | |
a5fa5889e117e5f7fcb706a194aef97acd741f36 | 4b09ab5e0addcb2f8160e40cb1bf1cae5066d102 | /src/kalman_filter.h | 33632cf5e05b50718cb8945289d15e36a40b2341 | [
"MIT"
] | permissive | jayshah19949596/Extended-Kalman-Filter | 4ab2d13b876aa75bfd09f4af4343abc4bc8ec650 | 0ff22cf78e7547275245088530581427927f393f | refs/heads/master | 2021-04-09T10:24:14.204441 | 2018-04-08T18:36:55 | 2018-04-08T18:36:55 | 125,472,897 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,737 | h | #ifndef KALMAN_FILTER_H_
#define KALMAN_FILTER_H_
#include "Eigen/Dense"
class KalmanFilter {
public:
// state vector
Eigen::VectorXd x_;
// state covariance matrix
Eigen::MatrixXd P_;
// state transition matrix
Eigen::MatrixXd F_;
// process covariance matrix
Eigen::MatrixXd Q_;
// measurement matrix
Eigen::MatrixXd H_;
// measurement covariance matrix
Eigen::MatrixXd R_;
/**
* Constructor
*/
KalmanFilter();
/**
* Destructor
*/
virtual ~KalmanFilter();
/**
* Init Initializes Kalman filter
* @param x_in Initial state
* @param P_in Initial state covariance
* @param F_in Transition matrix
* @param H_in Measurement matrix
* @param R_in Measurement covariance matrix
* @param Q_in Process covariance matrix
*/
void Init(Eigen::VectorXd &x_in, Eigen::MatrixXd &P_in, Eigen::MatrixXd &F_in,
Eigen::MatrixXd &H_in, Eigen::MatrixXd &R_in, Eigen::MatrixXd &Q_in);
/**
* Prediction Predicts the state and the state covariance
* using the process model
* @param delta_T Time between k and k+1 in s
*/
void Predict();
/**
* Updates the state by using standard Kalman Filter equations
* @param z The measurement at k+1
*/
void Update(const Eigen::VectorXd &z);
/**
* Updates the state by using Extended Kalman Filter equations
* @param z The measurement at k+1
*/
void UpdateEKF(const Eigen::VectorXd &z);
/**
* Updates the state by using Extended Kalman Filter equations
* @param z The measurement at k+1
*/
void UpdateCommon(const Eigen::VectorXd& y);
};
#endif /* KALMAN_FILTER_H_ */
| [
"[email protected]"
] | |
c5a02ccb0912e8f12ed93468314272e32c998b2a | 801f7ed77fb05b1a19df738ad7903c3e3b302692 | /refactoringOptimisation/differentiatedCAD/occt-min-topo-src/src/MoniTool/MoniTool_SignText.cxx | 8a0be6eacf9d36ea63896330bfce03bfb0d81ea8 | [] | no_license | salvAuri/optimisationRefactoring | 9507bdb837cabe10099d9481bb10a7e65331aa9d | e39e19da548cb5b9c0885753fe2e3a306632d2ba | refs/heads/master | 2021-01-20T03:47:54.825311 | 2017-04-27T11:31:24 | 2017-04-27T11:31:24 | 89,588,404 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,157 | cxx | // Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <MoniTool_SignText.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx>
TCollection_AsciiString MoniTool_SignText::TextAlone
(const Handle(Standard_Transient)& ent) const
{
Handle(Standard_Transient) nulctx; // no context
TCollection_AsciiString atext = Text (ent,nulctx);
if (atext.Length() == 0) {
if (ent.IsNull()) atext.AssignCat ("(NULL)");
else atext.AssignCat (ent->DynamicType()->Name());
}
return atext;
}
| [
"[email protected]"
] | |
840cdcad7e681deec3db18499902777bc8bd2c3f | d9c4b7e621e8016203008fc31e6d0d7bffaf7279 | /Node.h | 7e25b4eb7b868051931bc4501be4c51b11f2b944 | [] | no_license | FranciscoGJ/ABBTreap | c6965dfc4332f1309fd022a60d973c4145c55132 | f0117d9246555bb8de1c86adc2f45ed5bdf41427 | refs/heads/master | 2021-07-12T22:01:32.673302 | 2015-06-11T01:21:49 | 2015-06-11T01:21:49 | 107,433,935 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 544 | h | //
// Created by Francisco on 27-05-2015.
//
#ifndef TAREA2ESTRUCTURA_NODE_H
#define TAREA2ESTRUCTURA_NODE_H
#include <iostream>
using namespace std;
template <typename k, typename v>
class Node{
public:
k key;
v value;
int priority;
Node<k,v>* m_right;
Node<k,v>* m_left;
Node(k key, v value, int priority) : key(key), value(value), priority(priority), m_right(nullptr),
m_left(nullptr) { }
virtual ~Node() { }
};
#endif //TAREA2ESTRUCTURA_NODE_H
| [
"[email protected]"
] | |
745c00268e6601b6a53bcd05295b670c48393399 | 8dc84558f0058d90dfc4955e905dab1b22d12c08 | /content/browser/permissions/permission_controller_impl.h | 3b9de91634714ba77230ba591e27c85869acd284 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | meniossin/src | 42a95cc6c4a9c71d43d62bc4311224ca1fd61e03 | 44f73f7e76119e5ab415d4593ac66485e65d700a | refs/heads/master | 2022-12-16T20:17:03.747113 | 2020-09-03T10:43:12 | 2020-09-03T10:43:12 | 263,710,168 | 1 | 0 | BSD-3-Clause | 2020-05-13T18:20:09 | 2020-05-13T18:20:08 | null | UTF-8 | C++ | false | false | 2,493 | h | // Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_PERMISSIONS_PERMISSION_CONTROLLER_IMPL_H_
#define CONTENT_BROWSER_PERMISSIONS_PERMISSION_CONTROLLER_IMPL_H_
#include "content/common/content_export.h"
#include "content/public/browser/permission_controller.h"
namespace content {
class BrowserContext;
// Implementation of the PermissionController interface. This
// is used by content/ layer to manage permissions.
// There is one instance of this class per BrowserContext.
class CONTENT_EXPORT PermissionControllerImpl : public PermissionController {
public:
explicit PermissionControllerImpl(BrowserContext* browser_context);
~PermissionControllerImpl() override;
static PermissionControllerImpl* FromBrowserContext(
BrowserContext* browser_context);
// PermissionController implementation.
blink::mojom::PermissionStatus GetPermissionStatus(
PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) override;
blink::mojom::PermissionStatus GetPermissionStatusForFrame(
PermissionType permission,
RenderFrameHost* render_frame_host,
const GURL& requesting_origin) override;
int RequestPermission(
PermissionType permission,
RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
bool user_gesture,
const base::Callback<void(blink::mojom::PermissionStatus)>& callback);
int RequestPermissions(
const std::vector<PermissionType>& permission,
RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
bool user_gesture,
const base::Callback<
void(const std::vector<blink::mojom::PermissionStatus>&)>& callback);
void ResetPermission(PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin);
int SubscribePermissionStatusChange(
PermissionType permission,
RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
const base::Callback<void(blink::mojom::PermissionStatus)>& callback);
void UnsubscribePermissionStatusChange(int subscription_id);
private:
BrowserContext* browser_context_;
DISALLOW_COPY_AND_ASSIGN(PermissionControllerImpl);
};
} // namespace content
#endif // CONTENT_BROWSER_PERMISSIONS_PERMISSION_CONTROLLER_IMPL_H_
| [
"[email protected]"
] | |
cb10620aba1f70cac49bb6e675ada35b85c90ec1 | 1dbde8d4953e9e0aa6901d3f680d3cc838940da1 | /partie6/src/Stats/Stats.cpp | 996c648efc95ae91a0863cd23f07058527627889 | [] | no_license | Arturjssln/project_prog_wolf_sheep | c5cace75a2f8b090627a878fa26abf029040e197 | 1105ba33b0bfebce7768e62d73ad78c5e8ccebaa | refs/heads/master | 2020-09-15T23:32:57.535372 | 2019-11-23T12:24:05 | 2019-11-23T12:24:05 | 223,584,564 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,963 | cpp | #include "Stats.hpp"
#include "Application.hpp"
int Stats::getActive() const {
return activeIdentifier;
}
void Stats::setActive(int identifier) {
activeIdentifier = identifier;
}
void Stats::reset() {
for (auto& paire : graphs) {
paire.second->reset();
}
}
void Stats::addGraph(int activeId, std::string libelle, std::vector<std::string> const& series, double min, double max, Vec2d tailleGraphes) {
//Si il n'existe pas encore de paire avec cet identifiant, alors on en créé une dans libelles et dans graphs
if(libelles.count(activeId) == 0) {
libelles.insert(std::make_pair(activeId, libelle));
graphs.insert(std::make_pair(activeId, std::unique_ptr<Graph>(new Graph(series, tailleGraphes, min, max))));
} else {
//Sinon on reset le graph déja existant et on la remplace par un nouveau
libelles[activeId] = libelle;
graphs[activeId]->reset();
graphs[activeId] = std::unique_ptr<Graph>(new Graph(series, tailleGraphes, min, max));
}
setActive(activeId);
}
void Stats::update(sf::Time dt) {
if (refreshTime <= sf::Time::Zero) {
refreshTime = sf::seconds(getAppConfig().stats_refresh_rate);
for (auto& pair : graphs) {
//2e argument : On vérifie que le graph est actif pour mettre à jour ses données, sinon fetchData retournera une map vide
std::unordered_map<std::string, double> new_data(getAppEnv().fetchData(libelles[pair.first], activeIdentifier == pair.first));
if (!new_data.empty()) {
pair.second->updateData(refreshTime, new_data);
}
}
}
refreshTime -= dt;
}
void Stats::drawOn(sf::RenderTarget& targetWindow) {
//Si la clé (activeIdentifier) correspond bien à un graph, alors on le dessine
if(graphs.count(activeIdentifier) != 0 and activeIdentifier != -1) graphs[activeIdentifier]->drawOn(targetWindow);
}
void Stats::focusOn (std::string libelle) {
for (auto paire : libelles) {
if (paire.second == libelle) {
setActive(paire.first);
graphs[paire.first]->reset();
}
}
}
| [
"[email protected]"
] | |
fd183dbde4c9711dbcbf6597ec48defd28371bea | 1393b088958301a6c2f6766df2864c61365e9d4b | /Code/Algorithms/L2/CloudMasking/vnsShadowVariationThresholdImageFilter.h | 64ef3c3db3bcb5b0e0beb50a7e64527fad9d7e11 | [
"Apache-2.0"
] | permissive | alexgoussev/maja_gitlab | f6727468cb70e210d3c09453de22fee58ed9d656 | 9688780f8dd8244e60603e1f11385e1fadc90cb4 | refs/heads/develop | 2023-02-24T05:37:38.769452 | 2021-01-21T16:47:54 | 2021-01-21T16:47:54 | 332,269,078 | 0 | 0 | Apache-2.0 | 2021-01-23T18:17:25 | 2021-01-23T17:33:18 | C++ | UTF-8 | C++ | false | false | 10,093 | h | /*
* Copyright (C) 2020 Centre National d'Etudes Spatiales (CNES)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/************************************************************************************************************
* *
* ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo *
* o *
* o *
* o *
* o *
* o ooooooo ooooooo o o oo *
* o o o o o o o o o o *
* o o o o o o o o o o *
* o o o o o o o o o o *
* o o o oooo o o o o o o *
* o o o o o o o o o *
* o o o o o o o o o o *
* oo oooooooo o o o oooooo o oooo *
* o *
* o *
* o o *
* o o oooo o o oooo *
* o o o o o o *
* o o ooo o o ooo *
* o o o o o *
* ooooo oooo o ooooo oooo *
* o *
* *
************************************************************************************************************
* *
* Author: CS Systemes d'Information (France) *
* *
************************************************************************************************************
* HISTORIQUE *
* *
* VERSION : 5-1-0 : FA : LAIG-FA-MAC-145739-CS : 27 juin 2016 : Audit code - Supp de la macro ITK_EXPORT *
* VERSION : 5-0-0 : FA : LAIG-FA-MAC-143764-CS : 12 avril 2016 : Mise en forme du code (indentation, etc.) *
* VERSION : 1-0-0-3 : DM : 357 : 31 août. 2011 : pas de correlation avec la date courante *
* VERSION : 1-0-0 : <TypeFT> : <NumFT> : 7 juin 2010 : Creation
* *
* FIN-HISTORIQUE *
* *
* $Id$
* *
************************************************************************************************************/
#ifndef __vnsShadowVariationThresholdImageFilter_h
#define __vnsShadowVariationThresholdImageFilter_h
#include "itkImageToImageFilter.h"
#include "itkImageRegionConstIterator.h"
#include "vnsMacro.h"
#include "vnsUtilities.h"
namespace vns
{
/** \class ShadowVariationThresholdImageFilter
* \brief This class detects shadows caused by clouds outside the image.
*
* WWhen a ratio of the reflectance of date D and the composite image of date D-1 is below
* a threshold (for the red band), the pixel is considered as a shadow.
* The threshold increase with time delay between the image acquisition and the reference
* reflectance date.
* The detection is not activated above water surfaces to avoid false detection of shadows.
* It is only activated in the zone where clouds outside the image could cast shadows within image.
*
* The input images are otb::VectorImage (images of reflectance).
* The input mask and the image of date are otb::Image.
* The output mask is an otb::Image.
*
* \author CS Systemes d'Information
*
* \sa ImageToImageFilter
*
* \ingroup L2
*
*/
template<class TInputImage, class TInputMask, class TOutputImage>
class ShadowVariationThresholdImageFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage>
{
public:
/** Standard class typedefs. */
typedef ShadowVariationThresholdImageFilter Self;
typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Type macro */
itkNewMacro(Self)
/** Creation through object factory macro */
itkTypeMacro(ShadowVariationThresholdImageFilter, ImageToImageFilter )
/** Some convenient typedefs. */
typedef typename Superclass::InputImageType InputImageType;
typedef typename InputImageType::ConstPointer InputImageConstPointer;
typedef typename InputImageType::Pointer InputImagePointer;
typedef typename InputImageType::RegionType RegionType;
typedef typename InputImageType::PixelType InputImagePixelType;
typedef typename InputImageType::SizeType SizeType;
typedef typename InputImageType::InternalPixelType InputInternalPixelType;
typedef TInputMask InputMaskType;
typedef typename InputMaskType::Pointer InputMaskPointer;
typedef typename InputMaskType::ConstPointer InputMaskConstPointer;
typedef typename InputMaskType::PixelType InputMaskPixelType;
typedef typename Superclass::OutputImageType OutputImageType;
typedef typename OutputImageType::Pointer OutputImagePointer;
typedef typename OutputImageType::RegionType OutputImageRegionType;
typedef typename OutputImageType::PixelType OutputImagePixelType;
// No_data pixel value accessors
itkSetMacro(NoData, RealNoDataType)
itkGetConstReferenceMacro(NoData, RealNoDataType)
// CorrelThreshold parameter accesors
itkSetMacro(ThresholdValue, double)
itkGetConstReferenceMacro(ThresholdValue, double)
/** Set the image of the surface reflectance ratio*/
vnsSetGetInputRawMacro( ReflRatio, InputImageType ,0)
/** Set the outside cloud shadow mask */
vnsSetGetInputRawMacro( IPCLDOutShadInput , InputMaskType , 1)
/** Get the shadows mask from clouds outside image */
OutputImageType*
GetIPCLDShadVarOutput()
{
return static_cast<OutputImageType*>(this->itk::ProcessObject::GetOutput(0));
}
protected:
/** Constructor */
ShadowVariationThresholdImageFilter();
/** Destructor */
virtual
~ShadowVariationThresholdImageFilter();
/** Multi-thread version GenerateData. */
void
ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId);
/** PrintSelf method */
virtual void
PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
ShadowVariationThresholdImageFilter(const Self&); //purposely not implemented
void
operator=(const Self&); //purposely not implemented
/** No_data value */
RealNoDataType m_NoData;
/** Declaration of the threshold on reflectance ratio */
double m_ThresholdValue;
};
} // End namespace vns
#ifndef VNS_MANUAL_INSTANTIATION
#include "vnsShadowVariationThresholdImageFilter.txx"
#endif
#endif /* __vnsShadowVariationThresholdImageFilter_h */
| [
"[email protected]"
] | |
46ed807805ddaddd867d79c2afc747fd402bd52d | 1abf985d2784efce3196976fc1b13ab91d6a2a9e | /opentracker/include/OpenTracker/core/Module.h | 455c6be4510d69ccce823beac989c519bcbf501d | [
"BSD-3-Clause"
] | permissive | dolphinking/mirror-studierstube | 2550e246f270eb406109d4c3a2af7885cd7d86d0 | 57249d050e4195982c5380fcf78197073d3139a5 | refs/heads/master | 2021-01-11T02:19:48.803878 | 2012-09-14T13:01:15 | 2012-09-14T13:01:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,294 | h | /* ========================================================================
* Copyright (c) 2006,
* Institute for Computer Graphics and Vision
* Graz University of Technology
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the Graz University of Technology nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ========================================================================
* PROJECT: OpenTracker
* ======================================================================== */
/** header file for Module class.
*
* @author Gerhard Reitmayr
*
* $Id: Module.h 2114 2008-02-04 15:25:12Z bornik $
* @file */
/* ======================================================================= */
#ifndef _MODULE_H
#define _MODULE_H
#include "../dllinclude.h"
#include "ConfigNode.h"
#include "StringTable.h"
#include <OpenTracker/core/IRefCounted.h>
#include <OpenTracker/misc/Cptr.h>
/**
* Module is an abstract super class for all OpenTracker modules. A module
* is associated with a configuration element. If the configuration element
* is present, it is initialized with init. Then it is started. During the
* main loop in Context, pushEvent and pullEvent, and stop are periodically
* called. When the Context exits its main loop it calls close on all methods.
*
* This class provides empty implementations for all its methods instead of
* pure virtual functions, so that classes inheriting from it don't have to
* implement all methods in a trivial way.
* @author Gerhard Reitmayr
* @ingroup core
*/
namespace ot {
class OPENTRACKER_API Module
{
//members
protected:
/// check if this module appeared in the configuration section
int initialized;
/** pointer to the context this module is working in. It will be set
* by the initialize method.
*/
Context * context;
OT_DECLARE_IREFCOUNTED;
typedef Cptr<Module> Ptr;
public:
// static Context * contextx;
//methods
public:
/// constructor method
Module(): initialized(0), context(NULL) { OT_INITIALIZE_IREFCOUNTED; };
/// virtual destructor (as it befits any true class hierarchy)
virtual ~Module();
virtual void setContext(Context * c){ context = c; };
Context * getContext() const {return context;};
/**
* closes the module. A place for cleanup code etc.
* This class provides an empty implementation for subclasses not doing
* anything here. */
virtual void close() {};
/**
* initializes the tracker module. This class provides an implementation
* that sets the initialization flag to true. Subclasses should call this
* method, if they override it, before doing anything else. It takes the attributes of the
* element configuring this module and a local tree consisting of the
* children of the element. This tree must be build of Nodes.
* @param attributes StringTable of elements attribute values. Should be
* possibly , but is not for convenience.
* @param localTree pointer to root of configuration nodes tree
*/
virtual void init(StringTable& attributes, ConfigNode * localTree)
{
initialized = 1;
};
/**
* pulls event information out of the tracker tree. It enables the module
* to query any EventQueue or TimeDependend node in the shared memory. It
* is called after pushEvent was executed on each module.
*/
virtual void pullEvent() {};
/**
* pushes event information into the tracker tree. It enables the module
* to push new data into the tree by updating EventGenerator nodes and
* thereby triggering an event.
*/
virtual void pushEvent() {};
/**
* This method is called after initialisation is finished and before the
* main loop is started. It allows the module to finish any setups that
* need to be done before entering the main loop. */
virtual void start() {};
/**
* tests whether the module wants the tracker main loop to stop.
* @return 1 if main loop should stop, 0 otherwise. */
virtual int stop()
{
return 0;
};
/**
* This method should be called by the Node's factory, in order to register the Node with its Module.
* It should be overloaded by descendants that need to keep track of their Nodes.
*/
virtual void addNode(const Node * ){};
/**
* This method deregisters a node from the Module. It is called when removing a node from the graph.
* It should be overloaded by descendants that need to keep track of their Nodes.
*/
virtual void removeNode(Node *){};
/**
* tests whether the module was initialized or not.
* @return 1 of the module was initialized, 0 otherwise. */
int isInitialized()
{
return initialized;
};
friend class Context;
};
/*
#define OT_MODULE(MODNAME) OPENTRACKER_API static void registerModule (Context * context, void * data)
#define OT_MODULE_REGISTER_FUNC(MODNAME) \
OPENTRACKER_API void MODNAME::registerModule( Context * context , void * data)
#define OT_MODULE_REGISTRATION_DEFAULT(MODNAME, REGISTRATIONSTRING) \
MODNAME * mod = new MODNAME();\
context->addFactory (*mod);\
context->addModule (REGISTRATIONSTRING, *mod)
#define OT_REGISTER_MODULE (MODNAME, VOIDPARAMETER) \
Configurator::addModuleInit(#MODNAME, MODNAME::registerModule, VOIDPARAMETER)
*/
class Context;
#define OT_MODULE(MODNAME) OPENTRACKER_API void registerModule##MODNAME (Context * context, void * data)
#define OT_MODULE_REGISTER_FUNC(MODNAME) \
OPENTRACKER_API void registerModule##MODNAME( Context * context , void * data)
#define OT_MODULE_REGISTRATION_DEFAULT(MODNAME, REGISTRATIONSTRING) \
MODNAME * mod = new MODNAME();\
mod->setContext(context);\
context->addFactory (*mod);\
context->addModule (REGISTRATIONSTRING, *mod)
#define OT_REGISTER_MODULE(MODNAME, VOIDPARAMETER) \
Configurator::addModuleInit(#MODNAME, registerModule##MODNAME, VOIDPARAMETER)
} // namespace ot
#endif
/*
* ------------------------------------------------------------
* End of Module.h
* ------------------------------------------------------------
* Automatic Emacs configuration follows.
* Local Variables:
* mode:c++
* c-basic-offset: 4
* eval: (c-set-offset 'substatement-open 0)
* eval: (c-set-offset 'case-label '+)
* eval: (c-set-offset 'statement 'c-lineup-runin-statements)
* eval: (setq indent-tabs-mode nil)
* End:
* ------------------------------------------------------------
*/
| [
"[email protected]"
] | |
2b5593dd811aa94178d90735554ffe174a8c5180 | 1caffa74a68ba8bbd2eb2476492f9b641cca110a | /gframework/bases/InterruptLock.hpp | 4239d1031cf747b5686bba04c42c83caa41b5435 | [] | no_license | gabrieloliveirabrito/GFramework-Arduino | fe4d89fc2f12eeb7292cf0a45756ef3b73e52857 | b23f991715ddcf3a5a3b9c801cd6ec1618de51b5 | refs/heads/master | 2023-07-13T12:34:17.170753 | 2021-08-23T15:21:55 | 2021-08-23T15:21:55 | 391,129,265 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 237 | hpp | #pragma once
class InterruptLock
{
public:
InterruptLock()
{
#if !defined(ARDUINO_ARCH_NRF52)
noInterrupts();
#endif
}
~InterruptLock()
{
#if !defined(ARDUINO_ARCH_NRF52)
interrupts();
#endif
}
}; | [
"[email protected]"
] | |
c72ef323c2886c809cdb51af14a23853c8b2b2f8 | 8fc07a2acf52daf6c68fa3e87be1d7d801467ac3 | /LongestImprovement.cpp | 933ede89191edd0bff65c7d03cf8bd631dcefabf | [] | no_license | nclandrei/ProgChallenges | cba1518e5576ac83b64788e044378f5a67338100 | 0a331bce4bf55a0c0b98ea5eab32597501d3c09b | refs/heads/master | 2020-06-01T15:04:59.107408 | 2014-10-28T16:31:21 | 2014-10-28T16:31:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 313 | cpp | #include <iostream>
#include <vector>
void longest_improvement(const vector<int> &grades) {
int max = 1,k=1;
for(int i=0;i<grades.size()-1;i++){
if(grades[i] <= grades[i+1])
k++;
else
k=1;
if(max<k)
max=k;}
std::cout << max << std::endl;
}
| [
"[email protected]"
] | |
469ffb44cd81209a595a4846abeef86d0958c4b5 | c1dd9f2b51fbaad9e7f3b485a977a2b7cd49545b | /motor-control/lib/rover5/rover5.h | 1f809fcd61d348e23deca6ec4df651420e8e6d2f | [] | no_license | punitsoni/rover | a3131d58cc80a73037de387a39e0849e3916c268 | a827c2359f97453338481be0b694204e310bb055 | refs/heads/master | 2020-04-06T16:17:46.797046 | 2017-05-22T07:22:58 | 2017-05-22T07:22:58 | 14,195,523 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 586 | h | #pragma once
#include "Arduino.h"
#include "motor.h"
const int NUM_WHEELS = 4;
enum wheel_type
{
WHEEL_FR = 0,
WHEEL_FL,
WHEEL_RR,
WHEEL_RL,
};
struct wheel_config
{
uint8_t pwm_pin;
uint8_t dir_pin;
uint8_t enc_pin;
};
struct rover_config
{
wheel_config wheels[NUM_WHEELS];
};
class rover5
{
public:
rover5(const rover_config *config);
void update();
private:
const rover_config *_config;
motor _motors[NUM_WHEELS];
static void enc0_isr();
static void enc1_isr();
static void enc2_isr();
static void enc3_isr();
};
| [
"[email protected]"
] | |
becdde2298a41bce3033166345470bca59dedc15 | 37354fbd8d7c457d58d0b634c673271efaf86872 | /ResourceManager.h | 2dccc07fc86ddd884b21fc05e5e99c9ff08e184f | [] | no_license | Emorgas/Tower-Defence | 9b4d131a002312c97a9f6843602cd679bd9d7e26 | 1d70a1db2ced835f0eab41676e15d79619fc133d | refs/heads/master | 2020-03-07T01:18:47.136418 | 2018-05-12T11:38:14 | 2018-05-12T11:38:14 | 126,077,978 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,073 | h | #pragma once
#include <map>
#include <SDL.h>
#include <SDL_image.h>
#include "TextureResource.h"
namespace Engine
{
class ResourceManager
{
public:
static ResourceManager& GetInstance();
ResourceManager(ResourceManager const&) = delete;
void operator=(ResourceManager const&) = delete;
void Init(SDL_Renderer * renderer);
void CleanupResources();
void LoadTexturesFromFile(const std::string &file, SDL_Renderer *renderer);
void LoadTextureAtlasFromJSON(const std::string &file, const std::string &imagePath, SDL_Renderer *renderer);
TextureResource* GetTextureResource(const std::string &resourceName);
private:
ResourceManager() { }
std::map<std::string, TextureResource*> _textures;
const std::string _defaultImagePath = "res\\images\\defaultImage.png";
const std::string _defaultImageName = "defaultImage";
void AddTextureResource(const std::string &file, const std::string &resourceName, SDL_Renderer *renderer, SDL_Rect *srcRect);
void AddTextureResource(SDL_Texture *tex, const std::string &resourceName, SDL_Rect *srcRect);
};
} | [
"[email protected]"
] | |
3d107b7967d94d77e217b23b1e0a1b994329b840 | 6c945f5861276389d565fc2326ddfd069f61e6a9 | /src/boost/spirit/home/classic/actor/typeof.hpp | 177f5303a24d20f543c3500a2fc523503149b583 | [] | no_license | Springhead/dependency | 3f78387d2a50439ce2edf7790a296026c6012fa3 | 05d4e6f9a3e9c21aae8db4b47573aa34058c4705 | refs/heads/master | 2023-04-23T23:40:13.402639 | 2021-05-08T05:55:22 | 2021-05-08T05:55:22 | 112,149,782 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,750 | hpp | /*=============================================================================
Copyright (c) 2006 Tobias Schwinger
http://spirit.sourceforge.net/
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(BOOST_SPIRIT_ACTOR_TYPEOF_HPP)
#define BOOST_SPIRIT_ACTOR_TYPEOF_HPP
#include <boost/spirit/home/classic/namespace.hpp>
#include <boost/typeof/typeof.hpp>
namespace boost { namespace spirit {
BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
template<typename T, typename ActionT> class ref_actor;
template<typename T, typename ActionT> class ref_value_actor;
template<typename T, typename ValueT, typename ActionT>
class ref_const_ref_actor;
template<typename T, typename ValueT, typename ActionT>
class ref_const_ref_value_actor;
template<typename T, typename Value1T, typename Value2T, typename ActionT>
class ref_const_ref_const_ref_actor;
struct assign_action;
struct clear_action;
struct increment_action;
struct decrement_action;
struct push_back_action;
struct push_front_action;
struct insert_key_action;
struct insert_at_action;
struct assign_key_action;
template<typename T> class swap_actor;
BOOST_SPIRIT_CLASSIC_NAMESPACE_END
}} // namespace BOOST_SPIRIT_CLASSIC_NS
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::ref_actor,2)
#if !defined(BOOST_SPIRIT_CORE_TYPEOF_HPP)
// this part also lives in the core master header and is deprecated there...
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::ref_value_actor,2)
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::ref_const_ref_actor,3)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::assign_action)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::push_back_action)
#endif
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::ref_const_ref_value_actor,3)
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::ref_const_ref_const_ref_actor,4)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::clear_action)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::increment_action)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::decrement_action)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::push_front_action)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::insert_key_action)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::insert_at_action)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::assign_key_action)
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::swap_actor,1)
#endif
| [
"[email protected]"
] | |
f99bae25aaeb571345be6e92d8c50002b87d8495 | 948f4e13af6b3014582909cc6d762606f2a43365 | /testcases/juliet_test_suite/testcases/CWE762_Mismatched_Memory_Management_Routines/s05/CWE762_Mismatched_Memory_Management_Routines__new_array_free_struct_84_bad.cpp | da66b8ff28d3de2c4b6e6ccfcc45915eaa7291b8 | [] | no_license | junxzm1990/ASAN-- | 0056a341b8537142e10373c8417f27d7825ad89b | ca96e46422407a55bed4aa551a6ad28ec1eeef4e | refs/heads/master | 2022-08-02T15:38:56.286555 | 2022-06-16T22:19:54 | 2022-06-16T22:19:54 | 408,238,453 | 74 | 13 | null | 2022-06-16T22:19:55 | 2021-09-19T21:14:59 | null | UTF-8 | C++ | false | false | 1,627 | cpp | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE762_Mismatched_Memory_Management_Routines__new_array_free_struct_84_bad.cpp
Label Definition File: CWE762_Mismatched_Memory_Management_Routines__new_array_free.label.xml
Template File: sources-sinks-84_bad.tmpl.cpp
*/
/*
* @description
* CWE: 762 Mismatched Memory Management Routines
* BadSource: Allocate data using new []
* GoodSource: Allocate data using malloc()
* Sinks:
* GoodSink: Deallocate data using delete []
* BadSink : Deallocate data using free()
* Flow Variant: 84 Data flow: data passed to class constructor and destructor by declaring the class object on the heap and deleting it after use
*
* */
#ifndef OMITBAD
#include "std_testcase.h"
#include "CWE762_Mismatched_Memory_Management_Routines__new_array_free_struct_84.h"
namespace CWE762_Mismatched_Memory_Management_Routines__new_array_free_struct_84
{
CWE762_Mismatched_Memory_Management_Routines__new_array_free_struct_84_bad::CWE762_Mismatched_Memory_Management_Routines__new_array_free_struct_84_bad(twoIntsStruct * dataCopy)
{
data = dataCopy;
/* POTENTIAL FLAW: Allocate memory with a function that requires delete [] to free the memory */
data = new twoIntsStruct[100];
}
CWE762_Mismatched_Memory_Management_Routines__new_array_free_struct_84_bad::~CWE762_Mismatched_Memory_Management_Routines__new_array_free_struct_84_bad()
{
/* POTENTIAL FLAW: Deallocate memory using free() - the source memory allocation function may
* require a call to delete [] to deallocate the memory */
free(data);
}
}
#endif /* OMITBAD */
| [
"[email protected]"
] | |
07664d4e7e26df5b2bcdc9d8e947bebeba1df1d7 | a4f9e159fd976daa151a3cb2635e6bdc70d7b733 | /escomm/escomm_ecc.cpp | 9f673613850b6bbe5f7e46c51c67e555835bf509 | [] | no_license | vgromov/esfwx | 6d77f9303de3b8391a26bbbc41d117de851bf64d | c727752378cad36d32cb344f916d87cd84ea0830 | refs/heads/master | 2021-07-08T03:08:17.442342 | 2020-07-30T10:01:58 | 2020-07-30T10:01:58 | 166,006,433 | 0 | 0 | null | 2020-07-30T10:01:59 | 2019-01-16T08:51:10 | C++ | UTF-8 | C++ | false | false | 310 | cpp | #include "escommpch.h"
#pragma hdrstop
#if ES_COMPILER_VENDOR != ES_COMPILER_VENDOR_BORLAND
# error This file must be used for Embarcadero projects only!
#endif
#pragma package(smart_init)
#include "autolink.cxx"
#pragma argsused
extern "C" int _libmain(unsigned long reason)
{
return 1;
}
| [
"[email protected]"
] | |
bac1f2b22b8602d410e7fb2b16ca219def59a1ac | cefd6c17774b5c94240d57adccef57d9bba4a2e9 | /Crypto/testsuite/src/RSATest.cpp | 556e9fd990791aa5308c13227b023045d19cd99f | [
"BSL-1.0"
] | permissive | adzhou/oragle | 9c054c25b24ff0a65cb9639bafd02aac2bcdce8b | 5442d418b87d0da161429ffa5cb83777e9b38e4d | refs/heads/master | 2022-11-01T05:04:59.368831 | 2014-03-12T15:50:08 | 2014-03-12T15:50:08 | 17,238,063 | 0 | 1 | BSL-1.0 | 2022-10-18T04:23:53 | 2014-02-27T05:39:44 | C++ | UTF-8 | C++ | false | false | 8,995 | cpp | //
// RSATest.cpp
//
// $Id: //poco/1.4/Crypto/testsuite/src/RSATest.cpp#1 $
//
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "RSATest.h"
#include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h"
#include "Poco/Crypto/RSADigestEngine.h"
#include "Poco/Crypto/CipherFactory.h"
#include "Poco/Crypto/Cipher.h"
#include "Poco/Crypto/X509Certificate.h"
#include <sstream>
using namespace Poco::Crypto;
static const std::string anyPem(
"-----BEGIN CERTIFICATE-----\r\n"
"MIICaDCCAdECCQCzfxSsk7yaLjANBgkqhkiG9w0BAQUFADBzMQswCQYDVQQGEwJB\r\n"
"VDESMBAGA1UECBMJQ2FyaW50aGlhMRIwEAYDVQQHEwlTdC4gSmFrb2IxDzANBgNV\r\n"
"BAoTBkFwcEluZjEPMA0GA1UEAxMGQXBwSW5mMRowGAYJKoZIhvcNAQkBFgthcHBA\r\n"
"aW5mLmNvbTAeFw0wNjAzMDExMzA3MzFaFw0wNjAzMzExMzA3MzFaMH4xCzAJBgNV\r\n"
"BAYTAkFUMRIwEAYDVQQIEwlDYXJpbnRoaWExETAPBgNVBAcTCFN0IEpha29iMRww\r\n"
"GgYDVQQKExNBcHBsaWVkIEluZm9ybWF0aWNzMQowCAYDVQQDFAEqMR4wHAYJKoZI\r\n"
"hvcNAQkBFg9pbmZvQGFwcGluZi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ\r\n"
"AoGBAJHGyXDHyCYoWz+65ltNwwZbhwOGnxr9P1WMATuFJh0bPBZxKbZRdbTm9KhZ\r\n"
"OlvsEIsfgiYdsxURYIqXfEgISYLZcZY0pQwGEOmB+0NeC/+ENSfOlNSthx6zSVlc\r\n"
"zhJ7+dJOGwepHAiLr1fRuc5jogYLraE+lKTnqAAFfzwvti77AgMBAAEwDQYJKoZI\r\n"
"hvcNAQEFBQADgYEAY/ZoeY1ukkEJX7259NeoVM0oahlulWV0rlCqyaeosOiDORPT\r\n"
"m6X1w/5MTCf9VyaD1zukoSZ4QqNVjHFXcXidbB7Tgt3yRuZ5PC5LIFCDPv9mgPne\r\n"
"mUA70yfctNfza2z3ZiQ6NDkW3mZX+1tmxYIrJQIrkVeYeqf1Gh2nyZrUMcE=\r\n"
"-----END CERTIFICATE-----\r\n"
"-----BEGIN RSA PRIVATE KEY-----\r\n"
"Proc-Type: 4,ENCRYPTED\r\n"
"DEK-Info: DES-EDE3-CBC,E7AE93C9E49184EA\r\n"
"\r\n"
"A2IqzNcWs+I5vzV+i+woDk56+yr58eU0Onw8eEvXkLjnSc58JU4327IF7yUbKWdW\r\n"
"Q7BYGGOkVFiZ7ANOwviDg5SUhxRDWCcW8dS6/p1vfdQ1C3qj2OwJjkpg0aDBIzJn\r\n"
"FzgguT3MF3ama77vxv0S3kOfmCj62MLqPGpj5pQ0/1hefRFbL8oAX8bXUN7/rmGM\r\n"
"Zc0QyzFZv2iQ04dY/6TNclwKPB4H0On4K+8BMs3PRkWA0clCaQaFO2+iwnk3XZfe\r\n"
"+MsKUEbLCpAQeYspYv1cw38dCdWq1KTP5aJk+oXgwjfX5cAaPTz74NTqTIsCcaTD\r\n"
"3vy7ukJYFlDR9Kyo7z8rMazYrKJslhnuRH0BhK9st9McwL957j5tZmrKyraCcmCx\r\n"
"dMAGcsis1va3ayYZpIpFqA4EhYrTM+6N8ZRfUap20+b5IQwHfTQDejUhL6rBwy7j\r\n"
"Ti5yD83/itoOMyXq2sV/XWfVD5zk/P5iv22O1EAQMhhnPB9K/I/JhuSGQJfn3cNh\r\n"
"ykOUYT0+vDeSeEVa+FVEP1W35G0alTbKbNs5Tb8KxJ3iDJUxokM//SvPXZy9hOVX\r\n"
"Y05imB04J15DaGbAHlNzunhuJi7121WV/JRXZRW9diE6hwpD8rwqi3FMuRUmy7U9\r\n"
"aFA5poKRAYlo9YtZ3YpFyjGKB6MfCQcB2opuSnQ/gbugV41m67uQ4CDwWLaNRkTb\r\n"
"GlsMBNcHnidg15Bsat5HaB7l250ukrI13Uw1MYdDUzaS3gPfw9aC4F2w0p3U+DPH\r\n"
"80/zePxtroR7T4/+rI136Rl+aMXDMOEGCX1TVP8rjuZzuRyUSUKC8Q==\r\n"
"-----END RSA PRIVATE KEY-----\r\n"
"-----BEGIN CERTIFICATE-----\r\n"
"MIICXTCCAcYCCQC1Vk/N8qR4AjANBgkqhkiG9w0BAQUFADBzMQswCQYDVQQGEwJB\r\n"
"VDESMBAGA1UECBMJQ2FyaW50aGlhMRIwEAYDVQQHEwlTdC4gSmFrb2IxDzANBgNV\r\n"
"BAoTBkFwcEluZjEPMA0GA1UEAxMGQXBwSW5mMRowGAYJKoZIhvcNAQkBFgthcHBA\r\n"
"aW5mLmNvbTAeFw0wNjAyMjcxMzI3MThaFw0wNjAzMjkxMzI3MThaMHMxCzAJBgNV\r\n"
"BAYTAkFUMRIwEAYDVQQIEwlDYXJpbnRoaWExEjAQBgNVBAcTCVN0LiBKYWtvYjEP\r\n"
"MA0GA1UEChMGQXBwSW5mMQ8wDQYDVQQDEwZBcHBJbmYxGjAYBgkqhkiG9w0BCQEW\r\n"
"C2FwcEBpbmYuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCsFXiPuicN\r\n"
"Im4oJwF8NuaFN+lgYwcZ6dAO3ILIR3kLA2PxF8HSQLfF8J8a4odZhLhctIMAKTxm\r\n"
"k0w8TW5qhL8QLdGzY9vzvkgdKOkan2t3sMeXJAfrM1AphTsmgntAQazGZjOj5p4W\r\n"
"jDnxQ+VXAylqwjHh49eSBxM3wgoscF4iLQIDAQABMA0GCSqGSIb3DQEBBQUAA4GB\r\n"
"AIpfLdXiKchPvFMhQS8xTtXvrw5dVL3yImUMYs4GQi8RrjGmfGB3yMAR7B/b8v4a\r\n"
"+ztfusgWAWiUKuSGTk4S8YB0fsFlmOv0WDr+PyZ4Lui/a8opbyzGE7rqpnF/s0GO\r\n"
"M7uLCNNwIN7WhmxcWV0KZU1wTppoSWPJda1yTbBzF9XP\r\n"
"-----END CERTIFICATE-----\r\n"
);
RSATest::RSATest(const std::string& name): CppUnit::TestCase(name)
{
}
RSATest::~RSATest()
{
}
void RSATest::testNewKeys()
{
RSAKey key(RSAKey::KL_1024, RSAKey::EXP_SMALL);
std::ostringstream strPub;
std::ostringstream strPriv;
key.save(&strPub, &strPriv, "testpwd");
std::string pubKey = strPub.str();
std::string privKey = strPriv.str();
// now do the round trip
std::istringstream iPub(pubKey);
std::istringstream iPriv(privKey);
RSAKey key2(&iPub, &iPriv, "testpwd");
std::istringstream iPriv2(privKey);
RSAKey key3(0, &iPriv2, "testpwd");
std::ostringstream strPub3;
key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str();
assert (pubFromPrivate == pubKey);
}
void RSATest::testSign()
{
std::string msg("Test this sign message");
RSAKey key(RSAKey::KL_2048, RSAKey::EXP_LARGE);
RSADigestEngine eng(key);
eng.update(msg.c_str(), static_cast<unsigned>(msg.length()));
const Poco::DigestEngine::Digest& sig = eng.signature();
std::string hexDig = Poco::DigestEngine::digestToHex(sig);
// verify
std::ostringstream strPub;
key.save(&strPub);
std::string pubKey = strPub.str();
std::istringstream iPub(pubKey);
RSAKey keyPub(&iPub);
RSADigestEngine eng2(key);
eng2.update(msg.c_str(), static_cast<unsigned>(msg.length()));
assert (eng2.verify(sig));
}
void RSATest::testSignManipulated()
{
std::string msg("Test this sign message");
std::string msgManip("Test that sign message");
RSAKey key(RSAKey::KL_2048, RSAKey::EXP_LARGE);
RSADigestEngine eng(key);
eng.update(msg.c_str(), static_cast<unsigned>(msg.length()));
const Poco::DigestEngine::Digest& sig = eng.signature();
std::string hexDig = Poco::DigestEngine::digestToHex(sig);
// verify
std::ostringstream strPub;
key.save(&strPub);
std::string pubKey = strPub.str();
std::istringstream iPub(pubKey);
RSAKey keyPub(&iPub);
RSADigestEngine eng2(key);
eng2.update(msgManip.c_str(), static_cast<unsigned>(msgManip.length()));
assert (!eng2.verify(sig));
}
void RSATest::testRSACipher()
{
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(RSAKey(RSAKey::KL_1024, RSAKey::EXP_SMALL));
for (std::size_t n = 1; n <= 1200; n++)
{
std::string val(n, 'x');
std::string enc = pCipher->encryptString(val);
std::string dec = pCipher->decryptString(enc);
assert (dec == val);
}
}
void RSATest::testRSACipherLarge()
{
std::vector<std::size_t> sizes;
sizes.push_back (2047);
sizes.push_back (2048);
sizes.push_back (2049);
sizes.push_back (4095);
sizes.push_back (4096);
sizes.push_back (4097);
sizes.push_back (8191);
sizes.push_back (8192);
sizes.push_back (8193);
sizes.push_back (16383);
sizes.push_back (16384);
sizes.push_back (16385);
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(RSAKey(RSAKey::KL_1024, RSAKey::EXP_SMALL));
for (std::vector<std::size_t>::const_iterator it = sizes.begin(); it != sizes.end(); ++it)
{
std::string val(*it, 'x');
std::string enc = pCipher->encryptString(val);
std::string dec = pCipher->decryptString(enc);
assert (dec == val);
}
}
void RSATest::testCertificate()
{
std::istringstream str(anyPem);
X509Certificate cert(str);
RSAKey publicKey(cert);
std::istringstream str2(anyPem);
RSAKey privateKey(0, &str2, "test");
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(publicKey);
Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(privateKey);
std::string val("lets do some encryption");
std::string enc = pCipher->encryptString(val);
std::string dec = pCipher2->decryptString(enc);
assert (dec == val);
}
void RSATest::setUp()
{
}
void RSATest::tearDown()
{
}
CppUnit::Test* RSATest::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("RSATest");
CppUnit_addTest(pSuite, RSATest, testNewKeys);
CppUnit_addTest(pSuite, RSATest, testSign);
CppUnit_addTest(pSuite, RSATest, testSignManipulated);
CppUnit_addTest(pSuite, RSATest, testRSACipher);
CppUnit_addTest(pSuite, RSATest, testRSACipherLarge);
CppUnit_addTest(pSuite, RSATest, testCertificate);
return pSuite;
}
| [
"[email protected]"
] | |
a63ad94630e1a26f8d21b47604cf4634693bad21 | 71de6d5cfbdd4283ae08625375de9452732948bc | /classes/graphics/backends/cairo/fontcairo.cpp | 173a1af377d6a722d395242da55d5eedede4eeb0 | [
"Artistic-1.0",
"Artistic-2.0"
] | permissive | masums/smooth | 1e036e56a5ae71570b87e034594e6b854870778b | 50dd4a9b6eee83efcf8bc4199573dbdef19a67c9 | refs/heads/master | 2023-06-14T09:10:20.991377 | 2021-07-09T19:52:11 | 2021-07-09T19:52:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,964 | cpp | /* The smooth Class Library
* Copyright (C) 1998-2021 Robert Kausch <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of "The Artistic License, Version 2.0".
*
* THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
#include <smooth/graphics/backends/cairo/fontcairo.h>
#include <smooth/graphics/surface.h>
#include <smooth/files/file.h>
#include <smooth/foreach.h>
#include <smooth/init.h>
using namespace X11;
#include <cairo/cairo-xlib.h>
#include <pango/pangocairo.h>
#include <smooth/backends/xlib/backendxlib.h>
S::GUI::FontBackend *CreateFontCairo(const S::String &iFontName, S::Short iFontSize, S::Short iFontWeight, S::Short iFontStyle, const S::GUI::Color &iFontColor)
{
return new S::GUI::FontCairo(iFontName, iFontSize, iFontWeight, iFontStyle, iFontColor);
}
S::Int fontCairoTmp = S::GUI::FontBackend::SetBackend(&CreateFontCairo);
S::Int addFontCairoInitTmp = S::AddInitFunction(&S::GUI::FontCairo::Initialize);
S::Int S::GUI::FontCairo::Initialize()
{
Font::Default = "Helvetica";
String font = Backends::BackendXLib::QueryGSettings("org.gnome.desktop.interface", "font-name");
if (font != NIL)
{
Font::Default = font.SubString(1, font.FindLast(" ") - 1);
Setup::FontSize = font.SubString(font.FindLast(" ") + 1, font.Length() - font.FindLast(" ") - 2).ToFloat() / Font::DefaultSize;
}
return Success();
}
S::GUI::FontCairo::FontCairo(const String &iFontName, Short iFontSize, Short iFontWeight, Short iFontStyle, const Color &iFontColor) : FontBackend(iFontName, iFontSize, iFontWeight, iFontStyle, iFontColor)
{
type = FONT_CAIRO;
}
S::GUI::FontCairo::~FontCairo()
{
}
S::GUI::Size S::GUI::FontCairo::GetTextSize(const String &iText) const
{
if (iText == NIL) return Size();
String text = iText;
Int textLength = text.Length();
/* Set up Cairo font and calculate text size.
*/
Float dpi = Surface().GetSurfaceDPI();
cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 0, 0);
cairo_t *context = cairo_create(surface);
PangoLayout *layout = pango_cairo_create_layout(context);
PangoFontDescription *desc = pango_font_description_from_string(String(fontName)
.Append(" ")
.Append(fontStyle & Font::Italic ? "Italic " : "")
.Append(fontWeight >= Font::Bold ? "Bold " : "")
.Append(String::FromInt(Math::Round(fontSize * dpi / 96.0))));
if (textLength > 0) pango_layout_set_text(layout, text.ConvertTo("UTF-8"), -1);
pango_layout_set_font_description(layout, desc);
pango_font_description_free(desc);
int x = 0;
int y = 0;
pango_layout_get_pixel_size(layout, &x, &y);
g_object_unref(layout);
cairo_destroy(context);
cairo_surface_destroy(surface);
return Size(x, y - 2);
}
| [
"[email protected]"
] | |
7f2212d8ad9eaac19b1fd0d2616f412f3eed2f99 | 1f63dde39fcc5f8be29f2acb947c41f1b6f1683e | /Boss2D/addon/_old/webrtc-qt5.11.2_for_boss/modules/video_capture/video_capture_defines.h | 638395c5579f331834b0a5304501fd5a03628759 | [
"MIT",
"LicenseRef-scancode-google-patent-license-webrtc",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"GPL-1.0-or-later",
"LicenseRef-scancode-takuya-ooura",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown",
"MS-LPL",
"LicenseRef-scancode-google-patent-license-webm"
] | permissive | koobonil/Boss2D | 09ca948823e0df5a5a53b64a10033c4f3665483a | e5eb355b57228a701495f2660f137bd05628c202 | refs/heads/master | 2022-10-20T09:02:51.341143 | 2019-07-18T02:13:44 | 2019-07-18T02:13:44 | 105,999,368 | 7 | 2 | MIT | 2022-10-04T23:31:12 | 2017-10-06T11:57:07 | C++ | UTF-8 | C++ | false | false | 2,556 | h | /*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEFINES_H_
#define MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEFINES_H_
#include BOSS_WEBRTC_U_api__video__video_frame_h //original-code:"api/video/video_frame.h"
#include BOSS_WEBRTC_U_modules__include__module_common_types_h //original-code:"modules/include/module_common_types.h"
#include BOSS_WEBRTC_U_typedefs_h //original-code:"typedefs.h" // NOLINT(build/include)
namespace webrtc
{
// Defines
#ifndef NULL
#define NULL 0
#endif
enum {kVideoCaptureUniqueNameLength =1024}; //Max unique capture device name lenght
enum {kVideoCaptureDeviceNameLength =256}; //Max capture device name lenght
enum {kVideoCaptureProductIdLength =128}; //Max product id length
struct VideoCaptureCapability
{
int32_t width;
int32_t height;
int32_t maxFPS;
VideoType videoType;
bool interlaced;
VideoCaptureCapability()
{
width = 0;
height = 0;
maxFPS = 0;
videoType = VideoType::kUnknown;
interlaced = false;
}
;
bool operator!=(const VideoCaptureCapability &other) const
{
if (width != other.width)
return true;
if (height != other.height)
return true;
if (maxFPS != other.maxFPS)
return true;
if (videoType != other.videoType)
return true;
if (interlaced != other.interlaced)
return true;
return false;
}
bool operator==(const VideoCaptureCapability &other) const
{
return !operator!=(other);
}
};
/* External Capture interface. Returned by Create
and implemented by the capture module.
*/
class VideoCaptureExternal
{
public:
// |capture_time| must be specified in the NTP time format in milliseconds.
virtual int32_t IncomingFrame(uint8_t* videoFrame,
size_t videoFrameLength,
const VideoCaptureCapability& frameInfo,
int64_t captureTime = 0) = 0;
protected:
~VideoCaptureExternal() {}
};
} // namespace webrtc
#endif // MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEFINES_H_
| [
"[email protected]"
] | |
a385ba34fad18e4945c9139034838ffa8940b883 | c17cb8f229a6762cb88848a70e9b6505adbcbcdd | /c++/src/vs-2019/HelloWinUICppWinRT/HelloWinUICppWinRT/Generated Files/winrt/impl/Windows.System.Diagnostics.DevicePortal.1.h | f2d2d7a524877d8fa74555092c5ac5648d94f8cd | [] | no_license | awrznc/scribble | b1a49df8c66ffb0c63a01d0266a50277e3f2000a | cee07c2d6dc7960023673e3c3a31f1738da7a8e5 | refs/heads/master | 2023-08-18T22:31:01.852432 | 2023-06-12T12:16:42 | 2023-06-12T12:16:42 | 202,322,395 | 4 | 0 | null | 2023-09-13T13:12:44 | 2019-08-14T09:49:39 | C++ | UTF-8 | C++ | false | false | 3,008 | h | // WARNING: Please don't edit this file. It was generated by C++/WinRT v2.0.200703.9
#ifndef WINRT_Windows_System_Diagnostics_DevicePortal_1_H
#define WINRT_Windows_System_Diagnostics_DevicePortal_1_H
#include "winrt/impl/Windows.System.Diagnostics.DevicePortal.0.h"
WINRT_EXPORT namespace winrt::Windows::System::Diagnostics::DevicePortal
{
struct __declspec(empty_bases) IDevicePortalConnection :
Windows::Foundation::IInspectable,
impl::consume_t<IDevicePortalConnection>
{
IDevicePortalConnection(std::nullptr_t = nullptr) noexcept {}
IDevicePortalConnection(void* ptr, take_ownership_from_abi_t) noexcept : Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IDevicePortalConnectionClosedEventArgs :
Windows::Foundation::IInspectable,
impl::consume_t<IDevicePortalConnectionClosedEventArgs>
{
IDevicePortalConnectionClosedEventArgs(std::nullptr_t = nullptr) noexcept {}
IDevicePortalConnectionClosedEventArgs(void* ptr, take_ownership_from_abi_t) noexcept : Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IDevicePortalConnectionRequestReceivedEventArgs :
Windows::Foundation::IInspectable,
impl::consume_t<IDevicePortalConnectionRequestReceivedEventArgs>
{
IDevicePortalConnectionRequestReceivedEventArgs(std::nullptr_t = nullptr) noexcept {}
IDevicePortalConnectionRequestReceivedEventArgs(void* ptr, take_ownership_from_abi_t) noexcept : Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IDevicePortalConnectionStatics :
Windows::Foundation::IInspectable,
impl::consume_t<IDevicePortalConnectionStatics>
{
IDevicePortalConnectionStatics(std::nullptr_t = nullptr) noexcept {}
IDevicePortalConnectionStatics(void* ptr, take_ownership_from_abi_t) noexcept : Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IDevicePortalWebSocketConnection :
Windows::Foundation::IInspectable,
impl::consume_t<IDevicePortalWebSocketConnection>
{
IDevicePortalWebSocketConnection(std::nullptr_t = nullptr) noexcept {}
IDevicePortalWebSocketConnection(void* ptr, take_ownership_from_abi_t) noexcept : Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
struct __declspec(empty_bases) IDevicePortalWebSocketConnectionRequestReceivedEventArgs :
Windows::Foundation::IInspectable,
impl::consume_t<IDevicePortalWebSocketConnectionRequestReceivedEventArgs>
{
IDevicePortalWebSocketConnectionRequestReceivedEventArgs(std::nullptr_t = nullptr) noexcept {}
IDevicePortalWebSocketConnectionRequestReceivedEventArgs(void* ptr, take_ownership_from_abi_t) noexcept : Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {}
};
}
#endif
| [
"[email protected]"
] | |
caa3e7a4446413ad30083fd322fca0aedfa884f1 | c0376f9eb4eb1adf2db5aff3d25abc3576d0241b | /src/plugins/secman/interfaces/secman/istorageplugin.h | ba042974792f60f1d5279ebd6e09e7eb3edfe057 | [
"BSL-1.0"
] | permissive | ROOAARR/leechcraft | 0179e6f1e7c0b7afbfcce60cb810d61bd558b163 | 14bc859ca750598b77abdc8b2d5b9647c281d9b3 | refs/heads/master | 2021-01-17T22:08:16.273024 | 2013-08-05T12:28:45 | 2013-08-05T12:28:45 | 2,217,574 | 1 | 0 | null | 2013-01-19T15:32:47 | 2011-08-16T18:55:44 | C++ | UTF-8 | C++ | false | false | 2,833 | h | /**********************************************************************
* LeechCraft - modular cross-platform feature rich internet client.
* Copyright (C) 2006-2013 Georg Rudoy
*
* Boost Software License - Version 1.0 - August 17th, 2003
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated by
* a source language processor.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
**********************************************************************/
#ifndef PLUGINS_SECMAN_INTERFACES_ISTORAGEPLUGIN_H
#define PLUGINS_SECMAN_INTERFACES_ISTORAGEPLUGIN_H
#include <QtPlugin>
#include <QFlags>
namespace LeechCraft
{
namespace Plugins
{
namespace SecMan
{
class IStoragePlugin
{
public:
virtual ~IStoragePlugin () {}
enum StorageType
{
STInsecure,
STSecure
};
Q_DECLARE_FLAGS (StorageTypes, StorageType)
virtual StorageTypes GetStorageTypes () const = 0;
virtual QList<QByteArray> ListKeys (StorageType st = STInsecure) = 0;
virtual void Save (const QByteArray& key,
const QVariantList& value,
StorageType st = STInsecure,
bool overwrite = false) = 0;
virtual QVariantList Load (const QByteArray& key, StorageType st = STInsecure) = 0;
virtual void Save (const QList<QPair<QByteArray, QVariantList>>& keyValues,
StorageType st = STInsecure,
bool overwrite = false) = 0;
virtual QList<QVariantList> Load (const QList<QByteArray>& keys, StorageType st = STInsecure) = 0;
};
}
}
}
Q_DECLARE_INTERFACE (LeechCraft::Plugins::SecMan::IStoragePlugin,
"org.Deviant.LeechCraft.Plugins.SecMan.IStoragePlugin/1.0");
#endif
| [
"[email protected]"
] | |
ba1f1577c3af992acb18bef94e2cb5610c96d6de | a328c17ff42ba230a43186a50cbc292fd66ecd70 | /cdbjournalitem.h | f5911e10314c207f304aaecee9231526b73ad461 | [] | no_license | vlarry/emulator | cd072a6c7e5ee147fd20f9cd82d0c4a153ee0674 | bd84199ddfd3979d784d5e15eb968a45746daffd | refs/heads/master | 2020-03-29T07:45:48.455669 | 2019-03-01T09:29:52 | 2019-03-01T09:29:52 | 94,663,863 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 441 | h | #ifndef CDBJOURNALITEM_H
#define CDBJOURNALITEM_H
//-------------------------
#include <QTableWidgetItem>
#include <QDateTime>
//-------------------------------------------
class CDbJournalItem: public QTableWidgetItem
{
public:
explicit CDbJournalItem(const QString &text, int type = Type);
bool operator< (const QTableWidgetItem& other) const;
};
#endif // CDBJOURNALITEM_H
| [
"[email protected]"
] | |
0ee54cf88cd1e759ebf71dddffc918f2a0a80db7 | 944438a953b5a125aae48eeb578b80cc37e3577e | /ash/webui/eche_app_ui/system_info.cc | 6cc0af719c80403100a200083d8b2baa04f59778 | [
"BSD-3-Clause"
] | permissive | guhuaijian/chromium | 0dc346626cc2084bb9a786bb59911441a83d10e0 | 2b617d4be11c76220496be187d321325babb7cda | refs/heads/master | 2023-08-16T14:49:25.462662 | 2021-10-29T01:20:06 | 2021-10-29T01:20:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,113 | cc | // Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/webui/eche_app_ui/system_info.h"
#include "base/memory/ptr_util.h"
namespace chromeos {
namespace eche_app {
SystemInfo::Builder::Builder() = default;
SystemInfo::Builder::~Builder() = default;
std::unique_ptr<SystemInfo> SystemInfo::Builder::Build() {
return base::WrapUnique(new SystemInfo(device_name_, board_name_));
}
SystemInfo::Builder& SystemInfo::Builder::SetDeviceName(
const std::string& device_name) {
device_name_ = device_name;
return *this;
}
SystemInfo::Builder& SystemInfo::Builder::SetBoardName(
const std::string& board_name) {
board_name_ = board_name;
return *this;
}
SystemInfo::SystemInfo(const SystemInfo& other) = default;
SystemInfo::~SystemInfo() = default;
SystemInfo::SystemInfo(const std::string& device_name,
const std::string& board_name)
: device_name_(device_name), board_name_(board_name) {}
} // namespace eche_app
} // namespace chromeos
| [
"[email protected]"
] | |
dee7af35f3071ea6b6f469607b7d46e2d129d508 | 23be3225d101b3ecc03d8f324c77b396c9f405f1 | /src/ompl/geometric/planners/quotientspace/datastructures/components/SE2_R2.h | eebb50b2f5a42b6a00d6e48dcf565db4c8d3a235 | [
"BSD-3-Clause"
] | permissive | alexha98/ompl | 33dcccd8fc0c77a4cf03e9c9f0b3bac8eb5a2514 | e1a1ce690ea5d52eb12a9fd06c8fd8a04dcfeb9e | refs/heads/master | 2022-11-25T02:06:30.911713 | 2020-02-17T13:01:19 | 2020-02-17T13:01:19 | 275,031,082 | 0 | 0 | null | 2020-06-25T22:57:38 | 2020-06-25T22:57:37 | null | UTF-8 | C++ | false | false | 1,238 | h | #ifndef OMPL_GEOMETRIC_PLANNERS_BUNDLESPACE_BUNDLE_COMPONENT_SE2_R2__
#define OMPL_GEOMETRIC_PLANNERS_BUNDLESPACE_BUNDLE_COMPONENT_SE2_R2__
#include <ompl/geometric/planners/quotientspace/datastructures/BundleSpaceComponent.h>
namespace ompl
{
namespace geometric
{
class BundleSpaceComponent_SE2_R2: public BundleSpaceComponent
{
using BaseT = BundleSpaceComponent;
public:
BundleSpaceComponent_SE2_R2(
base::StateSpacePtr BundleSpace,
base::StateSpacePtr BaseSpace);
~BundleSpaceComponent_SE2_R2() override = default;
virtual void projectFiber(
const ompl::base::State *xBundle,
ompl::base::State *xFiber) const override;
virtual void projectBase(
const ompl::base::State *xBundle,
ompl::base::State *xBase) const override;
virtual void mergeStates(
const ompl::base::State *xBase,
const ompl::base::State *xFiber,
ompl::base::State *xBundle) const override;
protected:
ompl::base::StateSpacePtr computeFiberSpace() override;
};
}
}
#endif
| [
"[email protected]"
] | |
7596ced25ab1cbb174444321f32ee0a11a5e8adf | 30d637c4c1333d7f52a9f3b74205dacb52b025bb | /MakeUnitOwnedByTeam/Исходный код.cpp | 98f60aa6d14580a3087d17f603e013b6c3d84536 | [
"Unlicense"
] | permissive | asdlei99/MakeUnitOwnedByTeam | ff6ecceba6a39208035dab7def8114cb81bc6571 | 741b19182f4ef03f5236f826def9e5471a084a2a | refs/heads/main | 2023-08-16T19:20:53.015647 | 2021-09-19T11:40:44 | 2021-09-19T11:40:44 | null | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 1,300 | cpp | /*
1. Если юнит союзник и юнит из списка то он общий.
*/
#pragma region Headers
#define _WIN32_WINNT 0x0501
#define WINVER 0x0501
#define NTDDI_VERSION 0x05010000
//#define BOTDEBUG
#define WIN32_LEAN_AND_MEAN
#include <stdexcept>
#include <Windows.h>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <time.h>
#include <thread>
#pragma endregion
using namespace std;
int GameDll = 0;
typedef UINT( __cdecl * CreateUnit_p )( UINT id, int unitid, float *x, float *y, float *face );
CreateUnit_p CreateUnit_org;
CreateUnit_p CreateUnit_ptr;
UINT __cdecl CreateUnit_my( UINT id, int unitid, float *x, float *y, float *face )
{
UINT retval = CreateUnit_org( id, unitid, x, y, face );
return retval;
}
typedef int( __fastcall * GetUnitRealByHandle_p )( UINT unithandle, int unused );
GetUnitRealByHandle_p GetUnitRealByHandle_org;
GetUnitRealByHandle_p GetUnitRealByHandle_ptr;
int __fastcall GetUnitRealByHandle_my ( UINT unithandle, int unused )
{
int retval = GetUnitRealByHandle_org( unithandle, unused );
return retval;
}
BOOL WINAPI DllMain( HINSTANCE hDLL, UINT reason, LPVOID reserved )
{
if ( reason == DLL_PROCESS_ATTACH )
{
}
else if ( reason == DLL_PROCESS_DETACH )
{
}
return TRUE;
}
| [
"[email protected]"
] | |
ac469ef9c66617050c4af9b58bcd0173189363a3 | 9a12150c1672fa7b304a728d86e5434aafeb5120 | /580B.cpp | 1334edd00a61cddee9909d276bc6229bb4111929 | [] | no_license | apurvparekh30/codeforces | 93b53f99d5d9e16f3d833f89418c8f7edfb63549 | c18384a62ddfc514e4d087007a9717276d02a350 | refs/heads/master | 2021-07-24T20:04:29.526385 | 2020-08-01T05:10:25 | 2020-08-01T05:10:25 | 204,581,591 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 720 | cpp | #include <stdio.h>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
vector<pair<long long,long long>> friends;
int n,d;
int main() {
cin >> n >> d;
for(int i=0;i<n;i++) {
pair<long long,long long> p;
cin >> p.first >> p.second;
friends.push_back(p);
}
sort(friends.begin(),friends.end());
long long curr = friends[0].second;
long long best = friends[0].second;
long long low = 0;
for(int i=1;i<n;) {
if(friends[i].first - friends[low].first >= d) {
curr = curr - friends[low].second;
low++;
}
else {
curr = curr + friends[i].second;
i++;
}
if(best < curr) {
best = curr;
}
}
cout << best << endl;
}
| [
"[email protected]"
] | |
b937a0cb61a04730349d0eed12570dbd97271550 | 0484f5f227abbf5dc3a7f6310f0d2cac26633e00 | /UVa/156 - Ananagrams.cpp | 853f88c989748b43e92f89c5647f21f43a84efe8 | [] | no_license | LiboMa/Competitive-Programming | 826d32bcc116acdb5993e842a5a17786ce27c528 | 016e9ad599276dc1549ef4fa389658b2126098eb | refs/heads/master | 2020-12-11T03:43:30.861873 | 2015-10-25T17:12:08 | 2015-10-25T17:12:08 | 45,236,810 | 0 | 1 | null | 2015-10-30T07:55:16 | 2015-10-30T07:55:16 | null | UTF-8 | C++ | false | false | 1,575 | cpp | /*
156 - Ananagrams
UVa Online Judge
Esteban Arango Medina
Solution.
Ad Hoc, I used a map (string, pair<string,int>) to count how many times appears one letter and then just print
those that appears once.
Note.
Didn't know how to convert a string to upper or lower case.
http://notfaq.wordpress.com/2007/08/04/cc-convert-string-to-upperlower-case/
*/
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;
int main(){
map <string, pair<string,int> > words;
vector<string> result;
string word,wordSorted;cin>>word;
while(word != "#"){
wordSorted=word;
transform(wordSorted.begin(), wordSorted.end(),wordSorted.begin(),::toupper);
sort(wordSorted.begin(),wordSorted.end());
words[wordSorted].first=word;
words[wordSorted].second++;
cin>>word;
}
map<string, pair<string,int> >::const_iterator itr;
for(itr = words.begin(); itr != words.end(); ++itr){
if((*itr).second.second == 1)
result.push_back((*itr).second.first);
}
sort(result.begin(),result.end());
int total = result.size();
for (int i = 0; i < total; ++i)
{
cout<<result[i]<<endl;
}
return 0;
} | [
"[email protected]"
] | |
cde1680785afd75f41a8c4aeffe4f4dba60b3384 | 4357b36c493e28d6592c5a79d8f62f4795abfba6 | /main.cpp | 6f64fac5afc25e3165f3df1b562ea030851f71ab | [
"BSD-3-Clause"
] | permissive | fmorgner/dramatic | 210c3a3b2464cf8cf1d31995ba8953b0bb9a6596 | 1c355307c41d17936c589cc43198abb561dfc3c7 | refs/heads/master | 2022-12-04T07:57:33.677834 | 2020-08-26T22:46:05 | 2020-08-26T22:48:25 | 290,620,587 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 774 | cpp | #include "dramatic/dramatic.hpp"
#include <iostream>
auto main() -> int
{
// clang-format off
auto constexpr first_scene = drama::Scene{"1 + 1 equals 2"}
.Given(1)
.AsWellAs(1)
.Invoking(std::plus<>{})
.Yields(4);
auto result = first_scene.Perform();
std::cout << '\'' << first_scene.Name() << "' "
<< "returned '" << std::boolalpha << (result.first == drama::PerformanceResult::Success)
<< "' @ " << result.second.file_name() << ':' << result.second.line() << '\n';
// clang-format on
static_assert(drama::Scene{}.Given(2).AsWellAs(1).Invoking(std::plus<>{}).Yields(3));
} | [
"[email protected]"
] | |
d5992559077e6d9d59ce287ce2830374bb6e0214 | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5662291475300352_0/C++/uran198/C.cpp | 414a09f66ab9792aa1c5db54b98943633966a6b1 | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 818 | cpp | #include <iostream>
#include <algorithm>
#include <deque>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
using namespace std;
const double EPS = 1e-8;
int main() {
int t;cin>>t;
for(int K=1; K <= t; ++K) {
int n;
cin>>n;
vector<pair<int,int> > v;
for(int i=0;i<n; ++i) {
int dd;cin>>dd;
int h;cin>>h;
int mm;cin>>mm;
while(h--){
v.push_back(make_pair(dd,-(mm++)));
}
}
int res = 0;
sort(v.begin(), v.end());
if (v.size() > 1) {
double v1 = -double(360) / v[0].second,
v2 = -double(360) / v[1].second;
int d1 = v[0].first, d2 = v[1].first;
if ((360+0.001-d1)/v1 > (360+360-d2)/v2 ||
(360+0.001-d2)/v2 > (360+360-d1)/v1) res = 1;
}
printf("Case #%d: %d\n", K, res);
}
return 0;
}
| [
"[email protected]"
] | |
cca657bef4e610e5f7f20135aa2a1c9b8ef70335 | 38bdbce6fae462163bab39ef916335042b2d128c | /src/qt/askpassphrasedialog.h | e15275e66e92c606a6262b5e46d05ed0eb0619fc | [
"MIT"
] | permissive | sharkcoin32/Sharkcoin | b976203cf04d19805af78f7dd0735593dde3970d | 0ef5bba96df4abe51436856e2d0b12be86cabf6b | refs/heads/master | 2022-12-24T09:22:26.186773 | 2020-10-01T14:08:22 | 2020-10-01T14:08:22 | 261,544,989 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,272 | h | // Copyright (c) 2011-2013 The Bitcoin developers
// Copyright (c) 2017-2018 The PIVX developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_QT_ASKPASSPHRASEDIALOG_H
#define BITCOIN_QT_ASKPASSPHRASEDIALOG_H
#include <QDialog>
class WalletModel;
namespace Ui
{
class AskPassphraseDialog;
}
/** Multifunctional dialog to ask for passphrases. Used for encryption, unlocking, and changing the passphrase.
*/
class AskPassphraseDialog : public QDialog
{
Q_OBJECT
public:
enum class Mode {
Encrypt, /**< Ask passphrase twice and encrypt */
UnlockAnonymize, /**< Ask passphrase and unlock only for anonymization */
Unlock, /**< Ask passphrase and unlock */
ChangePass, /**< Ask old passphrase + new passphrase twice */
Decrypt /**< Ask passphrase and decrypt wallet */
};
// Context from where / for what the passphrase dialog was called to set the status of the checkbox
// Partly redundant to Mode above, but offers more flexibility for future enhancements
enum class Context {
Unlock_Menu, /** Unlock wallet from menu */
Unlock_Full, /** Wallet needs to be fully unlocked */
Encrypt, /** Encrypt unencrypted wallet */
ToggleLock, /** Toggle wallet lock state */
ChangePass, /** Change passphrase */
Send_SKN, /** Send SKN */
Send_zSKN, /** Send zSKN */
Mint_zSKN, /** Mint zSKN */
BIP_38, /** BIP38 menu */
Multi_Sig, /** Multi-Signature dialog */
Sign_Message, /** Sign/verify message dialog */
UI_Vote, /** Governance Tab UI Voting */
};
explicit AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel* model, Context context);
~AskPassphraseDialog();
void accept();
private:
Ui::AskPassphraseDialog* ui;
Mode mode;
WalletModel* model;
Context context;
bool fCapsLock;
private slots:
void textChanged();
protected:
bool event(QEvent* event);
bool eventFilter(QObject* object, QEvent* event);
};
#endif // BITCOIN_QT_ASKPASSPHRASEDIALOG_H
| [
"Sharkcoin dev"
] | Sharkcoin dev |
d717c3d52e125dd9d9806eab37590b0649be36fe | 77309531a6de95d615abd4a9df87e8f9e04a78a2 | /iptool/iptools/image/image.h | c64d02b618f55b805d3b3293840f459bb3c8f442 | [] | no_license | jeremyhernandezz/Image-Processing- | eaf35ced866ec70d7251c6531f7611f7f0758187 | af35606dd810aefa14f4763f5b3063e93fe56c7e | refs/heads/master | 2023-01-12T07:06:15.412999 | 2020-11-20T16:51:08 | 2020-11-20T16:51:08 | 314,599,325 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,583 | h | #ifndef IMAGE_H
#define IMAGE_H
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
enum channel{RED, GREEN, BLUE, GREY=RED, GRAY=GREY};
//Createad a struct type called roi to store all the roi information
struct roi {
//Stores the start and end i and j values of the ROI
int i, j;
int iEnd, jEnd;
/////////////////////////////////////////
//int intensities[256] = { 0 };
};
/////////////////////////////////////////////////
struct imageData
{
vector<int> redChannel, greenChannel, blueChannel;
int numRows, numColumns;
};
class image
{
private:
imageData data;
int getint(FILE *fp);
public:
image();
image(image &img);
image(int rows, int columns);
~image();
void deleteImage();
void copyImage(image &img);
void resize (int numberOfRows, int numberOfColumns);
void setNumberOfRows(int rows);
void setNumberOfColumns(int columns);
void setPixel(const int row, const int col, const int value);
void setPixel(const int row, const int col, const int rgb, const int value);
int getPixel(const int row, const int col);
int getPixel(const int row, const int col, const int rgb);
int getNumberOfRows();
int getNumberOfColumns();
vector<int>* getChannel(int rgb);
bool setChannel(int rgb, vector<int> &channel);
bool save (char* file);
bool save (const char* file);
bool read (char* file);
bool isInbounds (const int row, const int col);
};
#endif
| [
"[email protected]"
] | |
209703034066288d2925defaea92eb881c7aa0d0 | 7ed3e6e692d1fde482ef457ef111b46abc30c351 | /Monte-Carlo Ray Tracer/BoundingBox.h | 717bb62e8a9a6de65fb0aa5e33526d05f1aadea4 | [] | no_license | seu-xh/MonteCarloPathTracing | adf837eb66b0eec85ec0bc29ac6b509e52e51871 | 00efb91cdcd8de9a70c7ef8c88fb8d585ccc2170 | refs/heads/master | 2020-04-26T19:43:03.839998 | 2019-03-12T02:49:38 | 2019-03-12T02:49:38 | 173,784,388 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 479 | h | #pragma
#include<vector>
#include"glm\glm.hpp"
#include"Vertex.h"
#include"Ray.h"
struct BBOX
{
glm::vec3 min, max;
void ComputeBBOX(const std::vector<Vertex>&v);
//void ComputeBBOX(const std::vector<Triangle*>&tri);
void IncludeVertex(Vertex v);
int GetLongestAxis();
//void ComputeSpanAlongDir(glm::vec3 Dir, const std::vector<Vertex>&vertices, double& min, double& max);
BBOX(glm::vec3 a, glm::vec3 b) :min(a), max(b) {};
BBOX() {};
bool IsIntersect(Ray ray);
};
| [
"[email protected]"
] | |
b7b18fd35071018de05ddff066c1a830525cd206 | 4c25432a6d82aaebd82fd48e927317b15a6bf6ab | /data/dataset_2017/dataset_2017_8/sammyMaX/3264486_5736519012712448_sammyMaX.cpp | be0beedb84d3be5ed8252dfd0c475acbf0290b7d | [] | no_license | wzj1988tv/code-imitator | dca9fb7c2e7559007e5dbadbbc0d0f2deeb52933 | 07a461d43e5c440931b6519c8a3f62e771da2fc2 | refs/heads/master | 2020-12-09T05:33:21.473300 | 2020-01-09T15:29:24 | 2020-01-09T15:29:24 | 231,937,335 | 1 | 0 | null | 2020-01-05T15:28:38 | 2020-01-05T15:28:37 | null | UTF-8 | C++ | false | false | 717 | cpp | #include <bits/stdc++.h>
using namespace std;
ifstream fin("A-small-attempt1.in");
ofstream fout("A-small1.out");
void solve() {
string s;
int fsize;
fin >> s >> fsize;
int flips[1005] = {}, res = 0, i = 0;
for (char c : s) {
if (i >= fsize) res -= flips[i - fsize];
int now = (c == '+');
if (i <= s.size() - fsize && (now+res) % 2 == 0) flips[i] = 1;
res += flips[i];
i++;
if ((now+res) % 2 == 0) {
fout << "IMPOSSIBLE\n";
return;
}
}
res = 0;
for (int a : flips) res += a;
fout << res << '\n';
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
fin >> t;
for (int i = 0; i < t; i++) fout << "Case #" << i+1 << ": ", solve();
}
| [
"[email protected]"
] | |
4c1ec9f3799540f885e8cb4ff4a10bf10f453473 | 419899bcaab97207f31909491699b4c6cef8f18c | /main.cpp | 9d0daec6ee68c97c9fd7355794674e5249dc8132 | [
"MIT"
] | permissive | DiscreteTom/left-recursion-killer | de1fcaee335f1baafd89483842a9adffb3da918d | 0fd5f19a42ca09592ac0663b51329ab0c88b8825 | refs/heads/master | 2020-04-03T10:32:27.155043 | 2018-11-04T13:45:07 | 2018-11-04T13:45:07 | 155,195,899 | 6 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,306 | cpp | #include <iostream>
#include <string>
#include "gramma.h"
using namespace std;
void showDeveloper();
void showHelp();
int main(int argc, char **argv)
{
showDeveloper();
if (argc == 1)
{
showHelp();
//no file input
GrammaTable gt;
string str;
getline(cin, str);
while (str.length())
{
gt.insert(str);
getline(cin, str);
}
try
{
gt.start();
}
catch (string err)
{
cout << err;
}
}
else
{
for (int i = 1; i < argc; ++i)
{
cout << "============================ " << argv[i] << "==============================\n";
try
{
GrammaTable gt(argv[i]);
}
catch (string str)
{
cout << str;
}
}
}
system("pause");
}
void showDeveloper()
{
cout << "*************************************************************\n"
<< " Left-Recursion-Killer\n"
<< " Written By DiscreteTom\n"
<< " See source code and report BUG at\n"
<< " https://github.com/DiscreteTom/left-recursion-killer\n"
<< "*************************************************************\n\n";
}
void showHelp()
{
cout << "Drag file(s) on this exe to run.\n"
<< "Or run this exe then input.\n"
<< "Format: A -> xxx | xxx\n"
<< "Input '~' for epsilon\n"
<< "Input an empty line for end\n\n";
} | [
"[email protected]"
] | |
7d6ef07c075100191fea5da4b4307f9c946fc160 | bc90e70ee2139b034c65a5755395ff55faac87d0 | /sprout/stateful/counter.hpp | 8af669b49990472893ca35c49dfdcd0320857817 | [
"BSL-1.0"
] | permissive | Manu343726/Sprout | 0a8e2d090dbede6f469f6b875d217716d0200bf7 | feac3f52c785deb0e5e6cd70c8b4960095b064be | refs/heads/master | 2021-01-21T07:20:16.742204 | 2015-05-28T04:11:39 | 2015-05-28T04:11:39 | 37,670,169 | 0 | 1 | null | 2015-06-18T16:09:41 | 2015-06-18T16:09:41 | null | UTF-8 | C++ | false | false | 2,774 | hpp | /*=============================================================================
Copyright (c) 2011-2015 Bolero MURAKAMI
https://github.com/bolero-MURAKAMI/Sprout
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef SPROUT_STATEFUL_COUNTER_HPP
#define SPROUT_STATEFUL_COUNTER_HPP
#include <sprout/config.hpp>
#include <sprout/type_traits/integral_constant.hpp>
namespace sprout {
#ifndef SPROUT_CONFIG_DISABLE_CONSTEXPR
namespace counter_detail {
#if defined(__GNUC__) && !defined(__clang__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wnon-template-friend"
#endif
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wundefined-inline"
#endif
template<int N>
struct tag {
friend SPROUT_CONSTEXPR int adl_counter(sprout::counter_detail::tag<N>);
};
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
#if defined(__GNUC__) && !defined(__clang__)
# pragma GCC diagnostic pop
#endif
template<int N>
struct state
: public sprout::integral_constant<int, N>
{
friend SPROUT_CONSTEXPR int adl_counter(sprout::counter_detail::tag<N>) {
return N;
}
};
template<int N, int = adl_counter(sprout::counter_detail::tag<N>())>
inline SPROUT_CONSTEXPR bool check(int, sprout::counter_detail::tag<N>) {
return true;
}
template<int N>
inline SPROUT_CONSTEXPR bool check(long, sprout::counter_detail::tag<N>) {
return false;
}
template<int N>
inline SPROUT_CONSTEXPR bool check(bool R = sprout::counter_detail::check(0, sprout::counter_detail::tag<N>())) {
return R;
}
template<int N>
inline SPROUT_CONSTEXPR int counter(sprout::false_type, sprout::counter_detail::tag<N>) {
return 0;
}
template<int N>
inline SPROUT_CONSTEXPR int counter(
sprout::true_type, sprout::counter_detail::tag<N>,
int R = !sprout::counter_detail::check<N>() ? N
: counter(sprout::bool_constant<sprout::counter_detail::check<N>()>(), sprout::counter_detail::tag<N + 1>())
)
{
return R;
}
template<int N = 0>
inline SPROUT_CONSTEXPR int counter(int R = sprout::counter_detail::counter(sprout::true_type(), sprout::counter_detail::tag<N>())) {
return R;
}
} // namespace counter_detail
//
// counter
//
template<
int N = 1,
int R = sprout::counter_detail::state<
sprout::counter_detail::counter() + N - 1
>::value
>
inline SPROUT_CONSTEXPR int counter() {
return R;
}
#endif
} // namespace sprout
#endif // #ifndef SPROUT_STATEFUL_COUNTER_HPP
| [
"[email protected]"
] | |
6ba0df6d015cd0ef5baebe87362cf22473f7f7a8 | d9714160fd222bc49ef52a56edb7aeb82a591549 | /bench/lib/exp/scalar/bd2bd2bd2bd2ed2.cpp | f3ebd97b88657f7972edabfe4f620f40cd831656 | [
"MIT"
] | permissive | timocafe/poly | c2fb195a196f68c406fa10130c71e29d90bc125c | 3931892bcd04f9ebfc0fde202db34d50973bc73b | refs/heads/master | 2021-01-13T00:34:32.027241 | 2020-10-02T18:42:03 | 2020-10-02T18:42:03 | 41,051,374 | 0 | 0 | null | 2020-10-02T15:27:08 | 2015-08-19T18:08:26 | C++ | UTF-8 | C++ | false | false | 1,863 | cpp | //
// bd2bd2bd2bd2ed2_test.cpp
//
// Created by Ewart Timothée, 2/3/2016
// Copyright (c) Ewart Timothée. All rights reserved.
//
// This file is generated automatically, do not edit!
// TAG: bd2bd2bd2bd2ed2
// Helper:
// h = Horner, e = Estrin, b = BruteForce
// The number indicates the order for Horner
// e.g. h1h3 indicates a produce of polynomial with Horner order 1 and 3
//
#include <limits>
#include <string.h>
#include <cmath>
#include <iostream>
#include "poly/poly.h"
namespace poly {
inline double sse_floor(double a) {
double b;
#ifdef __x86_64__
asm ("roundsd $1,%1,%0 " :"=x"(b) :"x"(a));
#endif
#ifdef __PPC64__
asm ("frim %0,%1 " :"=d"(b) :"d"(a));
#endif
return b;
}
static inline uint64_t as_uint64(double x) {
uint64_t i;
memcpy(&i,&x,8);
return i;
}
static inline double as_double(uint64_t i) {
double x;
memcpy(&x,&i,8);
return x;
}
double exp(double x){
uint64_t mask1 = (fabs(x) > 700);
mask1 = (mask1-1);
uint64_t mask2 = (x < 700);
mask2 = ~(mask2-1);
uint64_t mask3 = as_uint64(std::numeric_limits<double>::infinity());
const long long int tmp((long long int)sse_floor(1.4426950408889634 * x));
const long long int twok = (1023 + tmp) << 52;
x -= ((double)(tmp))*6.93145751953125E-1;
x -= ((double)(tmp))*1.42860682030941723212E-6;
double y = poly::bruteforce<poly::coeffP2_1>(x)*poly::bruteforce<poly::coeffP2_2>(x)*poly::bruteforce<poly::coeffP2_3>(x)*poly::bruteforce<poly::coeffP2_4>(x)*poly::estrin<poly::coeffP2_5>(x)* (*(double *)(&twok));
uint64_t n = as_uint64(y);
n &= mask1;
mask3 &= ~mask2;
n |= mask3;
return as_double(n);
}
} //end namespace
| [
"[email protected]"
] | |
01bf1bc8efa4fe5f477cdaab946afc4dfe926d2e | 5ba7994573cf9f39d201809e77161c6d54d4398b | /src/Commands/Arm/PIDJoystickSwitch.h | 882578d8f39e2ee2542ad085183824d3127bb7b6 | [] | no_license | FRC-4476-WAFFLES/Robot2018 | e567059fc9ff5ae9c22cc117e7ab72ca220b63e2 | 30c14dc594192b2cfd8636c9ca4d6bd8324cf861 | refs/heads/master | 2022-01-21T17:29:42.368942 | 2019-07-23T20:38:03 | 2019-07-23T20:38:03 | 117,171,674 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 249 | h | #pragma once
#include "CommandBase.h"
#include "Subsystems/ArmSubsystem.h"
class PIDJoystickSwitch : public CommandBase {
public:
PIDJoystickSwitch();
void Initialize();
void Execute();
bool IsFinished();
void End();
void Interrupted();
};
| [
"[email protected]"
] | |
cd084b6df1922ff341ac8fc4ee8aa3ecf6bdecad | 41575c498b7197e97b12a8ce2a880047df363cc3 | /src/local/util/functional/cast.hpp | 8a6d898746eb994740a02c76a583faf8094e5c04 | [] | no_license | gongfuPanada/page | f00a6f9015b4aad79398f0df041613ab28be405b | fa2ccdef4b33480c2ac5f872d717323f45618a34 | refs/heads/master | 2021-01-15T22:09:34.836791 | 2013-03-23T18:54:13 | 2013-03-23T18:54:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,971 | hpp | /**
* @section license
*
* Copyright (c) 2006-2013 David Osborn
*
* Permission is granted to use and redistribute this software in source and
* binary form, with or without modification, subject to the following
* conditions:
*
* 1. Redistributions in source form must retain the above copyright notice,
* this list of conditions, and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions, and the following disclaimer in the documentation
* and/or other materials provided with the distribution, and in the same
* place and form as other copyright, license, and disclaimer information.
*
* As a special exception, distributions of derivative works in binary form may
* include an acknowledgement in place of the above copyright notice, this list
* of conditions, and the following disclaimer in the documentation and/or other
* materials provided with the distribution, and in the same place and form as
* other acknowledgements, similar in substance to the following:
*
* Portions of this software are based on the work of David Osborn.
*
* This software is provided "as is", without any express or implied warranty.
* In no event will the authors be liable for any damages arising out of the use
* of this software.
*/
#ifndef page_local_util_functional_cast_hpp
# define page_local_util_functional_cast_hpp
namespace page
{
namespace util
{
/**
* @defgroup functional-cast
*
* Function objects that wrap the type-cast operators.
*
* @{
*/
# define DEFINE_CAST_FUNCTION(TYPE) \
template <typename T, typename U> \
struct TYPE##_cast_function \
{ \
T operator ()(U x) const \
{ \
return TYPE##_cast<T>(x); \
} \
};
DEFINE_CAST_FUNCTION(const)
DEFINE_CAST_FUNCTION(dynamic)
DEFINE_CAST_FUNCTION(reinterpret)
DEFINE_CAST_FUNCTION(static)
# undef DEFINE_CAST_FUNCTION
///@}
}
}
#endif
| [
"[email protected]"
] | |
228b7a45a67ff352304e9b1c0cd7b112775f99e9 | e44620035d4d3ced29f50c48862b85c978415f42 | /Project3/Project3/Vampire.cpp | a1a35e6f204494b8b0b68f37f34050b008e72634 | [] | no_license | TuckerL-OSU/CS162 | 6338d34e10ae39f78cce7cb1aac94e72c2a589b9 | cab3d74fd643bf51accf65bdc9b2739a20c28c8f | refs/heads/master | 2020-09-05T09:08:16.289795 | 2019-11-06T17:23:47 | 2019-11-06T17:23:47 | 218,779,912 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 649 | cpp | #include "Vampire.hpp"
Vampire::Vampire() {
name = "Vampire";
attack = 0;
defense = 0;
armor = 1;
strength_points = 18;
}
Vampire::Vampire(int att, int def) : Character("Vampire", att, def, 1, 18) {
this->attack = att;
this->defense = def;
}
Vampire::~Vampire() {
}
int Vampire::attackRoll() {
Die *roll = new Die(12, 1);
this->attack = roll->roll();
delete roll;
return this->attack;
}
int Vampire::defenseRoll() {
charm = (rand() % 10) + 0;
if (charm < 6) {
cout << "Vampires Charm was activated!" << endl;
}
else {
Die *roll = new Die(6, 1);
this->defense = roll->roll();
delete roll;
return this->defense;
}
} | [
"[email protected]"
] | |
4e2aae19031a5ff108c7ea1d935d3ca7f0cc811b | baf5c0828f2f17557a16fdba6e8303d5a33daebd | /kernel/BIOS.cc | 51bcc79251d09c67c92c7612e80b679d6a6b8db2 | [] | no_license | Nils1337/hhuos | 59ca452481579628c037659adbbb1b3d857bf40e | e53967daef04addb0a2e5a3ac4595e60d13b1c1c | refs/heads/master | 2020-04-18T20:02:21.316793 | 2019-01-29T14:47:08 | 2019-01-29T14:47:08 | 167,727,385 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,160 | cc | /*****************************************************************************
* *
* B I O S *
* *
*---------------------------------------------------------------------------*
* Beschreibung: BIOS-Schnittstelle *
* *
* Autor: Michael Schoettner, 19.9.2016 *
*****************************************************************************/
#include "kernel/Globals.h"
#include "kernel/BIOS.h"
// 16-Bit Code aufrufen, siehe Konstruktor und Aufruf in startup.asm
extern "C" { void bios_call(); }
// in startup.asm im GDT-Eintrag so festgeschrieben!
#define BIOS16_CODE_MEMORY_START 0x24000
// Parameter fuer BIOS-Aufrufe (Register)
#define BIOS16_PARAM_BASE 0x26000
// Zeiger auf Speichbereich fuer Parameter fuer BIOS-Aufruf (siehe BIOS.h)
struct BIOScall_params* BC_params = (struct BIOScall_params*)BIOS16_PARAM_BASE;
/*****************************************************************************
* Methode: BIOS::BIOS *
*---------------------------------------------------------------------------*
* Beschreibung: Konstruktor. Baut manuell ein 16-Bit Code Segment fuer *
* den BIOS-Aufruf. Startadresse dieser Funktion steht *
* im 4. GDT-Eintrag (siehe startup.asm). *
*****************************************************************************/
BIOS::BIOS() {
unsigned char *codeAddr = (unsigned char*)BIOS16_CODE_MEMORY_START;
// mov eax, 25000
*codeAddr = 0x66; codeAddr++;
*codeAddr = 0xB8; codeAddr++;
*codeAddr = 0x00; codeAddr++;
*codeAddr = 0x50; codeAddr++;
*codeAddr = 0x02; codeAddr++;
*codeAddr = 0x00; codeAddr++;
// mov [eax], esp
*codeAddr = 0x66; codeAddr++;
*codeAddr = 0x67; codeAddr++;
*codeAddr = 0x89; codeAddr++;
*codeAddr = 0x20; codeAddr++;
// mov eax,cr0
*codeAddr = 0x0F; codeAddr++;
*codeAddr = 0x20; codeAddr++;
*codeAddr = 0xC0; codeAddr++;
// and eax, 7FFEFFFE
*codeAddr = 0x66; codeAddr++;
*codeAddr = 0x25; codeAddr++;
*codeAddr = 0xFE; codeAddr++;
*codeAddr = 0xFF; codeAddr++;
*codeAddr = 0xFE; codeAddr++;
*codeAddr = 0x7F; codeAddr++;
// mov cr0, eax
*codeAddr = 0x0F; codeAddr++;
*codeAddr = 0x22; codeAddr++;
*codeAddr = 0xC0; codeAddr++;
// jmp 2400:001B flush pipeline & switch decoding unit
// 2400:001B (2400<<4 = 24000 + 1B)
*codeAddr = 0xEA; codeAddr++;
*codeAddr = 0x1B; codeAddr++;
*codeAddr = 0x00; codeAddr++;
*codeAddr = 0x00; codeAddr++;
*codeAddr = 0x24; codeAddr++;
// mov dx,2400
*codeAddr = 0xBA; codeAddr++;
*codeAddr = 0x00; codeAddr++;
*codeAddr = 0x24; codeAddr++;
// mov ss,dx
*codeAddr = 0x8E; codeAddr++;
*codeAddr = 0xD2; codeAddr++;
// mov gs,dx
*codeAddr = 0x8E; codeAddr++;
*codeAddr = 0xEA; codeAddr++;
// mov esp,2000 -> BIOS16_PARAM_BASE 0x260000
*codeAddr = 0x66; codeAddr++;
*codeAddr = 0xBC; codeAddr++;
*codeAddr = 0x00; codeAddr++;
*codeAddr = 0x20; codeAddr++;
*codeAddr = 0x00; codeAddr++;
*codeAddr = 0x00; codeAddr++;
// pop ds
*codeAddr = 0x1F; codeAddr++;
// pop es
*codeAddr = 0x07; codeAddr++;
// pop fs
*codeAddr = 0x0f; codeAddr++;
*codeAddr = 0xa1; codeAddr++;
// pop ax -> we have to pop something for symmetry
*codeAddr = 0x58; codeAddr++;
// popad
*codeAddr = 0x66; codeAddr++;
*codeAddr = 0x61; codeAddr++;
// interrupt number (written here)
*codeAddr = 0xCD; codeAddr++;
*codeAddr = 0x00; codeAddr++;
// pushad
*codeAddr = 0x66; codeAddr++;
*codeAddr = 0x60; codeAddr++;
// pushf
*codeAddr = 0x9C; codeAddr++;
// push fs
*codeAddr = 0x0f; codeAddr++;
*codeAddr = 0xa0; codeAddr++;
// push es
*codeAddr = 0x06; codeAddr++;
// push ds
*codeAddr = 0x1E; codeAddr++;
// mov eax,cr0
*codeAddr = 0x0F; codeAddr++;
*codeAddr = 0x20; codeAddr++;
*codeAddr = 0xC0; codeAddr++;
// or eax, 00010001 (protected mode without paging)
*codeAddr = 0x66; codeAddr++;
*codeAddr = 0x0D; codeAddr++;
*codeAddr = 0x01; codeAddr++;
*codeAddr = 0x00; codeAddr++;
*codeAddr = 0x01; codeAddr++;
*codeAddr = 0x00; codeAddr++;
// mov cr0, eax
*codeAddr = 0x0F; codeAddr++;
*codeAddr = 0x22; codeAddr++;
*codeAddr = 0xC0; codeAddr++;
// jmp 0018:0049, flush pipeline & switch decoding
// 0018:0049
*codeAddr = 0xEA; codeAddr++;
*codeAddr = 0x49; codeAddr++;
*codeAddr = 0x00; codeAddr++;
*codeAddr = 0x18; codeAddr++;
*codeAddr = 0x00; codeAddr++;
// mov dx,0010
*codeAddr = 0xBA; codeAddr++;
*codeAddr = 0x10; codeAddr++;
*codeAddr = 0x00; codeAddr++;
// mov ds,dx
*codeAddr = 0x8E; codeAddr++;
*codeAddr = 0xDA; codeAddr++;
// mov es,dx
*codeAddr = 0x8E; codeAddr++;
*codeAddr = 0xC2; codeAddr++;
// mov es,dx
*codeAddr = 0x8E; codeAddr++;
*codeAddr = 0xE2; codeAddr++;
// mov fs,dx
*codeAddr = 0x8E; codeAddr++;
*codeAddr = 0xEA; codeAddr++;
// mov ss,dx
*codeAddr = 0x8E; codeAddr++;
*codeAddr = 0xD2; codeAddr++;
// mov eax, 25000
*codeAddr = 0x66; codeAddr++;
*codeAddr = 0xB8; codeAddr++;
*codeAddr = 0x00; codeAddr++;
*codeAddr = 0x50; codeAddr++;
*codeAddr = 0x02; codeAddr++;
*codeAddr = 0x00; codeAddr++;
// mov esp, [eax]
*codeAddr = 0x66; codeAddr++;
*codeAddr = 0x67; codeAddr++;
*codeAddr = 0x8B; codeAddr++;
*codeAddr = 0x20; codeAddr++;
// far ret
*codeAddr = 0x66; codeAddr++;
*codeAddr = 0xCB; codeAddr++;
}
/*****************************************************************************
* Methode: BIOS::Int *
*---------------------------------------------------------------------------*
* Beschreibung: Fuehrt einen BIOS-Aufruf per Software-Interrupt durch. *
*****************************************************************************/
void BIOS::Int(int inter) {
unsigned char *ptr = (unsigned char*)BIOS16_CODE_MEMORY_START;
// Interrupt-Nummer in 16-Bit Code-Segment schreiben (unschoen, aber ...)
*(ptr+48) = (unsigned char)inter;
cpu.disable_int (); // Interrupts abschalten
bios_call ();
cpu.enable_int ();
}
| [
"[email protected]"
] | |
75415e9fe3a397fdd649f9a768b349a6f8551be7 | 1300358e915ec390bfd4eef88c1ead89b8bf3ba2 | /my-trader/trunk/src/MyExchange/qtm/src/qtm.cpp | 72f1b8998bceb289b867757f280ca666a454b32f | [] | no_license | 19199883/gangof4 | d04e7a5fb4b556a7ee29410e83b7761fb25fecbd | 24370d709056fae7ff7085581a4d72478ce6ad3e | refs/heads/master | 2020-05-21T19:15:21.073690 | 2019-10-30T10:26:25 | 2019-10-30T10:26:25 | 64,183,829 | 0 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 451 | cpp | #include "qtm.h"
void
qtm_init(int type)
{
}
void
set_criteria(const criteria_t *data)
{
}
void
acquire_quote_time_field(const char *name, const char *time_str){}
void
update_state(const char *name, int type, int status, const char *description){}
void
update_compliance(const char *name, int type, int status, const char *description){}
void
qtm_finish(){}
void
acquire_tca_order(const char *name, int action, long time_stamp, long seq_no){}
| [
"[email protected]"
] | |
94df531c891ae226ac4815140ec0ab750f99e36a | 7e40d6d74c748db2331187f802a980b72636bfff | /Source/Cross/Graphics/Direct3D11/D3D11Graphics.cpp | 38836641c3c551d1ac39e399e8e9a018e69ce70f | [
"Zlib",
"BSD-3-Clause",
"NTP",
"BSL-1.0",
"Apache-2.0",
"MIT",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-khronos"
] | permissive | joaovsq/Cross | 3c63c8c67c03e869073fe64b9dd2baf3ce8e418c | 7e952d9f9c6da5de60e539182a279942452d9591 | refs/heads/master | 2021-07-07T12:38:47.344618 | 2019-11-21T19:50:41 | 2019-11-21T19:50:41 | 211,865,491 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 86,326 | cpp | //
// Copyright (c) 2008-2017 the Urho3D project.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#include "../../Precompiled.h"
#include "../../Core/Context.h"
#include "../../Core/ProcessUtils.h"
#include "../../Core/Profiler.h"
#include "../../Graphics/ConstantBuffer.h"
#include "../../Graphics/Geometry.h"
#include "../../Graphics/Graphics.h"
#include "../../Graphics/GraphicsEvents.h"
#include "../../Graphics/GraphicsImpl.h"
#include "../../Graphics/IndexBuffer.h"
#include "../../Graphics/Renderer.h"
#include "../../Graphics/Shader.h"
#include "../../Graphics/ShaderPrecache.h"
#include "../../Graphics/ShaderProgram.h"
#include "../../Graphics/Texture2D.h"
#include "../../Graphics/TextureCube.h"
#include "../../Graphics/VertexBuffer.h"
#include "../../IO/File.h"
#include "../../IO/Log.h"
#include "../../Resource/ResourceCache.h"
// CROSS BEGIN
#include <SDL/include/SDL.h>
#include <SDL/include/SDL_syswm.h>
// CROSS END
#include "../../DebugNew.h"
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
// Prefer the high-performance GPU on switchable GPU systems
extern "C"
{
__declspec(dllexport) DWORD NvOptimusEnablement = 1;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
namespace Cross
{
static const D3D11_COMPARISON_FUNC d3dCmpFunc[] =
{
D3D11_COMPARISON_ALWAYS,
D3D11_COMPARISON_EQUAL,
D3D11_COMPARISON_NOT_EQUAL,
D3D11_COMPARISON_LESS,
D3D11_COMPARISON_LESS_EQUAL,
D3D11_COMPARISON_GREATER,
D3D11_COMPARISON_GREATER_EQUAL
};
static const DWORD d3dBlendEnable[] =
{
FALSE,
TRUE,
TRUE,
TRUE,
TRUE,
TRUE,
TRUE,
TRUE
};
static const D3D11_BLEND d3dSrcBlend[] =
{
D3D11_BLEND_ONE,
D3D11_BLEND_ONE,
D3D11_BLEND_DEST_COLOR,
D3D11_BLEND_SRC_ALPHA,
D3D11_BLEND_SRC_ALPHA,
D3D11_BLEND_ONE,
D3D11_BLEND_INV_DEST_ALPHA,
D3D11_BLEND_ONE,
D3D11_BLEND_SRC_ALPHA,
};
static const D3D11_BLEND d3dDestBlend[] =
{
D3D11_BLEND_ZERO,
D3D11_BLEND_ONE,
D3D11_BLEND_ZERO,
D3D11_BLEND_INV_SRC_ALPHA,
D3D11_BLEND_ONE,
D3D11_BLEND_INV_SRC_ALPHA,
D3D11_BLEND_DEST_ALPHA,
D3D11_BLEND_ONE,
D3D11_BLEND_ONE
};
static const D3D11_BLEND_OP d3dBlendOp[] =
{
D3D11_BLEND_OP_ADD,
D3D11_BLEND_OP_ADD,
D3D11_BLEND_OP_ADD,
D3D11_BLEND_OP_ADD,
D3D11_BLEND_OP_ADD,
D3D11_BLEND_OP_ADD,
D3D11_BLEND_OP_ADD,
D3D11_BLEND_OP_REV_SUBTRACT,
D3D11_BLEND_OP_REV_SUBTRACT
};
static const D3D11_STENCIL_OP d3dStencilOp[] =
{
D3D11_STENCIL_OP_KEEP,
D3D11_STENCIL_OP_ZERO,
D3D11_STENCIL_OP_REPLACE,
D3D11_STENCIL_OP_INCR,
D3D11_STENCIL_OP_DECR
};
static const D3D11_CULL_MODE d3dCullMode[] =
{
D3D11_CULL_NONE,
D3D11_CULL_BACK,
D3D11_CULL_FRONT
};
static const D3D11_FILL_MODE d3dFillMode[] =
{
D3D11_FILL_SOLID,
D3D11_FILL_WIREFRAME,
D3D11_FILL_WIREFRAME // Point fill mode not supported
};
static void GetD3DPrimitiveType(unsigned elementCount, PrimitiveType type, unsigned& primitiveCount,
D3D_PRIMITIVE_TOPOLOGY& d3dPrimitiveType)
{
switch (type)
{
case TRIANGLE_LIST:
primitiveCount = elementCount / 3;
d3dPrimitiveType = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
break;
case LINE_LIST:
primitiveCount = elementCount / 2;
d3dPrimitiveType = D3D_PRIMITIVE_TOPOLOGY_LINELIST;
break;
case POINT_LIST:
primitiveCount = elementCount;
d3dPrimitiveType = D3D_PRIMITIVE_TOPOLOGY_POINTLIST;
break;
case TRIANGLE_STRIP:
primitiveCount = elementCount - 2;
d3dPrimitiveType = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
break;
case LINE_STRIP:
primitiveCount = elementCount - 1;
d3dPrimitiveType = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP;
break;
case TRIANGLE_FAN:
// Triangle fan is not supported on D3D11
primitiveCount = 0;
d3dPrimitiveType = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
break;
}
}
static HWND GetWindowHandle(SDL_Window* window)
{
SDL_SysWMinfo sysInfo;
SDL_VERSION(&sysInfo.version);
SDL_GetWindowWMInfo(window, &sysInfo);
return sysInfo.info.win.window;
}
const Vector2 Graphics::pixelUVOffset(0.0f, 0.0f);
bool Graphics::gl3Support = false;
Graphics::Graphics(Context* context) :
Object(context),
impl_(new GraphicsImpl()),
window_(0),
externalWindow_(0),
width_(0),
height_(0),
position_(SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED),
multiSample_(1),
fullscreen_(false),
borderless_(false),
resizable_(false),
highDPI_(false),
vsync_(false),
monitor_(0),
refreshRate_(0),
tripleBuffer_(false),
flushGPU_(false),
forceGL2_(false),
sRGB_(false),
anisotropySupport_(false),
dxtTextureSupport_(false),
etcTextureSupport_(false),
pvrtcTextureSupport_(false),
hardwareShadowSupport_(false),
lightPrepassSupport_(false),
deferredSupport_(false),
instancingSupport_(false),
sRGBSupport_(false),
sRGBWriteSupport_(false),
numPrimitives_(0),
numBatches_(0),
maxScratchBufferRequest_(0),
defaultTextureFilterMode_(FILTER_TRILINEAR),
defaultTextureAnisotropy_(4),
shaderPath_("Shaders/HLSL/"),
shaderExtension_(".hlsl"),
orientations_("LandscapeLeft LandscapeRight"),
apiName_("D3D11")
{
SetTextureUnitMappings();
ResetCachedState();
context_->RequireSDL(SDL_INIT_VIDEO);
// Register Graphics library object factories
RegisterGraphicsLibrary(context_);
}
Graphics::~Graphics()
{
{
MutexLock lock(gpuObjectMutex_);
// Release all GPU objects that still exist
for (PODVector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
(*i)->Release();
gpuObjects_.Clear();
}
impl_->vertexDeclarations_.Clear();
impl_->allConstantBuffers_.Clear();
for (HashMap<unsigned, ID3D11BlendState*>::Iterator i = impl_->blendStates_.Begin(); i != impl_->blendStates_.End(); ++i)
{
CROSS_SAFE_RELEASE(i->second_);
}
impl_->blendStates_.Clear();
for (HashMap<unsigned, ID3D11DepthStencilState*>::Iterator i = impl_->depthStates_.Begin(); i != impl_->depthStates_.End(); ++i)
{
CROSS_SAFE_RELEASE(i->second_);
}
impl_->depthStates_.Clear();
for (HashMap<unsigned, ID3D11RasterizerState*>::Iterator i = impl_->rasterizerStates_.Begin();
i != impl_->rasterizerStates_.End(); ++i)
{
CROSS_SAFE_RELEASE(i->second_);
}
impl_->rasterizerStates_.Clear();
CROSS_SAFE_RELEASE(impl_->defaultRenderTargetView_);
CROSS_SAFE_RELEASE(impl_->defaultDepthStencilView_);
CROSS_SAFE_RELEASE(impl_->defaultDepthTexture_);
CROSS_SAFE_RELEASE(impl_->resolveTexture_);
CROSS_SAFE_RELEASE(impl_->swapChain_);
CROSS_SAFE_RELEASE(impl_->deviceContext_);
CROSS_SAFE_RELEASE(impl_->device_);
if (window_)
{
SDL_ShowCursor(SDL_TRUE);
SDL_DestroyWindow(window_);
window_ = 0;
}
delete impl_;
impl_ = 0;
context_->ReleaseSDL();
}
bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless, bool resizable, bool highDPI, bool vsync, bool tripleBuffer,
int multiSample, int monitor, int refreshRate)
{
CROSS_PROFILE(SetScreenMode);
highDPI = false; // SDL does not support High DPI mode on Windows platform yet, so always disable it for now
bool maximize = false;
// Make sure monitor index is not bigger than the currently detected monitors
int monitors = SDL_GetNumVideoDisplays();
if (monitor >= monitors || monitor < 0)
monitor = 0; // this monitor is not present, use first monitor
// Find out the full screen mode display format (match desktop color depth)
SDL_DisplayMode mode;
SDL_GetDesktopDisplayMode(monitor, &mode);
DXGI_FORMAT fullscreenFormat = SDL_BITSPERPIXEL(mode.format) == 16 ? DXGI_FORMAT_B5G6R5_UNORM : DXGI_FORMAT_R8G8B8A8_UNORM;
// If zero dimensions in windowed mode, set windowed mode to maximize and set a predefined default restored window size. If zero in fullscreen, use desktop mode
if (!width || !height)
{
if (fullscreen || borderless)
{
width = mode.w;
height = mode.h;
}
else
{
maximize = resizable;
width = 1024;
height = 768;
}
}
// Fullscreen or Borderless can not be resizable
if (fullscreen || borderless)
resizable = false;
// Borderless cannot be fullscreen, they are mutually exclusive
if (borderless)
fullscreen = false;
// If nothing changes, do not reset the device
if (width == width_ && height == height_ && fullscreen == fullscreen_ && borderless == borderless_ && resizable == resizable_ &&
vsync == vsync_ && tripleBuffer == tripleBuffer_ && multiSample == multiSample_)
return true;
SDL_SetHint(SDL_HINT_ORIENTATIONS, orientations_.CString());
if (!window_)
{
if (!OpenWindow(width, height, resizable, borderless))
return false;
}
// Check fullscreen mode validity. Use a closest match if not found
if (fullscreen)
{
PODVector<IntVector3> resolutions = GetResolutions(monitor);
if (resolutions.Size())
{
unsigned best = 0;
unsigned bestError = M_MAX_UNSIGNED;
for (unsigned i = 0; i < resolutions.Size(); ++i)
{
unsigned error = (unsigned)(Abs(resolutions[i].x_ - width) + Abs(resolutions[i].y_ - height));
if (error < bestError)
{
best = i;
bestError = error;
}
}
width = resolutions[best].x_;
height = resolutions[best].y_;
refreshRate = resolutions[best].z_;
}
}
AdjustWindow(width, height, fullscreen, borderless, monitor);
monitor_ = monitor;
refreshRate_ = refreshRate;
if (maximize)
{
Maximize();
SDL_GetWindowSize(window_, &width, &height);
}
if (!impl_->device_ || multiSample_ != multiSample)
CreateDevice(width, height, multiSample);
UpdateSwapChain(width, height);
fullscreen_ = fullscreen;
borderless_ = borderless;
resizable_ = resizable;
highDPI_ = highDPI;
vsync_ = vsync;
tripleBuffer_ = tripleBuffer;
// Clear the initial window contents to black
Clear(CLEAR_COLOR);
impl_->swapChain_->Present(0, 0);
#ifdef CROSS_LOGGING
String msg;
msg.AppendWithFormat("Set screen mode %dx%d %s monitor %d", width_, height_, (fullscreen_ ? "fullscreen" : "windowed"), monitor_);
if (borderless_)
msg.Append(" borderless");
if (resizable_)
msg.Append(" resizable");
if (multiSample > 1)
msg.AppendWithFormat(" multisample %d", multiSample);
CROSS_LOGINFO(msg);
#endif
using namespace ScreenMode;
VariantMap& eventData = GetEventDataMap();
eventData[P_WIDTH] = width_;
eventData[P_HEIGHT] = height_;
eventData[P_FULLSCREEN] = fullscreen_;
eventData[P_BORDERLESS] = borderless_;
eventData[P_RESIZABLE] = resizable_;
eventData[P_HIGHDPI] = highDPI_;
eventData[P_MONITOR] = monitor_;
eventData[P_REFRESHRATE] = refreshRate_;
SendEvent(E_SCREENMODE, eventData);
return true;
}
bool Graphics::SetMode(int width, int height)
{
return SetMode(width, height, fullscreen_, borderless_, resizable_, highDPI_, vsync_, tripleBuffer_, multiSample_, monitor_, refreshRate_);
}
void Graphics::SetSRGB(bool enable)
{
bool newEnable = enable && sRGBWriteSupport_;
if (newEnable != sRGB_)
{
sRGB_ = newEnable;
if (impl_->swapChain_)
{
// Recreate swap chain for the new backbuffer format
CreateDevice(width_, height_, multiSample_);
UpdateSwapChain(width_, height_);
}
}
}
void Graphics::SetDither(bool enable)
{
// No effect on Direct3D11
}
void Graphics::SetFlushGPU(bool enable)
{
flushGPU_ = enable;
if (impl_->device_)
{
IDXGIDevice1* dxgiDevice;
impl_->device_->QueryInterface(IID_IDXGIDevice1, (void**)&dxgiDevice);
if (dxgiDevice)
{
dxgiDevice->SetMaximumFrameLatency(enable ? 1 : 3);
dxgiDevice->Release();
}
}
}
void Graphics::SetForceGL2(bool enable)
{
// No effect on Direct3D11
}
void Graphics::Close()
{
if (window_)
{
SDL_ShowCursor(SDL_TRUE);
SDL_DestroyWindow(window_);
window_ = 0;
}
}
bool Graphics::TakeScreenShot(Image* destImage_)
{
CROSS_PROFILE(TakeScreenShot);
if (!impl_->device_)
return false;
// CROSS BEGIN
if (!destImage_)
return false;
Image& destImage = *destImage_;
// CROSS END
D3D11_TEXTURE2D_DESC textureDesc;
memset(&textureDesc, 0, sizeof textureDesc);
textureDesc.Width = (UINT)width_;
textureDesc.Height = (UINT)height_;
textureDesc.MipLevels = 1;
textureDesc.ArraySize = 1;
textureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
textureDesc.SampleDesc.Count = 1;
textureDesc.SampleDesc.Quality = 0;
textureDesc.Usage = D3D11_USAGE_STAGING;
textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
ID3D11Texture2D* stagingTexture = 0;
HRESULT hr = impl_->device_->CreateTexture2D(&textureDesc, 0, &stagingTexture);
if (FAILED(hr))
{
CROSS_SAFE_RELEASE(stagingTexture);
CROSS_LOGD3DERROR("Could not create staging texture for screenshot", hr);
return false;
}
ID3D11Resource* source = 0;
impl_->defaultRenderTargetView_->GetResource(&source);
if (multiSample_ > 1)
{
// If backbuffer is multisampled, need another DEFAULT usage texture to resolve the data to first
CreateResolveTexture();
if (!impl_->resolveTexture_)
{
stagingTexture->Release();
source->Release();
return false;
}
impl_->deviceContext_->ResolveSubresource(impl_->resolveTexture_, 0, source, 0, DXGI_FORMAT_R8G8B8A8_UNORM);
impl_->deviceContext_->CopyResource(stagingTexture, impl_->resolveTexture_);
}
else
impl_->deviceContext_->CopyResource(stagingTexture, source);
source->Release();
D3D11_MAPPED_SUBRESOURCE mappedData;
mappedData.pData = 0;
hr = impl_->deviceContext_->Map(stagingTexture, 0, D3D11_MAP_READ, 0, &mappedData);
if (FAILED(hr) || !mappedData.pData)
{
CROSS_LOGD3DERROR("Could not map staging texture for screenshot", hr);
stagingTexture->Release();
return false;
}
destImage.SetSize(width_, height_, 3);
unsigned char* destData = destImage.GetData();
for (int y = 0; y < height_; ++y)
{
unsigned char* src = (unsigned char*)mappedData.pData + y * mappedData.RowPitch;
for (int x = 0; x < width_; ++x)
{
*destData++ = *src++;
*destData++ = *src++;
*destData++ = *src++;
++src;
}
}
impl_->deviceContext_->Unmap(stagingTexture, 0);
stagingTexture->Release();
return true;
}
bool Graphics::BeginFrame()
{
if (!IsInitialized())
return false;
// If using an external window, check it for size changes, and reset screen mode if necessary
if (externalWindow_)
{
int width, height;
SDL_GetWindowSize(window_, &width, &height);
if (width != width_ || height != height_)
SetMode(width, height);
}
else
{
// To prevent a loop of endless device loss and flicker, do not attempt to render when in fullscreen
// and the window is minimized
if (fullscreen_ && (SDL_GetWindowFlags(window_) & SDL_WINDOW_MINIMIZED))
return false;
}
// Set default rendertarget and depth buffer
ResetRenderTargets();
// Cleanup textures from previous frame
for (unsigned i = 0; i < MAX_TEXTURE_UNITS; ++i)
SetTexture(i, 0);
numPrimitives_ = 0;
numBatches_ = 0;
SendEvent(E_BEGINRENDERING);
return true;
}
void Graphics::EndFrame()
{
if (!IsInitialized())
return;
{
CROSS_PROFILE(Present);
SendEvent(E_ENDRENDERING);
impl_->swapChain_->Present(vsync_ ? 1 : 0, 0);
}
// Clean up too large scratch buffers
CleanupScratchBuffers();
}
void Graphics::Clear(unsigned flags, const Color& color, float depth, unsigned stencil)
{
IntVector2 rtSize = GetRenderTargetDimensions();
bool oldColorWrite = colorWrite_;
bool oldDepthWrite = depthWrite_;
// D3D11 clear always clears the whole target regardless of viewport or scissor test settings
// Emulate partial clear by rendering a quad
if (!viewport_.left_ && !viewport_.top_ && viewport_.right_ == rtSize.x_ && viewport_.bottom_ == rtSize.y_)
{
// Make sure we use the read-write version of the depth stencil
SetDepthWrite(true);
PrepareDraw();
if ((flags & CLEAR_COLOR) && impl_->renderTargetViews_[0])
impl_->deviceContext_->ClearRenderTargetView(impl_->renderTargetViews_[0], color.Data());
if ((flags & (CLEAR_DEPTH | CLEAR_STENCIL)) && impl_->depthStencilView_)
{
unsigned depthClearFlags = 0;
if (flags & CLEAR_DEPTH)
depthClearFlags |= D3D11_CLEAR_DEPTH;
if (flags & CLEAR_STENCIL)
depthClearFlags |= D3D11_CLEAR_STENCIL;
impl_->deviceContext_->ClearDepthStencilView(impl_->depthStencilView_, depthClearFlags, depth, (UINT8)stencil);
}
}
else
{
Renderer* renderer = GetSubsystem<Renderer>();
if (!renderer)
return;
Geometry* geometry = renderer->GetQuadGeometry();
Matrix3x4 model = Matrix3x4::IDENTITY;
Matrix4 projection = Matrix4::IDENTITY;
model.m23_ = Clamp(depth, 0.0f, 1.0f);
SetBlendMode(BLEND_REPLACE);
SetColorWrite((flags & CLEAR_COLOR) != 0);
SetCullMode(CULL_NONE);
SetDepthTest(CMP_ALWAYS);
SetDepthWrite((flags & CLEAR_DEPTH) != 0);
SetFillMode(FILL_SOLID);
SetScissorTest(false);
SetStencilTest((flags & CLEAR_STENCIL) != 0, CMP_ALWAYS, OP_REF, OP_KEEP, OP_KEEP, stencil);
SetShaders(GetShader(VS, "ClearFramebuffer"), GetShader(PS, "ClearFramebuffer"));
SetShaderParameter(VSP_MODEL, model);
SetShaderParameter(VSP_VIEWPROJ, projection);
SetShaderParameter(PSP_MATDIFFCOLOR, color);
geometry->Draw(this);
SetStencilTest(false);
ClearParameterSources();
}
// Restore color & depth write state now
SetColorWrite(oldColorWrite);
SetDepthWrite(oldDepthWrite);
}
bool Graphics::ResolveToTexture(Texture2D* destination, const IntRect& viewport)
{
if (!destination || !destination->GetRenderSurface())
return false;
CROSS_PROFILE(ResolveToTexture);
IntRect vpCopy = viewport;
if (vpCopy.right_ <= vpCopy.left_)
vpCopy.right_ = vpCopy.left_ + 1;
if (vpCopy.bottom_ <= vpCopy.top_)
vpCopy.bottom_ = vpCopy.top_ + 1;
D3D11_BOX srcBox;
srcBox.left = Clamp(vpCopy.left_, 0, width_);
srcBox.top = Clamp(vpCopy.top_, 0, height_);
srcBox.right = Clamp(vpCopy.right_, 0, width_);
srcBox.bottom = Clamp(vpCopy.bottom_, 0, height_);
srcBox.front = 0;
srcBox.back = 1;
ID3D11Resource* source = 0;
bool resolve = multiSample_ > 1;
impl_->defaultRenderTargetView_->GetResource(&source);
if (!resolve)
{
if (!srcBox.left && !srcBox.top && srcBox.right == width_ && srcBox.bottom == height_)
impl_->deviceContext_->CopyResource((ID3D11Resource*)destination->GetGPUObject(), source);
else
impl_->deviceContext_->CopySubresourceRegion((ID3D11Resource*)destination->GetGPUObject(), 0, 0, 0, 0, source, 0, &srcBox);
}
else
{
if (!srcBox.left && !srcBox.top && srcBox.right == width_ && srcBox.bottom == height_)
{
impl_->deviceContext_->ResolveSubresource((ID3D11Resource*)destination->GetGPUObject(), 0, source, 0, (DXGI_FORMAT)
destination->GetFormat());
}
else
{
CreateResolveTexture();
if (impl_->resolveTexture_)
{
impl_->deviceContext_->ResolveSubresource(impl_->resolveTexture_, 0, source, 0, DXGI_FORMAT_R8G8B8A8_UNORM);
impl_->deviceContext_->CopySubresourceRegion((ID3D11Resource*)destination->GetGPUObject(), 0, 0, 0, 0, impl_->resolveTexture_, 0, &srcBox);
}
}
}
source->Release();
return true;
}
bool Graphics::ResolveToTexture(Texture2D* texture)
{
if (!texture)
return false;
RenderSurface* surface = texture->GetRenderSurface();
if (!surface)
return false;
texture->SetResolveDirty(false);
surface->SetResolveDirty(false);
ID3D11Resource* source = (ID3D11Resource*)texture->GetGPUObject();
ID3D11Resource* dest = (ID3D11Resource*)texture->GetResolveTexture();
if (!source || !dest)
return false;
impl_->deviceContext_->ResolveSubresource(dest, 0, source, 0, (DXGI_FORMAT)texture->GetFormat());
return true;
}
bool Graphics::ResolveToTexture(TextureCube* texture)
{
if (!texture)
return false;
texture->SetResolveDirty(false);
ID3D11Resource* source = (ID3D11Resource*)texture->GetGPUObject();
ID3D11Resource* dest = (ID3D11Resource*)texture->GetResolveTexture();
if (!source || !dest)
return false;
for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
{
// Resolve only the surface(s) that were actually rendered to
RenderSurface* surface = texture->GetRenderSurface((CubeMapFace)i);
if (!surface->IsResolveDirty())
continue;
surface->SetResolveDirty(false);
unsigned subResource = D3D11CalcSubresource(0, i, texture->GetLevels());
impl_->deviceContext_->ResolveSubresource(dest, subResource, source, subResource, (DXGI_FORMAT)texture->GetFormat());
}
return true;
}
void Graphics::Draw(PrimitiveType type, unsigned vertexStart, unsigned vertexCount)
{
if (!vertexCount || !impl_->shaderProgram_)
return;
PrepareDraw();
unsigned primitiveCount;
D3D_PRIMITIVE_TOPOLOGY d3dPrimitiveType;
if (fillMode_ == FILL_POINT)
type = POINT_LIST;
GetD3DPrimitiveType(vertexCount, type, primitiveCount, d3dPrimitiveType);
if (d3dPrimitiveType != primitiveType_)
{
impl_->deviceContext_->IASetPrimitiveTopology(d3dPrimitiveType);
primitiveType_ = d3dPrimitiveType;
}
impl_->deviceContext_->Draw(vertexCount, vertexStart);
numPrimitives_ += primitiveCount;
++numBatches_;
}
void Graphics::Draw(PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned minVertex, unsigned vertexCount)
{
if (!vertexCount || !impl_->shaderProgram_)
return;
PrepareDraw();
unsigned primitiveCount;
D3D_PRIMITIVE_TOPOLOGY d3dPrimitiveType;
if (fillMode_ == FILL_POINT)
type = POINT_LIST;
GetD3DPrimitiveType(indexCount, type, primitiveCount, d3dPrimitiveType);
if (d3dPrimitiveType != primitiveType_)
{
impl_->deviceContext_->IASetPrimitiveTopology(d3dPrimitiveType);
primitiveType_ = d3dPrimitiveType;
}
impl_->deviceContext_->DrawIndexed(indexCount, indexStart, 0);
numPrimitives_ += primitiveCount;
++numBatches_;
}
void Graphics::Draw(PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned baseVertexIndex, unsigned minVertex, unsigned vertexCount)
{
if (!vertexCount || !impl_->shaderProgram_)
return;
PrepareDraw();
unsigned primitiveCount;
D3D_PRIMITIVE_TOPOLOGY d3dPrimitiveType;
if (fillMode_ == FILL_POINT)
type = POINT_LIST;
GetD3DPrimitiveType(indexCount, type, primitiveCount, d3dPrimitiveType);
if (d3dPrimitiveType != primitiveType_)
{
impl_->deviceContext_->IASetPrimitiveTopology(d3dPrimitiveType);
primitiveType_ = d3dPrimitiveType;
}
impl_->deviceContext_->DrawIndexed(indexCount, indexStart, baseVertexIndex);
numPrimitives_ += primitiveCount;
++numBatches_;
}
void Graphics::DrawInstanced(PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned minVertex, unsigned vertexCount,
unsigned instanceCount)
{
if (!indexCount || !instanceCount || !impl_->shaderProgram_)
return;
PrepareDraw();
unsigned primitiveCount;
D3D_PRIMITIVE_TOPOLOGY d3dPrimitiveType;
if (fillMode_ == FILL_POINT)
type = POINT_LIST;
GetD3DPrimitiveType(indexCount, type, primitiveCount, d3dPrimitiveType);
if (d3dPrimitiveType != primitiveType_)
{
impl_->deviceContext_->IASetPrimitiveTopology(d3dPrimitiveType);
primitiveType_ = d3dPrimitiveType;
}
impl_->deviceContext_->DrawIndexedInstanced(indexCount, instanceCount, indexStart, 0, 0);
numPrimitives_ += instanceCount * primitiveCount;
++numBatches_;
}
void Graphics::DrawInstanced(PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned baseVertexIndex, unsigned minVertex, unsigned vertexCount,
unsigned instanceCount)
{
if (!indexCount || !instanceCount || !impl_->shaderProgram_)
return;
PrepareDraw();
unsigned primitiveCount;
D3D_PRIMITIVE_TOPOLOGY d3dPrimitiveType;
if (fillMode_ == FILL_POINT)
type = POINT_LIST;
GetD3DPrimitiveType(indexCount, type, primitiveCount, d3dPrimitiveType);
if (d3dPrimitiveType != primitiveType_)
{
impl_->deviceContext_->IASetPrimitiveTopology(d3dPrimitiveType);
primitiveType_ = d3dPrimitiveType;
}
impl_->deviceContext_->DrawIndexedInstanced(indexCount, instanceCount, indexStart, baseVertexIndex, 0);
numPrimitives_ += instanceCount * primitiveCount;
++numBatches_;
}
void Graphics::SetVertexBuffer(VertexBuffer* buffer)
{
// Note: this is not multi-instance safe
static PODVector<VertexBuffer*> vertexBuffers(1);
vertexBuffers[0] = buffer;
SetVertexBuffers(vertexBuffers);
}
bool Graphics::SetVertexBuffers(const PODVector<VertexBuffer*>& buffers, unsigned instanceOffset)
{
if (buffers.Size() > MAX_VERTEX_STREAMS)
{
CROSS_LOGERROR("Too many vertex buffers");
return false;
}
for (unsigned i = 0; i < MAX_VERTEX_STREAMS; ++i)
{
VertexBuffer* buffer = 0;
bool changed = false;
buffer = i < buffers.Size() ? buffers[i] : 0;
if (buffer)
{
const PODVector<VertexElement>& elements = buffer->GetElements();
// Check if buffer has per-instance data
bool hasInstanceData = elements.Size() && elements[0].perInstance_;
unsigned offset = hasInstanceData ? instanceOffset * buffer->GetVertexSize() : 0;
if (buffer != vertexBuffers_[i] || offset != impl_->vertexOffsets_[i])
{
vertexBuffers_[i] = buffer;
impl_->vertexBuffers_[i] = (ID3D11Buffer*)buffer->GetGPUObject();
impl_->vertexSizes_[i] = buffer->GetVertexSize();
impl_->vertexOffsets_[i] = offset;
changed = true;
}
}
else if (vertexBuffers_[i])
{
vertexBuffers_[i] = 0;
impl_->vertexBuffers_[i] = 0;
impl_->vertexSizes_[i] = 0;
impl_->vertexOffsets_[i] = 0;
changed = true;
}
if (changed)
{
impl_->vertexDeclarationDirty_ = true;
if (impl_->firstDirtyVB_ == M_MAX_UNSIGNED)
impl_->firstDirtyVB_ = impl_->lastDirtyVB_ = i;
else
{
if (i < impl_->firstDirtyVB_)
impl_->firstDirtyVB_ = i;
if (i > impl_->lastDirtyVB_)
impl_->lastDirtyVB_ = i;
}
}
}
return true;
}
bool Graphics::SetVertexBuffers(const Vector<SharedPtr<VertexBuffer> >& buffers, unsigned instanceOffset)
{
return SetVertexBuffers(reinterpret_cast<const PODVector<VertexBuffer*>&>(buffers), instanceOffset);
}
void Graphics::SetIndexBuffer(IndexBuffer* buffer)
{
if (buffer != indexBuffer_)
{
if (buffer)
impl_->deviceContext_->IASetIndexBuffer((ID3D11Buffer*)buffer->GetGPUObject(),
buffer->GetIndexSize() == sizeof(unsigned short) ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT, 0);
else
impl_->deviceContext_->IASetIndexBuffer(0, DXGI_FORMAT_UNKNOWN, 0);
indexBuffer_ = buffer;
}
}
void Graphics::SetShaders(ShaderVariation* vs, ShaderVariation* ps)
{
// Switch to the clip plane variations if necessary
if (useClipPlane_)
{
if (vs)
vs = vs->GetOwner()->GetVariation(VS, vs->GetDefinesClipPlane());
if (ps)
ps = ps->GetOwner()->GetVariation(PS, ps->GetDefinesClipPlane());
}
if (vs == vertexShader_ && ps == pixelShader_)
return;
if (vs != vertexShader_)
{
// Create the shader now if not yet created. If already attempted, do not retry
if (vs && !vs->GetGPUObject())
{
if (vs->GetCompilerOutput().Empty())
{
CROSS_PROFILE(CompileVertexShader);
bool success = vs->Create();
if (!success)
{
CROSS_LOGERROR("Failed to compile vertex shader " + vs->GetFullName() + ":\n" + vs->GetCompilerOutput());
vs = 0;
}
}
else
vs = 0;
}
impl_->deviceContext_->VSSetShader((ID3D11VertexShader*)(vs ? vs->GetGPUObject() : 0), 0, 0);
vertexShader_ = vs;
impl_->vertexDeclarationDirty_ = true;
}
if (ps != pixelShader_)
{
if (ps && !ps->GetGPUObject())
{
if (ps->GetCompilerOutput().Empty())
{
CROSS_PROFILE(CompilePixelShader);
bool success = ps->Create();
if (!success)
{
CROSS_LOGERROR("Failed to compile pixel shader " + ps->GetFullName() + ":\n" + ps->GetCompilerOutput());
ps = 0;
}
}
else
ps = 0;
}
impl_->deviceContext_->PSSetShader((ID3D11PixelShader*)(ps ? ps->GetGPUObject() : 0), 0, 0);
pixelShader_ = ps;
}
// Update current shader parameters & constant buffers
if (vertexShader_ && pixelShader_)
{
Pair<ShaderVariation*, ShaderVariation*> key = MakePair(vertexShader_, pixelShader_);
ShaderProgramMap::Iterator i = impl_->shaderPrograms_.Find(key);
if (i != impl_->shaderPrograms_.End())
impl_->shaderProgram_ = i->second_.Get();
else
{
ShaderProgram* newProgram = impl_->shaderPrograms_[key] = new ShaderProgram(this, vertexShader_, pixelShader_);
impl_->shaderProgram_ = newProgram;
}
bool vsBuffersChanged = false;
bool psBuffersChanged = false;
for (unsigned i = 0; i < MAX_SHADER_PARAMETER_GROUPS; ++i)
{
ID3D11Buffer* vsBuffer = impl_->shaderProgram_->vsConstantBuffers_[i] ? (ID3D11Buffer*)impl_->shaderProgram_->vsConstantBuffers_[i]->
GetGPUObject() : 0;
if (vsBuffer != impl_->constantBuffers_[VS][i])
{
impl_->constantBuffers_[VS][i] = vsBuffer;
shaderParameterSources_[i] = (const void*)M_MAX_UNSIGNED;
vsBuffersChanged = true;
}
ID3D11Buffer* psBuffer = impl_->shaderProgram_->psConstantBuffers_[i] ? (ID3D11Buffer*)impl_->shaderProgram_->psConstantBuffers_[i]->
GetGPUObject() : 0;
if (psBuffer != impl_->constantBuffers_[PS][i])
{
impl_->constantBuffers_[PS][i] = psBuffer;
shaderParameterSources_[i] = (const void*)M_MAX_UNSIGNED;
psBuffersChanged = true;
}
}
if (vsBuffersChanged)
impl_->deviceContext_->VSSetConstantBuffers(0, MAX_SHADER_PARAMETER_GROUPS, &impl_->constantBuffers_[VS][0]);
if (psBuffersChanged)
impl_->deviceContext_->PSSetConstantBuffers(0, MAX_SHADER_PARAMETER_GROUPS, &impl_->constantBuffers_[PS][0]);
}
else
impl_->shaderProgram_ = 0;
// Store shader combination if shader dumping in progress
if (shaderPrecache_)
shaderPrecache_->StoreShaders(vertexShader_, pixelShader_);
// Update clip plane parameter if necessary
if (useClipPlane_)
SetShaderParameter(VSP_CLIPPLANE, clipPlane_);
}
void Graphics::SetShaderParameter(StringHash param, const float* data, unsigned count)
{
HashMap<StringHash, ShaderParameter>::Iterator i;
if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
return;
ConstantBuffer* buffer = i->second_.bufferPtr_;
if (!buffer->IsDirty())
impl_->dirtyConstantBuffers_.Push(buffer);
buffer->SetParameter(i->second_.offset_, (unsigned)(count * sizeof(float)), data);
}
void Graphics::SetShaderParameter(StringHash param, float value)
{
HashMap<StringHash, ShaderParameter>::Iterator i;
if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
return;
ConstantBuffer* buffer = i->second_.bufferPtr_;
if (!buffer->IsDirty())
impl_->dirtyConstantBuffers_.Push(buffer);
buffer->SetParameter(i->second_.offset_, sizeof(float), &value);
}
void Graphics::SetShaderParameter(StringHash param, int value)
{
HashMap<StringHash, ShaderParameter>::Iterator i;
if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
return;
ConstantBuffer* buffer = i->second_.bufferPtr_;
if (!buffer->IsDirty())
impl_->dirtyConstantBuffers_.Push(buffer);
buffer->SetParameter(i->second_.offset_, sizeof(int), &value);
}
void Graphics::SetShaderParameter(StringHash param, bool value)
{
HashMap<StringHash, ShaderParameter>::Iterator i;
if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
return;
ConstantBuffer* buffer = i->second_.bufferPtr_;
if (!buffer->IsDirty())
impl_->dirtyConstantBuffers_.Push(buffer);
buffer->SetParameter(i->second_.offset_, sizeof(bool), &value);
}
void Graphics::SetShaderParameter(StringHash param, const Color& color)
{
HashMap<StringHash, ShaderParameter>::Iterator i;
if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
return;
ConstantBuffer* buffer = i->second_.bufferPtr_;
if (!buffer->IsDirty())
impl_->dirtyConstantBuffers_.Push(buffer);
buffer->SetParameter(i->second_.offset_, sizeof(Color), &color);
}
void Graphics::SetShaderParameter(StringHash param, const Vector2& vector)
{
HashMap<StringHash, ShaderParameter>::Iterator i;
if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
return;
ConstantBuffer* buffer = i->second_.bufferPtr_;
if (!buffer->IsDirty())
impl_->dirtyConstantBuffers_.Push(buffer);
buffer->SetParameter(i->second_.offset_, sizeof(Vector2), &vector);
}
void Graphics::SetShaderParameter(StringHash param, const Matrix3& matrix)
{
HashMap<StringHash, ShaderParameter>::Iterator i;
if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
return;
ConstantBuffer* buffer = i->second_.bufferPtr_;
if (!buffer->IsDirty())
impl_->dirtyConstantBuffers_.Push(buffer);
buffer->SetVector3ArrayParameter(i->second_.offset_, 3, &matrix);
}
void Graphics::SetShaderParameter(StringHash param, const Vector3& vector)
{
HashMap<StringHash, ShaderParameter>::Iterator i;
if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
return;
ConstantBuffer* buffer = i->second_.bufferPtr_;
if (!buffer->IsDirty())
impl_->dirtyConstantBuffers_.Push(buffer);
buffer->SetParameter(i->second_.offset_, sizeof(Vector3), &vector);
}
void Graphics::SetShaderParameter(StringHash param, const Matrix4& matrix)
{
HashMap<StringHash, ShaderParameter>::Iterator i;
if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
return;
ConstantBuffer* buffer = i->second_.bufferPtr_;
if (!buffer->IsDirty())
impl_->dirtyConstantBuffers_.Push(buffer);
buffer->SetParameter(i->second_.offset_, sizeof(Matrix4), &matrix);
}
void Graphics::SetShaderParameter(StringHash param, const Vector4& vector)
{
HashMap<StringHash, ShaderParameter>::Iterator i;
if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
return;
ConstantBuffer* buffer = i->second_.bufferPtr_;
if (!buffer->IsDirty())
impl_->dirtyConstantBuffers_.Push(buffer);
buffer->SetParameter(i->second_.offset_, sizeof(Vector4), &vector);
}
void Graphics::SetShaderParameter(StringHash param, const Matrix3x4& matrix)
{
HashMap<StringHash, ShaderParameter>::Iterator i;
if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
return;
ConstantBuffer* buffer = i->second_.bufferPtr_;
if (!buffer->IsDirty())
impl_->dirtyConstantBuffers_.Push(buffer);
buffer->SetParameter(i->second_.offset_, sizeof(Matrix3x4), &matrix);
}
bool Graphics::NeedParameterUpdate(ShaderParameterGroup group, const void* source)
{
if ((unsigned)(size_t)shaderParameterSources_[group] == M_MAX_UNSIGNED || shaderParameterSources_[group] != source)
{
shaderParameterSources_[group] = source;
return true;
}
else
return false;
}
bool Graphics::HasShaderParameter(StringHash param)
{
return impl_->shaderProgram_ && impl_->shaderProgram_->parameters_.Find(param) != impl_->shaderProgram_->parameters_.End();
}
bool Graphics::HasTextureUnit(TextureUnit unit)
{
return (vertexShader_ && vertexShader_->HasTextureUnit(unit)) || (pixelShader_ && pixelShader_->HasTextureUnit(unit));
}
void Graphics::ClearParameterSource(ShaderParameterGroup group)
{
shaderParameterSources_[group] = (const void*)M_MAX_UNSIGNED;
}
void Graphics::ClearParameterSources()
{
for (unsigned i = 0; i < MAX_SHADER_PARAMETER_GROUPS; ++i)
shaderParameterSources_[i] = (const void*)M_MAX_UNSIGNED;
}
void Graphics::ClearTransformSources()
{
shaderParameterSources_[SP_CAMERA] = (const void*)M_MAX_UNSIGNED;
shaderParameterSources_[SP_OBJECT] = (const void*)M_MAX_UNSIGNED;
}
void Graphics::SetTexture(unsigned index, Texture* texture)
{
if (index >= MAX_TEXTURE_UNITS)
return;
// Check if texture is currently bound as a rendertarget. In that case, use its backup texture, or blank if not defined
if (texture)
{
if (renderTargets_[0] && renderTargets_[0]->GetParentTexture() == texture)
texture = texture->GetBackupTexture();
else
{
// Resolve multisampled texture now as necessary
if (texture->GetMultiSample() > 1 && texture->GetAutoResolve() && texture->IsResolveDirty())
{
if (texture->GetType() == Texture2D::GetTypeStatic())
ResolveToTexture(static_cast<Texture2D*>(texture));
if (texture->GetType() == TextureCube::GetTypeStatic())
ResolveToTexture(static_cast<TextureCube*>(texture));
}
}
if (texture->GetLevelsDirty())
texture->RegenerateLevels();
}
if (texture && texture->GetParametersDirty())
{
texture->UpdateParameters();
textures_[index] = 0; // Force reassign
}
if (texture != textures_[index])
{
if (impl_->firstDirtyTexture_ == M_MAX_UNSIGNED)
impl_->firstDirtyTexture_ = impl_->lastDirtyTexture_ = index;
else
{
if (index < impl_->firstDirtyTexture_)
impl_->firstDirtyTexture_ = index;
if (index > impl_->lastDirtyTexture_)
impl_->lastDirtyTexture_ = index;
}
textures_[index] = texture;
impl_->shaderResourceViews_[index] = texture ? (ID3D11ShaderResourceView*)texture->GetShaderResourceView() : 0;
impl_->samplers_[index] = texture ? (ID3D11SamplerState*)texture->GetSampler() : 0;
impl_->texturesDirty_ = true;
}
}
void SetTextureForUpdate(Texture* texture)
{
// No-op on Direct3D11
}
void Graphics::SetDefaultTextureFilterMode(TextureFilterMode mode)
{
if (mode != defaultTextureFilterMode_)
{
defaultTextureFilterMode_ = mode;
SetTextureParametersDirty();
}
}
void Graphics::SetDefaultTextureAnisotropy(unsigned level)
{
level = Max(level, 1U);
if (level != defaultTextureAnisotropy_)
{
defaultTextureAnisotropy_ = level;
SetTextureParametersDirty();
}
}
void Graphics::Restore()
{
// No-op on Direct3D11
}
void Graphics::SetTextureParametersDirty()
{
MutexLock lock(gpuObjectMutex_);
for (PODVector<GPUObject*>::Iterator i = gpuObjects_.Begin(); i != gpuObjects_.End(); ++i)
{
Texture* texture = dynamic_cast<Texture*>(*i);
if (texture)
texture->SetParametersDirty();
}
}
void Graphics::ResetRenderTargets()
{
for (unsigned i = 0; i < MAX_RENDERTARGETS; ++i)
SetRenderTarget(i, (RenderSurface*)0);
SetDepthStencil((RenderSurface*)0);
SetViewport(IntRect(0, 0, width_, height_));
}
void Graphics::ResetRenderTarget(unsigned index)
{
SetRenderTarget(index, (RenderSurface*)0);
}
void Graphics::ResetDepthStencil()
{
SetDepthStencil((RenderSurface*)0);
}
void Graphics::SetRenderTarget(unsigned index, RenderSurface* renderTarget)
{
if (index >= MAX_RENDERTARGETS)
return;
if (renderTarget != renderTargets_[index])
{
renderTargets_[index] = renderTarget;
impl_->renderTargetsDirty_ = true;
// If the rendertarget is also bound as a texture, replace with backup texture or null
if (renderTarget)
{
Texture* parentTexture = renderTarget->GetParentTexture();
for (unsigned i = 0; i < MAX_TEXTURE_UNITS; ++i)
{
if (textures_[i] == parentTexture)
SetTexture(i, textures_[i]->GetBackupTexture());
}
// If multisampled, mark the texture & surface needing resolve
if (parentTexture->GetMultiSample() > 1 && parentTexture->GetAutoResolve())
{
parentTexture->SetResolveDirty(true);
renderTarget->SetResolveDirty(true);
}
// If mipmapped, mark the levels needing regeneration
if (parentTexture->GetLevels() > 1)
parentTexture->SetLevelsDirty();
}
}
}
void Graphics::SetRenderTarget(unsigned index, Texture2D* texture)
{
RenderSurface* renderTarget = 0;
if (texture)
renderTarget = texture->GetRenderSurface();
SetRenderTarget(index, renderTarget);
}
void Graphics::SetDepthStencil(RenderSurface* depthStencil)
{
if (depthStencil != depthStencil_)
{
depthStencil_ = depthStencil;
impl_->renderTargetsDirty_ = true;
}
}
void Graphics::SetDepthStencil(Texture2D* texture)
{
RenderSurface* depthStencil = 0;
if (texture)
depthStencil = texture->GetRenderSurface();
SetDepthStencil(depthStencil);
// Constant depth bias depends on the bitdepth
impl_->rasterizerStateDirty_ = true;
}
void Graphics::SetViewport(const IntRect& rect)
{
IntVector2 size = GetRenderTargetDimensions();
IntRect rectCopy = rect;
if (rectCopy.right_ <= rectCopy.left_)
rectCopy.right_ = rectCopy.left_ + 1;
if (rectCopy.bottom_ <= rectCopy.top_)
rectCopy.bottom_ = rectCopy.top_ + 1;
rectCopy.left_ = Clamp(rectCopy.left_, 0, size.x_);
rectCopy.top_ = Clamp(rectCopy.top_, 0, size.y_);
rectCopy.right_ = Clamp(rectCopy.right_, 0, size.x_);
rectCopy.bottom_ = Clamp(rectCopy.bottom_, 0, size.y_);
static D3D11_VIEWPORT d3dViewport;
d3dViewport.TopLeftX = (float)rectCopy.left_;
d3dViewport.TopLeftY = (float)rectCopy.top_;
d3dViewport.Width = (float)(rectCopy.right_ - rectCopy.left_);
d3dViewport.Height = (float)(rectCopy.bottom_ - rectCopy.top_);
d3dViewport.MinDepth = 0.0f;
d3dViewport.MaxDepth = 1.0f;
impl_->deviceContext_->RSSetViewports(1, &d3dViewport);
viewport_ = rectCopy;
// Disable scissor test, needs to be re-enabled by the user
SetScissorTest(false);
}
void Graphics::SetBlendMode(BlendMode mode, bool alphaToCoverage)
{
if (mode != blendMode_ || alphaToCoverage != alphaToCoverage_)
{
blendMode_ = mode;
alphaToCoverage_ = alphaToCoverage;
impl_->blendStateDirty_ = true;
}
}
void Graphics::SetColorWrite(bool enable)
{
if (enable != colorWrite_)
{
colorWrite_ = enable;
impl_->blendStateDirty_ = true;
}
}
void Graphics::SetCullMode(CullMode mode)
{
if (mode != cullMode_)
{
cullMode_ = mode;
impl_->rasterizerStateDirty_ = true;
}
}
void Graphics::SetDepthBias(float constantBias, float slopeScaledBias)
{
if (constantBias != constantDepthBias_ || slopeScaledBias != slopeScaledDepthBias_)
{
constantDepthBias_ = constantBias;
slopeScaledDepthBias_ = slopeScaledBias;
impl_->rasterizerStateDirty_ = true;
}
}
void Graphics::SetDepthTest(CompareMode mode)
{
if (mode != depthTestMode_)
{
depthTestMode_ = mode;
impl_->depthStateDirty_ = true;
}
}
void Graphics::SetDepthWrite(bool enable)
{
if (enable != depthWrite_)
{
depthWrite_ = enable;
impl_->depthStateDirty_ = true;
// Also affects whether a read-only version of depth-stencil should be bound, to allow sampling
impl_->renderTargetsDirty_ = true;
}
}
void Graphics::SetFillMode(FillMode mode)
{
if (mode != fillMode_)
{
fillMode_ = mode;
impl_->rasterizerStateDirty_ = true;
}
}
void Graphics::SetLineAntiAlias(bool enable)
{
if (enable != lineAntiAlias_)
{
lineAntiAlias_ = enable;
impl_->rasterizerStateDirty_ = true;
}
}
void Graphics::SetScissorTest(bool enable, const Rect& rect, bool borderInclusive)
{
// During some light rendering loops, a full rect is toggled on/off repeatedly.
// Disable scissor in that case to reduce state changes
if (rect.min_.x_ <= 0.0f && rect.min_.y_ <= 0.0f && rect.max_.x_ >= 1.0f && rect.max_.y_ >= 1.0f)
enable = false;
if (enable)
{
IntVector2 rtSize(GetRenderTargetDimensions());
IntVector2 viewSize(viewport_.Size());
IntVector2 viewPos(viewport_.left_, viewport_.top_);
IntRect intRect;
int expand = borderInclusive ? 1 : 0;
intRect.left_ = Clamp((int)((rect.min_.x_ + 1.0f) * 0.5f * viewSize.x_) + viewPos.x_, 0, rtSize.x_ - 1);
intRect.top_ = Clamp((int)((-rect.max_.y_ + 1.0f) * 0.5f * viewSize.y_) + viewPos.y_, 0, rtSize.y_ - 1);
intRect.right_ = Clamp((int)((rect.max_.x_ + 1.0f) * 0.5f * viewSize.x_) + viewPos.x_ + expand, 0, rtSize.x_);
intRect.bottom_ = Clamp((int)((-rect.min_.y_ + 1.0f) * 0.5f * viewSize.y_) + viewPos.y_ + expand, 0, rtSize.y_);
if (intRect.right_ == intRect.left_)
intRect.right_++;
if (intRect.bottom_ == intRect.top_)
intRect.bottom_++;
if (intRect.right_ < intRect.left_ || intRect.bottom_ < intRect.top_)
enable = false;
if (enable && intRect != scissorRect_)
{
scissorRect_ = intRect;
impl_->scissorRectDirty_ = true;
}
}
if (enable != scissorTest_)
{
scissorTest_ = enable;
impl_->rasterizerStateDirty_ = true;
}
}
void Graphics::SetScissorTest(bool enable, const IntRect& rect)
{
IntVector2 rtSize(GetRenderTargetDimensions());
IntVector2 viewPos(viewport_.left_, viewport_.top_);
if (enable)
{
IntRect intRect;
intRect.left_ = Clamp(rect.left_ + viewPos.x_, 0, rtSize.x_ - 1);
intRect.top_ = Clamp(rect.top_ + viewPos.y_, 0, rtSize.y_ - 1);
intRect.right_ = Clamp(rect.right_ + viewPos.x_, 0, rtSize.x_);
intRect.bottom_ = Clamp(rect.bottom_ + viewPos.y_, 0, rtSize.y_);
if (intRect.right_ == intRect.left_)
intRect.right_++;
if (intRect.bottom_ == intRect.top_)
intRect.bottom_++;
if (intRect.right_ < intRect.left_ || intRect.bottom_ < intRect.top_)
enable = false;
if (enable && intRect != scissorRect_)
{
scissorRect_ = intRect;
impl_->scissorRectDirty_ = true;
}
}
if (enable != scissorTest_)
{
scissorTest_ = enable;
impl_->rasterizerStateDirty_ = true;
}
}
void Graphics::SetStencilTest(bool enable, CompareMode mode, StencilOp pass, StencilOp fail, StencilOp zFail, unsigned stencilRef,
unsigned compareMask, unsigned writeMask)
{
if (enable != stencilTest_)
{
stencilTest_ = enable;
impl_->depthStateDirty_ = true;
}
if (enable)
{
if (mode != stencilTestMode_)
{
stencilTestMode_ = mode;
impl_->depthStateDirty_ = true;
}
if (pass != stencilPass_)
{
stencilPass_ = pass;
impl_->depthStateDirty_ = true;
}
if (fail != stencilFail_)
{
stencilFail_ = fail;
impl_->depthStateDirty_ = true;
}
if (zFail != stencilZFail_)
{
stencilZFail_ = zFail;
impl_->depthStateDirty_ = true;
}
if (compareMask != stencilCompareMask_)
{
stencilCompareMask_ = compareMask;
impl_->depthStateDirty_ = true;
}
if (writeMask != stencilWriteMask_)
{
stencilWriteMask_ = writeMask;
impl_->depthStateDirty_ = true;
}
if (stencilRef != stencilRef_)
{
stencilRef_ = stencilRef;
impl_->stencilRefDirty_ = true;
impl_->depthStateDirty_ = true;
}
}
}
void Graphics::SetClipPlane(bool enable, const Plane& clipPlane, const Matrix3x4& view, const Matrix4& projection)
{
useClipPlane_ = enable;
if (enable)
{
Matrix4 viewProj = projection * view;
clipPlane_ = clipPlane.Transformed(viewProj).ToVector4();
SetShaderParameter(VSP_CLIPPLANE, clipPlane_);
}
}
bool Graphics::IsInitialized() const
{
return window_ != 0 && impl_->GetDevice() != 0;
}
PODVector<int> Graphics::GetMultiSampleLevels() const
{
PODVector<int> ret;
ret.Push(1);
if (impl_->device_)
{
for (unsigned i = 2; i <= 16; ++i)
{
if (impl_->CheckMultiSampleSupport(sRGB_ ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB : DXGI_FORMAT_R8G8B8A8_UNORM, i))
ret.Push(i);
}
}
return ret;
}
unsigned Graphics::GetFormat(CompressedFormat format) const
{
switch (format)
{
case CF_RGBA:
return DXGI_FORMAT_R8G8B8A8_UNORM;
case CF_DXT1:
return DXGI_FORMAT_BC1_UNORM;
case CF_DXT3:
return DXGI_FORMAT_BC2_UNORM;
case CF_DXT5:
return DXGI_FORMAT_BC3_UNORM;
default:
return 0;
}
}
ShaderVariation* Graphics::GetShader(ShaderType type, const String& name, const String& defines) const
{
return GetShader(type, name.CString(), defines.CString());
}
ShaderVariation* Graphics::GetShader(ShaderType type, const char* name, const char* defines) const
{
if (lastShaderName_ != name || !lastShader_)
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
String fullShaderName = shaderPath_ + name + shaderExtension_;
// Try to reduce repeated error log prints because of missing shaders
if (lastShaderName_ == name && !cache->Exists(fullShaderName))
return 0;
lastShader_ = cache->GetResource<Shader>(fullShaderName);
lastShaderName_ = name;
}
return lastShader_ ? lastShader_->GetVariation(type, defines) : (ShaderVariation*)0;
}
VertexBuffer* Graphics::GetVertexBuffer(unsigned index) const
{
return index < MAX_VERTEX_STREAMS ? vertexBuffers_[index] : 0;
}
ShaderProgram* Graphics::GetShaderProgram() const
{
return impl_->shaderProgram_;
}
TextureUnit Graphics::GetTextureUnit(const String& name)
{
HashMap<String, TextureUnit>::Iterator i = textureUnits_.Find(name);
if (i != textureUnits_.End())
return i->second_;
else
return MAX_TEXTURE_UNITS;
}
const String& Graphics::GetTextureUnitName(TextureUnit unit)
{
for (HashMap<String, TextureUnit>::Iterator i = textureUnits_.Begin(); i != textureUnits_.End(); ++i)
{
if (i->second_ == unit)
return i->first_;
}
return String::EMPTY;
}
Texture* Graphics::GetTexture(unsigned index) const
{
return index < MAX_TEXTURE_UNITS ? textures_[index] : 0;
}
RenderSurface* Graphics::GetRenderTarget(unsigned index) const
{
return index < MAX_RENDERTARGETS ? renderTargets_[index] : 0;
}
IntVector2 Graphics::GetRenderTargetDimensions() const
{
int width, height;
if (renderTargets_[0])
{
width = renderTargets_[0]->GetWidth();
height = renderTargets_[0]->GetHeight();
}
else if (depthStencil_) // Depth-only rendering
{
width = depthStencil_->GetWidth();
height = depthStencil_->GetHeight();
}
else
{
width = width_;
height = height_;
}
return IntVector2(width, height);
}
bool Graphics::GetDither() const
{
return false;
}
bool Graphics::IsDeviceLost() const
{
// Direct3D11 graphics context is never considered lost
/// \todo The device could be lost in case of graphics adapters getting disabled during runtime. This is not currently handled
return false;
}
void Graphics::OnWindowResized()
{
if (!impl_->device_ || !window_)
return;
int newWidth, newHeight;
SDL_GetWindowSize(window_, &newWidth, &newHeight);
if (newWidth == width_ && newHeight == height_)
return;
UpdateSwapChain(newWidth, newHeight);
// Reset rendertargets and viewport for the new screen size
ResetRenderTargets();
CROSS_LOGDEBUGF("Window was resized to %dx%d", width_, height_);
using namespace ScreenMode;
VariantMap& eventData = GetEventDataMap();
eventData[P_WIDTH] = width_;
eventData[P_HEIGHT] = height_;
eventData[P_FULLSCREEN] = fullscreen_;
eventData[P_RESIZABLE] = resizable_;
eventData[P_BORDERLESS] = borderless_;
eventData[P_HIGHDPI] = highDPI_;
SendEvent(E_SCREENMODE, eventData);
}
void Graphics::OnWindowMoved()
{
if (!impl_->device_ || !window_ || fullscreen_)
return;
int newX, newY;
SDL_GetWindowPosition(window_, &newX, &newY);
if (newX == position_.x_ && newY == position_.y_)
return;
position_.x_ = newX;
position_.y_ = newY;
CROSS_LOGDEBUGF("Window was moved to %d,%d", position_.x_, position_.y_);
using namespace WindowPos;
VariantMap& eventData = GetEventDataMap();
eventData[P_X] = position_.x_;
eventData[P_Y] = position_.y_;
SendEvent(E_WINDOWPOS, eventData);
}
void Graphics::CleanupShaderPrograms(ShaderVariation* variation)
{
for (ShaderProgramMap::Iterator i = impl_->shaderPrograms_.Begin(); i != impl_->shaderPrograms_.End();)
{
if (i->first_.first_ == variation || i->first_.second_ == variation)
i = impl_->shaderPrograms_.Erase(i);
else
++i;
}
if (vertexShader_ == variation || pixelShader_ == variation)
impl_->shaderProgram_ = 0;
}
void Graphics::CleanupRenderSurface(RenderSurface* surface)
{
// No-op on Direct3D11
}
ConstantBuffer* Graphics::GetOrCreateConstantBuffer(ShaderType type, unsigned index, unsigned size)
{
// Ensure that different shader types and index slots get unique buffers, even if the size is same
unsigned key = type | (index << 1) | (size << 4);
ConstantBufferMap::Iterator i = impl_->allConstantBuffers_.Find(key);
if (i != impl_->allConstantBuffers_.End())
return i->second_.Get();
else
{
SharedPtr<ConstantBuffer> newConstantBuffer(new ConstantBuffer(context_));
newConstantBuffer->SetSize(size);
impl_->allConstantBuffers_[key] = newConstantBuffer;
return newConstantBuffer.Get();
}
}
unsigned Graphics::GetAlphaFormat()
{
return DXGI_FORMAT_A8_UNORM;
}
unsigned Graphics::GetLuminanceFormat()
{
// Note: not same sampling behavior as on D3D9; need to sample the R channel only
return DXGI_FORMAT_R8_UNORM;
}
unsigned Graphics::GetLuminanceAlphaFormat()
{
// Note: not same sampling behavior as on D3D9; need to sample the RG channels
return DXGI_FORMAT_R8G8_UNORM;
}
unsigned Graphics::GetRGBFormat()
{
return DXGI_FORMAT_R8G8B8A8_UNORM;
}
unsigned Graphics::GetRGBAFormat()
{
return DXGI_FORMAT_R8G8B8A8_UNORM;
}
unsigned Graphics::GetRGBA16Format()
{
return DXGI_FORMAT_R16G16B16A16_UNORM;
}
unsigned Graphics::GetRGBAFloat16Format()
{
return DXGI_FORMAT_R16G16B16A16_FLOAT;
}
unsigned Graphics::GetRGBAFloat32Format()
{
return DXGI_FORMAT_R32G32B32A32_FLOAT;
}
unsigned Graphics::GetRG16Format()
{
return DXGI_FORMAT_R16G16_UNORM;
}
unsigned Graphics::GetRGFloat16Format()
{
return DXGI_FORMAT_R16G16_FLOAT;
}
unsigned Graphics::GetRGFloat32Format()
{
return DXGI_FORMAT_R32G32_FLOAT;
}
unsigned Graphics::GetFloat16Format()
{
return DXGI_FORMAT_R16_FLOAT;
}
unsigned Graphics::GetFloat32Format()
{
return DXGI_FORMAT_R32_FLOAT;
}
unsigned Graphics::GetLinearDepthFormat()
{
return DXGI_FORMAT_R32_FLOAT;
}
unsigned Graphics::GetDepthStencilFormat()
{
return DXGI_FORMAT_R24G8_TYPELESS;
}
unsigned Graphics::GetReadableDepthFormat()
{
return DXGI_FORMAT_R24G8_TYPELESS;
}
unsigned Graphics::GetFormat(const String& formatName)
{
String nameLower = formatName.ToLower().Trimmed();
if (nameLower == "a")
return GetAlphaFormat();
if (nameLower == "l")
return GetLuminanceFormat();
if (nameLower == "la")
return GetLuminanceAlphaFormat();
if (nameLower == "rgb")
return GetRGBFormat();
if (nameLower == "rgba")
return GetRGBAFormat();
if (nameLower == "rgba16")
return GetRGBA16Format();
if (nameLower == "rgba16f")
return GetRGBAFloat16Format();
if (nameLower == "rgba32f")
return GetRGBAFloat32Format();
if (nameLower == "rg16")
return GetRG16Format();
if (nameLower == "rg16f")
return GetRGFloat16Format();
if (nameLower == "rg32f")
return GetRGFloat32Format();
if (nameLower == "r16f")
return GetFloat16Format();
if (nameLower == "r32f" || nameLower == "float")
return GetFloat32Format();
if (nameLower == "lineardepth" || nameLower == "depth")
return GetLinearDepthFormat();
if (nameLower == "d24s8")
return GetDepthStencilFormat();
if (nameLower == "readabledepth" || nameLower == "hwdepth")
return GetReadableDepthFormat();
return GetRGBFormat();
}
unsigned Graphics::GetMaxBones()
{
return 128;
}
bool Graphics::GetGL3Support()
{
return gl3Support;
}
bool Graphics::OpenWindow(int width, int height, bool resizable, bool borderless)
{
if (!externalWindow_)
{
unsigned flags = 0;
if (resizable)
flags |= SDL_WINDOW_RESIZABLE;
if (borderless)
flags |= SDL_WINDOW_BORDERLESS;
window_ = SDL_CreateWindow(windowTitle_.CString(), position_.x_, position_.y_, width, height, flags);
}
else
window_ = SDL_CreateWindowFrom(externalWindow_, 0);
if (!window_)
{
CROSS_LOGERRORF("Could not create window, root cause: '%s'", SDL_GetError());
return false;
}
SDL_GetWindowPosition(window_, &position_.x_, &position_.y_);
CreateWindowIcon();
return true;
}
void Graphics::AdjustWindow(int& newWidth, int& newHeight, bool& newFullscreen, bool& newBorderless, int& monitor)
{
if (!externalWindow_)
{
if (!newWidth || !newHeight)
{
SDL_MaximizeWindow(window_);
SDL_GetWindowSize(window_, &newWidth, &newHeight);
}
else
{
SDL_Rect display_rect;
SDL_GetDisplayBounds(monitor, &display_rect);
if (newFullscreen || (newBorderless && newWidth >= display_rect.w && newHeight >= display_rect.h))
{
// Reposition the window on the specified monitor if it's supposed to cover the entire monitor
SDL_SetWindowPosition(window_, display_rect.x, display_rect.y);
}
SDL_SetWindowSize(window_, newWidth, newHeight);
}
// Hack fix: on SDL 2.0.4 a fullscreen->windowed transition results in a maximized window when the D3D device is reset, so hide before
SDL_HideWindow(window_);
SDL_SetWindowFullscreen(window_, newFullscreen ? SDL_WINDOW_FULLSCREEN : 0);
SDL_SetWindowBordered(window_, newBorderless ? SDL_FALSE : SDL_TRUE);
SDL_ShowWindow(window_);
}
else
{
// If external window, must ask its dimensions instead of trying to set them
SDL_GetWindowSize(window_, &newWidth, &newHeight);
newFullscreen = false;
}
}
bool Graphics::CreateDevice(int width, int height, int multiSample)
{
// Device needs only to be created once
if (!impl_->device_)
{
HRESULT hr = D3D11CreateDevice(
0,
D3D_DRIVER_TYPE_HARDWARE,
0,
0,
0,
0,
D3D11_SDK_VERSION,
&impl_->device_,
0,
&impl_->deviceContext_
);
if (FAILED(hr))
{
CROSS_SAFE_RELEASE(impl_->device_);
CROSS_SAFE_RELEASE(impl_->deviceContext_);
CROSS_LOGD3DERROR("Failed to create D3D11 device", hr);
return false;
}
CheckFeatureSupport();
// Set the flush mode now as the device has been created
SetFlushGPU(flushGPU_);
}
// Check that multisample level is supported
PODVector<int> multiSampleLevels = GetMultiSampleLevels();
if (!multiSampleLevels.Contains(multiSample))
multiSample = 1;
// Create swap chain. Release old if necessary
if (impl_->swapChain_)
{
impl_->swapChain_->Release();
impl_->swapChain_ = 0;
}
DXGI_SWAP_CHAIN_DESC swapChainDesc;
memset(&swapChainDesc, 0, sizeof swapChainDesc);
swapChainDesc.BufferCount = 1;
swapChainDesc.BufferDesc.Width = (UINT)width;
swapChainDesc.BufferDesc.Height = (UINT)height;
swapChainDesc.BufferDesc.Format = sRGB_ ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB : DXGI_FORMAT_R8G8B8A8_UNORM;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.OutputWindow = GetWindowHandle(window_);
swapChainDesc.SampleDesc.Count = (UINT)multiSample;
swapChainDesc.SampleDesc.Quality = impl_->GetMultiSampleQuality(swapChainDesc.BufferDesc.Format, multiSample);
swapChainDesc.Windowed = TRUE;
swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
IDXGIDevice* dxgiDevice = 0;
impl_->device_->QueryInterface(IID_IDXGIDevice, (void**)&dxgiDevice);
IDXGIAdapter* dxgiAdapter = 0;
dxgiDevice->GetParent(IID_IDXGIAdapter, (void**)&dxgiAdapter);
IDXGIFactory* dxgiFactory = 0;
dxgiAdapter->GetParent(IID_IDXGIFactory, (void**)&dxgiFactory);
HRESULT hr = dxgiFactory->CreateSwapChain(impl_->device_, &swapChainDesc, &impl_->swapChain_);
// After creating the swap chain, disable automatic Alt-Enter fullscreen/windowed switching
// (the application will switch manually if it wants to)
dxgiFactory->MakeWindowAssociation(GetWindowHandle(window_), DXGI_MWA_NO_ALT_ENTER);
dxgiFactory->Release();
dxgiAdapter->Release();
dxgiDevice->Release();
if (FAILED(hr))
{
CROSS_SAFE_RELEASE(impl_->swapChain_);
CROSS_LOGD3DERROR("Failed to create D3D11 swap chain", hr);
return false;
}
multiSample_ = multiSample;
return true;
}
bool Graphics::UpdateSwapChain(int width, int height)
{
bool success = true;
ID3D11RenderTargetView* nullView = 0;
impl_->deviceContext_->OMSetRenderTargets(1, &nullView, 0);
if (impl_->defaultRenderTargetView_)
{
impl_->defaultRenderTargetView_->Release();
impl_->defaultRenderTargetView_ = 0;
}
if (impl_->defaultDepthStencilView_)
{
impl_->defaultDepthStencilView_->Release();
impl_->defaultDepthStencilView_ = 0;
}
if (impl_->defaultDepthTexture_)
{
impl_->defaultDepthTexture_->Release();
impl_->defaultDepthTexture_ = 0;
}
if (impl_->resolveTexture_)
{
impl_->resolveTexture_->Release();
impl_->resolveTexture_ = 0;
}
impl_->depthStencilView_ = 0;
for (unsigned i = 0; i < MAX_RENDERTARGETS; ++i)
impl_->renderTargetViews_[i] = 0;
impl_->renderTargetsDirty_ = true;
impl_->swapChain_->ResizeBuffers(1, (UINT)width, (UINT)height, DXGI_FORMAT_UNKNOWN, DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH);
// Create default rendertarget view representing the backbuffer
ID3D11Texture2D* backbufferTexture;
HRESULT hr = impl_->swapChain_->GetBuffer(0, IID_ID3D11Texture2D, (void**)&backbufferTexture);
if (FAILED(hr))
{
CROSS_SAFE_RELEASE(backbufferTexture);
CROSS_LOGD3DERROR("Failed to get backbuffer texture", hr);
success = false;
}
else
{
hr = impl_->device_->CreateRenderTargetView(backbufferTexture, 0, &impl_->defaultRenderTargetView_);
backbufferTexture->Release();
if (FAILED(hr))
{
CROSS_SAFE_RELEASE(impl_->defaultRenderTargetView_);
CROSS_LOGD3DERROR("Failed to create backbuffer rendertarget view", hr);
success = false;
}
}
// Create default depth-stencil texture and view
D3D11_TEXTURE2D_DESC depthDesc;
memset(&depthDesc, 0, sizeof depthDesc);
depthDesc.Width = (UINT)width;
depthDesc.Height = (UINT)height;
depthDesc.MipLevels = 1;
depthDesc.ArraySize = 1;
depthDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthDesc.SampleDesc.Count = (UINT)multiSample_;
depthDesc.SampleDesc.Quality = impl_->GetMultiSampleQuality(depthDesc.Format, multiSample_);
depthDesc.Usage = D3D11_USAGE_DEFAULT;
depthDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
depthDesc.CPUAccessFlags = 0;
depthDesc.MiscFlags = 0;
hr = impl_->device_->CreateTexture2D(&depthDesc, 0, &impl_->defaultDepthTexture_);
if (FAILED(hr))
{
CROSS_SAFE_RELEASE(impl_->defaultDepthTexture_);
CROSS_LOGD3DERROR("Failed to create backbuffer depth-stencil texture", hr);
success = false;
}
else
{
hr = impl_->device_->CreateDepthStencilView(impl_->defaultDepthTexture_, 0, &impl_->defaultDepthStencilView_);
if (FAILED(hr))
{
CROSS_SAFE_RELEASE(impl_->defaultDepthStencilView_);
CROSS_LOGD3DERROR("Failed to create backbuffer depth-stencil view", hr);
success = false;
}
}
// Update internally held backbuffer size
width_ = width;
height_ = height;
ResetRenderTargets();
return success;
}
void Graphics::CheckFeatureSupport()
{
anisotropySupport_ = true;
dxtTextureSupport_ = true;
lightPrepassSupport_ = true;
deferredSupport_ = true;
hardwareShadowSupport_ = true;
instancingSupport_ = true;
shadowMapFormat_ = DXGI_FORMAT_R16_TYPELESS;
hiresShadowMapFormat_ = DXGI_FORMAT_R32_TYPELESS;
dummyColorFormat_ = DXGI_FORMAT_UNKNOWN;
sRGBSupport_ = true;
sRGBWriteSupport_ = true;
}
void Graphics::ResetCachedState()
{
for (unsigned i = 0; i < MAX_VERTEX_STREAMS; ++i)
{
vertexBuffers_[i] = 0;
impl_->vertexBuffers_[i] = 0;
impl_->vertexSizes_[i] = 0;
impl_->vertexOffsets_[i] = 0;
}
for (unsigned i = 0; i < MAX_TEXTURE_UNITS; ++i)
{
textures_[i] = 0;
impl_->shaderResourceViews_[i] = 0;
impl_->samplers_[i] = 0;
}
for (unsigned i = 0; i < MAX_RENDERTARGETS; ++i)
{
renderTargets_[i] = 0;
impl_->renderTargetViews_[i] = 0;
}
for (unsigned i = 0; i < MAX_SHADER_PARAMETER_GROUPS; ++i)
{
impl_->constantBuffers_[VS][i] = 0;
impl_->constantBuffers_[PS][i] = 0;
}
depthStencil_ = 0;
impl_->depthStencilView_ = 0;
viewport_ = IntRect(0, 0, width_, height_);
indexBuffer_ = 0;
vertexDeclarationHash_ = 0;
primitiveType_ = 0;
vertexShader_ = 0;
pixelShader_ = 0;
blendMode_ = BLEND_REPLACE;
alphaToCoverage_ = false;
colorWrite_ = true;
cullMode_ = CULL_CCW;
constantDepthBias_ = 0.0f;
slopeScaledDepthBias_ = 0.0f;
depthTestMode_ = CMP_LESSEQUAL;
depthWrite_ = true;
fillMode_ = FILL_SOLID;
lineAntiAlias_ = false;
scissorTest_ = false;
scissorRect_ = IntRect::ZERO;
stencilTest_ = false;
stencilTestMode_ = CMP_ALWAYS;
stencilPass_ = OP_KEEP;
stencilFail_ = OP_KEEP;
stencilZFail_ = OP_KEEP;
stencilRef_ = 0;
stencilCompareMask_ = M_MAX_UNSIGNED;
stencilWriteMask_ = M_MAX_UNSIGNED;
useClipPlane_ = false;
impl_->shaderProgram_ = 0;
impl_->renderTargetsDirty_ = true;
impl_->texturesDirty_ = true;
impl_->vertexDeclarationDirty_ = true;
impl_->blendStateDirty_ = true;
impl_->depthStateDirty_ = true;
impl_->rasterizerStateDirty_ = true;
impl_->scissorRectDirty_ = true;
impl_->stencilRefDirty_ = true;
impl_->blendStateHash_ = M_MAX_UNSIGNED;
impl_->depthStateHash_ = M_MAX_UNSIGNED;
impl_->rasterizerStateHash_ = M_MAX_UNSIGNED;
impl_->firstDirtyTexture_ = impl_->lastDirtyTexture_ = M_MAX_UNSIGNED;
impl_->firstDirtyVB_ = impl_->lastDirtyVB_ = M_MAX_UNSIGNED;
impl_->dirtyConstantBuffers_.Clear();
}
void Graphics::PrepareDraw()
{
if (impl_->renderTargetsDirty_)
{
impl_->depthStencilView_ =
(depthStencil_ && depthStencil_->GetUsage() == TEXTURE_DEPTHSTENCIL) ?
(ID3D11DepthStencilView*)depthStencil_->GetRenderTargetView() : impl_->defaultDepthStencilView_;
// If possible, bind a read-only depth stencil view to allow reading depth in shader
if (!depthWrite_ && depthStencil_ && depthStencil_->GetReadOnlyView())
impl_->depthStencilView_ = (ID3D11DepthStencilView*)depthStencil_->GetReadOnlyView();
for (unsigned i = 0; i < MAX_RENDERTARGETS; ++i)
impl_->renderTargetViews_[i] =
(renderTargets_[i] && renderTargets_[i]->GetUsage() == TEXTURE_RENDERTARGET) ?
(ID3D11RenderTargetView*)renderTargets_[i]->GetRenderTargetView() : 0;
// If rendertarget 0 is null and not doing depth-only rendering, render to the backbuffer
// Special case: if rendertarget 0 is null and depth stencil has same size as backbuffer, assume the intention is to do
// backbuffer rendering with a custom depth stencil
if (!renderTargets_[0] &&
(!depthStencil_ || (depthStencil_ && depthStencil_->GetWidth() == width_ && depthStencil_->GetHeight() == height_)))
impl_->renderTargetViews_[0] = impl_->defaultRenderTargetView_;
impl_->deviceContext_->OMSetRenderTargets(MAX_RENDERTARGETS, &impl_->renderTargetViews_[0], impl_->depthStencilView_);
impl_->renderTargetsDirty_ = false;
}
if (impl_->texturesDirty_ && impl_->firstDirtyTexture_ < M_MAX_UNSIGNED)
{
// Set also VS textures to enable vertex texture fetch to work the same way as on OpenGL
impl_->deviceContext_->VSSetShaderResources(impl_->firstDirtyTexture_, impl_->lastDirtyTexture_ - impl_->firstDirtyTexture_ + 1,
&impl_->shaderResourceViews_[impl_->firstDirtyTexture_]);
impl_->deviceContext_->VSSetSamplers(impl_->firstDirtyTexture_, impl_->lastDirtyTexture_ - impl_->firstDirtyTexture_ + 1,
&impl_->samplers_[impl_->firstDirtyTexture_]);
impl_->deviceContext_->PSSetShaderResources(impl_->firstDirtyTexture_, impl_->lastDirtyTexture_ - impl_->firstDirtyTexture_ + 1,
&impl_->shaderResourceViews_[impl_->firstDirtyTexture_]);
impl_->deviceContext_->PSSetSamplers(impl_->firstDirtyTexture_, impl_->lastDirtyTexture_ - impl_->firstDirtyTexture_ + 1,
&impl_->samplers_[impl_->firstDirtyTexture_]);
impl_->firstDirtyTexture_ = impl_->lastDirtyTexture_ = M_MAX_UNSIGNED;
impl_->texturesDirty_ = false;
}
if (impl_->vertexDeclarationDirty_ && vertexShader_ && vertexShader_->GetByteCode().Size())
{
if (impl_->firstDirtyVB_ < M_MAX_UNSIGNED)
{
impl_->deviceContext_->IASetVertexBuffers(impl_->firstDirtyVB_, impl_->lastDirtyVB_ - impl_->firstDirtyVB_ + 1,
&impl_->vertexBuffers_[impl_->firstDirtyVB_], &impl_->vertexSizes_[impl_->firstDirtyVB_], &impl_->vertexOffsets_[impl_->firstDirtyVB_]);
impl_->firstDirtyVB_ = impl_->lastDirtyVB_ = M_MAX_UNSIGNED;
}
unsigned long long newVertexDeclarationHash = 0;
for (unsigned i = 0; i < MAX_VERTEX_STREAMS; ++i)
{
if (vertexBuffers_[i])
newVertexDeclarationHash |= vertexBuffers_[i]->GetBufferHash(i);
}
// Do not create input layout if no vertex buffers / elements
if (newVertexDeclarationHash)
{
/// \todo Using a 64bit total hash for vertex shader and vertex buffer elements hash may not guarantee uniqueness
newVertexDeclarationHash += vertexShader_->GetElementHash();
if (newVertexDeclarationHash != vertexDeclarationHash_)
{
VertexDeclarationMap::Iterator i =
impl_->vertexDeclarations_.Find(newVertexDeclarationHash);
if (i == impl_->vertexDeclarations_.End())
{
SharedPtr<VertexDeclaration> newVertexDeclaration(new VertexDeclaration(this, vertexShader_, vertexBuffers_));
i = impl_->vertexDeclarations_.Insert(MakePair(newVertexDeclarationHash, newVertexDeclaration));
}
impl_->deviceContext_->IASetInputLayout((ID3D11InputLayout*)i->second_->GetInputLayout());
vertexDeclarationHash_ = newVertexDeclarationHash;
}
}
impl_->vertexDeclarationDirty_ = false;
}
if (impl_->blendStateDirty_)
{
unsigned newBlendStateHash = (unsigned)((colorWrite_ ? 1 : 0) | (alphaToCoverage_ ? 2 : 0) | (blendMode_ << 2));
if (newBlendStateHash != impl_->blendStateHash_)
{
HashMap<unsigned, ID3D11BlendState*>::Iterator i = impl_->blendStates_.Find(newBlendStateHash);
if (i == impl_->blendStates_.End())
{
CROSS_PROFILE(CreateBlendState);
D3D11_BLEND_DESC stateDesc;
memset(&stateDesc, 0, sizeof stateDesc);
stateDesc.AlphaToCoverageEnable = alphaToCoverage_ ? TRUE : FALSE;
stateDesc.IndependentBlendEnable = false;
stateDesc.RenderTarget[0].BlendEnable = d3dBlendEnable[blendMode_];
stateDesc.RenderTarget[0].SrcBlend = d3dSrcBlend[blendMode_];
stateDesc.RenderTarget[0].DestBlend = d3dDestBlend[blendMode_];
stateDesc.RenderTarget[0].BlendOp = d3dBlendOp[blendMode_];
stateDesc.RenderTarget[0].SrcBlendAlpha = d3dSrcBlend[blendMode_];
stateDesc.RenderTarget[0].DestBlendAlpha = d3dDestBlend[blendMode_];
stateDesc.RenderTarget[0].BlendOpAlpha = d3dBlendOp[blendMode_];
stateDesc.RenderTarget[0].RenderTargetWriteMask = colorWrite_ ? D3D11_COLOR_WRITE_ENABLE_ALL : 0x0;
ID3D11BlendState* newBlendState = 0;
HRESULT hr = impl_->device_->CreateBlendState(&stateDesc, &newBlendState);
if (FAILED(hr))
{
CROSS_SAFE_RELEASE(newBlendState);
CROSS_LOGD3DERROR("Failed to create blend state", hr);
}
i = impl_->blendStates_.Insert(MakePair(newBlendStateHash, newBlendState));
}
impl_->deviceContext_->OMSetBlendState(i->second_, 0, M_MAX_UNSIGNED);
impl_->blendStateHash_ = newBlendStateHash;
}
impl_->blendStateDirty_ = false;
}
if (impl_->depthStateDirty_)
{
unsigned newDepthStateHash =
(depthWrite_ ? 1 : 0) | (stencilTest_ ? 2 : 0) | (depthTestMode_ << 2) | ((stencilCompareMask_ & 0xff) << 5) |
((stencilWriteMask_ & 0xff) << 13) | (stencilTestMode_ << 21) |
((stencilFail_ + stencilZFail_ * 5 + stencilPass_ * 25) << 24);
if (newDepthStateHash != impl_->depthStateHash_ || impl_->stencilRefDirty_)
{
HashMap<unsigned, ID3D11DepthStencilState*>::Iterator i = impl_->depthStates_.Find(newDepthStateHash);
if (i == impl_->depthStates_.End())
{
CROSS_PROFILE(CreateDepthState);
D3D11_DEPTH_STENCIL_DESC stateDesc;
memset(&stateDesc, 0, sizeof stateDesc);
stateDesc.DepthEnable = TRUE;
stateDesc.DepthWriteMask = depthWrite_ ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
stateDesc.DepthFunc = d3dCmpFunc[depthTestMode_];
stateDesc.StencilEnable = stencilTest_ ? TRUE : FALSE;
stateDesc.StencilReadMask = (unsigned char)stencilCompareMask_;
stateDesc.StencilWriteMask = (unsigned char)stencilWriteMask_;
stateDesc.FrontFace.StencilFailOp = d3dStencilOp[stencilFail_];
stateDesc.FrontFace.StencilDepthFailOp = d3dStencilOp[stencilZFail_];
stateDesc.FrontFace.StencilPassOp = d3dStencilOp[stencilPass_];
stateDesc.FrontFace.StencilFunc = d3dCmpFunc[stencilTestMode_];
stateDesc.BackFace.StencilFailOp = d3dStencilOp[stencilFail_];
stateDesc.BackFace.StencilDepthFailOp = d3dStencilOp[stencilZFail_];
stateDesc.BackFace.StencilPassOp = d3dStencilOp[stencilPass_];
stateDesc.BackFace.StencilFunc = d3dCmpFunc[stencilTestMode_];
ID3D11DepthStencilState* newDepthState = 0;
HRESULT hr = impl_->device_->CreateDepthStencilState(&stateDesc, &newDepthState);
if (FAILED(hr))
{
CROSS_SAFE_RELEASE(newDepthState);
CROSS_LOGD3DERROR("Failed to create depth state", hr);
}
i = impl_->depthStates_.Insert(MakePair(newDepthStateHash, newDepthState));
}
impl_->deviceContext_->OMSetDepthStencilState(i->second_, stencilRef_);
impl_->depthStateHash_ = newDepthStateHash;
}
impl_->depthStateDirty_ = false;
impl_->stencilRefDirty_ = false;
}
if (impl_->rasterizerStateDirty_)
{
unsigned depthBits = 24;
if (depthStencil_ && depthStencil_->GetParentTexture()->GetFormat() == DXGI_FORMAT_R16_TYPELESS)
depthBits = 16;
int scaledDepthBias = (int)(constantDepthBias_ * (1 << depthBits));
unsigned newRasterizerStateHash =
(scissorTest_ ? 1 : 0) | (lineAntiAlias_ ? 2 : 0) | (fillMode_ << 2) | (cullMode_ << 4) |
((scaledDepthBias & 0x1fff) << 6) | (((int)(slopeScaledDepthBias_ * 100.0f) & 0x1fff) << 19);
if (newRasterizerStateHash != impl_->rasterizerStateHash_)
{
HashMap<unsigned, ID3D11RasterizerState*>::Iterator i = impl_->rasterizerStates_.Find(newRasterizerStateHash);
if (i == impl_->rasterizerStates_.End())
{
CROSS_PROFILE(CreateRasterizerState);
D3D11_RASTERIZER_DESC stateDesc;
memset(&stateDesc, 0, sizeof stateDesc);
stateDesc.FillMode = d3dFillMode[fillMode_];
stateDesc.CullMode = d3dCullMode[cullMode_];
stateDesc.FrontCounterClockwise = FALSE;
stateDesc.DepthBias = scaledDepthBias;
stateDesc.DepthBiasClamp = M_INFINITY;
stateDesc.SlopeScaledDepthBias = slopeScaledDepthBias_;
stateDesc.DepthClipEnable = TRUE;
stateDesc.ScissorEnable = scissorTest_ ? TRUE : FALSE;
stateDesc.MultisampleEnable = lineAntiAlias_ ? FALSE : TRUE;
stateDesc.AntialiasedLineEnable = lineAntiAlias_ ? TRUE : FALSE;
ID3D11RasterizerState* newRasterizerState = 0;
HRESULT hr = impl_->device_->CreateRasterizerState(&stateDesc, &newRasterizerState);
if (FAILED(hr))
{
CROSS_SAFE_RELEASE(newRasterizerState);
CROSS_LOGD3DERROR("Failed to create rasterizer state", hr);
}
i = impl_->rasterizerStates_.Insert(MakePair(newRasterizerStateHash, newRasterizerState));
}
impl_->deviceContext_->RSSetState(i->second_);
impl_->rasterizerStateHash_ = newRasterizerStateHash;
}
impl_->rasterizerStateDirty_ = false;
}
if (impl_->scissorRectDirty_)
{
D3D11_RECT d3dRect;
d3dRect.left = scissorRect_.left_;
d3dRect.top = scissorRect_.top_;
d3dRect.right = scissorRect_.right_;
d3dRect.bottom = scissorRect_.bottom_;
impl_->deviceContext_->RSSetScissorRects(1, &d3dRect);
impl_->scissorRectDirty_ = false;
}
for (unsigned i = 0; i < impl_->dirtyConstantBuffers_.Size(); ++i)
impl_->dirtyConstantBuffers_[i]->Apply();
impl_->dirtyConstantBuffers_.Clear();
}
void Graphics::CreateResolveTexture()
{
if (impl_->resolveTexture_)
return;
D3D11_TEXTURE2D_DESC textureDesc;
memset(&textureDesc, 0, sizeof textureDesc);
textureDesc.Width = (UINT)width_;
textureDesc.Height = (UINT)height_;
textureDesc.MipLevels = 1;
textureDesc.ArraySize = 1;
textureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
textureDesc.SampleDesc.Count = 1;
textureDesc.SampleDesc.Quality = 0;
textureDesc.Usage = D3D11_USAGE_DEFAULT;
textureDesc.CPUAccessFlags = 0;
HRESULT hr = impl_->device_->CreateTexture2D(&textureDesc, 0, &impl_->resolveTexture_);
if (FAILED(hr))
{
CROSS_SAFE_RELEASE(impl_->resolveTexture_);
CROSS_LOGD3DERROR("Could not create resolve texture", hr);
}
}
void Graphics::SetTextureUnitMappings()
{
textureUnits_["DiffMap"] = TU_DIFFUSE;
textureUnits_["DiffCubeMap"] = TU_DIFFUSE;
textureUnits_["NormalMap"] = TU_NORMAL;
textureUnits_["SpecMap"] = TU_SPECULAR;
textureUnits_["EmissiveMap"] = TU_EMISSIVE;
textureUnits_["EnvMap"] = TU_ENVIRONMENT;
textureUnits_["EnvCubeMap"] = TU_ENVIRONMENT;
textureUnits_["LightRampMap"] = TU_LIGHTRAMP;
textureUnits_["LightSpotMap"] = TU_LIGHTSHAPE;
textureUnits_["LightCubeMap"] = TU_LIGHTSHAPE;
textureUnits_["ShadowMap"] = TU_SHADOWMAP;
textureUnits_["FaceSelectCubeMap"] = TU_FACESELECT;
textureUnits_["IndirectionCubeMap"] = TU_INDIRECTION;
textureUnits_["VolumeMap"] = TU_VOLUMEMAP;
textureUnits_["ZoneCubeMap"] = TU_ZONE;
textureUnits_["ZoneVolumeMap"] = TU_ZONE;
}
// CROSS BEGIN
// To satisfy script binding linking
void Graphics::SetTextureForUpdate(Texture* texture)
{
}
void Graphics::MarkFBODirty()
{
}
void Graphics::SetVBO(unsigned object)
{
}
void Graphics::SetUBO(unsigned object)
{
}
// CROSS END
}
| [
"[email protected]"
] | |
f68ed236c631e86121bc8d319e7175f99397a141 | 73a539e11f3b1e929b9c81c1cda9f39186360be1 | /source/event/event_untlity.cc | 985a2177c3eedfa98110ab3c3c7076d6fd6962b0 | [] | no_license | csky6688/libuv-evpp | ceefab9afd5c97fc8aceac40c4d18580208ec185 | 33ecccd910a8394af1a5c71cb859f6e1525a8146 | refs/heads/master | 2023-02-22T12:29:49.026081 | 2021-01-28T11:16:09 | 2021-01-28T11:16:09 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,266 | cc | #include <event_untlity.h>
#include <tcp_session.h>
#include <event_loop.h>
#include <config.h>
#include <buffer.h>
namespace Evpp
{
namespace Import
{
std::string send_data = "hello";
bool DefaultAccepts(EventLoop* loop, const std::shared_ptr<TcpSession>& session, const u96 index)
{
(void)loop, session, index;
printf("DefaultAccepts:%d Thread:%d\n", index, loop->EventThreadId());
return true;
}
bool DefaultDiscons(EventLoop* loop, const u96 index)
{
(void)loop, index;
printf("DefaultDiscons:%d Thread:%d\n", index, loop->EventThreadId());
return true;
}
bool DefaultMessage(EventLoop* loop, const std::shared_ptr<TcpSession>& session, const std::shared_ptr<TcpBuffer>& buffer, const u96 index)
{
(void)loop, session, buffer, index;
//printf("用户消息:%d 消息长度:%d 线程:%d\n", index, buffer->readableBytes(), loop->EventThreadId());
//buffer->retrieve(buffer->readableBytes());
//thread_local std::string send_str = send_data + std::to_string(index) + "\n";
printf("Message:%d MessageLen:%d Thread:%d\n", index, buffer->readableBytes(), loop->EventThreadId());
session->Send(send_data + std::to_string(index) + "\n" + char(10));
buffer->retrieve(buffer->readableBytes());
return true;
}
bool DefaultConnect(EventLoop* loop, const std::shared_ptr<TcpSession>& session, const u96 index)
{
(void)loop, session, index;
return true;
}
bool DefaultRestore(EventLoop* loop, const std::shared_ptr<TcpSession>& session, const u96 index)
{
(void)loop, session, index;
printf("重新连接成功\n");
return true;
}
bool DefaultFailure(EventLoop* loop, const u96 index, const i32 status, const String* name, const String* msgs)
{
(void)loop, index, status, name, msgs;
printf("与服务器连接失败 - index:%d - status:%d - name:%s - msgs:%s\n", index, status, name, msgs);
return true;
}
}
} | [
"[email protected]"
] | |
2c6e7699963d6824f3667b2588a6854b7e0e1d24 | e00f0be7179fdfe87f87475984dfdc55acdab16a | /7zip_4_65/CPP/7zip/Archive/DllExports.cpp | bfb7ba295283f3965f13354bea6593ae56e2d9ff | [] | no_license | BIAINC/7Zip | 5ee647c9d3d02e127a6793bc47075848c97fd4be | aecbbd0bc9612fac8676ab8caf521be64575bd62 | refs/heads/master | 2021-01-01T05:51:58.730009 | 2014-09-04T23:40:09 | 2014-09-04T23:40:09 | 9,531,434 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,310 | cpp | // DLLExports.cpp
#include "StdAfx.h"
#include "../../Common/MyInitGuid.h"
#include "../../Common/ComTry.h"
#include "../../Common/Types.h"
#include "../../Windows/PropVariant.h"
#include "IArchive.h"
#include "../ICoder.h"
#include "../IPassword.h"
HINSTANCE g_hInstance;
#ifndef _UNICODE
bool g_IsNT = false;
static bool IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
#endif
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
g_hInstance = hInstance;
#ifndef _UNICODE
g_IsNT = IsItWindowsNT();
#endif
}
return TRUE;
}
DEFINE_GUID(CLSID_CArchiveHandler,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00);
STDAPI CreateArchiver(const GUID *classID, const GUID *iid, void **outObject);
STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
{
return CreateArchiver(clsid, iid, outObject);
}
STDAPI SetLargePageMode()
{
#if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
SetLargePageSize();
#endif
return S_OK;
}
| [
"[email protected]"
] | |
79678983b131fde3db7b8a68cd96c9b8f044e8a1 | 5ebd5cee801215bc3302fca26dbe534e6992c086 | /blaze/math/constraints/MatMapExpr.h | e8e8b0d3ca95ec3fd0f5b2b471abf98e1b6bc334 | [
"BSD-3-Clause"
] | permissive | mhochsteger/blaze | c66d8cf179deeab4f5bd692001cc917fe23e1811 | fd397e60717c4870d942055496d5b484beac9f1a | refs/heads/master | 2020-09-17T01:56:48.483627 | 2019-11-20T05:40:29 | 2019-11-20T05:41:35 | 223,951,030 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,112 | h | //=================================================================================================
/*!
// \file blaze/math/constraints/MatMapExpr.h
// \brief Constraint on the data type
//
// Copyright (C) 2012-2019 Klaus Iglberger - All Rights Reserved
//
// This file is part of the Blaze library. You can redistribute it and/or modify it under
// the terms of the New (Revised) BSD License. Redistribution and use in source and binary
// forms, with or without modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
// 3. Neither the names of the Blaze development group nor the names of its contributors
// may be used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
*/
//=================================================================================================
#ifndef _BLAZE_MATH_CONSTRAINTS_MATMAPEXPR_H_
#define _BLAZE_MATH_CONSTRAINTS_MATMAPEXPR_H_
//*************************************************************************************************
// Includes
//*************************************************************************************************
#include <blaze/math/typetraits/IsMatMapExpr.h>
namespace blaze {
//=================================================================================================
//
// MUST_BE_MATMAPEXPR_TYPE CONSTRAINT
//
//=================================================================================================
//*************************************************************************************************
/*!\brief Constraint on the data type.
// \ingroup math_constraints
//
// In case the given data type \a T is not a unary matrix map expression (i.e. a type derived
// from the MatMapExpr base class), a compilation error is created.
*/
#define BLAZE_CONSTRAINT_MUST_BE_MATMAPEXPR_TYPE(T) \
static_assert( ::blaze::IsMatMapExpr_v<T>, "Non-unary matrix map expression type detected" )
//*************************************************************************************************
//=================================================================================================
//
// MUST_NOT_BE_MATMAPEXPR_TYPE CONSTRAINT
//
//=================================================================================================
//*************************************************************************************************
/*!\brief Constraint on the data type.
// \ingroup math_constraints
//
// In case the given data type \a T is a unary matrix map expression (i.e. a type derived from
// the MatMapExpr base class), a compilation error is created.
*/
#define BLAZE_CONSTRAINT_MUST_NOT_BE_MATMAPEXPR_TYPE(T) \
static_assert( !::blaze::IsMatMapExpr_v<T>, "Unary matrix map expression type detected" )
//*************************************************************************************************
} // namespace blaze
#endif
| [
"[email protected]"
] | |
dcf6e7c0fa3eaef4fd2e348b173a1e2dd5643cae | b475d6c2f875a149e0e8c722240af1c8d661c5ca | /moveZeroes.cc | 66dcbeee78593cdca0abee822833d3893c429b47 | [] | no_license | hankers/my_leetcode | 00139ae31d26460c8b01adde8f479243dabc121d | fa05cca504d8531726d65eaa1250a233812436cc | refs/heads/master | 2021-01-21T07:44:37.379144 | 2016-01-06T14:00:38 | 2016-01-06T14:00:38 | 27,265,616 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 844 | cc | // Source : https://leetcode.com/problems/move-zeroes/
// Author : hanker
// Date : 2015-12-10
/**********************************************************************************
* Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.
*
* For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums should be [1, 3, 12, 0, 0].
***********************************************************************************/
class Solution {
public:
void moveZeroes(vector<int>& nums) {
int pos = 0;
for (int i = 0; i < nums.size(); i ++) {
if (nums[i] != 0) {
nums[pos ++] = nums[i];
}
}
for (int i = pos; i < nums.size(); i ++) {
nums[i] = 0;
}
}
};
| [
"[email protected]"
] | |
d21dfb9873e91155e3f79289435f02a9fb61fec8 | 864e42081eaaeb58a4e13033c0ec6e66cad813da | /src/main.cpp | 219d49d9f3d407b1612f8b9914b642b3560ea284 | [] | no_license | selavy/tictac | beca2e574625f82f3cb21f42b5de6bc9a9cb3c8f | 842c628d2a34c6fa2d9134e9e6cfc92422e51f02 | refs/heads/master | 2020-12-02T00:51:53.012465 | 2020-01-11T18:11:41 | 2020-01-11T18:11:41 | 230,836,056 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,346 | cpp | #include "tictac.h"
#include <assert.h>
#include <climits>
#include <iostream>
#include <readline/history.h>
#include <readline/readline.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <string>
void print(Board b) {
for (int y = 0; y < 3; ++y) {
for (int x = 0; x < 3; ++x) {
int i = 3 * y + x;
char c = b.xplayed(i) ? 'X' : b.oplayed(i) ? 'O' : /*' '*/ i + '1';
if (x != 2)
printf(" %c |", c);
else if (y != 2)
printf(" %c\n-----------\n", c);
else
printf(" %c\n", c);
}
}
}
int negamax(Board board, int color, int depth) {
if (board.xwin())
return color * 100;
else if (board.owin())
return color * -100;
else if (board.tie())
return color * -10;
int value = INT_MIN;
Moves moves = board.genmoves();
assert(moves.length() != 0);
for (auto move : moves) {
board.make_move(move);
value = std::max(value, -negamax(board, -color, depth - 1));
board.undo_move(move);
}
assert(value != INT_MIN);
return value;
}
int search(Board board) {
int mult = board.xtm() ? -1 : 1;
int bestscore = INT_MIN;
int bestmove = -1;
Moves moves = board.genmoves();
for (int i = 0; i < moves.length(); ++i) {
int move = moves[i];
board.make_move(move);
int score = -negamax(board, mult, 9);
board.undo_move(move);
if (score > bestscore) {
bestscore = score;
bestmove = move;
}
}
assert(bestmove != -1);
return bestmove;
}
int get_move(Board board) {
int x = -1;
char *input;
do {
if ((input = readline("Move? (1-9) ")) == NULL) {
exit(0);
}
x = input ? input[0] - '1' : -1;
free(input);
} while (!board.is_valid(x));
printf("\n");
return x;
}
bool check_win(Board board) {
if (board.xwin()) {
print(board);
std::cout << "\nX's win!\n";
return true;
} else if (board.owin()) {
print(board);
std::cout << "\nO's win!\n";
return true;
} else if (board.tie()) {
print(board);
std::cout << "\nCat's game!\n";
return true;
}
return false;
}
int main(int argc, char **argv) {
// max possible states is bounded by 9! = 362880, likely can reduce
// this upper bound because many states end early from a win.
// static Board stk[1 << 19];
bool human_is_x = true;
bool okay = false;
do {
char *input = readline("Play X's? [Y/n] ");
if (!input) {
exit(0);
} else if (input[0] == '\0' || input[0] == 'Y' || input[0] == 'y') {
human_is_x = true;
okay = true;
} else if (input[0] == 'N' || input[0] == 'n') {
human_is_x = false;
okay = true;
}
free(input);
} while (!okay);
printf("\n\n");
Board board;
int move;
for (;;) {
if (check_win(board))
break;
if (board.xtm() == human_is_x) {
print(board);
printf("\n");
move = get_move(board);
} else {
move = search(board);
}
board.make_move(move);
}
return 0;
}
| [
"[email protected]"
] | |
aa1cf1f3ed6f13e4a0b2271d4ec4ce1eb0756087 | b65288060f800ab1456f9f0183864742669dae15 | /source/Graphics/Shader.cpp | 861c7502d27de4049b2b1a3282c042eca402e230 | [] | no_license | lud99/FlappyBirdNX | 30f989c1258676b4d0c3b4e085d1094259ecfb79 | 6857cb7e2243ecefc3bebbcc2413124dd3018f04 | refs/heads/master | 2023-02-06T06:55:35.066964 | 2020-12-29T12:51:32 | 2020-12-29T12:51:32 | 325,091,697 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,944 | cpp | #include "Shader.h"
#include <glad/glad.h>
#include <glm/gtc/type_ptr.hpp>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <sstream>
Shader::Shader()
{
}
Shader::Shader(unsigned int shaderProgramId) : m_id(shaderProgramId)
{
}
int Shader::GetUniformLocation(const std::string& name)
{
// Return it if it's already cached
if (m_UniformLocations.count(name) > 0)
return m_UniformLocations[name];
int location = glGetUniformLocation(m_id, name.c_str());
m_UniformLocations[name] = location;
return location;
}
void Shader::Bind()
{
glUseProgram(m_id);
}
void Shader::Unbind()
{
glUseProgram(0);
}
void Shader::SetUniform(const std::string& name, glm::vec2 vector)
{
glUniform2f(GetUniformLocation(name.c_str()), vector.x, vector.y);
}
void Shader::SetUniform(const std::string& name, glm::ivec2 vector)
{
glUniform2i(GetUniformLocation(name.c_str()), vector.x, vector.y);
}
void Shader::SetUniform(const std::string& name, glm::vec3 vector)
{
glUniform3f(GetUniformLocation(name.c_str()), vector.x, vector.y, vector.z);
}
void Shader::SetUniform(const std::string& name, glm::ivec3 vector)
{
glUniform3i(GetUniformLocation(name.c_str()), vector.x, vector.y, vector.z);
}
void Shader::SetUniform(const std::string& name, glm::mat4 matrix)
{
glUniformMatrix4fv(GetUniformLocation(name.c_str()), 1, GL_FALSE, glm::value_ptr(matrix));
}
void Shader::SetUniform(const std::string& name, float value)
{
glUniform1f(GetUniformLocation(name.c_str()), value);
}
void Shader::SetUniform(const std::string& name, int value)
{
glUniform1i(GetUniformLocation(name.c_str()), value);
}
void Shader::Delete()
{
glDeleteProgram(m_id);
printf("Shader delete");
}
Shader::~Shader()
{
}
std::string ShaderLoader::ParseShader(const std::string& filepath)
{
std::ifstream stream(filepath);
//assert(!stream.is_open() && "Invalid file specified");
std::string line;
std::stringstream shaderStringStream;
while (getline(stream, line)) {
shaderStringStream << line << "\n";
}
printf(shaderStringStream.str().c_str());
return shaderStringStream.str();
}
Shader ShaderLoader::CreateShader(const std::string& vertexPath, const std::string& fragmentPath)
{
unsigned int program = glCreateProgram();
unsigned int vertex = CompileShader(GL_VERTEX_SHADER, ParseShader(vertexPath));
unsigned int fragment = CompileShader(GL_FRAGMENT_SHADER, ParseShader(fragmentPath));
glAttachShader(program, vertex);
glAttachShader(program, fragment);
glLinkProgram(program);
glValidateProgram(program);
glDeleteShader(vertex);
glDeleteShader(fragment);
return Shader(program);
}
Shader ShaderLoader::CreateShaderFromSource(const std::string& vertexSource, const std::string& fragmentSource)
{
unsigned int program = glCreateProgram();
unsigned int vertex = CompileShader(GL_VERTEX_SHADER, vertexSource);
unsigned int fragment = CompileShader(GL_FRAGMENT_SHADER, fragmentSource);
glAttachShader(program, vertex);
glAttachShader(program, fragment);
glLinkProgram(program);
glValidateProgram(program);
glDeleteShader(vertex);
glDeleteShader(fragment);
return Shader(program);
}
Shader ShaderLoader::CreateShader()
{
return Shader(0);
}
unsigned int ShaderLoader::CompileShader(unsigned int type, const std::string& source)
{
unsigned int id = glCreateShader(type);
const char* src = source.c_str();
glShaderSource(id, 1, &src, nullptr);
glCompileShader(id);
// Get the compilation status
int result;
glGetShaderiv(id, GL_COMPILE_STATUS, &result);
// If the shader couldn't compile
if (result == GL_FALSE)
{
int length;
glGetShaderiv(id, GL_INFO_LOG_LENGTH, &length);
// Create char array
char* message = new char[length];
glGetShaderInfoLog(id, length, &length, message); // Get the actual message
std::cout << "Failed to compile shader " << source << std::endl;
std::cout << message << std::endl;
glDeleteShader(id);
return 0;
}
return id;
} | [
"[email protected]"
] | |
48a4d335014de2b3dfbc217f92cbac297139b319 | 970a44d955670032360303f03d597c13b20551fb | /pillbutton.h | 92ca40fbd3ca39b39cd3de23d73fdf7d80d0ba59 | [] | no_license | kolya-t/PillClicker | e73657aad1cf64e9908750b315979a310ce1333e | 420710108df963cab4c7c0c9acab178fd6a02910 | refs/heads/master | 2021-01-10T18:34:32.644400 | 2016-04-18T19:46:37 | 2016-04-18T19:46:37 | 56,455,879 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 482 | h | #ifndef PILLBUTTON_H
#define PILLBUTTON_H
#include <QLabel>
class PillButton : public QLabel
{
Q_OBJECT
public:
explicit PillButton(QWidget *parent = 0);
explicit PillButton(QWidget *parent, QPixmap px);
signals:
void clicked();
public slots:
protected:
void mousePressEvent(QMouseEvent *ev);
void mouseReleaseEvent(QMouseEvent *ev);
void enterEvent(QEvent *);
void leaveEvent(QEvent *);
private:
QPixmap pixmap;
};
#endif // PILLBUTTON_H
| [
"[email protected]"
] | |
7fdb7417c12963e73bee2797d8f19e6731fef377 | e30a92d3c06e8bf6d0c463f88016f988b1d1eb03 | /ex9_4b/main.cpp | c4064c0a5c7c0a3f9aa2f0f53ce129469c165198 | [] | no_license | surfmich/SoftwareProjects | 70c6793e4fa0c5d60eddc03f7728a10c3289c979 | 1de2f218a6b6581d4749adf434f0ed69c35b0e97 | refs/heads/master | 2022-01-10T16:31:31.080919 | 2019-05-30T13:13:02 | 2019-05-30T13:13:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,666 | cpp | #include <iostream>
#include <cstdint>
#include <assert.h>
/*A better solution would be to use a 16-bit signed integer to hold the non-fractional part of the number, and an 8-bit signed integer to hold the fractional component.
4b) Write a class named FixedPoint2 that implements the recommended solution from the previous question. If either (or both) of the non-fractional and fractional part of the number are negative, the number should be treated as negative. Provide the overloaded operators and constructors required for the following program to run:
*/
class FixedPoint2{
private:
int16_t m_number;
int8_t m_decimal;
public:
FixedPoint2(int16_t number = 0,int8_t decimal = 0):m_number(number),m_decimal(decimal) {
//assert(m_decimal < 99 && "decimal needs to be less than 99");
if (m_number > 0 && m_decimal < 0) {
m_number = -m_number;
} else if (m_number < 0 && m_decimal > 0) {
m_decimal = -m_decimal;
}
//friend std::ostream operator<<(std::ostream &out, const FixedPoint2 &point);
}
operator double() const{
return m_number + static_cast<double>(m_decimal)/100;
}
};
std::ostream& operator<<(std::ostream &out, const FixedPoint2 &point){
out << static_cast<double>(point);
return out;
}
int main()
{
FixedPoint2 a(34, 56);
std::cout << a << '\n';
FixedPoint2 b(-2, 8);
std::cout << b << '\n';
FixedPoint2 c(2, -8);
std::cout << c << '\n';
FixedPoint2 d(-2, -8);
std::cout << d << '\n';
FixedPoint2 e(0, -5);
std::cout << e << '\n';
std::cout << static_cast<double>(e) << '\n';
return 0;
} | [
"[email protected]"
] | |
ba1181847b2a4c1552612a50b10e70bb691c7b9f | efe2b4dedbc6bab31ffe88c271daa5463f8649f6 | /tags/libtorrent-0_12/src/kademlia/rpc_manager.cpp | 7295938d04159024801a797b37c4d96da834d97f | [] | no_license | svn2github/libtorrent | 867c84f0c271cdc255c3e268c17db75d46010dde | 8cfe21e253d8b90086bb0b15c6c881795bf12ea1 | refs/heads/master | 2020-03-30T03:50:32.931129 | 2015-01-07T23:21:54 | 2015-01-07T23:21:54 | 17,344,601 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 10,460 | cpp | /*
Copyright (c) 2006, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/date_time/posix_time/ptime.hpp>
#include <boost/bind.hpp>
#include <libtorrent/io.hpp>
#include <libtorrent/invariant_check.hpp>
#include <libtorrent/kademlia/rpc_manager.hpp>
#include <libtorrent/kademlia/logging.hpp>
#include <libtorrent/kademlia/routing_table.hpp>
#include <libtorrent/hasher.hpp>
#include <fstream>
using boost::posix_time::ptime;
using boost::posix_time::time_duration;
using boost::posix_time::microsec_clock;
using boost::posix_time::seconds;
using boost::posix_time::milliseconds;
using boost::shared_ptr;
using boost::bind;
namespace libtorrent { namespace dht
{
namespace io = libtorrent::detail;
#ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_DEFINE_LOG(rpc)
#endif
node_id generate_id();
rpc_manager::rpc_manager(fun const& f, node_id const& our_id
, routing_table& table, send_fun const& sf)
: m_next_transaction_id(rand() % max_transactions)
, m_oldest_transaction_id(m_next_transaction_id)
, m_incoming(f)
, m_send(sf)
, m_our_id(our_id)
, m_table(table)
, m_timer(boost::posix_time::microsec_clock::universal_time())
, m_random_number(generate_id())
, m_destructing(false)
{
std::srand(time(0));
}
rpc_manager::~rpc_manager()
{
m_destructing = true;
#ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_LOG(rpc) << "Destructing";
#endif
std::for_each(m_aborted_transactions.begin(), m_aborted_transactions.end()
, bind(&observer::abort, _1));
for (transactions_t::iterator i = m_transactions.begin()
, end(m_transactions.end()); i != end; ++i)
{
if (*i) (*i)->abort();
}
}
#ifndef NDEBUG
void rpc_manager::check_invariant() const
{
assert(m_oldest_transaction_id >= 0);
assert(m_oldest_transaction_id < max_transactions);
assert(m_next_transaction_id >= 0);
assert(m_next_transaction_id < max_transactions);
assert(!m_transactions[m_next_transaction_id]);
for (int i = (m_next_transaction_id + 1) % max_transactions;
i != m_oldest_transaction_id; i = (i + 1) % max_transactions)
{
assert(!m_transactions[i]);
}
}
#endif
bool rpc_manager::incoming(msg const& m)
{
INVARIANT_CHECK;
if (m_destructing) return false;
if (m.reply)
{
// if we don't have the transaction id in our
// request list, ignore the packet
if (m.transaction_id.size() != 2)
{
#ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_LOG(rpc) << "Reply with invalid transaction id size: "
<< m.transaction_id.size() << " from " << m.addr;
#endif
return false;
}
std::string::const_iterator i = m.transaction_id.begin();
int tid = io::read_uint16(i);
if (tid >= (int)m_transactions.size()
|| tid < 0)
{
#ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_LOG(rpc) << "Reply with unknown transaction id: "
<< tid << " from " << m.addr;
#endif
return false;
}
boost::shared_ptr<observer> o = m_transactions[tid];
if (!o)
{
#ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_LOG(rpc) << "Reply with unknown transaction id: "
<< tid << " from " << m.addr;
#endif
return false;
}
if (m.addr != o->target_addr)
{
#ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_LOG(rpc) << "Reply with incorrect address and valid transaction id: "
<< tid << " from " << m.addr;
#endif
return false;
}
#ifdef TORRENT_DHT_VERBOSE_LOGGING
std::ofstream reply_stats("libtorrent_logs/round_trip_ms.log", std::ios::app);
reply_stats << m.addr << "\t" << (microsec_clock::universal_time()
- o->sent).total_milliseconds() << std::endl;
#endif
o->reply(m);
m_transactions[tid].reset();
if (m.piggy_backed_ping)
{
// there is a ping request piggy
// backed in this reply
msg ph;
ph.message_id = messages::ping;
ph.transaction_id = m.ping_transaction_id;
ph.id = m_our_id;
ph.addr = m.addr;
msg empty;
reply(empty, ph);
}
return m_table.node_seen(m.id, m.addr);
}
else
{
// this is an incoming request
m_incoming(m);
}
return false;
}
time_duration rpc_manager::tick()
{
INVARIANT_CHECK;
using boost::posix_time::microsec_clock;
const int timeout_ms = 10 * 1000;
// look for observers that has timed out
if (m_next_transaction_id == m_oldest_transaction_id) return milliseconds(timeout_ms);
std::vector<shared_ptr<observer> > timeouts;
for (;m_next_transaction_id != m_oldest_transaction_id;
m_oldest_transaction_id = (m_oldest_transaction_id + 1) % max_transactions)
{
assert(m_oldest_transaction_id >= 0);
assert(m_oldest_transaction_id < max_transactions);
boost::shared_ptr<observer> o = m_transactions[m_oldest_transaction_id];
if (!o) continue;
time_duration diff = o->sent + milliseconds(timeout_ms)
- microsec_clock::universal_time();
if (diff > seconds(0))
{
if (diff < seconds(1)) return seconds(1);
return diff;
}
try
{
m_transactions[m_oldest_transaction_id].reset();
timeouts.push_back(o);
} catch (std::exception) {}
}
std::for_each(timeouts.begin(), timeouts.end(), bind(&observer::timeout, _1));
timeouts.clear();
// clear the aborted transactions, will likely
// generate new requests. We need to swap, since the
// destrutors may add more observers to the m_aborted_transactions
std::vector<shared_ptr<observer> >().swap(m_aborted_transactions);
return milliseconds(timeout_ms);
}
unsigned int rpc_manager::new_transaction_id(shared_ptr<observer> o)
{
INVARIANT_CHECK;
unsigned int tid = m_next_transaction_id;
m_next_transaction_id = (m_next_transaction_id + 1) % max_transactions;
if (m_transactions[m_next_transaction_id])
{
// moving the observer into the set of aborted transactions
// it will prevent it from spawning new requests right now,
// since that would break the invariant
m_aborted_transactions.push_back(m_transactions[m_next_transaction_id]);
m_transactions[m_next_transaction_id].reset();
assert(m_oldest_transaction_id == m_next_transaction_id);
}
assert(!m_transactions[tid]);
m_transactions[tid] = o;
if (m_oldest_transaction_id == m_next_transaction_id)
{
m_oldest_transaction_id = (m_oldest_transaction_id + 1) % max_transactions;
#ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_LOG(rpc) << "WARNING: transaction limit reached! Too many concurrent"
" messages! limit: " << (int)max_transactions;
#endif
update_oldest_transaction_id();
}
return tid;
}
void rpc_manager::update_oldest_transaction_id()
{
INVARIANT_CHECK;
assert(m_oldest_transaction_id != m_next_transaction_id);
while (!m_transactions[m_oldest_transaction_id])
{
m_oldest_transaction_id = (m_oldest_transaction_id + 1)
% max_transactions;
if (m_oldest_transaction_id == m_next_transaction_id)
break;
}
}
void rpc_manager::invoke(int message_id, udp::endpoint target_addr
, shared_ptr<observer> o)
{
INVARIANT_CHECK;
if (m_destructing)
{
o->abort();
return;
}
msg m;
m.message_id = message_id;
m.reply = false;
m.id = m_our_id;
m.addr = target_addr;
assert(!m_transactions[m_next_transaction_id]);
#ifndef NDEBUG
int potential_new_id = m_next_transaction_id;
#endif
try
{
m.transaction_id.clear();
std::back_insert_iterator<std::string> out(m.transaction_id);
io::write_uint16(m_next_transaction_id, out);
o->send(m);
o->sent = boost::posix_time::microsec_clock::universal_time();
o->target_addr = target_addr;
#ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_LOG(rpc) << "Invoking " << messages::ids[message_id]
<< " -> " << target_addr;
#endif
m_send(m);
new_transaction_id(o);
}
catch (std::exception& e)
{
// m_send may fail with "no route to host"
assert(potential_new_id == m_next_transaction_id);
o->abort();
}
}
void rpc_manager::reply(msg& m, msg const& reply_to)
{
INVARIANT_CHECK;
if (m_destructing) return;
if (m.message_id != messages::error)
m.message_id = reply_to.message_id;
m.addr = reply_to.addr;
m.reply = true;
m.piggy_backed_ping = false;
m.id = m_our_id;
m.transaction_id = reply_to.transaction_id;
m_send(m);
}
namespace
{
struct dummy_observer : observer
{
virtual void reply(msg const&) {}
virtual void timeout() {}
virtual void send(msg&) {}
void abort() {}
};
}
void rpc_manager::reply_with_ping(msg& m, msg const& reply_to)
{
INVARIANT_CHECK;
if (m_destructing) return;
if (m.message_id != messages::error)
m.message_id = reply_to.message_id;
m.addr = reply_to.addr;
m.reply = true;
m.piggy_backed_ping = true;
m.id = m_our_id;
m.transaction_id = reply_to.transaction_id;
try
{
m.ping_transaction_id.clear();
std::back_insert_iterator<std::string> out(m.ping_transaction_id);
io::write_uint16(m_next_transaction_id, out);
boost::shared_ptr<observer> o(new dummy_observer);
assert(!m_transactions[m_next_transaction_id]);
o->sent = boost::posix_time::microsec_clock::universal_time();
o->target_addr = m.addr;
m_send(m);
new_transaction_id(o);
}
catch (std::exception& e)
{
// m_send may fail with "no route to host"
}
}
} } // namespace libtorrent::dht
| [
"arvidn@f43f7eb3-cfe1-5f9d-1b5f-e45aa6702bda"
] | arvidn@f43f7eb3-cfe1-5f9d-1b5f-e45aa6702bda |
c42ec167bff22e666fb905b02de7e15d5f9f8dc1 | bfa9f9fc43f1c70f71ebabd70324e14ca64cd862 | /gfx/font.hpp | ae4721c80a739ad49c36e59a050caf1b27341de2 | [] | no_license | someone235/liero | 7952097441ab709946f51929cc3ef846c695dc84 | 187e5ddb02d2aad22a0ff1b9b7185838eb209473 | refs/heads/master | 2020-12-24T19:12:44.850847 | 2016-10-25T18:09:31 | 2016-10-25T18:09:31 | 57,980,373 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,541 | hpp | #ifndef UUID_B06B65B783A849C7B4E509A9676180F8
#define UUID_B06B65B783A849C7B4E509A9676180F8
#include <vector>
#include <string>
#include <gvl/io/encoding.hpp>
struct Bitmap;
struct ReaderFile;
struct Font
{
struct Char
{
unsigned char data[8*7];
int width;
};
Font()
: chars(250)
{
}
void loadFromEXE(ReaderFile& exe);
void drawText(Bitmap& scr, char const* str, std::size_t len, int x, int y, int color);
int getDims(char const* str, std::size_t len, int* height = 0);
void drawChar(Bitmap& scr, unsigned char ch, int x, int y, int color);
void drawText(Bitmap& scr, std::string const& str, int x, int y, int color)
{
drawText(scr, str.data(), str.size(), x, y, color);
}
void drawText(Bitmap& scr, gvl::cell const& str, int x, int y, int color)
{
if (str.buffer.empty())
return;
if (str.text_placement != gvl::cell::left)
{
int w = getDims(
reinterpret_cast<char const*>(&str.buffer[0]),
str.buffer.size());
if (str.text_placement == gvl::cell::center)
x -= w / 2;
else if (str.text_placement == gvl::cell::right)
x -= w;
}
drawText(scr, reinterpret_cast<char const*>(&str.buffer[0]), str.buffer.size(), x, y, color);
}
int getDims(std::string const& str, int* height = 0)
{
return getDims(str.data(), str.size(), height);
}
void drawFramedText(Bitmap& scr, std::string const& text, int x, int y, int color);
std::vector<Char> chars;
};
#endif // UUID_B06B65B783A849C7B4E509A9676180F8
| [
"[email protected]"
] | |
4565800e1876722962aa35ecd81ed6155fd3b2e9 | a66f43ebb6bebfe509f8aaeff3989c6153668de8 | /UVA/160 - Factors and Factorials.cpp | 73e54a4d62c7e99d36975ab4f24b4d1e5f43fc16 | [] | no_license | ShikariSohan/Problems-Solving | e6cbeaaa9a8a091364aee12cc28cce06165cf84d | 26809bddfcb357ca232be5e8016ef1e705a94f9a | refs/heads/master | 2023-02-24T08:05:27.161840 | 2021-01-26T12:44:55 | 2021-01-26T12:44:55 | 283,302,951 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,925 | cpp |
/*
"""Bismillahir Rahmanur Rahim"""
*/
#include<bits/stdc++.h>
using namespace std;
#define pi 2*acos(0.0)
#define ll long long int
#define pb push_back
#define pf push_front
const ll sz = 1000001;
#define mp make_pair
#define ses '\n'
#define stm istringstream
#define gcd __gcd
ll lcm(ll x,ll y){return (x*y)/gcd(x,y);}
#define tin ll T;cin>>T; for(ll o=1;o<=T;o++)
#define tout cout<<"Case "<<o<<": ";
int main()
{
//freopen ("input.txt","r",stdin);
//freopen ("output.txt","w",stdout);
while(1)
{
ll n,x,m=0;
ll a[100]={},ar[4]={2,3,5,7};
cin>>n;
if(n==0)
return 0;
for(ll i=2;i<=n;i++)
{
x=i;
for(ll j=0;j<4;j++)
{
if(x%ar[j]==0)
while(x%ar[j]==0)
{
x=x/ar[j];
a[ar[j]]++;
m=max(m,ar[j]);
}
}
if(x!=1)
{
a[x]++;m=max(m,x);
}
}
printf("%#3lld! =",n);
ll k=0;
for(ll i=2;i<100;i++)
{
if(a[i]!=0)
{
k++;
if(k==16)
{
cout<<ses;
cout<<" ";
k=0;
}
printf(" %#2lld",a[i]);
}
}
cout<<ses;
}
return 0;
}
/* --------------------
| ~SOHAN~ |
| ~Chandler68~ |
--------------------
|| VALAR MORGULIS||==|| ALL MEN MUST DIE ||
\\ Power Is Power//
|| I Can Do This All day ||
// We are on a Break \\ // How you doin'? \\
|| Say My Name || ~~ || I Am The Who Knocks ||
// I Am Ted Mosby Architect \\
|| It Is Legen --wait for it -- dary ,Legendary ||
\\ Penny - Penny - Penny // -- Bazinga
*/
| [
"[email protected]"
] | |
06172048b38e0fc778f2bdb6f4b7531f5de31b6a | 82b5fba8225fad076e85855b7d5300011d1279ab | /PA7_AverageTemperature/PA7_AverageTemperature.cpp | 0685551bc12964e458b313cb0effdbf85e2a3b4e | [] | no_license | AndriiHura/CppBasics_WhiteBelt | 195e8cda0ffa625dda3cf3a76ba70b02fda5caf8 | e795a35a9dc3fae7bc79ccac8638fd6c7dd47e30 | refs/heads/master | 2022-11-27T02:38:21.979092 | 2020-08-01T16:56:45 | 2020-08-01T16:56:45 | 281,151,088 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,798 | cpp | // PA7_AverageTemperature.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <vector>
using namespace std;
vector<int> DayTemperatureInput() {
int DaysNumber;
cin >> DaysNumber;
vector<int> TemperatureEachDay(DaysNumber);
for (int& d : TemperatureEachDay) {
cin >> d;
}
return TemperatureEachDay;
}
int GetAverageSum(const vector<int>& vec) {
int TempSum = 0;
for (auto d : vec) {
TempSum += d;
}
int AverageTemp = TempSum / vec.size();
return AverageTemp;
}
void PrintVector(const vector<int>& vec) {
cout << vec.size() << endl;
for (auto n : vec) {
cout << n << " ";
}
}
vector<int> GetResultVector(const vector<int>& vec) {
vector<int> ResultDays;
for (int i = 0; i < vec.size(); ++i) {
if (vec[i] > GetAverageSum(vec)) {
ResultDays.push_back(i);
}
}
return ResultDays;
}
int main()
{
vector<int> Temperatures = DayTemperatureInput();
vector<int> ResultDays = GetResultVector(Temperatures);
PrintVector(ResultDays);
return 0;
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
| [
"[email protected]"
] | |
1384bc78f8d3f87a4b30821d849573dd4b6251b6 | e813becb00b78aea262bec638f594f7b0d30cc7b | /CresusCore/AbstractImportModule.h | d4b2a511fcd981751a2738609fdf873ae63ab242 | [] | no_license | jjdubois/cresus | ffbe96eaf62574d7114017b81042276b317f5705 | 64d7336ad4ef4a2653cf2c39d188a9593804d866 | refs/heads/master | 2021-01-10T09:10:33.292537 | 2016-02-26T22:09:56 | 2016-02-26T22:09:56 | 49,322,443 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 387 | h | #ifndef ABSTRACTIMPORTMODULE_H
#define ABSTRACTIMPORTMODULE_H
#include <ImportModule.h>
#include <QSet>
#include <QString>
#include <QRegExp>
class CRESUSCORESHARED_EXPORT AbstractImportModule : public ImportModule
{
QRegExp m_rexExp;
public:
AbstractImportModule( const QRegExp& regExp );
bool acceptFile( const QFileInfo& file );
};
#endif // ABSTRACTIMPORTMODULE_H
| [
"[email protected]"
] | |
60eef25ea12e6649f7c231c4c727e8ace75cf232 | b768c60c17e6c93a4d32c93eeef073869d4f5fee | /src/include/bufferreadable.h | 142fbc663cd9837da37f2898794bdcbf9d2dcb3e | [] | no_license | ThatFatPat/CppConstruct | 09ea364e473fe8a631094cf539b86625cfa37cf9 | a2dba2ebe01a49485f1e4b10fcd0d52863733ba9 | refs/heads/main | 2023-06-01T07:58:05.084903 | 2021-06-12T18:38:58 | 2021-06-12T18:38:58 | 376,051,277 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 366 | h | #pragma once
#include <cstddef>
#include <span>
#include "ireadable.h"
class BufferReadable : public IReadable {
public:
BufferReadable(std::span<const std::byte> span)
: m_span(span), m_ptr(span.begin()) {}
void read(std::span<std::byte> buffer) override;
private:
std::span<const std::byte> m_span;
std::span<const std::byte>::iterator m_ptr;
}; | [
"[email protected]"
] | |
66fd713e094c47d331960dbcc1e6070a4252bbfe | 3523ce08e2402f78859e063615aee0d0889946cf | /src/normalizer.cpp | 11e64413e82a979c950a21948c7763f5f529a53b | [
"MIT"
] | permissive | ernire/next-dbscan | 4f38130665d97b993cbd56c25f60320e4adf3d77 | 408bed5ea455086ebc3d28dec217cd532ca7cd16 | refs/heads/master | 2021-07-08T19:04:26.265728 | 2020-01-18T22:25:13 | 2020-01-18T22:25:13 | 176,022,674 | 0 | 1 | MIT | 2020-01-18T22:25:15 | 2019-03-16T20:42:39 | C++ | UTF-8 | C++ | false | false | 3,962 | cpp | /*
Copyright (c) 2019, Ernir Erlingsson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <sstream>
#include <cmath>
#include <chrono>
#include <iostream>
#include <iomanip>
#include <vector>
#include <fstream>
int count_lines(const std::string &in_file) {
std::ifstream is(in_file);
std::string line;
int cnt = 0;
while (std::getline(is, line)) {
++cnt;
}
return cnt;
}
void write_output(const std::string &out_file, const float *v_points, const int max_d, const int n) {
std::ofstream os(out_file);
for (int i = 0; i < n; i ++) {
for (int j = 0; j < max_d; j++) {
os << v_points[i*max_d + j] << " ";
}
os << '\n';
}
os.flush();
os.close();
}
void read_input(const std::string &in_file, float *v_points, int max_d) noexcept {
std::ifstream is(in_file);
std::string line, buf;
std::stringstream ss;
int index = 0;
auto t1 = std::chrono::high_resolution_clock::now();
while (std::getline(is, line)) {
ss.str(std::string());
ss.clear();
ss << line;
for (int j = 0; j < max_d; j++) {
ss >> buf;
v_points[index++] = atof(buf.c_str());
}
}
is.close();
auto t2 = std::chrono::high_resolution_clock::now();
std::cout << std::endl;
std::cout << "Read input took: "
<< std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count()
<< " milliseconds\n";
}
int main(int argc, char* const* argv) {
std::string in_file = argv[1];
std::string out_file = argv[2];
std::cout << "Input file: " << in_file << std::endl;
uint max_d = 7;
uint n = count_lines(in_file);
std::cout << "Number of samples: " << n << std::endl;
auto *v_points = new float[n*max_d];
read_input(in_file, v_points, max_d);
float mins[max_d];
float maxs[max_d];
float minmaxs[max_d];
for (uint j = 0; j < max_d; j++) {
mins[j] = v_points[j];
maxs[j] = v_points[j];
}
std::cout << std::endl;
for (uint i = 1; i < n; i ++) {
for (uint j = 0; j < max_d; j++) {
float val = v_points[i*max_d + j];
if (val < mins[j]) {
mins[j] = val;
}
if (val > maxs[j]) {
maxs[j] = val;
}
}
}
for (uint j = 0; j < max_d; j++) {
std::cout << "Min: " << mins[j] << ", Max: " << maxs[j] << std::endl;
minmaxs[j] = maxs[j] - mins[j];
}
for (uint i = 0; i < n; i ++) {
for (uint j = 0; j < max_d; j++) {
if (minmaxs[j] == 0) {
v_points[i*max_d + j] = 0;
} else {
float val = v_points[i*max_d + j];
v_points[i*max_d + j] = ((val - mins[j]) / minmaxs[j]) * 100000;
}
}
}
std::cout << "Writing output file: " << out_file << std::endl;
write_output(out_file, v_points, max_d, n);
} | [
"[email protected]"
] | |
02633f651e3c6ca12d4745eedc419bc381deae56 | 8645ba7368f2ba10893e1ff8962e9e2eedf5104d | /src/Core/Loaders/ImageLoader.cpp | a51a89666c2473b5707f6c07196b1a787e23ef81 | [
"Apache-2.0"
] | permissive | reubenlindroos/OmniPhotos | c4560d74fd1bb031cc5c953269b95153ea3716f1 | de62590edc9caf1cfbd1c833bb9176993a10a579 | refs/heads/main | 2023-05-13T19:21:49.495691 | 2021-06-07T10:31:55 | 2021-06-07T10:31:55 | 344,496,849 | 1 | 0 | Apache-2.0 | 2021-03-04T14:10:47 | 2021-03-04T14:10:46 | null | UTF-8 | C++ | false | false | 17,626 | cpp | #include "ImageLoader.hpp"
#define STB_DXT_IMPLEMENTATION
#include "3rdParty/stb_dxt.h"
#include "Core/GL/GLFormats.hpp"
#include "Utils/ErrorChecking.hpp"
#include "Utils/Exceptions.hpp"
#include "Utils/Logger.hpp"
#include "Utils/Timer.hpp"
#include "Utils/Utils.hpp"
#include "Utils/cvutils.hpp"
#ifdef _OPENMP
#include <omp.h>
#endif //_OPENMP
#include <iomanip>
// Initialise static member variable.
std::vector<std::string> ImageLoader::supportedTextureFormats;
ImageLoader::ImageLoader(std::vector<Camera*>* _cameras, bool _enableTextureCompression) :
Loader(_cameras),
enableTextureCompression(_enableTextureCompression)
{
// Query the supported compressed texture formats and store if DXT1/DXT5 is supported.
// Following the suggestion at https://www.khronos.org/opengl/wiki/Common_Mistakes,
// we do this just once, to call `glGetIntegerv` as little as possible, and store
// the result in the static variable `ImageLoader::supportedTextureFormats`.
if (enableTextureCompression && supportedTextureFormats.empty())
{
// Uncompressed textures are always supported.
supportedTextureFormats.push_back("GL_RGB");
// Check the graphics card's GL_COMPRESSED_RGBA_S3TC_DXT5/1_EXT support.
GLint numSupportedFormats = 0;
glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numSupportedFormats);
if (numSupportedFormats <= 0)
LOG(ERROR) << "Graphic card feature detection error.";
// List supported texture compression formats and save the one's we're interested in.
GLint* supportedFormatsList = new GLint[numSupportedFormats];
glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, supportedFormatsList);
for (int i = 0; i < numSupportedFormats; i++)
{
if (GL_COMPRESSED_RGBA_S3TC_DXT5_EXT == supportedFormatsList[i])
supportedTextureFormats.push_back("DXT5");
else if (GL_COMPRESSED_RGBA_S3TC_DXT1_EXT == supportedFormatsList[i])
supportedTextureFormats.push_back("DXT1");
else if (GL_COMPRESSED_RGB_S3TC_DXT1_NV == supportedFormatsList[i])
supportedTextureFormats.push_back("DXT1");
}
delete[] supportedFormatsList;
std::string msg;
for (auto& it : supportedTextureFormats)
msg = msg + " " + it;
VLOG(1) << "Current graphics card '" << glGetString(GL_RENDERER) << "' supports the following texture compression formats:" << msg;
}
}
ImageLoader::~ImageLoader()
{
releaseGPUMemory();
}
// @param image 4-channel RGBA image
// @param alphaEnable 0 is DXT1, 1 is DXT5
void compressTextureInPlace(cv::Mat& image, int alphaEnable)
{
if (image.channels() != 4)
{
LOG(ERROR) << "The DXT1/5 texture compression expects 4-channel RGBA input.";
return;
}
// Note the DTX1 just uses half of the mat's memory.
cv::Mat imageDXT = cv::Mat::zeros(image.rows, image.cols, CV_8UC1);
if (!imageDXT.isContinuous())
LOG(ERROR) << "OpenCV failed to allocate contiguous memory.";
unsigned char* outputDataPtr = imageDXT.data;
const unsigned int blockWidth = image.cols / 4;
const unsigned int blockHeight = image.rows / 4;
// Block-wise DXT1/DXT5 image compression.
for (unsigned int j = 0; j < blockHeight; j++)
{
for (unsigned int i = 0; i < blockWidth; i++)
{
// Extract 4-by-4 pixel block.
unsigned char block[64];
for (int blockRowIndex = 0; blockRowIndex < 4; blockRowIndex++)
{
const int blockOffset = (j * 4 + blockRowIndex) * (blockWidth * 4 * 4) + i * 4 * 4;
memcpy(&block[blockRowIndex * 4 * 4], image.data + blockOffset, 4 * 4);
}
// Compress the block.
if (alphaEnable == 1) // DXT5
{
stb_compress_dxt_block(outputDataPtr, block, 1, STB_DXT_HIGHQUAL);
outputDataPtr += 16;
}
else if (alphaEnable == 0) // DXT1
{
stb_compress_dxt_block(outputDataPtr, block, 0, STB_DXT_HIGHQUAL);
outputDataPtr += 8;
}
}
}
image = imageDXT;
}
bool ImageLoader::checkTextureFormat()
{
if (enableTextureCompression == false && imageTextureFormat != "GL_RGB")
{
std::string msg = "Error: Texture compression is disabled but texture format is not GL_RGB.";
RUNTIME_EXCEPTION(msg);
}
if (imageTextureFormat != "GL_RGB" && imageTextureFormat != "DXT1" && imageTextureFormat != "DXT5")
{
std::string msg = "Error: Image texture format should be [GL_RGB|DXT1|DXT5].";
RUNTIME_EXCEPTION(msg);
}
// Check if the GPU supports the selected format and fall back to uncompressed if not.
if (imageTextureFormat == "DXT1" || imageTextureFormat == "DXT5")
{
// check the graphic card GL_COMPRESSED_RGBA_S3TC_DXT5_EXT support
bool textureCompressSupport = false;
for (int i = 0; i < ImageLoader::supportedTextureFormats.size(); i++)
{
if (imageTextureFormat == ImageLoader::supportedTextureFormats[i])
{
textureCompressSupport = true;
break;
}
}
if (textureCompressSupport)
{
VLOG(1) << "Current graphics card supports " << imageTextureFormat << " textures.";
}
else
{
LOG(WARNING) << imageTextureFormat << " texture compression is not supported. Disabling texture compression.";
imageTextureFormat = "GL_RGB";
}
}
// Check if image dimensions are supported (width/height a multiple of 4).
if (imageTextureFormat == "DXT1" || imageTextureFormat == "DXT5")
{
cv::Mat image = (*cameras)[0]->getImage();
if (image.rows % 4 != 0 || image.cols % 4 != 0)
{
LOG(WARNING) << "The RGB image size is " << image.size() << ". DXT1/5 texture compression requires the image size to be a multiple of 4. Disabling texture compression.";
imageTextureFormat = "GL_RGB";
}
}
return true;
}
bool ImageLoader::loadImages()
{
if (!checkTextureFormat())
return false;
ScopedTimer timer;
int imagesLoaded = 0;
std::vector<Camera*>& camera_list = *cameras;
#ifdef _OPENMP
#pragma omp parallel for shared(imagesLoaded) schedule(static, 1)
#endif
for (int i = 0; i < camera_list.size(); ++i)
{
LOG(INFO) << "Loading image (" << (i + 1) << " of " << camera_list.size() << ")";
Camera* camera = camera_list[i];
if (camera->loadImageWithOpenCV())
{
#ifdef _OPENMP
#pragma omp atomic
#endif
imagesLoaded++;
// Compress images if texture compression using DXT1/5 is enabled and supported.
if (imageTextureFormat == "DXT1" || imageTextureFormat == "DXT5")
{
LOG(INFO) << "Compressing texture image (" << (i + 1) << " of " << camera_list.size() << ")";
// The input for texture compression must be RGBA.
cv::Mat image = camera_list[i]->getImage();
if (image.channels() == 3)
cv::cvtColor(image, image, cv::COLOR_BGR2RGBA);
if (imageTextureFormat == "DXT1")
compressTextureInPlace(image, 0);
else if (imageTextureFormat == "DXT5")
compressTextureInPlace(image, 1);
camera_list[i]->setImage(image);
}
}
else
{
LOG(WARNING) << "Loading image '" << camera->imageName << "' failed.";
}
}
LOG(INFO) << "Loaded " << imagesLoaded << " images in " << std::fixed << std::setprecision(2) << timer.getElapsedSeconds() << "s";
return imagesLoaded == getImageCount();
}
void ImageLoader::loadTextures()
{
if (!loadImages())
LOG(ERROR) << "Failed to load all images";
}
void ImageLoader::initTextures()
{
ErrorChecking::checkGLError();
if (imageTexture)
{
imageTexture->layout.mem.elements = getImageCount();
}
else
{
GLMemoryLayout memLayout;
if (imageTextureFormat == "GL_RGB")
memLayout = GLMemoryLayout(getImageCount(), 3, "GL_BGR", "GL_UNSIGNED_BYTE", "GL_RGB8");
else if (imageTextureFormat == "DXT5")
memLayout = GLMemoryLayout(getImageCount(), 3, "GL_RGBA_DXT5", "", "GL_RGBA_DXT5");
else if (imageTextureFormat == "DXT1")
memLayout = GLMemoryLayout(getImageCount(), 3, "GL_RGBA_DXT1", "", "GL_RGBA_DXT1");
GLTextureLayout texLayout = GLTextureLayout(memLayout, getImageDims(), "set in app", -1);
imageTexture = new GLTexture(texLayout, "GL_TEXTURE_2D_ARRAY");
}
ErrorChecking::checkGLError();
//setting up image textures
if (!imageTexture->gl_ID)
{
glGenTextures(1, &imageTexture->gl_ID);
ErrorChecking::checkGLError();
}
glBindTexture(GL_TEXTURE_2D_ARRAY, imageTexture->gl_ID);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
if (imageTextureFormat == "GL_RGB")
{
glTexImage3D(GL_TEXTURE_2D_ARRAY,
0, //level
getGLInternalFormat(imageTexture->layout.mem.internalFormat),
imageTexture->layout.resolution.x(),
imageTexture->layout.resolution.y(),
imageTexture->layout.mem.elements,
0, //border
getGLFormat(imageTexture->layout.mem.format),
getGLType(imageTexture->layout.mem.type),
NULL);
}
else if (imageTextureFormat == "DXT1" || imageTextureFormat == "DXT5")
{
// DXT1/DXT5 texture size unit is Byte
unsigned int dxtDataSize = 0;
if (imageTextureFormat == "DXT5")
dxtDataSize = ((imageTexture->layout.resolution.x() + 3) / 4) * ((imageTexture->layout.resolution.y() + 3) / 4) * 16;
else if (imageTextureFormat == "DXT1")
dxtDataSize = ((imageTexture->layout.resolution.x() + 3) / 4) * ((imageTexture->layout.resolution.y() + 3) / 4) * 8;
glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY,
0, //level
getGLInternalFormat(imageTexture->layout.mem.internalFormat),
imageTexture->layout.resolution.x(), // block's width to image width
imageTexture->layout.resolution.y(), // block's height to image height
imageTexture->layout.mem.elements, // slice number
0,
dxtDataSize * imageTexture->layout.mem.elements,
NULL);
}
ErrorChecking::checkGLError();
if (projectionMatrixTexture)
{
projectionMatrixTexture->layout.mem.elements = getImageCount();
}
else
{
GLMemoryLayout memLayout = GLMemoryLayout(getImageCount(), 1, "GL_RED", "GL_FLOAT", "GL_R32F"); // these are settings from config.yaml
GLTextureLayout texLayout = GLTextureLayout(memLayout, Eigen::Vector2i(4, 4), "set in app", -1);
projectionMatrixTexture = new GLTexture(texLayout, "GL_TEXTURE_2D_ARRAY");
}
// Setting up projection matrices
if (!projectionMatrixTexture->gl_ID)
glGenTextures(1, &projectionMatrixTexture->gl_ID);
glBindTexture(GL_TEXTURE_2D_ARRAY, projectionMatrixTexture->gl_ID);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage3D(GL_TEXTURE_2D_ARRAY,
0,
getGLInternalFormat(projectionMatrixTexture->layout.mem.internalFormat),
projectionMatrixTexture->layout.resolution.x(),
projectionMatrixTexture->layout.resolution.y(),
projectionMatrixTexture->layout.mem.elements,
0,
getGLFormat(projectionMatrixTexture->layout.mem.format),
getGLType(projectionMatrixTexture->layout.mem.type),
NULL);
ErrorChecking::checkGLError();
if (posViewTexture)
{
posViewTexture->layout.mem.elements = getImageCount();
posViewTexture->layout.resolution = Eigen::Vector2i(2, getImageCount());
}
else
{
GLMemoryLayout memLayout = GLMemoryLayout(getImageCount(), 3, "GL_RGB", "GL_FLOAT", "GL_RGB16F"); // these are settings from config.yaml
GLTextureLayout texLayout = GLTextureLayout(memLayout, Eigen::Vector2i(2, getImageCount()), "set in app", -1);
posViewTexture = new GLTexture(texLayout, "GL_TEXTURE_2D");
}
if (!posViewTexture->gl_ID)
glGenTextures(1, &posViewTexture->gl_ID);
glBindTexture(GL_TEXTURE_2D, posViewTexture->gl_ID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D,
0,
getGLInternalFormat(posViewTexture->layout.mem.internalFormat),
posViewTexture->layout.resolution.x(),
posViewTexture->layout.resolution.y(),
0,
getGLFormat(posViewTexture->layout.mem.format),
getGLType(posViewTexture->layout.mem.type),
NULL);
ErrorChecking::checkGLError();
}
void ImageLoader::fillTextures()
{
ScopedTimer timer;
for (int i = 0; i < getImageCount(); i++)
{
VLOG(1) << "Filling image texture (" << (i + 1) << " of " << getImageCount() << ")";
Camera* cam = cameras->at(i);
if (imageTextureFormat == "GL_RGB")
{
fillCameraTextureOpenCV(cam, i);
}
else if (imageTextureFormat == "DXT1" || imageTextureFormat == "DXT5")
{
cv::Mat img = cam->getImage();
if (img.empty())
{
LOG(WARNING) << "Image '" << cam->imageName << "' is empty. Skipping texture upload.";
return;
}
unsigned int dxtDataSize = 0;
if (imageTextureFormat == "DXT5")
dxtDataSize = ((img.cols + 3) / 4) * ((img.rows + 3) / 4) * 16;
else if (imageTextureFormat == "DXT1")
dxtDataSize = ((img.cols + 3) / 4) * ((img.rows + 3) / 4) * 8;
glBindTexture(GL_TEXTURE_2D_ARRAY, imageTexture->gl_ID);
glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY,
0,
0,
0,
i,
imageTexture->layout.resolution.x(), // block's width to image width
imageTexture->layout.resolution.y(), // block's height to image height
1,
getGLFormat(imageTexture->layout.mem.format), // GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
dxtDataSize,
img.data);
}
// projection matrices
fillProjectionTexture(cam, i);
}
//glBindTexture(GL_TEXTURE_2D_ARRAY, images);
//glGenerateMipmap(GL_TEXTURE_2D_ARRAY);
ErrorChecking::checkGLError();
LOG(INFO) << "Loaded images from CPU memory to GPU memory in "
<< std::fixed << std::setprecision(2) << timer.getElapsedSeconds() << "s";
updatePosViewTex();
}
void ImageLoader::releaseCPUMemory()
{
// Images are stored inside Camera instances and not released here.
}
void ImageLoader::releaseGPUMemory()
{
if (imageTexture)
{
delete imageTexture;
imageTexture = nullptr;
}
if (projectionMatrixTexture)
{
delete projectionMatrixTexture;
projectionMatrixTexture = nullptr;
}
if (posViewTexture)
{
delete posViewTexture;
posViewTexture = nullptr;
}
}
void ImageLoader::fillProjectionTexture(Camera* cam, int layer)
{
Eigen::Matrix4f mat = cam->getProjection44();
GLfloat* data = new GLfloat[4 * 4];
memset(data, 0, 4 * 4 * sizeof(GLfloat));
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
data[i * 4 + j + 0] = (GLfloat)mat(i, j);
glBindTexture(GL_TEXTURE_2D_ARRAY, projectionMatrixTexture->gl_ID);
glTexSubImage3D(GL_TEXTURE_2D_ARRAY,
0,
0, 0, layer,
4, 4, 1,
GL_RED,
GL_FLOAT,
data);
glBindTexture(GL_TEXTURE_2D_ARRAY, 0);
delete[] data;
ErrorChecking::checkGLError();
}
void ImageLoader::fillCameraTextureOpenCV(Camera* cam, int layer)
{
cv::Mat img = cam->getImage();
if (img.empty())
{
LOG(WARNING) << "Image '" << cam->imageName << "' is empty. Skipping texture upload.";
return;
}
uploadImageToOpenGLTexture(img, imageTexture, layer);
}
void ImageLoader::uploadImageToOpenGLTexture(cv::Mat& img, GLTexture* texture, int layer)
{
glBindTexture(GL_TEXTURE_2D_ARRAY, texture->gl_ID);
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, layer, img.cols, img.rows, 1,
getGLFormat(texture->layout.mem.format), // GL_RGB
getGLType(texture->layout.mem.type), // GL_UNSIGNED_CHAR
(uchar*)img.ptr());
//ErrorChecking::checkGLError();
}
void ImageLoader::updateProjectionTex()
{
LOG(INFO) << "Update projection matrix textures.";
int size = getImageCount();
for (int i = 0; i < size; i++)
{
Camera* cam = cameras->at(i);
fillProjectionTexture(cam, i);
//ErrorChecking::checkGLError();
}
}
void ImageLoader::setPosViewTex(int layer)
{
const Camera* cam = cameras->at(layer);
glTexSubImage2D(GL_TEXTURE_2D,
0,
0, layer,
1, 1,
GL_RGB, GL_FLOAT, cam->getCentre().data());
ErrorChecking::checkGLError();
glTexSubImage2D(GL_TEXTURE_2D,
0,
1, layer,
1, 1,
GL_RGB, GL_FLOAT, cam->getZDir().data());
ErrorChecking::checkGLError();
}
void ImageLoader::updateSinglePosViewTex(int layer)
{
glBindTexture(GL_TEXTURE_2D, posViewTexture->gl_ID);
setPosViewTex(layer);
glBindTexture(GL_TEXTURE_2D, 0);
}
void ImageLoader::updatePosViewTex()
{
VLOG(1) << "Updating position and viewing directions texture.";
glBindTexture(GL_TEXTURE_2D, posViewTexture->gl_ID);
//glTexStorage2D(GL_TEXTURE_2D, 1, formats.er->internalFormat, 2, size);
ErrorChecking::checkGLError();
int size = posViewTexture->layout.mem.elements;
for (int i = 0; i < size; i++)
{
setPosViewTex(i);
}
glBindTexture(GL_TEXTURE_2D, 0);
ErrorChecking::checkGLError();
}
| [
"[email protected]"
] | |
91716768a9fe036ff8c6cf13fe10d338f3904cda | c41cbb3cfa514e10cf726d9d338a15b340f05d84 | /.adev/rouge/ui/ievent_listener.h | bab361d408331d7042b23944592538cc023f70e6 | [] | no_license | astrellon/GPP | e9c432afbd3d0401ee0fddfed5ffad77a5b26e8e | d3ba5f9339051acbfb507fe489443f454459f27c | refs/heads/master | 2021-01-25T05:28:11.823329 | 2013-07-08T12:53:25 | 2013-07-08T12:53:25 | 1,505,792 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,137 | h | #pragma once
#include <base/imanaged.h>
using am::base::IManaged;
#include <vector>
using std::vector;
#include "event.h"
#include "mouse_event.h"
#include "keyboard_event.h"
#include "inventory_event.h"
#include "equip_event.h"
#include "value_change_event.h"
#include "dialogue_event.h"
#include "stat_event.h"
namespace am {
namespace ui {
class EventInterface;
class IEventListener : virtual public IManaged {
public:
typedef vector<EventInterface *> ListeningList;
virtual ~IEventListener();
virtual void onEvent(Event *e) {}
virtual void onEvent(MouseEvent *e) {}
virtual void onEvent(KeyboardEvent *e) {}
virtual void onEvent(ValueChangeEvent *e) {}
virtual void onEvent(InventoryEvent *e) {}
virtual void onEvent(EquipEvent *e) {}
virtual void onEvent(DialogueEvent *e) {}
virtual void onEvent(StatEvent *e) {}
virtual bool compareListeners(const IEventListener *rhs) const { return this == rhs; }
void addListeningTo(EventInterface *e);
void removeListeningTo(EventInterface *e);
const ListeningList &getListeningToList() const;
protected:
ListeningList mListeningTo;
};
}
}
| [
"[email protected]"
] |
Subsets and Splits