我正在尝试为我的OpenGL项目创建一个加载屏幕并阅读它以使其正常工作,最好使用线程.我试图用我的线程调用我的函数,但我不断收到这些错误:
错误C2064:术语不评估为采用3个参数的函数
智能感知:无构造"的std ::螺纹::线程"的实例相匹配的参数列表参数类型有:(无效(屏幕*newScreen,布尔activeVisuals,布尔activeControls),播放屏幕*,布尔,布尔)
这是我的代码:
//LoadingScreen
class LoadingScreen
{
LoadingScreen();
void LoadNewScreen(Screen* newScreen, bool activeVisuals, bool activeControls);
void Setup();
};
void LoadingScreen::LoadNewScreen(Screen* newScreen, bool activeVisuals, bool activeControls)
{
}
void LoadingScreen::Setup()
{
PlayScreen *playScreen = new PlayScreen();
std::thread first(LoadingScreen::LoadNewScreen,playScreen, true, true);// , playScreen, true, true);
first.join();
}
//source.cpp
LoadingScreen loadingScreen;
int main()
{
LoadingScreen loadingScreen = LoadingScreen();
loadingScreen.Setup();
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我正试图摆脱立即模式,因为我不断被告知它真的不是在Opengl中编程的最佳方式.我找到了一个教程,它将制作一个立方体并为其着色,但它不包括纹理.
这是我的代码:
GLfloat vertices[] = { 1, 1, 1, -1, 1, 1, -1,-1, 1, 1,-1, 1, // v0,v1,v2,v3 (front)
1, 1, 1, 1,-1, 1, 1,-1,-1, 1, 1,-1, // v0,v3,v4,v5 (right)
1, 1, 1, 1, 1,-1, -1, 1,-1, -1, 1, 1, // v0,v5,v6,v1 (top)
-1, 1, 1, -1, 1,-1, -1,-1,-1, -1,-1, 1, // v1,v6,v7,v2 (left)
-1,-1,-1, 1,-1,-1, 1,-1, 1, -1,-1, 1, // v7,v4,v3,v2 (bottom)
1,-1,-1, -1,-1,-1, -1, 1,-1, 1, 1,-1 }; // v4,v7,v6,v5 (back)
// normal array
GLfloat normals[] = { …Run Code Online (Sandbox Code Playgroud) 目前我正在尝试使用OpenGL在C++中制作游戏引擎,并希望让3D动画能够正常工作.我被建议使用Assimp并且能够找到一个让静态模型工作的教程,但我不知道从哪里开始动画.我一直试图谷歌它,但一直无法找到任何有用的东西.如何修改代码以获取动画?建议使用哪种文件格式?
这是我目前的代码:
//Mesh.h
#include <string>
#include "glut\include\GL\glew.h"
#include "glut\include\GL\glut.h"
#include <assimp/Importer.hpp> // C++ importer interface
#include <assimp/scene.h> // Output data structure
#include <assimp/postprocess.h> // Post processing fla
//textures
#include <SOIL.h>
class Mesh
{
public:
Mesh(void);
Mesh(std::string filename, std::string textureFilename, float x, float y, float z, float width, float height, float depth, float rotX, float rotY, float rotZ);
~Mesh(void);
void Init(std::string filename);
void LoadTexture(std::string textureName);
void Draw();
private:
GLfloat *vertexArray;
GLfloat *normalArray;
GLfloat *uvArray;
GLint numVerts;
GLuint m_Texture[1];
float m_CenterX, m_CenterY, …Run Code Online (Sandbox Code Playgroud) 我写了一堂课来绘制一个平面并在上面放置一个纹理。我还开设了灯光课程。看起来我的光会影响固体物体,但它不会改变我的平面上的照明。无论如何,我的飞机似乎总是具有相同的照明。知道为什么它不起作用吗?
这就是我运行项目时的样子(圆锥体显示光线来自哪里): https: //i.stack.imgur.com/g1xOo.png
这是我的代码:
class Light
{
public:
//light constructor
void Draw();
private:
GLenum m_LightSource;
float m_Ambient[4];//ambient is light all around
float m_Specular[4];//gleem that hits an object
float m_Diffuse[4];//lights oart of an object
float m_SpotlightWidth;
float m_Position[4];
float m_Attenuation;
float m_MaterialSpecular[4];
float m_MaterialShine[1];
};
void Light::Draw()
{
glPushMatrix();
glTranslatef(m_Position[0], m_Position[1], m_Position[2]); // Move the spotlight.
// Light properties.
glLightfv(m_LightSource, GL_AMBIENT, m_Ambient);
glLightfv(m_LightSource, GL_DIFFUSE, m_Diffuse);
glLightfv(m_LightSource, GL_SPECULAR, m_Specular);
glEnable(m_LightSource);// Enable particular light source.
// Material properties shared by all the …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试用C++制作游戏.在我的代码中,我试图嵌套我的变量,以便我的主要没有很多包含.我现在的问题是我班上变量的值没有变化.单步执行代码会显示它设置值,但它不起作用.有谁知道发生了什么?先感谢您.
这是我到目前为止:
Location.h
#ifndef LOCATION_H
#define LOCATION_H
#include <string>
class Location
{
public:
Location(void);
Location(std::string name);
~Location(void);
std::string GetName();
void SetName(std::string value);
private:
std::string m_Name
};
#endif
Run Code Online (Sandbox Code Playgroud)
Location.cpp
#include "Location.h"
Location::Location(void): m_Name("") {}
Location::Location(std::string name): m_Name(name) {}
Location::~Location(void)
{
}
std::string Location::GetName()
{return m_Name;}
void Location::SetName(std::string value){m_Name = value;}
Run Code Online (Sandbox Code Playgroud)
PlayerStats.h
#ifndef PLAYERSTATS_H
#define PLAYERSTATS_H
#include "Location.h"
class PlayerStats
{
public:
PlayerStats(void);
~PlayerStats(void);
Location GetLocation();
void SetLocation(Location location);
private:
Location m_Location;
};
#endif
Run Code Online (Sandbox Code Playgroud)
PlayerStats.cpp
#include "PlayerStats.h"
PlayerStats::PlayerStats(void): m_Location(Location()) {}
PlayerStats::~PlayerStats(void)
{ …Run Code Online (Sandbox Code Playgroud)