Форум программистов, компьютерный форум, киберфорум
OpenGL
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
0 / 0 / 0
Регистрация: 13.02.2015
Сообщений: 2
1

Окно вьюпорта OpenGL отдельным классом с прицепом GLEW

13.02.2015, 22:33. Показов 592. Ответов 0
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Всем привет,

Начал писать движок. Разработал хорошую архитектуру, в которой окна вьюпорта 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++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#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
В чем может быть проблема?

Спасибо!
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
13.02.2015, 22:33
Ответы с готовыми решениями:

Vibrator отдельным классом
Как можно сделать вибрацию в отдельном классе и вызвать его при нажатии на кнопку? Пробовал так...

Как осуществить вывод Console.WriteLine() отдельным классом
Вот пример программы static void Main(string args) { ListFiltering(); ...

Как сделать класс по записи отдельным классом от форм?
Код: public partial class Form1 : Form { public Form1() { InitializeComponent(); } private...

Как сделать вывод отдельным классом в виде таблицы
using System; using System.Collections.Generic; using System.Text; namespace Lab2b { class...

0
13.02.2015, 22:33
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
13.02.2015, 22:33
Помогаю со студенческими работами здесь

Закрывается OpenGL окно
Пишу программу, которая работает с векторами, мне надо чтобы пользователь взаимодействовал с...

Окно OpenGL на форме Qt
Добрый день! Помогите, вывести окно OpenGl на форму Qt,чтоб объект(в моем случае дерево) на нем...

Вывод текста в окно OpenGL - С++
Как вывести целое предложение или матрицу в окно OpenGL

Создать окно и подключить opengl
собственно вопрос такой: нужно создать окно и подключить к нему огл, но окно надо создать...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
1
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru