+ 3

[CLOSED] Error when trying graphics.

So I got all the stuff I need to make graphics in C++, but whenever I run the code an error shows up. "Drawing operation was attempted when there was no current window." How do I fix this?

5th Aug 2019, 2:34 PM
UrBoyO
UrBoyO - avatar
7 Answers
+ 8
I suffer he same thing too... please help
6th Nov 2019, 4:07 PM
MCGAmedCoder gamerArtist
MCGAmedCoder gamerArtist - avatar
+ 4
It would be hopefull if you posted the code. When you say you got all the stuff i need i assume that the error is because it wasnt set up properly.
5th Aug 2019, 3:10 PM
Ole113
Ole113 - avatar
+ 2
~ swim ~ I did forget... Lol. Thanks. Ole113 Thank you for your help. Sorry for not posting code. It went right over my head. It was literally just circle(300, 300, 50) along with the header files and stuff. I did forget to call initwindow() so I've realized my mistake. THANK YOU BOTH!! 😁
5th Aug 2019, 4:47 PM
UrBoyO
UrBoyO - avatar
+ 2
Ian Moore If you want C++ graphics, I reccommend. SDL2 or SFML ( if you do not want to use an engine) Sdl2 - What I use : https://www.libsdl.org/ SFML https://www.sfml-dev.org/index.php
6th Aug 2019, 2:02 PM
Manual
Manual - avatar
+ 1
put getch(); inside closegraph(); and initgraph(); it work for me
12th Sep 2021, 6:10 AM
Atharva Tirkhunde
Atharva Tirkhunde - avatar
0
~ swim ~ I thought we were done with this but we're not. RIP. So now it's saying "warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]". Here's my code: #include<graphics.h> #include <conio.h> int main() { int gd = DETECT, gm; initgraph(&gd,&gm, "C:\\tc\\bgi"); circle(300,300,50); closegraph(); getch(); } I've tried all I can... It still doesnt work. The error seems to be inside the initgraph().
5th Aug 2019, 6:01 PM
UrBoyO
UrBoyO - avatar
0
closegraph(getch()); it solves the issue!
23rd Sep 2024, 1:03 PM
Rony Mir
Rony Mir - avatar