2015-10-04 82 views
0

我正在使用Visual C++ 2012在我的简单OpenGL游戏中创建一个块,并且遇到了一个奇怪的错误。这是完整的错误:无法解决“意外的文件结尾找到”错误

  • 消息 - 错误C1004:意外的结束文件中找到
  • 文件 - block.cpp
  • 线 - 27
  • - 1

这里是代码:

block.h

#pragma once 
#include "agent.h" 
#include <Engine2D/spritebatch.h> 

class Block { 
public: 
    Block(glm::vec2 dim, glm::vec4 uv, glm::vec2 pos, GLuint texture); 
    // Draws the block to the sprite batch 
    void draw(e2d::SpriteBatch& spriteBatch); 
    // Returns the position 
    glm::vec2 getPosition(); 
    // Returns the size 
    glm::vec2 getSize(); 
private: 
    glm::vec2 _dim; 
    glm::vec4 _uv; 
    glm::vec2 _pos; 
    GLuint _texture; 
}; 

block.cpp

#include "block.h" 

Block::Block(glm::vec2 dim, glm::vec4 uv, glm::vec2 pos, GLuint texture) : 
    _dim(dim), 
    _uv(uv), 
    _pos(pos), 
    _texture(texture) 
{} 

void Block::draw(e2d::SpriteBatch& spriteBatch) { 

    spriteBatch.draw(glm::vec4(_pos.x, _pos.y, _dim.x, _dim.y), _uv, e2d::color(), 0.0f, _texture); 

} 

glm::vec2 Block::getPosition() { 

    return _pos; 

} 

glm::vec2 Block::getSize() { 

    return _dim; 

} 
// ERROR LINE 

如果发现问题,或者可以在事业这将是大加赞赏阐述。谢谢!

注:

  • 的Engine2D/spritebatch.h是我创建了引擎的一部分。它只是绘制和渲染对象到屏幕上。这门课是和不可能有关的问题。
  • glm命名空间用于OpenGL数学库。它包含有用的矢量和矩阵类以及用于计算两点之间距离等函数的函数。
  • 当我使用e2d :: color时,它在里面创建一个带有RGBA颜色值的结构体。它是我的引擎的一部分,它的默认构造函数将所有的RGBA值设置为255.
+0

检查你的头文件,如果你有缺少分号或#endif卫兵 – Gabriel

回答

1

现在我已经回顾了它,我发现了错误的原因。这是因为我包括了我的agent.h类,从来没有做过任何事情。哎呀!

+0

我不认为这应该重要,如果agent.h是空的或不 – Gabriel

+0

或ms工作室坚持这样愚蠢的事情? – Gabriel

+0

@加布里埃尔我不知道。我只是注意到它,删除它,并且它工作。 – gooroo7

相关问题