小编Tor*_*ous的帖子

我如何在Freeglut中画彩虹?

我正试图在openGL中绘制一个彩虹色的情节传奇.这是我到目前为止所得到的:

glBegin(GL_QUADS);
for (int i = 0; i != legendElements; ++i)
{
    GLfloat const cellColorIntensity = (GLfloat) i / (GLfloat) legendElements;
    OpenGL::pSetHSV(cellColorIntensity*360.0f, 1.0f, 1.0f);

    // draw the ith legend element
    GLdouble const xLeft = xBeginRight - legendWidth;
    GLdouble const xRight = xBeginRight;
    GLdouble const yBottom = (GLdouble)i * legendHeight /
    (GLdouble)legendElements + legendHeight;
    GLdouble const yTop = yBottom + legendHeight;

    glVertex2d(xLeft, yTop); // top-left
    glVertex2d(xRight, yTop); // top-right
    glVertex2d(xRight, yBottom); // bottom-right
    glVertex2d(xLeft, yBottom); // bottom-left
}

glEnd();
Run Code Online (Sandbox Code Playgroud)

legendElements是构成"彩虹"的离散方块的数量. …

c++ opengl freeglut

7
推荐指数
1
解决办法
3572
查看次数

使用Jenkins http-request-plugin进行基本身份验证

我试图用"Http Request Plugin"做一个简单的POST请求.我的问题是让凭据工作.我已经设置了全球凭证 user:pass.

但是在我的代码中尝试这个

withCredentials([usernameColonPassword(credentialsId: 'akamai', variable: 'akamai')]) {

    def response = httpRequest url: requestUrl, contentType: requestContentType, httpMode: requestHttpMode, requestBody: requestContent, authentication: akamai
    echo "Status: ${response.status}\nContent: ${response.content}"
}
Run Code Online (Sandbox Code Playgroud)

结果是

java.lang.IllegalStateException: Authentication 'user:pass' doesn't exist anymore
Run Code Online (Sandbox Code Playgroud)

groovy jenkins-plugins jenkins-pipeline

7
推荐指数
1
解决办法
1万
查看次数

Groovy 将路径拆分为名称和父级

我正在尝试将路径分成父级和名称。

当尝试时

String path = "/root/file"
File file = new File(path)

println("Name: " + file.name)
println("Parent: " + file.parent)
Run Code Online (Sandbox Code Playgroud)

我们得到

Name: file
Parent: /root
Run Code Online (Sandbox Code Playgroud)

通过 Windows 路径C:\\root\\file.exe我们得到

Name: C:\root\file.exe
Parent: null
Run Code Online (Sandbox Code Playgroud)

这是预期的行为吗?如果是的话我如何获得 Windows 路径的相同结果?(如果可能请不要使用正则表达式)

groovy path

6
推荐指数
1
解决办法
5388
查看次数

如果 C++11 lambda 返回错误类型,则不会出现 clang 警告或错误

如果 lambda 的返回类型不匹配,看起来我的 clang 编译器 (3.3) 不会生成任何错误:

#include <functional>
typedef std::function<void()> voidFunc;

void foo(voidFunc func) 
{
    func();
}

int main() 
{
    int i = 42;
    foo([i]()
    {
        return i;
    });
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

编译此代码不会显示任何错误:

clang++ -c -Xclang -stdlib=libc++ -std=c++11 -Weverything -Wno-c++98-compat -Wno-missing-prototypes -o foo.o foo.cpp
Run Code Online (Sandbox Code Playgroud)

如何针对此类问题生成类型错误?

编辑:

这会产生类型错误:

#include <functional>

struct A {};
struct B {};

typedef std::function<A()> aFunc;

void foo(aFunc func)
{
    func();
}

int main()
{
    int i = 42;
    foo([i]() 
    {
        return B();
    });
    return 0;
} …
Run Code Online (Sandbox Code Playgroud)

c++ lambda types clang c++11

4
推荐指数
1
解决办法
1300
查看次数

创建vector <thread>

我只是想创建一个std::vector线程并运行它们.

码:

thread t1(calc, 95648, "t1");
thread t2(calc, 54787, "t2");
thread t3(calc, 42018, "t3");
thread t4(calc, 75895, "t4");
thread t5(calc, 81548, "t5");

vector<thread> threads { t1, t2, t3, t4, t5 };
Run Code Online (Sandbox Code Playgroud)

错误:"函数std :: thread :: thread(const std :: thread&)"(在"C:\ Program Files(x86)\ Microsoft Visual Studio 12.0\VC\include\thread"的第70行声明)不能引用 - 它是一个已删除的函数

thread(const thread&) = delete;
Run Code Online (Sandbox Code Playgroud)

什么似乎是问题?

c++

0
推荐指数
1
解决办法
166
查看次数