2015-10-04 84 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

相關問題