Attempting to start with OpenGL. Lots of failure

Started by
37 comments, last by Syrinth 12 years, 1 month ago

Hmmm, nope. Still failing O.o


Are you kidding?

What are the error messages?
Advertisement
Still terminates at the same location and in the exact same way, No error messages.
Correction, no error messages aside from the ones that get triggered directly in the code

Unable to create OpenGL Context
Unable to recreate GLFW Window
Failed to open GLFW window

Correction, no error messages aside from the ones that get triggered directly in the code

Unable to create OpenGL Context
Unable to recreate GLFW Window
Failed to open GLFW window


It's hard to say what the problem is.

The first thing I would try is to change the parameters to the glfwOpenWindow function to something else. For example


...

GLFWvidmode vm;
glfwGetDesktopMode(&vm);
// Open a window and create the OpenGL context
if(!glfwOpenWindow(800, 600, vm.RedBits, vm.GreenBits, vm.BlueBits, 0, 0, 0, GLFW_WINDOW)) {
fprintf(stderr, "Failed to open GLFW window!\n");
glfwTerminate();
return 2;
}
...


If that doesn't lead anywhere I guess it could be a corrupted openGL library, or it could be that you dont have the latest graphic drivers installed, or it could be that your graphic card simply doesn't support the latest openGL library.

http://openglbook.co...gs-n-profile-n/

I know the code and the libraries work so at this point I would install the latest drivers for the graphic card, you can also try to run the program on a newer gaming machine (dump the program along with the dll's into the same folder and try to run it)
You could also try to downgrade the openGL libraries on your computer to an older version but I'm not sure how much work that is and if it is worth it.

If you have a laptop that is not designed for gaming there is a chance that the graphic card doesn't support openGL at all.
Ok, so I tried almost anything mentioned although finally I didn't realize what's the use of templates as the input of the name must always be a string. Anyway, of course you can use templates if you want but I don't see the use for this particular program. It just gets more complicated for the programmer. Do we gain more speed as the template executes each time it's called? Also can you elaborate a little what OP is?

Anyway, what I finally came up with is the following code which as long as I tested it works for every case. That is if the user inputs a string with a space in between characters, if there are multiple arguments of the same type in a line and if there isn't any argument in a line.

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <fstream>
#include <sstream>
#include <map>
using namespace std;

class ReadGameFile {
public:
string line;
fstream file;
int count;
string args[7];
void enterDetails (){

for (count = 0; count <= 6; count++){

if (count == 0){ cout << "Please enter name: "; getline(cin, args[count]); }

else if (count == 1){ cout << "Please enter age: "; getline(cin, args[count]); }

else if (count == 2){ cout << "Please enter weight: "; getline(cin, args[count]); }

else if (count == 3){ cout << "Please enter class: "; getline(cin, args[count]); }

else if (count == 4){ cout << "Please enter race: "; getline(cin, args[count]); }

else if (count == 5){ cout << "Please enter hair color: "; getline(cin, args[count]); }

else if (count == 6){ cout << "Please enter pant size: "; getline(cin, args[count]); }

}

readFile();

}
void readFile (){

file.open("Rebels_after_start.txt");

while(file.good()){

getline(file,line);

repTags(line, args);

cout << line << '\n';
}

file.close();

}

void repTags(string &line, string args[]){

static map<int,string> tags;
size_t pos = 0;

tags[0] = "/NAME/";
tags[1] = "/AGE/";
tags[2] = "/WEIGHT/";
tags[3] = "/CLASS/";
tags[4] = "/RACE/";
tags[5] = "/HAIR-COLOR/";
tags[6] = "/PANT-SIZE/";

for (count = 0; count <= 6; count++){
while ( (pos = line.find(tags[count])) != string::npos){

line.replace(pos, tags[count].size(), args[count], 0, args[count].size());
pos += args[count].size() + 1;

}// while
}//for


} // mapTEXT FUNCTION
}; // ReadGameFile CLASS

int main (){

ReadGameFile game;

game.enterDetails();

return 0;

}



So the output I get is something like this:

Hello Commander Shepard, you're looking mighty spry for a infiltrator of 26 years.
I see you are still dying your hair (I don't have any hair... :/), which is mightily becoming of a human like yourself.
You're putting on a few pounds, however. You look like you weigh about 70 lbs, and your belly is bulging out quite alot. Is that a size 32 pantaloons you are wearing?

You need to get into shape before your journey, Commander Shepard, if you don't mind me pointing out the obvious.[/quote]


Now, I want to ask is there any other way to optimize the code and make it faster/better/more readable/more efficient?

If, so can you propose some ideas?

Again thanks a lot.
Well that's completely depressing...

I'm sure I updated my graphics drivers but will check again.
Get rid of those lines:

glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

It's way too easy to specify contradictory hints or something that simply isn't supported by your driver/hardware.
f@dzhttp://festini.device-zero.de
That did it!

Thank you so much!

This topic is closed to new replies.

Advertisement