I'm a c++
beginner , trying to build my first application with openGL
.
I'm trying to create a Room class that will take parameters like width, length and height to create a mesh object which I then want to draw from the main function.
At the moments I'm not trying to initialize Room with any parameters, just trying to create a basic mesh from within room, CPP rather than from main.
I'm having trouble creating a mesh object as a private variable within the class room, and then defining a method to draw it by calling it from main.
I'm using Benny's awesome tutorial and have his exact GitHub files on my visual studio solution.
Im posting it here, they include the mesh.h and mesh. CPP which are probably where the problem is coming from this link.
Here is the current code (I've included everything I include in main, just to make sure)
----Room.h ---------------
#pragma once
#include <iostream>
#include <SDL2/SDL.h>
#include "display.h"
#include "mesh.h"
#include "shader.h"
#include "texture.h"
#include "transform.h"
#include "camera.h"
class Room
{
public:
Room();
~Room();
void drawRoom();
private:
Mesh* mesh;
};
----Room.cpp ---------------
#include "Room.h"
#include <iostream>
#include <SDL2/SDL.h>
#include "display.h"
#include "mesh.h"
#include "shader.h"
#include "texture.h"
#include "transform.h"
#include "camera.h"
Room::Room()
{
Vertex vertices[] =
{
Vertex(glm::vec3(-1, -1, -1), glm::vec2(1, 0), glm::vec3(0, 0, -1)),
Vertex(glm::vec3(-1, 1, -1), glm::vec2(0, 0), glm::vec3(0, 0, -1)),
Vertex(glm::vec3(1, 1, -1), glm::vec2(0, 1), glm::vec3(0, 0, -1)),
Vertex(glm::vec3(1, -1, -1), glm::vec2(1, 1), glm::vec3(0, 0, -1)),
Vertex(glm::vec3(-1, -1, 1), glm::vec2(1, 0), glm::vec3(0, 0, 1)),
Vertex(glm::vec3(-1, 1, 1), glm::vec2(0, 0), glm::vec3(0, 0, 1)),
Vertex(glm::vec3(1, 1, 1), glm::vec2(0, 1), glm::vec3(0, 0, 1)),
Vertex(glm::vec3(1, -1, 1), glm::vec2(1, 1), glm::vec3(0, 0, 1)),
Vertex(glm::vec3(-1, -1, -1), glm::vec2(0, 1), glm::vec3(0, -1, 0)),
Vertex(glm::vec3(-1, -1, 1), glm::vec2(1, 1), glm::vec3(0, -1, 0)),
Vertex(glm::vec3(1, -1, 1), glm::vec2(1, 0), glm::vec3(0, -1, 0)),
Vertex(glm::vec3(1, -1, -1), glm::vec2(0, 0), glm::vec3(0, -1, 0)),
Vertex(glm::vec3(-1, 1, -1), glm::vec2(0, 1), glm::vec3(0, 1, 0)),
Vertex(glm::vec3(-1, 1, 1), glm::vec2(1, 1), glm::vec3(0, 1, 0)),
Vertex(glm::vec3(1, 1, 1), glm::vec2(1, 0), glm::vec3(0, 1, 0)),
Vertex(glm::vec3(1, 1, -1), glm::vec2(0, 0), glm::vec3(0, 1, 0)),
Vertex(glm::vec3(-1, -1, -1), glm::vec2(1, 1), glm::vec3(-1, 0, 0)),
Vertex(glm::vec3(-1, -1, 1), glm::vec2(1, 0), glm::vec3(-1, 0, 0)),
Vertex(glm::vec3(-1, 1, 1), glm::vec2(0, 0), glm::vec3(-1, 0, 0)),
Vertex(glm::vec3(-1, 1, -1), glm::vec2(0, 1), glm::vec3(-1, 0, 0)),
Vertex(glm::vec3(1, -1, -1), glm::vec2(1, 1), glm::vec3(1, 0, 0)),
Vertex(glm::vec3(1, -1, 1), glm::vec2(1, 0), glm::vec3(1, 0, 0)),
Vertex(glm::vec3(1, 1, 1), glm::vec2(0, 0), glm::vec3(1, 0, 0)),
Vertex(glm::vec3(1, 1, -1), glm::vec2(0, 1), glm::vec3(1, 0, 0)),
};
unsigned int indices[] = { 0, 1, 2,
0, 2, 3,
6, 5, 4,
7, 6, 4,
10, 9, 8,
11, 10, 8,
12, 13, 14,
12, 14, 15,
16, 17, 18,
16, 18, 19,
22, 21, 20,
23, 22, 20
};
mesh = new Mesh(vertices, sizeof(vertices) / sizeof(vertices[0]), indices, sizeof(indices) / sizeof(indices[0]));
}
Room::~Room()
{
}
void Room::drawRoom()
{
mesh.Draw();
}
I'm getting the following error:
Error C2228 left of '.Draw' must have class/struct/union ArchProgramer c:\users\nuno bártolo\documents\visual studio 2015\projects\archprogramer\archprogramer\room.cpp 78
Thank very much you for your help!