错误C2065:' mClock':未声明的标识符 [英] error C2065: 'mClock': undeclared identifier

查看:229
本文介绍了错误C2065:' mClock':未声明的标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我已经在renderer.h文件中声明了'mClock'。为什么现在说它在我的renderer.cpp文件中链接到头文件时未定义。这可能是因为我需要在范围内声明它。有人可以给我一个
的例子吗? 

I understand that I have already declared 'mClock' in my renderer.h file. Why is it now saying it is undefined in my renderer.cpp file when it is linked to the header file. Could this be because I need to declare it in the scope.. Could someone give me an example of this? 

我的错误代码:

MY ERROR CODES:




MY RENDERER.CPP文件:

MY RENDERER.CPP FILE:

# include< GL / glew.h>

#include< GLFW / glfw3.h>

#include" Renderer.h"

#include" Timer.h"

#include" Windows.h"





#b包括< iostream>

$


$
int WINAPI wWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPWSTR lpCmdLine,int nShowCmd)

{

$


$
GLFWwindow *窗口;



/ *初始化库* / $




渲染::渲染()

{



mClock =新时钟;

}



渲染::〜渲染()

{

shutdown();

}

bool Rendering :: initialize(uint width,uint height,bool fullscreen,std :: string window_title)

{

if(!glfwInit()){

返回-1;

}





/ *创建一个窗口模式窗口及其OpenGL上下文* / b
window = glfwCreateWindow(640,480," Hello World",NULL,NULL);

if(!window)

{

glfwTerminate();

返回-1;

}



/ *使窗口的上下文变为当前* / b
glfwMakeContextCurrent(window);
$


glViewport(0,0,(GLsizei)宽度,(GLsizei)高度);

glOrtho(0,(GLsizei)width,(GLsizei)height,0,1,-1);



glMatrixMode(GL_PROJECTION);

glLoadIdentity();



glfwSwapInterval(1);

glEnable(GL_SMOOTH);

glEnable(GL_DEPTH_TEST);

glEnable(GL_BLEND);

glDepthFunc(GL_LEQUAL);

glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);

glEnable(GL_TEXTURE_2D);

glLoadIdentity();



返回true;

}




bool渲染::渲染()

{

/ *循环直到用户关闭窗口* / b
if(!glfwWindowShouldClose(window))

返回false;

/ *这里渲染* /

mClock-> reset();
$


glfwPollEvents();



if(mClock-> step())

{

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
$


glfwSwapBuffers(窗口);



mClock-> update();

}



返回true;

}



void渲染: :shutdown()

{
$


glfwDestroyWindow(window);

glfwTerminate();

}



GLFWwindow * Rendering :: getCurrentWindow()

{

返回窗口;

}



}

#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include "Renderer.h"
#include "Timer.h"
#include "Windows.h"


#include <iostream>



int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd)
{



GLFWwindow* window;

/* Initialize the library */


Rendering::Rendering()
{

mClock = new Clock;
}

Rendering::~Rendering()
{
shutdown();
}
bool Rendering::initialize(uint width, uint height, bool fullscreen, std::string window_title)
{
if (!glfwInit()) {
return -1;
}


/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}

/* Make the window's context current */
glfwMakeContextCurrent(window);

glViewport(0, 0, (GLsizei)width, (GLsizei)height);
glOrtho(0, (GLsizei)width, (GLsizei)height, 0, 1, -1);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glfwSwapInterval(1);
glEnable(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glEnable(GL_TEXTURE_2D);
glLoadIdentity();

return true;
}


bool Rendering::render()
{
/* Loop until the user closes the window */
if (!glfwWindowShouldClose(window))
return false;
/* Render here */
mClock->reset();

glfwPollEvents();

if (mClock->step())
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glfwSwapBuffers(window);

mClock->update();
}

return true;
}

void Rendering::shutdown()
{

glfwDestroyWindow(window);
glfwTerminate();
}

GLFWwindow* Rendering::getCurrentWindow()
{
return window;
}

}

MY RENDERER.H文件:

MY RENDERER.H FILE:

#pragma once zh-b $ b #include" Common.h"







类时钟;



类渲染

{

public:

渲染();

〜渲染();



$
bool initialize(uint width,uint height,bool fullscreen,std :: string window_title =" Rendering window");

void shutdown();
$


bool render();
$


GLFWwindow * getCurrentWindow();





private:

GLFWwindow *窗口;

时钟* mClock;



};

#pragma once
#include "Common.h"



class Clock;

class Rendering
{
public:
Rendering();
~Rendering();


bool initialize(uint width, uint height, bool fullscreen, std::string window_title = "Rendering window");
void shutdown();

bool render();

GLFWwindow* getCurrentWindow();


private:
GLFWwindow * window;
Clock* mClock;

};

推荐答案

似乎
渲染构造函数,析构函数等在
wWinMain
函数中显示不正确。将它们放在此功能之外。

Seems that the Rendering constructor, destructor, etc., appear incorrectly inside the wWinMain function. Place them outside this function.


这篇关于错误C2065:&amp;#39; mClock&amp;#39;:未声明的标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆