- 1
typedef long char wchar_t;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+142
typedef long char wchar_t;
qnx4.25 /usr/include/stdlib.h:
sizeof(long char) == 2
+143
char * hmod = (char *)GetModuleHandleW(L"msenv.dll");
IMAGE_DOS_HEADER *pDosHeader = (IMAGE_DOS_HEADER *)hmod;
IMAGE_NT_HEADERS *pNtHeaders = (IMAGE_NT_HEADERS *)(hmod + pDosHeader->e_lfanew);
char *pcode = (hmod + pNtHeaders->OptionalHeader.BaseOfCode);
char *ecode = (pcode + pNtHeaders->OptionalHeader.SizeOfCode);
while (pcode < ecode - sizeof(int))
{
if((*(int *)pcode) == 0xFFFFDCB8 ||
(*(int *)pcode) == 0xFFFFDC89 )
{
wchar_t buf[1024];
wsprintfW(buf, L"%p\n", pcode);
OutputDebugStringW(buf);
}
pcode++;
}
А как в студийном отладчике искать по памяти?
+142
http://pastebin.com/NeWPms7u
Лаконичное решение как разместить OpenCL и C++ в одном файле. Самое главное что можно спокойно отлаживать данный код. Также объявлять общие переменные и функции OpenCL и host коду. Единственное но! Придется задать пару флагов компилятору OpenCL кода для того чтобы сие подделие заработало. Главный принцип заключается в #if(n)def CL_DEVICE. По умолчанию он не объявлен. Также следует включить поддержку C++ в OpenCL. Скоро кстати выйдет OpenCL 2.1, и вполне возможно что такой трюк и там прокатит. Можно попробовать проделать это с шейдерами, но OpenCL подходит больше всего. Жаль что для OpenCL нету GLM, а если бы он щас был... Тогда можно было такое накодить.
+144
uint8_t value = arg & 1 ? arg ^ 1 : arg;
+142
void BloomPattern::process(GLuint rectangleVao, float blurRadius) const
{
sptrFrameBufferTwo->enable();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
sptrBrightPassShaderProgram->enable();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, sptrFrameBufferThree->getColorTexture().getTexture());
sptrBrightPassShaderProgram->setUniform("colorTexture", 0);
glBindVertexArray(rectangleVao);
glViewport(0, 0, windowWidth >> 1, windowHeight >> 1);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, nullptr);
sptrFrameBufferOne->enable();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
sptrBlurShaderProgram->enable();
glBindTexture(GL_TEXTURE_2D, sptrFrameBufferTwo->getColorTexture().getTexture());
sptrBlurShaderProgram->setUniform("defaultTexture", 0);
sptrBlurShaderProgram->setUniform("blurRadius", 1.0F / (windowWidth >> 1), 0.0F, blurRadius);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, nullptr);
sptrFrameBufferTwo->enable();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBindTexture(GL_TEXTURE_2D, sptrFrameBufferOne->getColorTexture().getTexture());
sptrBlurShaderProgram->setUniform("defaultTexture", 0);
sptrBlurShaderProgram->setUniform("blurRadius", 0.0F, 1.0F / (windowHeight >> 1), blurRadius);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, nullptr);
sptrFinalFrameBuffer->enable();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
sptrBloomShaderProgram->enable();
glBindTexture(GL_TEXTURE_2D, sptrFrameBufferThree->getColorTexture().getTexture());
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, sptrFrameBufferTwo->getColorTexture().getTexture());
sptrBloomShaderProgram->setUniform("defaultTexture", 0);
sptrBloomShaderProgram->setUniform("brightpassTexture", 1);
glViewport(0, 0, windowWidth, windowHeight);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, nullptr);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
+64
XmlWriter<xhtml11::XHtmlDocument>(stream)
<html
<head
<title
<"Hello world!"
>title
>head
<body
<p
<"Some nice paragraph text."
>p
<img(src="http://example.com/hello.jpg",alt="Hello")>img
>body
>html;
кресты в квадрате. любителям темплейтов посвящается.
http://www.vandenoever.info/blog/2015/07/05/literal-xml-in-c++.html
Creating and processing XML feels awkward in most programming languages. With Blasien, a tiny C++11 header library, XML in C++ feels easy and natural. As an extra the XML that is written is mostly validated at compile time.
+144
var::var (double initial) {
(*this) = initial;
}
var::var (char *initial) {
(*this) = initial;
}
С воландесайта.http://habrahabr.ru/post/261351
+142
RECT rect;
GetWindowRect(hWnd, &rect);
int iWidth = rect.right - rect.left;
int iHeight = rect.bottom - rect.top;
Line(hDC, 0, 0, 5000, 0);
Line(hDC, 0, 0, 0, 5000);
Line(hDC, 0, iHeight - 1, iWidth, iHeight - 1);
Line(hDC, iWidth - 1, 0, iWidth - 1, iHeight - 1);
Рисование линий на границе окна.
+145
union Viewport
{
private:
D3D10_VIEWPORT viewport;
public:
struct {
INT x;
INT y;
UINT width;
UINT height;
FLOAT minDepth;
FLOAT maxDepth;
};
Viewport(){}
Viewport(const Viewport& viewport)
:viewport(viewport.viewport) {}
Viewport(D3D10_VIEWPORT viewport)
:viewport(viewport) {}
Viewport(INT x, INT y, UINT width, UINT height, FLOAT minDepth, FLOAT maxDepth)
:x(x), y(y), width(width), height(height), minDepth(minDepth), maxDepth(maxDepth){}
FLOAT GetAspectRatio();
Vector3 Unproject(Vector3 source, Matrix projection, Matrix view, Matrix world);
};
+142
float SGammaUIPanel::OnGetGamma() const
{
float DisplayGamma = GEngine->DisplayGamma;
return GEngine ? DisplayGamma : 2.2f;
}
Этот и другие прелести из UE в статье https://www.unrealengine.com/blog/how-pvs-studio-team-improved-unreal-engines-code