# Alternate Video Driver in Allegro for Windows?

This topic is 4897 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I was wondering if there were any besides... GFX_AUTODETECT, GFX_AUTODETECT_FULLSCREEN, GFX_AUTODETECT_WINDOWED, GFX_DIRECTX, GFX_DIRECTX_ACCEL, GFX_DIRECTX_SOFT, GFX_DIRECTX_WIN, GFX_DIRECTX_OVL, GFX_GDI. Although these do meet what I need, I would sure like to be able to use DirectX_Accel in a windowed mode.

##### Share on other sites
GFX_DIRECTX_WIN not good enough for you?

##### Share on other sites
While I am using Allegro, when I set the graphics mode, the only thing able to do what I want is a SAFE driver.

if(set_gfx_mode(GFX_DIRECTX_WIN, 320, 240, 640, 480)!=0)   allegro_message("Unable to set Graphics mode 320x240!");

Returns unable to set graphics mode.

##### Share on other sites
Well, it seems your drivers do not support virtual screens in windowed modes. Actually, I've never been able to set up a virtual screen under windows in any mode. Why would you need one, anyway?

##### Share on other sites
No, its not just the windowed mode. I want it because I was told it was required for smooth map scrolling.

##### Share on other sites
You can do smooth scrolling in software very easily. I don't know how you're setting up your graphics, but more often than not smooth scrolling amounts to blitting the correct portion of a bitmap to the screen. That means, if you have a 640x480 screen and a 1280x480 background, you keep a bounding box of the visible portion of the background and only blit that to the screen. By updating the bbox in a smooth way (ie. no more than ~4 pixels at a time), you can achieve smooth scrolling.

Keep in mind that you can tile the background to improve memory usage, ie. use a tilemap instead of a giant bitmap covering the whole background.

You should also take a look into double/triple buffering and page flipping if you haven't already.

EDIT: I remember reading that hardware scrolling (with virtual screens), was more or less used in the old DOS days. However, even then it wasn't reliable, as, at least for SVGA, many cards had broken drivers or did not support it. I also believe that it cannot be used in any modern multitasking OS. The bottom line is: this is a DOS legacy, so don't use it anymore (it has been silently deprecated in allegro, by removing the examples that used it).

##### Share on other sites
So, I want to only draw the part of the map that I am using to the screen? Also, with the tiles, how do I tile the map. Does that mean that I have to have individual tiles and then somehow construct the map tile by tile?

##### Share on other sites
Precisely. In fact, computers nowadays are easily fast enough for your screen-drawing section to work by calculating where in your map the screen is, and for each tile in your map that is visible in the display, blit it to the screen. F'rinstance, here's what I have going in my tile-based platformer: (actually quite a bit simpler, since I use multiple layers, color-key transparency, etc.)

int screen_x, screen_y; //the upper left corner of the screen in pixel-based map coordinatesint start_tile_x = screen_x / TILE_WIDTH;int start_tile_y = screen_y / TILE_HEIGHT;clear_bitmap(double_buffer);for (int tile_x = start_tile_x; tile_x < (SCREEN_W / TILE_WIDTH + 1); tile_x++){  for (int tile_y = start_tile_y; tile_y < (SCREEN_H / TILE_HEIGHT + 1); tile_y++)  {    blit(tiles_bitmap, double_buffer,     area_map[tile_x][tile_y] * TILE_WIDTH, 0,     tile_x * TILE_WIDTH - screen_x, tile_y * TILE_HEIGHT - screen_y,     TILE_WIDTH, TILE_HEIGHT);  }}blit(double_buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);

The way it works is, I have my tiles stored sequentially in tiles_bitmap -- each to the right of the previous, so it's TILE_HEIGHT from top to bottom and TILE_WIDTH * number_of_tiles from left to right. Then area_map is a 2d array of ints (or similar), which are indexes into tiles_bitmap. (0 is the first tile, 1 is the next, and so on).

Remember to make sure that (screen_x + SCREEN_W) is always less than (map_width_in_tiles * TILE_WIDTH), and (screen_y + SCREEN_H) is always less than (map_height_in_tiles * TILE_HEIGHT).

##### Share on other sites
My problem is how to store the individual tiles. I get that I need them in an array, but it has to be an array of bitmaps. This is where I get messed up. Hope someone can help.

##### Share on other sites
You'd need:
a) A TILE struct, containing at the very least a BITMAP pointer (the graphics) and a bool that indicates if the TILE is walkable or not (for collision detection).

b) Code to load your TILEs from the hard disk. You get to decide how a TILE is stored on the disk.

c) A MAP definition, which in its most basic form is an array of TILE indices.

A possible way for this system to work is as follows: you have a tile_array which contains all possible TILEs. Then you have another array for each map which represents what TILE goes to what position of the map. This array basically stores indices to the tile_array.

Obvisously, this system works well only for very simple gfx-wise games. If you have a large amount of different tile graphics (where large could be several megs, that is hunderds of tiles in a today's computer) you should devise a system where only the needed tiles for the current map are loaded into memory.

For more in depth info, you could take a look in gamedev's tutotrials, or google for 'tile engines'. There is a plethora of information on this subject in the web.

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
13
5. 5
frob
12

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633663
• Total Posts
3013236
×