delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/14/10:45:58

From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
Newsgroups: comp.os.msdos.djgpp
Subject: 3D gfx hard, allegro, and all that
Date: 14 Mar 1997 08:42:57 GMT
Organization: The National Capital FreeNet
Lines: 94
Message-ID: <5gb32h$gdb@freenet-news.carleton.ca>
Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
NNTP-Posting-Host: freenet3.carleton.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp


I am in the process of writing a C++ library for Allegro, allegcpp, which
mostly uses the C functions in Allegro and therefore is an add-on to it
with little original code, but creates an object oriented wrapper for it.
In addition, I am creating a 3D library to add to Allegro and Allegcpp,
called A-Vision. It will be an object oriented way to manage "universes"
containing "objects" and "cameras", the objects made of "polygons", using
Allegro's math, vector and matrix, and 3d routines.
This might take a while if I ever finish it <grin>

Allegcpp will feature:

global object allegro. Functions including
allegro.initialize_light_table(palette,r,g,b)
allegro.last_error, etc.
Error handling macros and functions. Wrappers for any allegro function
capable of failing (e.g. set_gfx_mode) will set a global variable. To trap it,
this construct can be used:

risky_fn_call();
ifError
  print_error_msg();
  exit(1);
endError

(Note no braces... ifError is actually
if (globalvar_whose_name_I_forget) { globalvar==0;
and endError is a close brace.

Or an error handler can be set up: allegro.set_error_callback(func);
errors result in a call to this function then as well.

Object monitor:
monitor.palette is the palette. Change the palette with overloaded =:
monitor.palette=my_palette;
monitor.img is the screen image. monitor.img.rect(x1,y1,x2,y2,color) or
.rect(x1,y1,x2,y2,r,g,b) are examples. These work with other image objects
too, except the screen isn't affected.
monitor.set_mode(mode);
Mode is a structure defined by a mode like GFX_MODEX, and width, height,
virtual width and height. Some are predefined in global variables:
co80mode, basic640480mode, basicVGA (mode 13h).
monitor.set_modex (virtual_w, virtual_h) gives 320x240 modex.
monitor.split(line) requires modex, this is trapped for Returns an image
object pointing to the section of the screen bitmap that will show below
the line, 0,0 - SCREEN_W, SCREEN_H-line to be exact.
Changes monitor.work_img from being the whole virtual workspace to being
the space less the top line pixels, so if you use work_img and not img you
won't accidentally write over parts of the status bar or whatever.
monitor.start_triple_buffering()
This divides work_img (depending on splitting) into three parts one third
its height each, so use a tall virtual screen, like 320x720. It internally
stores these buffers and points work_img to one of them saving its
previous state. It sets the screen to displaying a different one.
Requires and traps for modex and retrace sync.
monitor.flip()
Only works with triple buffering on, which is trapped for. Scrolls the
video display to work_img and points work_img to the next buffer in turn.
monitor.end_triple_buffering()
Cleans up, restores the previous work_img, and scrolls the screen to the
upper left of work_img. Called automatically if you change video modes.
images take methods such as clear(), and so forth. An image consists of a
BITMAP *bmp and some methods essentially. Depending on whether bmp is a
screen bitmap it is or is not automatically deallocated with
destroy_bitmap by the image's assignment, copy, and destructor methods.
(I imagine grave consequences of destroy_bitmap(screen) being executed!)


A-Vision will support object creation with an object editor I will make;
and objects and methods like:

triangle   for making all objects;
triangle.setpoints (vector3d,vector3d,vector3d); vector3d being the object
                to wrap V3D.
triangle.setrendermode() will accept assorted rendering modes, such as
.rendermode (POLYTYPE_ATEX,image texture_to_use);

object.addtriangle (triangle)   (the triangle is destroyed with delete
when the object's destructor executes, so allocate it with new and don't
rely on a pointer to it staying valid.)
object.removetriangle (triangle number) the triangle number is returned by
addtriangle. In fact linked lists (my own class) will be used.
object.triangle(index) will return a triangle pointer. Since the triangle
is at the mercy of a ticking time bomb, namely the object's scope,
lifetime, and destructor method, use it temporarily only. The editor will
use this to allow selecting, deleting and modifying triangles when editing
objects.

--
    .*.  Where feelings are concerned, answers are rarely simple [GeneDeWeese]
 -()  <  When I go to the theater, I always go straight to the "bag and mix"
    `*'  bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019