Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Unable to create Window

Credits go to Ampersand, Evert, GullRaDriel, jamyskis, Kitty Cat, miran, and Onewing for helping out!
This thread is locked; no one can reply to it. rss feed Print
Unable to create Window
Cody Harris
Member #4,406
March 2004
avatar

I want to create a window of 850x650px. Every time I go to set the graphics mode, I see the window pop up, but it's filled with pink (and would segfault upon drawing if I didn't add an if in there). 850*650 isn't all that big, what's going on? Can only certain sizes be used?

1int main(int argc, char *argv[]){
2 for (int i = 0; i < 256; i++){
3 sysLines<i>.flags = 0;
4 sysLines<i>.height = 0;
5 }
6
7 allegro_init();
8 install_keyboard();
9 install_timer();
10 LOCK_VARIABLE(systime);
11 LOCK_FUNCTION(sysTimer);
12 install_int_ex(sysTimer, BPS_TO_TIMER(30));
13 set_color_depth(desktop_color_depth());
14 set_window_title("Level Editor");
15 //THIS ALWAYS RETURNS -1 WITH 850 & 650
16 if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 850, 650, 0, 0) == -1){
17 allegro_message("Error");
18 allegro_exit();
19 return 0;
20 }
21 ...

It's also worth noting I can't set anything bigger than 800*600 (or rather that's the smallest res it wants to set)

---------------------------------
Homepage - Art (Photography)
I'm QBasicer on #allegro on Freenode.

Onewing
Member #6,152
August 2005
avatar

What's the resolution of your monitor set to? (althought that's a longshot...)

------------
Solo-Games.org | My Tech Blog: The Digital Helm

Cody Harris
Member #4,406
March 2004
avatar

1024*768 (or wtv).

I tried to edit my post, but I couldn't shakes fist.

Anyways, I'm using DevC++ with MingW 3.1 and Allegro 2.0 (off the site, compiled this morning)

---------------------------------
Homepage - Art (Photography)
I'm QBasicer on #allegro on Freenode.

Ampersand
Member #5,622
March 2005

I've seen the pink screen before. I think you do have to use one of the standard screen sizes to avoid it. (640x480, 800x600, 1024x768, etc.)

(Just did a quick test on an existing project. Even though it drew properly, the pink was a visible flash when using an awkward screen size.)

Kitty Cat
Member #2,815
October 2002
avatar

Neither 850 nor 650 are multiples of 4, which IIRC, is a requirement of Windows. Though in that case, set_gfx_mode should be failing...

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Cody Harris
Member #4,406
March 2004
avatar

Windows creates weird window sizes all the time, another one of my programs does a small windowed weird size, however, it's like it can't get enough memory together or something, as if I did a window of like 320*325, I can do that.

I'd like to note that 1024*768 does not work windowed, but fullscreen it does.

---------------------------------
Homepage - Art (Photography)
I'm QBasicer on #allegro on Freenode.

miran
Member #2,407
June 2002

Quote:

Neither 850 nor 650 are multiples of 4, which IIRC, is a requirement of Windows.

That's a requirement of DirectX, not Windows itself. So, 848x648 will work, as well as 852x652, or any other combination of those numbers, but not 850x650...

If 850x650 is really required and speed of drawing is not very important, you could use the GDI driver...

--
sig used to be here

Evert
Member #794
November 2000
avatar

Quote:

I'd like to note that 1024*768 does not work windowed

You cannot create windows larger than or as large as the desktop.

GullRaDriel
Member #3,861
September 2003
avatar

But you can use fullscreen and have the thing you want.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Cody Harris
Member #4,406
March 2004
avatar

There, a multiple of 2 fixed it, thanks!

---------------------------------
Homepage - Art (Photography)
I'm QBasicer on #allegro on Freenode.

miran
Member #2,407
June 2002

Multiple of 4!!!

--
sig used to be here

jamyskis
Member #6,557
November 2005
avatar

Quote:

You cannot create windows larger than or as large as the desktop.

Can't you? I can't say that I've ever had this experience, although I do program under Linux. I say experience, and not problem, because there isn't actually a sensible reason why you would create a window that is bigger than the desktop resolution.

__________________________________________________________________
In a world without fences and walls, who needs Windows and Gates?
http://www.jamyskis.net

Evert
Member #794
November 2000
avatar

Quote:

Can't you? I can't say that I've ever had this experience, although I do program under Linux.

Oh, under X you can. I don't know if it's a limitation in Windows or Allegro that prevents you from doing it in Windows - but it's not usually a good idea to do anyway.

Cody Harris
Member #4,406
March 2004
avatar

SOrry Miran, that's what I ment :D

---------------------------------
Homepage - Art (Photography)
I'm QBasicer on #allegro on Freenode.

Johan Halmén
Member #1,550
September 2001

I can create just any size smaller than the Windows graphics mode, which is 1024*768*32.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

Go to: