我有以下代码:
#include <SFML\Graphics.hpp>
#include <iostream>
int main(int argc, char* argv[])
{
sf::RenderWindow window(sf::VideoMode(640, 480), "SFML Render");
sf::Image image;
sf::Texture texture;
sf::Sprite sprite;
image.loadFromFile("D:/Project/Sprites/bt1.png");
texture.loadFromImage(image);
sprite.setTexture(texture);
sprite.setPosition(100.0f, 100.0f);
sf::Event event;
while (window.isOpen())
{
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(sprite);
window.display();
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这很简单,但没有用.
我尝试使用不同种类的路径:
D:/Project/CPP/Game_Engine/Debug/sprites/first.bmp
D:\\Project\\CPP\\Game_Engine\\Debug\\sprites\\first.bmp
d:\\Project\\CPP\\Game_Engine\\Debug\\sprites\\first.bmp
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用不同的文件:
D:/Project/Sprites/bt.png
D:/Project/Sprites/anim.bmp
D:/Project/Sprites/boy.jpg
Run Code Online (Sandbox Code Playgroud)
编译器指示在以下行:
image.loadFromFile("D:/Project/Sprites/bt1.png");
Run Code Online (Sandbox Code Playgroud)
更确切地说,程序在此行崩溃.

我的配置如下:

错误/崩溃消息如下:
Необработанноеисключениепоадресу0x5007DEF8(msvcr110.dll)вSFML_ERROR.exe:0xC0000005:нарушениеправдоступапричтениипоадресу0x03BC1000.
翻译如下:
SFML_ERROR.exe中0x5007DEF8(msvcr110.dll)的未处理异常:0xC0000005:地址0x03BC1000上的访问冲突读取.
如何在Eigen中转换矩阵(4x4)?
//identity matrix 4x4
/*type=*/Eigen::Matrix<float, 4, 4> /*name=*/result = Eigen::Matrix<float, 4, 4>::Identity();
//translation vector
// 3.0f
// 4.0f
// 5.0f
Translation<float, 3> trans(3.0f, 4.0f, 5.0f);
Run Code Online (Sandbox Code Playgroud)
即,我有矩阵:
1.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0
0.0 0.0 1.0 0.0
0.0 0.0 0.0 1.0
我想得到:
1.0 0.0 0.0 3.0
0.0 1.0 0.0 4.0
0.0 0.0 1.0 5.0
0.0 0.0 0.0 1.0
对?我怎么能这样做?
我可以做这个:
result(0, 3) = 3.0f;
result(1, 3) = 4.0f;
result(2, 3) = 5.0f;
Run Code Online (Sandbox Code Playgroud)
但它并不优雅.=)你的建议是什么?
如何将"特征矩阵"发送给GLSL?例如:
// Set up the model and projection matrix
Eigen::Matrix<GLfloat,4,4> projection_matrix;
projection_matrix = frustum(-1.0f, 1.0f, -aspect, aspect, 1.0f, 500.0f);
glUniformMatrix4fv(render_projection_matrix_loc, 1, GL_FALSE, &projection_matrix.data()[0]);
Run Code Online (Sandbox Code Playgroud)
我way(matrix.date()[0])为uBLAS 看了这个,但是Eigen不是uBLAS.我怎么能这样做?
我不明白 OpenGL 的缓冲区是如何工作的。我通过 OpenGL 红皮书第 8 版学习 OpenGL。例如,我有一个位置数组、一个颜色数组和一个索引数组:
static const GLfloat strip_position[] =
{
-4.0f, 0.0f, -1.0f, 1.0f, //0
-3.5f, -1.0f, -1.0f, 1.0f, //1
-3.0f, 0.0f, -1.0f, 1.0f, //2
-2.5f, -1.0f, -1.0f, 1.0f, //3
-2.0f, 0.0f, -1.0f, 1.0f, //4
-1.5f, -1.0f, -1.0f, 1.0f, //5
-1.0f, 0.0f, -1.0f, 1.0f, //6
-0.5f, -1.0f, -1.0f, 1.0f, //7
0.0f, 0.0f, -1.0f, 1.0f //8
};
static const GLfloat strip_colors[] =
{
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 0.0f, 1.0f,
1.0f, 0.0f, 1.0f, 1.0f,
1.0f, 0.0f, …Run Code Online (Sandbox Code Playgroud) 我使用VC++ 2013,我有以下代码:
#pragma warning(disable:4996)
#define D_SCL_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <object.pb.h>
using namespace std;
int main(int argc, char** argv)
{
Object object;
object.set_id(1);
object.set_name("Ermolaev Ivan");
object.set_vertex(300.0f);
fstream output("myfile", ios::out | ios::binary);
object.SerializeToOstream(&output);
return 0x0;
}
Run Code Online (Sandbox Code Playgroud)
但继续显示以下错误.
Error 1 error C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked …Run Code Online (Sandbox Code Playgroud) 例如,我有以下课程:
class singelton
{
public:
static singelton* Instance()
{
if (m_pInstance == 0)
{
m_pInstance = new singelton();
}
return m_pInstance;
}
void setData(std::string input) { data = input; }
void getData() const { std::cout << data << std::endl; }
private:
singelton() {}
~singelton() {}
static singelton* m_pInstance;
std::string data;
};
typedef singelton s;
//what is this? Why need a singleton name? I mean "singelton*".
singelton* singelton::m_pInstance = 0;
int main(int argc, char** argv)
{
s.Instance()->setData("Something...");
s.Instance()->getData();
return 0;
} …Run Code Online (Sandbox Code Playgroud)