试图在其他头文件中包含头(C ++)

时间:2018-12-13 02:32:49

标签: c++

嗨,我正在尝试将Toolkit.h包含在Neptune Actions.h中

工具包(库)

动作(功能)

代码运行时,编译器无法识别Neptune Actions.h中的任何功能,这意味着它没有收到Toolkit.h。为什么工具包中的库在Actions中不被识别?我想念什么或做错什么? 谢谢你的帮助!

注意:在Neptune.cpp项目中会发生相同的效果,但我认为这是因为Action无法获取工具包

下面的海王星动作。包括:init()

此处gl, GL代码会产生以下错误(示例):

1> c:\ users \ jjsun \ source \ repos \ project neptune \ project neptune \ neptune actions.h(79):错误C2065:'GL_SMOOTH':未声明的标识符

1> c:\ users \ jjsun \ source \ repos \ project neptune \ project neptune \ neptune actions.h(79):错误C3861:'glShadeModel':找不到标识符

#ifndef Neptune Actions_H_INCLUDED
#define Neptune Actions_H_INCLUDED

// ToolKit not moving into both Source/Project
#include "Neptune ToolKit.h"
#include <iostream>

void init(void)
{
    // Clear Color + Shade Model
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glShadeModel(GL_SMOOTH);

    // Star Initialization
    glNewList(1, GL_COMPILE);
    glBegin(GL_POINTS);
    glColor3f(1.0, 1.0, 1.0);
    for (int i = 0; i < 200; i++) {
        for (int j = 0; j < 300; j++) {
            if (((i + j) % 2) == 0) {
                glVertex3f(100 * i, 100 * j, 0.0);
            }
        }
    }
    glEnd();
    glEndList();

    // Material Specs
    GLfloat mat_specular[] = { 0.8, 0.8, 0.9, 0.1 };
    GLfloat mat_shininess[] = { 128.0 };
    GLfloat lightDiffuse[] = { 1.0, 1.0, 1.0, 0.0 };
    GLfloat lmodel_ambient[] = { 0.1, 0.2, 0.7, 0.0 };

    // Light 0 Initialized.
    GLfloat light0[] = { 1.0, 1.0, 1.0, 0.1 };
    GLfloat light_position[] = { 1.0, 0.5, 0.0, -100.0 };

    // Light 1 Initialized 
    GLfloat light1[] = { 0.3, 0.2, 0.8 };
    GLfloat light_position1[] = { -0.3, 1.0, 0.3, -50.0 };

    GLfloat light2[] = { 1.0, 1.0, 1.0 };
    GLfloat light_position2[] = { 0.0, 0.0, 0.0, 0.0 };
    // Light 0
    glLightfv(GL_LIGHT0, GL_SPECULAR, light0);
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);

    // Light 1
    glLightfv(GL_LIGHT1, GL_SPECULAR, light1);
    glLightfv(GL_LIGHT1, GL_POSITION, light_position1);

    // Spotlight Light 2
    glLightfv(GL_LIGHT2, GL_SPOT_CUTOFF, light2);

    // Mat Specs Implmentations.
    glMaterialfv(GL_FRONT, GL_DIFFUSE, lightDiffuse);
    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);

    //Ambient surrounding light on object.
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);

    // Enable Lighting and Depth
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    //glEnable(GL_LIGHT1);
    glEnable(GL_LIGHT2);
    glEnable(GL_DEPTH_TEST);

    // Enable AntiAliased Lines
    glEnable(GL_LINE_SMOOTH);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
    glLineWidth(1.5);
}

ToolKit.h在下面

#ifndef Neptune ToolKit_H
#define Neptune ToolKit_H

#include <iostream>
//GL/Windows
#include <Windows.h>
#include <GL/glew.h>
#include <GL/GL.h>
#include <GL/GLU.h>
#include <glut.h>
 //Texture 
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
 //Math
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

1 个答案:

答案 0 :(得分:0)

将您的Neptune Action.h标头文件重命名为Neptune_Action.h之类的文件,然后在此之后更新标头后卫