Advertisement

drawing sprites

Started by June 22, 2017 04:18 AM
87 comments, last by Tom Sloper 7 years, 4 months ago
27 minutes ago, phil67rpg said:

I get an error with the minus sign(-) no operand matches these operators

You're going to have to provide more information about the actual code you wrote, and the exact text of the error, if anybody's going to be able to help you with that. If you are using chrono like I suggested, you should look at the example code for now() usage.

You can subtract two time_point's, which is what now() returns, and you'll get a duration. It's possible you aren't including the correct headers to use those types. Or it's also possible your compiler doesn't support C++11, in which case unfortunately chrono won't be available to you and  you'll have to use something platform-specific like QueryPerformanceCounter on Windows.

here is the code I am using




void drawScene() {
 glClear(GL_COLOR_BUFFER_BIT);
    drawScene_bug();
 auto timeStampNow = chrono::high_resolution_clock::now();
 auto elapsed = timeStampPrevious - timeStampNow;
 eraseScene_bug();
// drawScene_bug_two();
// eraseScene_bug_two();
 drawScene_ship();
 drawScene_bullet();
 auto timeStampPrevious = timeStampNow;
 glutSwapBuffers();
}

sorry


void drawScene() {
 glClear(GL_COLOR_BUFFER_BIT);
    drawScene_bug();
 auto timeStampNow = chrono::high_resolution_clock::now();
 auto elapsed = timeStampPrevious - timeStampNow;
 eraseScene_bug();
// drawScene_bug_two();
// eraseScene_bug_two();
 drawScene_ship();
 drawScene_bullet();
 auto timeStampPrevious = timeStampNow;
 glutSwapBuffers();
}

Advertisement

Are you including the appropriate headers? What is the exact line of the error message and what is the exact error message?

I am using #include <chrono> which seems to be working.

this is the error:

 8 IntelliSense: no operator "-" matches these operands
            operand types are: int - std::chrono::time_point<std::chrono::system_clock, std::chrono::system_clock::duration> c:\Users\phil6_000\Desktop\main.cpp 644 35 space5
 

You're trying to subtract an integer (int) and a std::time_point<>. You can't. You have to subtract two time_points. "timeStampPrevious" sounds like it is an int, and it shouldn't be. It should be of type std::chono::time_point<std::chono_high_resolution_clock>, which is the return type of now().

As shown in the documentation you've been linked several times.

Spoiler

 

auto timeStampPrevious=chrono::time_point<chrono_high_resolution_clock>;

the above code has an error of typename is not allowed. I am almost figured out this piece of code. thanks jpetrie. I am really trying to figure out this problem. I am going to do more research on this problem.

Just now, phil67rpg said:

chrono_high_resolution_clock

here is where the error is

1 minute ago, phil67rpg said:

chrono::time_point

sorry the error is also here as well

Advertisement
  1. Do you know how "auto" works?
  2. Where is the "auto timeStampPrevious=chrono::time_point<chrono_high_resolution_clock>;" line located?
  3. Where did Josh tell you timeStampPrevious variable should be?

Hello to all my stalkers.


	chrono::high_resolution_clock::time_point previous = chrono::high_resolution_clock::now();
	auto timeStampPrevious = previous;
	auto timeStampNow = chrono::high_resolution_clock::now();
	auto elapsed = timeStampPrevious - timeStampNow;
	

That doesn't answer any of my questions.

Hello to all my stalkers.

thanks jpetrie I finally figured out my problem. I had to do some research.

This topic is closed to new replies.

Advertisement