I am trying to render a very simple scene by loading various parameters from a file (MLC.txt)

When compiling I receive the following error

main.cpp: In function ‘void renderScene()’:
main.cpp:77: error: ‘pBeam’ was not declared in this scope

H

Somehow the last paragraph of my post was lost ...

If I add the line Beam *pBeam into the void renderScene() function then a window appears but nothing is shown. I inserted a comment line to print the coordinates to a terminal ,which does not appear

Somehow the last paragraph of my post was lost ...

If I add the line Beam *pBeam into the void renderScene() function then a window appears but nothing is shown. I inserted a comment line to print the coordinates to a terminal ,which does not appear

Lets see your main.cpp file and the rest of what you have because I'm pretty sure you are not declaring "beam" correctly.

Lets see your main.cpp file and the rest of what you have because I'm pretty sure you are not declaring "beam" correctly.

good point - see attachment

Thanks in advance

Pretty sure that is the wrong main.cpp you linked.

Pretty sure that is the wrong main.cpp you linked.

okay now I've got it right - phew!

I see that you put Beam *pBeam=NULL; in your main() function. This does not mean that pBeam is now going to be a global variable that everything can use. I made a really crappy 2D batman game in OpenGL and having a clean layout is key and that pretty much means make a bunch of files that divide your program into sections (I see you did that with your class and that is a good start).

Anyways you should be able to fix the problem you have by declaring pBeam in a global scope (by declaring it outside of functions at the top of your file).

If you run into any other problems feel free to ask.

>>Anyways you should be able to fix the problem you have by declaring pBeam in a global scope (by declaring it outside of functions at the top of your file).

You should but that is not a good solution. Don't start of learning bad practices. It will only come back to haunt you. I can't look at your code right now, but I might get back at this later.

I totally agree that making everything global is a really poor way of coding but for projects like this where you are going to have your primary elements of the game being used lots you might as well make it global since you know you will be using it all the time.

If you have another way of doing it I too would like to see.

Thanks for all your help. I, like sfuo, would be interested in learning another way of doing this without defining stuff globally. But it works!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.