PDA

View Full Version : No idea how to start



Jossos
07-02-2012, 06:07 AM
I've actually figured out the problems I've been having, and am following this tutorial to learn openGL: http://www.arcsynthesis.org/gltut/

If you would like to help me, just check out the latest post in this thread. I'll keep all my problems together in one thread, rather than a new thread for each.

This was what this thread was initially.

So I've spent the last few hours scouring google for answers and haven't gotten anything. I have a decent knowledge of c++ and Microsoft visual studio set up, and I just can't get any openGL programs to work. The problems are weird and the programs I copy/paste are always missing stuff (even with all the include files working fine). For example I copy-pasted the code from this page: http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Chapter-2:-Hello-World:-The-Slideshow.html and there's 3 things I'm missing apparently ('render' and 'update_fade_factor' are undeclared identifiers and 'make_resources' can't be found.) and somehow the code used by the originator worked just fine.

I'm pretty newbie, and I just want to play with this thing, but it's impossible to even get a blank window. All tutorials I have found are either outdated or assume you know how to get everything perfectly set up.

I'm eager to learn, but I can't even start with all this crap getting in the way. If I can just make a blank window that would be totally awesome, and I could work my way from there.

PS: freeImage has no freeImage.lib file included with it now, which is annoying since tutorials using it require that this file be included.
PSS: VS refuses to acknowledge the existence of glaux.h, but it recognises all the other files in the same folder. This is really frustrating and makes no sense to me.

Any help/guidance is very much appreciated.

ZbuffeR
07-02-2012, 02:56 PM
http://www.arcsynthesis.org/gltut/
This one should have everything you need. The author is often around these forum if you need help.

Jossos
07-02-2012, 03:24 PM
"The source to this tutorial, found in Tut1 Hello Triangle/tut1.cpp, is fairly simple. The project file that builds the final executable actually uses two source files: the tutorial file and a common framework file found in framework/framework.cpp. The framework file is where the actual initialization of FreeGLUT is done; it is also where main is. This file simply uses functions defined in the main tutorial file."

Where am I meant to get these?

Alfonse Reinheart
07-02-2012, 04:08 PM
Where am I meant to get these?

Maybe from the page that explains how to build the tutorials. (http://www.arcsynthesis.org/gltut/Building%20the%20Tutorials.html) ;)

The book is meant to be read front-to-back.

Jossos
07-02-2012, 04:27 PM
"MSVCRTD.lib(wcrtexew.obj) : error LNK2019: unresolved external symbol _wWinMain@16 referenced in function ___tmainCRTStartup"

I'm about to give up. I'm frustrated beyond belief

Alfonse Reinheart
07-02-2012, 05:55 PM
If you're so frustrated, just stop already and come back to it when you've calmed down.

If there is a problem, you need to explain the steps you took that led to the problem. Simply posting an error message isn't helpful to anyone.

Jossos
07-02-2012, 06:43 PM
Ok I calmed down, and am following this: http://www.arcsynthesis.org/gltut/Building%20the%20Tutorials.html

I'm at this line: "The SDK his library uses Premake to generate its build files. So, with premake4.exe in your path, go to the glsdk directory. Type premake4 plat, where plat is the name of the platform of choice (Type where???). For Visual Studio 2008, this would be “vs2008”; for VS2010, this would be “vs2010.” This will generate Visual Studio projects and solution files for that particular version."

I got no idea wtf it's talking about. I downloaded premake4 which when run opens a console window and quickly dissapears. What am I suppose to be doing here? where do type this stuff?

Alfonse Reinheart
07-02-2012, 08:16 PM
As stated at the top of the page, "You will need minimal familiarity with using the command line in order to build these tutorials." You type that line into the command line. If you don't know what that is... I'm not sure how much I can help. I don't know of any Windows help pages that explain what a command prompt is and how to use it.

Jossos
07-02-2012, 08:40 PM
I TYPE THat line in command prompt and nothing happens. I'm in the directory.

Jossos
07-02-2012, 08:51 PM
Good news folks I did a crash course in command prompt and got it working. Just want to say, despite my frustration, you guys have actually helped a lot! I'm going to continue to bump this thread with my problems as I come accross them. You may respond or not as you see fit, but I do want to thank you helpful folks for your replies.

Jossos
07-02-2012, 11:16 PM
Just a quick question: vectors ( with x,y,z) for opengl have no relation to the vectors in c++ right (the "vector<string> words")? Or are they somehow related?

thokra
07-03-2012, 12:11 AM
No, none whatsoever - and a vector is not an OpenGL concept as well. In mathematics, an n-component vector is an entity of an n-dimensional vector space, i.e. a 3-component vector is an entity of the R^3. A std::vector in C++ is simply a dynamically growing (or shrinking if demanded) container with an internal C-array. C-arrays are also referred to as vectors (or sometimes as fields) but essentially represent nothing else than a contiguous, one-dimensional area in memory.

Since vectors are used to describe positions and directions in space and linear transformations between vector spaces are an essential concept in computer graphics - as is linear algebra in general - it is no coincidence you have to deal with such entities when doing graphics programming with OpenGL. When you define vertex attributes, you'll do it using vectors. When doing a transformation from object space to eye space, you'll do a linear transformation from R^4 to R^4 using a 4x4 matrix (or 3x4 to spare your shader the 4th row being (0,0,0,1)).

Jossos
07-03-2012, 07:14 AM
Ok so, I have these boolean arrays created in one of my header files above a bunch of functions that use them:

bool* keyStates = new bool[256]; // Create an array of boolean values of length 256 (0-255)
bool* keySpecialStates = new bool[246]; // Create an array of boolean values of length 246 (0-245)

And for some reason, I get this compiler error:

error LNK2005: "bool * keyStates" (?keyStates@@3PA_NA) already defined in main.obj
error LNK2005: "bool * keySpecialStates" (?keySpecialStates@@3PA_NA) already defined in main.obj

I'm not sure what this means, even after googling it. These are the only declarations of these arrays in the program, they are right before the functions they are used in.

Help is appreciated!

ZbuffeR
07-03-2012, 11:04 AM
Rename your vars with something silly like append AAA to the name to rule out any name collision.
Maybe your project tries to link the same file twice ?

Jossos
07-03-2012, 03:08 PM
No they're still apparently already defined in main.obj

If I cut and paste these lines into the .cpp file (this file doesn't contain main, just a bunch of functions) that has all the functions declared in the .h file, the whole thing compiles and works fine. However this feels messy. Is it normal to declare variables like this? or is there a way I can have these in the header file?

Alfonse Reinheart
07-03-2012, 04:42 PM
Ok so, I have these boolean arrays created in one of my header files above a bunch of functions that use them:

OK, it seems clear at this point that you're not very experienced with C/C++. I would strongly advise you to stop working on graphics and spend some time learning the ins and outs of C++. Graphics programming is hard enough; you don't want to compound it by not having firm foundation of how the language you're using works.

The particular problem you're encountering has to do with the difference between a declaration and a definition in C/C++. You're defining the same global variable in multiple .cpp files (through the inclusion of the same .h). That's not allowed. You are allowed to declare the same global variable in multiple .cpp files, but it can only be defined in one of them. More information can be found here. (http://stackoverflow.com/questions/8108634/global-variables-in-header-file)

Also, do note that this is an OpenGL forum, not a general programming issues forum. (http://stackoverflow.com/)

Jossos
07-03-2012, 05:56 PM
OK, it seems clear at this point that you're not very experienced with C/C++. I would strongly advise you to stop working on graphics and spend some time learning the ins and outs of C++. Graphics programming is hard enough; you don't want to compound it by not having firm foundation of how the language you're using works.

The particular problem you're encountering has to do with the difference between a declaration and a definition in C/C++. You're defining the same global variable in multiple .cpp files (through the inclusion of the same .h). That's not allowed. You are allowed to declare the same global variable in multiple .cpp files, but it can only be defined in one of them. More information can be found here. (http://stackoverflow.com/questions/8108634/global-variables-in-header-file)

Also, do note that this is an OpenGL forum, not a general programming issues forum. (http://stackoverflow.com/)

pfft
Nahh I'm doing fine. I already got cubes an am about to animate them.

And sorry i forgot this was opengl specific. I'll try to keep it as such.

thokra
07-03-2012, 11:08 PM
pfft Nahh I'm doing fine.

It's always good to arrogantly dismiss a sound advice by an experienced developer which is obviously more than justified... :doh:

Jossos
07-04-2012, 02:45 AM
It's always good to arrogantly dismiss a sound advice by an experienced developer which is obviously more than justified... :doh:

I didn't mean to be arrogant, sorry if it seems I was. At the time of reading this, I was (and still am) going strong in openGL, and think I can start creating some interesting programs soon with current knowledge.

thokra
07-04-2012, 03:11 AM
I don't know about the others, but to me it seemed to be. You need to plan ahead. Most interesting programs aren't easily developed without proper knowledge of the programming language and libraries involved. Otherwise you're going to trip and fall many many times. Personally fully I support Alfonse's suggestion.

Jossos
07-04-2012, 03:29 AM
I don't know about the others, but to me it seemed to be. You need to plan ahead. Most interesting programs aren't easily developed without proper knowledge of the programming language and libraries involved. Otherwise you're going to trip and fall many many times. Personally fully I support Alfonse's suggestion.

Planning ahead, you mean like writing psuedo code?

thokra
07-04-2012, 03:36 AM
No, I mean assuming you're gonna face problems you can't solve and can't work around with your current level of knowledge. Every developer faces such problems every once in a while but with a good foundation you're gonna get around them much more easily. Others may suggest a different approach, but working through one comprehensive tutorial (no matter if online or with a textbook, as long as its good) for C++ and OpenGL doesn't hurt. I will take you some time in the beginning but will save you a lot as you go on.

Jossos
07-04-2012, 03:50 AM
No, I mean assuming you're gonna face problems you can't solve and can't work around with your current level of knowledge. Every developer faces such problems every once in a while but with a good foundation you're gonna get around them much more easily. Others may suggest a different approach, but working through one comprehensive tutorial (no matter if online or with a textbook, as long as its good) for C++ and OpenGL doesn't hurt. I will take you some time in the beginning but will save you a lot as you go on.

Oh. Well I finished the book "Beginning C++ Game Programming by Michael Dawson" which is mostly console stuff, but it covers a lot of the groundwork stuff, and I have it for reference should I need it. I've also done a heap of other tutorials, but they were all pretty inferior to this book I have found. I am currently working through this tutorial for OpenGL: http://www.swiftless.com/opengltuts.html

I find that I can really understand all the code, and I am writing my own code to go with the exercises. I am expecting to hit problems I can't solve eventually, in which case I would invest more time in learning whatever it is I'm having trouble with.

Jossos
07-04-2012, 06:31 PM
HEY guys. I once again need some help. I'm trying to use the glut "glutEnterGameMode();"
method. (glutGameModeString("1024768:32@60");)

I get an error in my command prompt window:

freeglut (C:\.exe directory of project) unable to parse game mode string: '1024||768:32@60'
freeglut (C:\.exe directory of project) The graphics mode is not supported. Problem with requested mode: '1024||1050:32@59'
freeglut (C:\.exe directory of project) failed to change screen settings.

Any help is greatly appreciated.

PS: the program just runs in its standard 300x300 window (or whatever size i give it)

Jossos
07-04-2012, 10:20 PM
...Anyone? this problem isn't yet solved. how Do i make this work???

Alfonse Reinheart
07-04-2012, 10:51 PM
1024768

You used a Unicode character, not the lowercase character "x". These are two different characters, and FreeGLUT has no idea what you're trying to give it. Indeed, depending on your compiler mode, it may have no idea what you meant.

Also, did you really need to bump this thread after four hours? People aren't being paid to answer you; let it happen in its own time.

Jossos
07-04-2012, 11:47 PM
You used a Unicode character, not the lowercase character "x". These are two different characters, and FreeGLUT has no idea what you're trying to give it. Indeed, depending on your compiler mode, it may have no idea what you meant.

Also, did you really need to bump this thread after four hours? People aren't being paid to answer you; let it happen in its own time.

Even using lowercase 'x' it gives the same errors and doesnt work

Jossos
07-05-2012, 04:41 AM
800
I need your help yet again, friends!

For some reason It kinda inverts the red/blue of "picture.bmp" when I add it as a texture to my square. Why is it doing this, and how can I fix it?

thanks.

Fixed. I'm such a genius.

Jossos
07-06-2012, 09:30 PM
Hey guys, I need some help. For some reason the following code isn't working as I'd like it to.

this is the display function in my: glutDisplayFunc(display); and glutIdleFunc(display);


void display()
{
glColor3f(1.0f, 0.0f, 0.0f); // Sets Color to red <--- Only works for the first frame and then the cube turns white for rest of program
glutSolidCube(2); // our character to follow

... some other code

glColor3f(1.0f, 1.0f, 1.0f);
cubeFunc(); // creates a bunch of cubes

glutSwapBuffers();
}

For some reason The program makes the cube that's meant to be red, white like the other cubes created by cubeFunc(). It's truly bizzare and I can't figure out why it's doing this.

Help is greatly appreciated

Jossos
07-07-2012, 01:27 AM
HELP!

1>InitialFunctions.obj : error LNK2019: unresolved external symbol "unsigned int __cdecl loadtextures(char const *,float,float)" (?loadtextures@@YAIPBDMM@Z) referenced in function "void __cdecl loaderUp(void)" (?loaderUp@@YAXXZ)
1>C:\Users\Jossos\Documents\lrn2prgrm\OGLPrax7\Debug \OGLPrax7.exe : fatal error LNK1120: 1 unresolved externals

I have no idea what this means. My loadtextures function works fine in other programs. Why am I getting this error???

Also in properties -> linker -> additional dependencies I have:
opengl32.lib
glu32.lib
glut32.lib
glew32.lib

Still doesn't work?!?!?