Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Why is this throwing an error???

This thread is locked; no one can reply to it. rss feed Print
Why is this throwing an error???
Dizzy Egg
Member #10,824
March 2009
avatar

Ok, totally stumped here. Why is this code fine:

But this is throwing an assertion error:

ALLEGRO_DISPLAY *display = al_create_display(1280, 720);
al_set_target_bitmap(al_get_backbuffer(display)); //causing issues....
al_clear_to_color(al_map_rgb(255, 255, 0));
al_flip_display();

Given I've written games using this logic I can't work out why it's crashing, but it has been a loooong day...

[EDIT]
Loool, sometimes you need to step away from the code and ask a question!

I was declaring:

ALLEGRO_DISPLAY *display;

at the top of my code, but in my setup function was using:

ALLEGRO_DISPLAY *display = al_create_display(1280, 720);

Stand down!! ;D

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

-Wshadow

{"name":"613203","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/8\/788c5d84a1aeb6bd3607407bebb760a2.png","w":301,"h":366,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/8\/788c5d84a1aeb6bd3607407bebb760a2"}613203

DanielH
Member #934
January 2001
avatar

Reminds me of a class I was teaching.

This kid couldn't figure out why his program wasn't working. It was a zoom class so a little difficult. I had him pull up his project (in Visual Studios). We modified it a bit, but it didn't auto-compile when he ran it. That was the first thing I noticed was wrong. After about 5 minutes of messing around I realized the error. The cpp file we were messing with wasn't even apart of the solution he had open.

Sometimes you want to shake some people.

After that, we got it to run.

----
also about this kid

The assignment:
Choose a sample program. Modify the code or add a function or subroutine to it. Debug and demonstrate the modified program.

I gave them a few to chose from or they could find their own. He picked one of mine. Here is the original:

#SelectExpand
1#include <iostream> 2 3float convertToCelsius(float fTemp) 4{ 5 return (fTemp - 32.0f) / 1.8f; 6} 7 8//feet to inches 9//miles to feet 10 11int main() 12{ 13 float fTemp = 0.0f; 14 std::cout << "Enter a temperature in Farenheit (F)" << std::endl; 15 std::cin >> fTemp; 16 17 std::cout << std::endl 18 << fTemp 19 << " deg F = " << convertToCelsius(fTemp) << " deg C" 20 << std::endl << std::endl; 21 22 return 0; 23}

This is what he submitted:

#SelectExpand
1#include <iostream> 2 3float convertToFahrenheit(float fTemp) 4{ 5 return (fTemp - 32.0f) / 1.8f; 6} 7int main() 8{ 9 float fTemp = 0.0f; 10 std::cout << "Enter a temperature in Celsius (C)" << std::endl; 11 std::cin >> fTemp; 12 13 std::cout << std::endl 14 << fTemp 15 << " deg C = " << convertToFahrenheit(fTemp) << " deg F" 16 << std::endl << std::endl; 17 18 return 0; 19}

Anyone see what he did? He did follow the directions. Technically.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Dizzy Egg
Member #10,824
March 2009
avatar

It's nuts; I write code all day for work, writing Java code which I test using Junit, I write C# code that I test with Moq, I write C code that gets tested on a proprietary debugger, and then when then I've done all that I try to test an OpenGL shader using Mingw and CodeBlocks and spend an hour straight not realising my stupid mistake.

I guess there's an argument there to improve my Allegro workflow, but therein lies a conundrum; I "LIKE" the old school way of Allegro, for me it's like taking a holiday after all the "proper" work....

That said, I might move from Mingw and CodeBlocks into the Visual Studio and Nuget world of A5.

It was a looong day, plus I've had a few jars (no pun intended) so I'll see what happens tomorrow.

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

Go to: