Salut!
J'ai une classe dans un namespace SDLWindow :
Code cpp : Sélectionner tout - Visualiser dans une fenêtre à part
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 #include "../../../include/odfaeg/Graphics/sdlWindow.hpp" namespace odfaeg { namespace window { SDLWindow::SDLWindow(unsigned int width, unsigned int height, std::string title) { create(width, height,title); } void SDLWindow::create(unsigned int width, unsigned int height, std::string title) { window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL); this->width = width; this->height = height; } void SDLWindow::initSDL() { if (SDL_Init(SDL_INIT_VIDEO) != 0 ) { fprintf(stdout,"Échec de l'initialisation de la SDL (%s)\n",SDL_GetError()); return -1; } } void SDLWindow::onCreate() { } void SDLWindow::onResize() { } void SDLWindow::setPosition(unsigned int x, unsigned int y) { SDL_SetWindowPosition(window, x, y); } bool SDLWindow::pollEvent(SDL_Event event) { } bool SDLWindow::isOpen() { return window != nullptr; } void SDLWindow::close() { SDL_DestroyWindow(window); window = nullptr; } void SDLWindow::display() { SDL_GL_SwapWindow(window); } SDL_Window* SDLWindow::getWindow() { return window; } SDLWindow::~SDLWindow() { SDL_DestroyWindow(window); } } }
Et une autre classe dans un autre namespace qui hérite de SDLWindow :
Code cpp : Sélectionner tout - Visualiser dans une fenêtre à part
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 #include "../../../include/odfaeg/Graphics/sdlRenderWindow.hpp" #include "glCheck.h" namespace odfaeg { namespace graphic { using namespace sf; SDLRenderWindow::SDLRenderWindow(unsigned int width, unsigned int height, const std::string& title, const sf::ContextSettings& settings) { this->settings = settings; activated = false; create(width, height, title); } bool SDLRenderWindow::activate(bool active) { if (active && !activated) { if(SDL_GL_MakeCurrent(window::SDLWindow::getWindow(), context)) { return false; } else { activated = true; return true; } } else if (!active && activated) { if(SDL_GL_MakeCurrent(window::SDLWindow::getWindow(), nullptr)) { return false; } else { activated = false; return true; } } return true; } bool SDLRenderWindow::isActive() { return activated; } bool SDLRenderWindow::isUsingDepthTest() const { return useDepthTest; } void SDLRenderWindow::onCreate() { SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, settings.majorVersion); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, settings.minorVersion); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, settings.stencilBits); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, settings.depthBits); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, (settings.antialiasingLevel > 0) ? 1 : 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, settings.antialiasingLevel); context = SDL_GL_CreateContext(window); priv::ensureGlewInit(); /*glewExperimental = GL_TRUE; GLenum status = glewInit(); if (status == GLEW_OK) { std::cout<<"Glew initialized!"<<std::endl; } else { err() << "Failed to initialize GLEW, " << glewGetErrorString(status) << std::endl; }*/ // Just initialize the render target part RenderTarget::initialize(); } SDLRenderWindow::~SDLRenderWindow() { SDL_GL_DeleteContext(context); } } }
Le problème c'est que le compilateur me dit qu'il ne trouve pas la méthode getWindow() de la classe mère :
Est ce que la classe mère doit être dans le même namespace que la classe fille ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 /home/laurent/Développement/Projets-c++/ODFAEG/src/odfaeg/Graphics/sdlRenderWindow.cpp|14|error: getWindow is not a member of odfaeg::window::SDLWindow|
Partager