Russian Qt Forum
Март 29, 2024, 16:21 *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

Войти
 
  Начало   Форум  WIKI (Вики)FAQ Помощь Поиск Войти Регистрация  

Страниц: [1]   Вниз
  Печать  
Автор Тема: Окно вьюпорта OpenGL отдельным классом с прицепом GLEW  (Прочитано 4716 раз)
Hrundel
Гость
« : Февраль 13, 2015, 22:15 »

Всем привет,

Начал писать движок. Разработал хорошую архитектуру, в которой окна вьюпорта OpenGL представлено отдельным классом. В минимальной сборке все запускается.
Написал класс шейдера, все компилится. Добавляю его к вьюпорту начинаются ошибки:

Цитировать
1>GLSLShader.obj : warning LNK4075: /EDITANDCONTINUE wird aufgrund der Angabe von /OPT:LBR ignoriert.
1>TwoDimViewportControl.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""private: static class GLSLShader TwoDimViewportControl::shader" (?shader@TwoDimViewportControl@@0VGLSLShader@@A)".
1>TwoDimViewportControl.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""private: static unsigned int TwoDimViewportControl::vaoID" (?vaoID@TwoDimViewportControl@@0IA)".
1>TwoDimViewportControl.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""private: static unsigned int TwoDimViewportControl::vboVerticesID" (?vboVerticesID@TwoDimViewportControl@@0IA)".
1>TwoDimViewportControl.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""private: static unsigned int TwoDimViewportControl::vboIndicesID" (?vboIndicesID@TwoDimViewportControl@@0IA)".
1>TwoDimViewportControl.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""private: static struct TwoDimViewportControl::Vertex * TwoDimViewportControl::vertices" (?vertices@TwoDimViewportControl@@0PAUVertex@1@A)".
1>TwoDimViewportControl.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""private: static unsigned short * TwoDimViewportControl::indices" (?indices@TwoDimViewportControl@@0PAGA)".
1>E:\PROJECTS\Software Projects\TwoDimEngine\Implementierung\TwoDimEngine\TwoDimEngine_v.0.0.0_FreeGLUT_GLEW\Debug\TwoDimEngine_v.0.0.0.exe : fatal error LNK1120: 6 nicht aufgelöste Externe
========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 0 aktuell, 0 übersprungen ==========

Все ошибки исходят из этой функции:
Код
C++ (Qt)
void TwoDimViewportControl::bindShader()
{
GL_CHECK_ERRORS
//load the shader
shader.LoadFromFile(GL_VERTEX_SHADER, "shaders/shader.vert");
shader.LoadFromFile(GL_FRAGMENT_SHADER, "shaders/shader.frag");
//compile and link shader
shader.CreateAndLinkProgram();
shader.Use();
//add attributes and uniforms
shader.AddAttribute("vVertex");
shader.AddAttribute("vColor");
shader.AddUniform("MVP");
shader.UnUse();
 
GL_CHECK_ERRORS
 
//setup triangle geometry
//setup triangle vertices
vertices[0].color=glm::vec3(1,0,0);
vertices[1].color=glm::vec3(0,1,0);
vertices[2].color=glm::vec3(0,0,1);
 
vertices[0].position=glm::vec3(-1,-1,0);
vertices[1].position=glm::vec3(0,1,0);
vertices[2].position=glm::vec3(1,-1,0);
 
//setup triangle indices
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
 
GL_CHECK_ERRORS
 
//setup triangle vao and vbo stuff
glGenVertexArrays(1, &vaoID);
glGenBuffers(1, &vboVerticesID);
glGenBuffers(1, &vboIndicesID);
GLsizei stride = sizeof(Vertex);
 
glBindVertexArray(vaoID);
 
glBindBuffer (GL_ARRAY_BUFFER, vboVerticesID);
//pass triangle verteices to buffer object
glBufferData (GL_ARRAY_BUFFER, sizeof(vertices), &vertices[0], GL_STATIC_DRAW);
GL_CHECK_ERRORS
//enable vertex attribute array for position
glEnableVertexAttribArray(shader["vVertex"]);
glVertexAttribPointer(shader["vVertex"], 3, GL_FLOAT, GL_FALSE,stride,0);
GL_CHECK_ERRORS
//enable vertex attribute array for colour
glEnableVertexAttribArray(shader["vColor"]);
glVertexAttribPointer(shader["vColor"], 3, GL_FLOAT, GL_FALSE,stride, (const GLvoid*)offsetof(Vertex, color));
GL_CHECK_ERRORS
//pass indices to element array buffer
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndicesID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), &indices[0], GL_STATIC_DRAW);
GL_CHECK_ERRORS
 
cout<<"Initialization successfull"<<endl;
}
 

В заголовочном:
Код
C++ (Qt)
#pragma once
 
#ifndef TWODIMVIEWPORCONTROL_H
#define TWODIMVIEWPORCONTROL_H
 
/*
Right at the start of the above code, some headers are being included.
The include order matters! To use GLEW with GLFW, the GLEW header must
be included before the GLFW header. Then, after that, include any other
library that may be required .
*/

 
//#define GLEW_STATIC
 
//Include GLEW  
   #include <GL/glew.h>  
 
   //Include GLFW  
   #include <GLFW/glfw3.h>  
 
//Include FreeGLUT
#include <GL/freeglut.h>
 
   //Include the standard C++ headers  
   #include <stdio.h>  
   #include <stdlib.h>  
#include <iostream>
#include <SOIL.h>
 
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "GLSLShader.h"
 
#define GL_CHECK_ERRORS assert(glGetError()== GL_NO_ERROR);
 
/**
TwoDimViewportControl is a class designed to store all of OpenGL functions and keep them
out of the way of  application logic. Here stored the ability to create an OpenGL
context on a given window and then render to that window.
*/

 
class TwoDimViewportControl
{
public:
TwoDimViewportControl(void);
virtual ~TwoDimViewportControl(void);
int initViewportControl(int argc, char **argv);
 
void setAffectPolygonSize(bool input){TwoDimViewportControl::affectPolygonSize = input;}
void setZoomFactor(double zoom){TwoDimViewportControl::zoomFactor = zoom;}
 
private:
static void display();
static void resize(int w, int h) ;
static void error_callback(int error, const char* description);
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods);
static void OnInit();
static void OnShutdown() ;
static void OnResize(int nw, int nh);
static void OnRender();
static void bindShader();
 
//screen size
static const int WIDTH  = 1280;
static const int HEIGHT = 800;
 
//shader reference
static GLSLShader shader;
 
//vertex array and vertex buffer object for fullscreen quad
static GLuint vaoID;
static GLuint vboVerticesID;
static GLuint vboIndicesID;
 
//out vertex struct for interleaved attributes
struct Vertex {
glm::vec3 position;
glm::vec3 color;
};
 
//triangle vertices and indices
static Vertex vertices[3];
static GLushort indices[3];
 
static bool affectPolygonSize;
static double zoomFactor;
};
 
#endif //TWODIMVIEWPORCONTROL_H
 
 
 

В чем может быть проблема?


Спасибо!
« Последнее редактирование: Февраль 13, 2015, 22:18 от Hrundel » Записан
Old
Джедай : наставник для всех
*******
Offline Offline

Сообщений: 4349



Просмотр профиля
« Ответ #1 : Февраль 14, 2015, 09:10 »

А вы инициализируете, где нибудь, указанные в сообщениях переменные?
Записан
Old
Джедай : наставник для всех
*******
Offline Offline

Сообщений: 4349



Просмотр профиля
« Ответ #2 : Февраль 15, 2015, 02:11 »

Конечно, однозначно.
А можно посмотреть вывод линкера на английском языке?
Записан
Hrundel
Гость
« Ответ #3 : Февраль 15, 2015, 12:56 »

Old, ну конечно, вы правы. Я их инициализировал, потом закомментировал и забыл, что они так и остались закомментироваными.
Спасибо. Извините за даром потраченное время.
« Последнее редактирование: Февраль 15, 2015, 13:00 от Hrundel » Записан
Страниц: [1]   Вверх
  Печать  
 
Перейти в:  


Страница сгенерирована за 0.117 секунд. Запросов: 23.