type gfx_buffer
    wwidth as integer
    height as integer
    pixels as uinteger pointer
end type
dim as gfx_buffer ptr screen_buffer
screen_buffer=create_gfx_buffer( 640, 480 )
function create_gfx_buffer(byval wwidth as integer,_
                            byval height as integer )as gfx_buffer pointer
    
    dim as gfx_buffer pointer buffer
    
    buffer=callocate(len(gfx_buffer)+len(uinteger)*wwidth*height)
    
    buffer->wwidth=wwidth
    buffer->height=height
    
    buffer->pixels=cast(uinteger pointer,cast(byte pointer,buffer)+len(gfx_buffer))
   
    return buffer
end function
#include <windows.h>
// remember ( ALT+F7) to add linker -> input -> dependencies 'libmmx.lib' & 'libtinyptc_ext.lib'
#include <tinyptc_ext.h>
const int XRES=640;
const int YRES=480;
const int ARES=XRES*YRES;
class gfx_buffer {
	public:
	int wwidth, height, wwidth2, height2;
	unsigned int *pixels;
};
static gfx_buffer* screen_buffer;
// functions.
int set_graphics( int wwidth, int height );
gfx_buffer* create_gfx_buffer( int wwidth, int height );
screen_buffer=create_gfx_buffer( 640, 480 )
int main()
{
	set_graphics( XRES, YRES );
	
	while (1)
	{
		// clear screen.	
		// render to the screen buffer.
		ptc_update( screen_buffer->pixels[0] );
	}
	// wend.
}
gfx_buffer* create_gfx_buffer( int wwidth, int height )
{
	gfx_buffer* buffer=callocate 
}
int set_graphics( int wwidth, int height )
{
	ptc_allowclose(1);
	ptc_setflip(1);
	
	ptc_setdialog(1,"Would You Prefer Fullscreen Dude?",1,0);
    if (!ptc_open("mOnKeY bUiSnEsS 1",XRES,YRES)) return 1;
	return 0;
}
gfx_buffer *screen_buffer = new gfx_buffer;
screen_buffer->pixels = new unsigned int [width * height];
Even better, your class should do this in its constructor:class gfx_buffer
{
private:
int width, height;
unsigned int *pixels;
public:
//constructor
gfx_buffer(int w, int h)
{
  width = w;
  height = h;
  pixels = new unsigned int [w*h];
}
//destructor
~gfx_buffer()
{
  delete [] pixels;
}
// getters
int get_width() { return width; }
int get_height() { return height; }
unsigned int *get_pixels() { return pixels; }
//other methods, eg.
void setpixel(int x, int y, unsigned int colour)
{
if (x>=0 && x < width && y>=0 && y < height)
  pixels[x+y*width] = colour;
}
void plotsprite(int x, int y, gfx_buffer *sprite)
{
//draw sprite into this gfx_buffer at x,y
}
}
gfx_buffer *screen = new gfx_buffer(640,480);
gfx_buffer *sprite = new gfx_buffer(64,64);
...
//and the code you're looking for
ptc_update(screen->get_pixels());
typedef struct
{
int x, y;
unsigned int *pixels;
} gfx_buffer;
...
gfx_buffer *screen = (gfx_buffer *)malloc(sizeof *screen + 640*480*sizeof(unsigned int));
screen->pixels = (unsigned int *)(((char *)screen)+sizeof *screen);
But this is NASTY!  The C++ in my previous post is WAY WAY WAY better coding style.
#include "raw_data.bi"
#include "pal_data.bi"
dim as gfx_buffer ptr image1
image1=load_image_8bit(32,32,@raw_variable_name_ubyte(0),@pal_variable_name_ubyte(0))
function Load_Image_8bit( byval image as ubyte pointer,byval palet as ubyte pointer,byval wwidth as integer,byval height as integer )as gfx_buffer pointer
    
    while ((wwidth mod 4) <> 0) 
        wwidth += 1
    wend
    
    dim as gfx_buffer pointer buffer=create_gfx_buffer(wwidth,height)
    dim as uinteger pal(0 to 255), col
    dim as integer a,x,y
    
    for a=0 to 255
        pal(a)=(palet[a*3] shl 16)or(palet[a*3+1] shl 8)or(palet[a*3+2]) 'or &HFF000000 
    next    
    
    for y=0 to height-1
        for x=0 to wwidth-1
            buffer->pixels[ x+y*wwidth ]=pal(image[x+(y*wwidth)]) 
        next
    next
    
    return buffer
end function
hows about this routine in FB for loading an image from a file / binary.I'm not quite sure what your question is, or if there is any ;)
I have yet to find a bmp2raw for C++, and also Binary2...The binary version would be something like this (http://www.programmersheaven.com/download/713/4/ZipView.aspx) but you've got a resource-manager in Visual Studio, so you can include your images as jpeg or png and let Windows do the decoding for you.
unsigned char picture_pal[] =
unsigned char picture_raw[] =
gfx_buffer *load_image(unsigned char *pal, unsigned char *raw, int width, int height)
{
  //round width up to next multiple of 4
  width += (4-(width&3))&3;
  //create a new image
  gfx_buffer *gfx = new gfx_buffer(width, height);
  //convert the palette to 32bit
  unsigned int palette[256];
  for (int i=0; i < 256; i++)
     palette[i] = 0xff000000 | (pal[i*3]<<16) | (pal[i*3+1] << 8) | pal[i*3+2];
  //convert the pixels
  unsigned int *pix = gfx->get_pixels();
  for (int j=0; j<width*height; j++)
     *pix++ = palette[*raw++];
  return gfx;
}
extern unsigned char picture_pal[];
extern unsigned char picture_raw[];
That will tell the main cpp file where to find the picture data - you'd need this for each picture.#include <windows.h>
#include <tinyptc_ext.h> // remember ( ALT+F7) to add linker -> input -> dependencies 'libmmx.lib' & 'libtinyptc_ext.lib'
const int XRES=640;
const int YRES=480;
const int ARES=XRES*YRES;
class gfx_buffer
{
	private:
	int wwidth, height;
	int wwidth2, height2;
	unsigned int *pixels;
}
// funksters.
//void draw_gfx_buffer( gfx_buffer *dest, gfx_buffer *srce, int x, int y );
gfx_buffer* create_gfx_buffer( int wwidth, int height );
int set_graphics( int wwidth, int height );
gfx_buffer *screen_buffer=create_gfx_buffer( XRES, YRES );
//screen_buffer=create_gfx_buffer( 640, 480 );
int main()
{
	set_graphics( XRES, YRES );
	
	while (1)
	{
		// clear screen.	
		// render to the screen buffer.
		ptc_update( screen_buffer->pixels[0] );
	
	} // wend.
} // end function.
gfx_buffer *create_gfx_buffer( int wwidth, int height )
{
	gfx_buffer *buffer = new gfx_buffer;
	
	buffer->pixels = new unsigned int [ wwidth * height ];
	buffer->wwidth=wwidth;
	buffer->height=height;
	buffer->wwidth2=wwidth/2;
	buffer->height2=height/2;
	return buffer;
}
//void set_pixel()
//{
//}
int set_graphics( int wwidth, int height )
{
	ptc_allowclose(1);
	ptc_setflip(1);
	
	ptc_setdialog(1,"Would You Prefer Fullscreen Dude?",1,0);
    if (!ptc_open("mOnKeY bUiSnEsS 1",wwidth,height)) return 1;
	return 0;
}
ptc_update( screen_buffer->pixels[0] );
to
ptc_update( &screen_buffer->pixels[0] );
Compiling...
Main1-2.cpp
.\Main1-2.cpp(23) : error C2143: syntax error : missing ';' before '*'
.\Main1-2.cpp(23) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
.\Main1-2.cpp(27) : error C2143: syntax error : missing ';' before '*'
.\Main1-2.cpp(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
.\Main1-2.cpp(27) : error C2371: 'gfx_buffer' : redefinition; different basic types
        .\Main1-2.cpp(23) : see declaration of 'gfx_buffer'
.\Main1-2.cpp(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
.\Main1-2.cpp(40) : error C2227: left of '->pixels' must point to class/struct/union/generic type
        type is 'int *'
.\Main1-2.cpp(46) : error C2143: syntax error : missing ';' before '*'
.\Main1-2.cpp(46) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
.\Main1-2.cpp(46) : error C2371: 'gfx_buffer' : redefinition; different basic types
        .\Main1-2.cpp(23) : see declaration of 'gfx_buffer'
.\Main1-2.cpp(47) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
.\Main1-2.cpp(48) : error C2065: 'buffer' : undeclared identifier
.\Main1-2.cpp(48) : error C2061: syntax error : identifier 'gfx_buffer'
.\Main1-2.cpp(50) : error C2065: 'buffer' : undeclared identifier
.\Main1-2.cpp(50) : error C2227: left of '->pixels' must point to class/struct/union/generic type
        type is ''unknown-type''
.\Main1-2.cpp(52) : error C2065: 'buffer' : undeclared identifier
.\Main1-2.cpp(52) : error C2227: left of '->wwidth' must point to class/struct/union/generic type
        type is ''unknown-type''
.\Main1-2.cpp(53) : error C2065: 'buffer' : undeclared identifier
.\Main1-2.cpp(53) : error C2227: left of '->height' must point to class/struct/union/generic type
        type is ''unknown-type''
.\Main1-2.cpp(55) : error C2065: 'buffer' : undeclared identifier
.\Main1-2.cpp(55) : error C2227: left of '->wwidth2' must point to class/struct/union/generic type
        type is ''unknown-type''
.\Main1-2.cpp(56) : error C2065: 'buffer' : undeclared identifier
.\Main1-2.cpp(56) : error C2227: left of '->height2' must point to class/struct/union/generic type
        type is ''unknown-type''
.\Main1-2.cpp(58) : error C2065: 'buffer' : undeclared identifier
Semi Colon Adventures 1 - 24 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
			//
// includes.
// remember ( ALT+F7) to add linker -> input -> dependencies 'libmmx.lib' & 'libtinyptc_ext.lib'
//
#include <windows.h>
#include <tinyptc_ext.h> 
//
// classes.
//
class gfx_buffer
{
	public:
	int wwidth, height;
	int wwidth2, height2;
	unsigned int *pixels;
};
//
// functions.
//
int set_graphics( int wwidth, int height );
gfx_buffer *create_gfx_buffer( int width, int height);
//
// variables.
//
//unsigned int screen_buffer[ ARES ];
gfx_buffer *screen_buffer=create_gfx_buffer( 640, 480 );
int main()
{
	// initializing.
	set_graphics( XRES, YRES );
	
	// main program loop.
	while (1)
	{
		// clear screen.
		for( int index=0; index<(screen_buffer->wwidth*screen_buffer->height); index++)
			screen_buffer->pixels[index]=0x000000;
		// render to the screen buffer.
		ptc_update( &screen_buffer->pixels[0] );
	
	} // wend.
	
} // end function main()
int set_graphics( int wwidth, int height )
{
	ptc_allowclose(1);
	ptc_setflip(1);
	
	ptc_setdialog(1,"Would You Prefer Full Screen Dude?",1,0);
    if (!ptc_open("sEmI cOl0n AdVeNtUrEs",wwidth,height)) 
		return 1;
	else
		return 0;
	// end if.	
}
gfx_buffer *create_gfx_buffer( int wwidth, int height )
{
	gfx_buffer *buffer = new gfx_buffer;
	
	buffer->pixels = new unsigned int [wwidth*height];
	buffer->wwidth = wwidth;
	buffer->height = height;
	buffer->wwidth2=wwidth/2;
	buffer->height2=height/2;
	return buffer;
}
gfx_buffer *my_image=load_image( &cool_pal[0], &cool_raw[0], 480, 92 );
or
gfx_buffer *my_image=load_image( cool_pal, cool_raw, 480, 92 );
// basic lingo example: if (x>0) and (x<wwidth-1) then
if (x>0)
if (x<width)
if (y>0)
if (y<height)
insert_clever_code_here();
what does extern (external) actually do? Couldn't I use #include "raw_image.cpp" ?extern is just an external reference which tells the compiler everything is OK and the linker will fix it up later. You *could* rename raw_image.cpp to raw_image.h and #include it, but the problem with that is it will get build every single time you compile. If you leave it as a separate file it only gets rebuilt if it changes. Using extern is way better.
I've tried using #include <string.h> but I can't use the string scope.After all your #includes add the line
using namespace std;
I notice there isnt a MOD command, how is the calc for rounding width in the load function work?The MOD command for integer types is %. So 10%7=3.
I can't find much on using IF, i've found elseYou should be able to find these on any good C++ website.
if (a>b)
{
//something
}
else if (b>c)
{
//something else
}
else
{
//otherwise
}
type anim_image
    total_frames as integer
    frame_Width As Integer
    frame_Height As Integer
    frame as gfx_buffer pointer pointer
end type
function create_anim_images(byval srce As gfx_buffer Pointer,_
                            byval wwidth        As Integer,_
                            byval height        As Integer) As anim_image pointer
    dim as integer framesw=srce_buffer->wwidth\wwidth
    dim as integer framesh=srce_buffer->height\height
    dim as anim_image pointer image=callocate(len(anim_image))
    image->frame        =callocate(len(gfx_buffer pointer)*framesw*framesh)
    
    dim as integer frame_number,x,y
    for y=0 to (framesh-1)*height step height
        for x=0 to (framesw-1)*wwidth step wwidth
            
            image->frame[frame_number]=create_gfx_buffer(wwidth,height)
            draw_image(image->frame[frame_number],srce,-x,-y)
            
            frame_number+=1
            
        next
    next
    
    //;delete_gfx_buffer(srce)
    
    image->frame_wwidth=wwidth
    image->frame_height=height
    image->total_frames=framesw*framesh
    
    return image
End function
class anim_buffer
{
	public:
	int total_frames; 
	int frame_wwidth, frame_height;
	gfx_buffer **frame;
};
frame = new gfx_buffer *[num_frames];
then you need to allocate the framesfor (int i=0; i<num_frames; i++)
  frame[i] = new gfx_buffer(...);
//
// includes.
//
#include <windows.h>
#include <tinyptc_ext.h>
#include <math.h>
extern unsigned char gb_pal[];
extern unsigned char gb_raw[];
extern unsigned char sca_pal[];
extern unsigned char sca_raw[];
#define PI 3.141593f
#define DEGREES (PI/180.00f)
//
// classes.
//
class gfx_buffer
{
	public:
	int wwidth, height;
	int wwidth2, height2;
	unsigned int *pixels;
};
//
// function declarations.
//
int set_graphics( char *title, int wwidth, int height );
gfx_buffer *create_gfx_buffer( int wwidth, int height);
gfx_buffer *load_gfx_buffer( unsigned char *pal, unsigned char *raw, int wwidth, int height);
//
// sub routines.
//
void draw_buffer_rect( gfx_buffer *dest, gfx_buffer *srce, int pos_x, int pos_y, int rect_x, int rect_y, int rect_wwidth, int rect_height );
void draw_gfx_buffer( gfx_buffer *dest, gfx_buffer *srce, int pos_x, int pos_y );
int main()
{
	//
	// initializing.
	//
	gfx_buffer *screen_buffer=create_gfx_buffer( 640, 480 );
	gfx_buffer *gravity_image=load_gfx_buffer( gb_raw, gb_pal, 300, 300 );
	set_graphics( ".:wIgGlE jIgGlE:.", 640, 480 );
	
	int x=0,y=0;
	int sin_y=0;
	int cos_x=0;
	int sin_height=24;
	int angle1=0;
	
	//
	// main program loop.
	//
	while(1)
	{
		//
		// clear screen_buffer.
		//
		for( int index=0; index<(screen_buffer->wwidth*screen_buffer->height); index++)
			screen_buffer->pixels[ index ]=0x000000;
		
		//
		// wiggle it.
		//
		for ( x=0; x<gravity_image->wwidth; x++)
		{	
			sin_y=sin_height * sin( (angle1+x)*(DEGREES));
			
			draw_buffer_rect( screen_buffer, gravity_image, x, sin_y, x, 0, 1, gravity_image->height );
		}    	
 
		angle1+=1;
		//	
		// render to the screen_buffer.
		//
		ptc_update( &screen_buffer->pixels[0] );
	
	}
}
int set_graphics( char *title, int wwidth, int height )
{
	ptc_allowclose(1);
	ptc_setflip(1);
	
	ptc_setdialog(1,"Would You Prefer Full Screen Dude?",1,0);
	if (!ptc_open( title,wwidth,height)) 
		return 1;
	else
		return 0;
		
}
gfx_buffer *create_gfx_buffer( int wwidth, int height )
{
	gfx_buffer *buffer = new gfx_buffer;
	
	buffer->pixels = new unsigned int [wwidth*height];
	buffer->wwidth = wwidth;
	buffer->height = height;
	buffer->wwidth2=wwidth/2;
	buffer->height2=height/2;
	return buffer;
}
void draw_gfx_buffer( gfx_buffer *dest, gfx_buffer *srce, int pos_x, int pos_y )
{
	for (int y=0; y<srce->height; y++)
		for (int x=0; x<srce->wwidth; x++)
			dest->pixels[ (x+pos_x)+(y+pos_y) * dest->wwidth ]=srce->pixels[ x+y*srce->wwidth ];
}
void draw_buffer_rect( gfx_buffer *dest, gfx_buffer *srce, int pos_x, int pos_y, int rect_x, int rect_y, int rect_wwidth, int rect_height )
{                   
    unsigned int col;
    int x,y;
    for ( y=0; y<rect_height; y++)
        for ( x=0; x<rect_wwidth; x++)
            
            if (x+rect_x>0)  
				if (x+rect_x<srce->wwidth-1) 
					if (y+rect_y>0) 
						if (y+rect_y<srce->height-1)
							col=srce->pixels[ (x+rect_x) + (y+rect_y) * srce->wwidth ];
            end if
            
            if (x+pos_x>0)
				if (x+pos_x<dest->wwidth-1)
					if(y+pos_y>0)
						if(y+pos_y<dest->height-1)
							//if(col>0)
								dest->pixels[ (x+pos_x) + (y+pos_y) * dest->wwidth ]=col;
} 
gfx_buffer *load_gfx_buffer(unsigned char *raw, unsigned char *pal, int wwidth, int height)
{
	//
	// round width up to next multiple of 4.
	//
	wwidth += ( 4-( wwidth&3 )) & 3;
	
	//
	// create a new image.
	//
	gfx_buffer *buffer = create_gfx_buffer( wwidth, height );
   
	//
	// convert the palette to 32 bit ( requires alpha channel set )
	//
	unsigned int palette[256];
	int index;
	for ( index=0; index < 256; index++ )
		palette[ index ] = 0xff000000 | ( pal[ index*3 ] << 16) | ( pal[ index*3+1 ] << 8) | pal[ index*3+2 ];
	
	//
	// convert the pixels.
	//
	for ( index=0; index<(wwidth*height); index++)
		buffer->pixels[ index ] = palette[ *raw++ ];
	return buffer;
}
for (y...)
  for (x...)
  {//need this bracket
     if ()
      ...
     if ()
      ...
  }//and this bracket
The curly braces group expressions together.  Otherwise only the first expression after the control expression is used.  I often use {} even when I don't need to to make the grouping more clear. eg. in the code above, I'd have {} belonging to the (for y) going round the whole thing, just for clarity.double a=0.5;
int b=a;
will give you the same warning.  You have 'lost' data because b==0 now.double a=0.5;
int b=(int)a;
The 'type cast' operator turns one object into another in a meaningful way.int a=5;
float b=a;
Even though a float can hold much bigger numbers than an int, it's not possible to exactly represent every int as a float.int a=2147483647;
float b=a;
a=b;
and display the value of a. (hint: it's NOT 2147483647)int a=5;
double b=a;
a double can hold all integer values.for (int a=0; a < 320; a+=32)
int a,b;
for (a=0,b=0; a < 320; a+=32, b+=1)
//
// includes.
//
#include <windows.h>
#include <tinyptc_ext.h>
extern unsigned char font64_pal[];
extern unsigned char font64_raw[];
#define PI 3.141593
#define DEGREES (PI/180.00f)
//
// classes.
//
class gfx_buffer
{
	public:
	int wwidth, height;
	int wwidth2, height2;
	unsigned int *pixels;
};
class anim_image
{
	public:
	int frame_wwidth, frame_height;
	int total_frames;
	gfx_buffer **images;
};
//
// function declarations.
//
int set_graphics( char *title, int wwidth, int height );
gfx_buffer *create_gfx_buffer( int wwidth, int height);
gfx_buffer *load_gfx_buffer( unsigned char *pal, unsigned char *raw, int wwidth, int height);
anim_image *create_anim_images( gfx_buffer *srce, int wwidth, int height, int blank_wwidth, int min_wwidth, int spacing );
//
// sub routines.
//
void draw_gfx_buffer( gfx_buffer *dest, gfx_buffer *srce, int pos_x, int pos_y );
int main()
{
	//
	// initializing.
	//
	gfx_buffer *screen_buffer=create_gfx_buffer( 640, 480 );
	
	gfx_buffer *font_image=load_gfx_buffer( font64_raw, font64_pal, 512, 512 );
	anim_image *font_one=create_anim_images( font_image, 64, 64, 32, 32, 1 );
	set_graphics( "gRaPhIcS aNtIcS", 640, 480 );
	
	// main program loop.
	while(1)
	{
		// clear screen.
		for( int index=0; index<(screen_buffer->wwidth*screen_buffer->height); index++)
			screen_buffer->pixels[index]=0x000000;
		// next index
		
		draw_gfx_buffer( screen_buffer, font_one->images[19], 0, 0 );
		//draw_gfx_buffer( screen_buffer, font_image,0,0);
		
		
		// render to the screen buffer.
		ptc_update( &screen_buffer->pixels[0] );
	
	} // wend.
	
} // end function main()
int set_graphics( char *title, int wwidth, int height )
{
	ptc_allowclose(1);
	ptc_setflip(1);
	
	ptc_setdialog(1,"Would You Prefer Full Screen Dude?",1,0);
	if (!ptc_open( title,wwidth,height)) 
		return 1;
	else
		return 0;
	// end if.	
}
gfx_buffer *create_gfx_buffer( int wwidth, int height )
{
	gfx_buffer *buffer = new gfx_buffer;
	
	buffer->pixels = new unsigned int [wwidth*height];
	buffer->wwidth = wwidth;
	buffer->height = height;
	buffer->wwidth2=wwidth/2;
	buffer->height2=height/2;
	return buffer;
}
void draw_gfx_buffer( gfx_buffer *dest, gfx_buffer *srce, int pos_x, int pos_y )
{
	for (int y=0; y<srce->height; y++)
		for (int x=0; x<srce->wwidth; x++)
			
			if (x+pos_x>0)
				if (x+pos_x<dest->wwidth-1)
					if (y+pos_y>0)
						if (y+pos_y<dest->height-1)
			
			dest->pixels[ (x+pos_x)+(y+pos_y) * dest->wwidth ]=srce->pixels[ x+y*srce->wwidth ];
		// next x.
	//next y
}
gfx_buffer *load_gfx_buffer(unsigned char *raw, unsigned char *pal, int wwidth, int height)
{	
	//
	// round width up to next multiple of 4.
	//
	wwidth += ( 4-( wwidth&3 )) & 3;
	
	//
	// create a new image.
	//
	gfx_buffer *buffer = create_gfx_buffer( wwidth, height );
   
	//
	// convert the palette to 32 bit.
	//
	unsigned int palette[256];
	int index;
	for ( index=0; index < 256; index++ )
		palette[ index ] = 0xff000000 | ( pal[ index*3 ] << 16) | ( pal[ index*3+1 ] << 8) | pal[ index*3+2 ];
	// next index
	//convert the pixels
	for ( index=0; index<(wwidth*height); index++)
		buffer->pixels[ index ] = palette[ *raw++ ];
	// next index
	return buffer;
}
anim_image *create_anim_images( gfx_buffer *srce, int wwidth, int height, int blank_wwidth, int min_wwidth, int spacing )
{
	int frame_w= srce->wwidth / wwidth;
	int frame_h= srce->height / height;
	int total_frames= frame_w * frame_h;
	anim_image *anim_buffer = new anim_image;
	
	anim_buffer->images=new gfx_buffer *[ total_frames ];
	
	if (blank_wwidth==0) 
		blank_wwidth=wwidth;
    
	if (min_wwidth>wwidth) 
		min_wwidth=wwidth;
	
	int frame_number=0, x=0, y=0, test_l=0, test_r=0, x_test=0, y_test=0;
	
	for (y=0; y<(frame_h-1)*height; y+=height )
	{
		for (x=0; x<(frame_w-1)*wwidth; x+=wwidth )
		{
			//
			// test x.
			//
			test_r=x;
            
			for ( x_test=x; x_test<(x+wwidth-1); x_test+=1 )
			{
				for ( y_test=y; y_test<(y+height-1); y_test+=1 )
				{
					if (srce->pixels[ (x_test)+(y_test) * srce->wwidth]!=0xff000000)
						test_r=x_test;
				} // next y_test.
			} //next x_test.
			
			
			//
			// test l.
			//
			test_l=x+wwidth-1;
            
			for ( x_test=x+wwidth-1; x_test<x; x_test-=1 )
			{
                for ( y_test=y; y_test<(y+height-1); y_test=+1)
				{
					if (srce->pixels[ (x_test)+(y_test)*srce->wwidth]!=0xff000000)
						test_l=x_test;
				}
				// next y_test.
			} // next x_test.
			
			//
			// bob the builder time! :)
			//
			if (test_r>=test_l)
			{    
				test_l-=spacing >> 1;
                test_r+=spacing-(spacing >> 1);
                
				if ((test_r-test_l)<min_wwidth)
				{
					x_test=min_wwidth-(test_r-test_l);
                    test_r+=x_test >> 1 ;
                    test_l-=x_test-(x_test >> 1);
				} //end if
                
				if (test_r>x+wwidth-1)
					test_r=x+wwidth-1;
				
				
				if (test_l<x) 
				{				
					test_l=x;
					anim_buffer->images[frame_number]=create_gfx_buffer(test_r-test_l+1,height);
					draw_gfx_buffer( anim_buffer->images[frame_number],srce,-test_l,-y);
				}
			}
			else
			{
				anim_buffer->images[frame_number]=create_gfx_buffer(blank_wwidth,height);
			} // end if
			
		frame_number+=1;
		
		} // next x
	}// next y
	anim_buffer->frame_wwidth = frame_w;
	anim_buffer->frame_height = frame_h;
	anim_buffer->total_frames = total_frames;
	return anim_buffer;
}
type gfx_buffer
    wwidth as integer
    height as integer
    pixels as uinteger pointer
end type
type anim_image
    total_frames as integer
    FrameWWidth As Integer
    FrameHeight As Integer
    frame as gfx_buffer pointer pointer
end type
function create_anim_images(byval source_buffer As gfx_buffer Pointer,_
                    byval wwidth        As Integer,_
                    byval height        As Integer,_
                    byval blank_wwidth as integer=0,_
                    byval min_wwidth as integer=0,_
                    byval spacing as integer=1) As anim_image pointer
    dim as integer framesw=source_buffer->wwidth\wwidth
    dim as integer framesh=source_buffer->height\height
    
    if blank_wwidth=0 then blank_wwidth=wwidth
    if min_wwidth>wwidth then min_wwidth=wwidth
    
    dim as anim_image pointer image=callocate(len(anim_image))
    image->frame=callocate(len(gfx_buffer pointer)*framesw*framesh)
    
    dim as integer frame_number,x,y,test_l,test_r,x_test,y_test
    for y=0 to (framesh-1)*height step height
        for x=0 to (framesw-1)*wwidth step wwidth
            
            test_r=x
            for x_test=x to x+wwidth-1
                for y_test=y to y+height-1
                    if source_buffer->pixels[x_test+y_test*source_buffer->wwidth]<>0 then test_r=x_test
                next
            next
            
            test_l=x+wwidth-1
            for x_test=x+wwidth-1 to x step-1
                for y_test=y to y+height-1
                    if source_buffer->pixels[x_test+y_test*source_buffer->wwidth]<>0 then test_l=x_test
                next
            next
            
            if test_r>=test_l then
                test_l-=spacing shr 1
                test_r+=spacing-(spacing shr 1)
                if (test_r-test_l)<min_wwidth then
                    x_test=min_wwidth-(test_r-test_l)
                    test_r+=x_test shr 1
                    test_l-=x_test-(x_test shr 1)
                end if
                if test_r>x+wwidth-1 then test_r=x+wwidth-1
                if test_l<x then test_l=x
                image->frame[frame_number]=create_gfx_buffer(test_r-test_l+1,height)
                draw_image(image->frame[frame_number],source_buffer,-test_l,-y)
            else
                image->frame[frame_number]=create_gfx_buffer(blank_wwidth,height)
            end if
            frame_number+=1
            
        next
    next
    
    delete_gfx_buffer(source_buffer)
    
    image->FrameWWidth=WWidth
    image->FrameHeight=Height
    image->total_frames=framesw*framesh
    
    return image
End function
for ( x_test=x+wwidth-1; x_test<x; x_test-=1 )
You write the equivalent ofFor x=10 To 0 Step -1
asfor (x = 10; x >=0; x-=1)
Mostly you just need to change the < to a >= when you are counting downwards.if (test_l<x) 
{				
	test_l=x;
	anim_buffer->images[frame_number]=create_gfx_buffer(test_r-test_l+1,height);
	draw_gfx_buffer( anim_buffer->images[frame_number],srce,-test_l,-y);
}
should beif (test_l<x) 				
	test_l=x;
anim_buffer->images[frame_number]=create_gfx_buffer(test_r-test_l+1,height);
draw_gfx_buffer( anim_buffer->images[frame_number],srce,-test_l,-y);
for ( x_test=x+wwidth-1; x_test>=x; x_test-=1 )
if (test_l<x) 
{				
	test_l=x;
}
anim_buffer->images[frame_number]=create_gfx_buffer(test_r-test_l+1,height);
draw_gfx_buffer( anim_buffer->images[frame_number],srce,-test_l,-y);
Sure thing dude, and that's really swell of you.
for ( y_test=y; y_test<(y+height-1); y_test=+1)should be:for ( y_test=y; y_test<(y+height-1); y_test+=1)draw_gfx_buffer( screen_buffer, font_one->images[19], 0, 0 );
draw_gfx_buffer( screen_buffer, font_one->frame[19], 0, 0 );
Since you dont have an "images" in that class, which should be an error when trying to compile. BTW displays a 5 on screen but has some white lines like its offcentre, probably your sizes are slightly out ;)	if (x+pos_x>0)
		if (x+pos_x<dest->wwidth-1)
			if (y+pos_y>0)
				if (y+pos_y<dest->height-1)
and that we have a selection of 'off by one' errors here	if (x+pos_x>=0)
		if (x+pos_x<dest->wwidth)
			if (y+pos_y>=0)
				if (y+pos_y<dest->height)
With those fixed you can now draw on the first and last scanlines and first and last pixels of every scanline.void print_text( gfx_buffer *dest, anim_image *font, int pos_x, int pos_y, char *message )
{
	int len=strlen( message ); //length of the message text.
	
	for ( int a=0; a<len; a++)
	{
		char frame=message[a]-32; //splits message into appropriate letter.
		
		if (frame>=0 )
			if ( frame<=font->total_frames-1 )
			{		
				draw_gfx_buffer( dest, font->frame[a], pos_x, pos_y );
				pos_x+=font->frame[a]->wwidth;
			}
	} // next a
} // end function
			You don't want to draw character "a" (which counts the letters in your string) but "frame".Code: [Select]draw_gfx_buffer( dest, font->frame[a], pos_x, pos_y );
	if (srce->pixels[ (x_test)+(y_test) * srce->wwidth]!=0)
should be	if (srce->pixels[ (x_test)+(y_test) * srce->wwidth]!=0xff000000)
That fixes most of the width-based stuff, though there's still something else wrong//
// includes.
//
#include <windows.h>
#include "tinyptc_ext.h"
extern unsigned char us64_pal[]; // 64 distinguishes a variable font based around max width of 64, height == 64
extern unsigned char us64_raw[]; // i am unsure if this font is 8*8, or 8*16 ( including upper and lower case characters )
//
// classes.
//
class gfx_buffer
{
public:
	int wwidth, height;
	int wwidth2, height2;
	unsigned int *pixels;
};
class anim_image
{
public:
	int frame_wwidth, frame_height;
	int total_frames;
	gfx_buffer **frame;
};
//
// function declarations.
//
int set_graphics( char *title, int wwidth, int height );
gfx_buffer *create_gfx_buffer( int wwidth, int height);
gfx_buffer *load_gfx_buffer( unsigned char *pal, unsigned char *raw, int wwidth, int height);
anim_image *create_anim_images( gfx_buffer *srce, int wwidth, int height, int blank_wwidth, int min_wwidth, int spacing );
anim_image *create_anim_images2( gfx_buffer *srce, int wwidth, int height );
//
// sub routines.
//
void draw_gfx_buffer( gfx_buffer *dest, gfx_buffer *srce, int pos_x, int pos_y );
void print_text( gfx_buffer *dest, anim_image *font, int pos_x, int pos_y, char *message );
int main()
{
	//
	// initializing.
	//
	gfx_buffer *screen_buffer=create_gfx_buffer( 640, 480 );
	gfx_buffer *font_image=load_gfx_buffer( us64_raw, us64_pal, 512, 512 );
	anim_image *font_one=create_anim_images( font_image, 64, 64, 32, 2, 1 );
	set_graphics( "gRaPhIcS aNtIcS", 640, 480 );
	// main program loop.
	while (1)
	{
		// clear screen.
		for( int index=0; index<(screen_buffer->wwidth*screen_buffer->height); index++)
			screen_buffer->pixels[index]=0x000000;
		// next index
		// remove remarks to test the image has been loaded successfully.
		//draw_gfx_buffer( screen_buffer, font_one->frame[19], 0, 0 );
		//draw_gfx_buffer( screen_buffer, font_image, 0, 0 );
		print_text(screen_buffer, font_one, 10,10, "HELLO");
		// render to the screen buffer.
		ptc_update( &screen_buffer->pixels[0] );
	} // wend.
} // end function main()
void print_text( gfx_buffer *dest, anim_image *font, int pos_x, int pos_y, char *message )
{
	int len=strlen( message ); //length of the message text.
	for ( int a=0; a<len; a++)
	{
		char frame=message[a]-32; //splits message into appropriate letter.
		if (frame>=0 )
			if ( frame<=font->total_frames-1 )
			{		
				draw_gfx_buffer( dest, font->frame[frame], pos_x, pos_y );
				pos_x+=font->frame[frame]->wwidth;
			}
	} // next a
} // end function
int set_graphics( char *title, int wwidth, int height )
{
	ptc_allowclose(1);
	ptc_setflip(1);
	ptc_setdialog(1,"Would You Prefer Full Screen Dude?",1,0);
	if (!ptc_open( title,wwidth,height)) 
		return 1;
	else
		return 0;
	// end if.	
}
gfx_buffer *create_gfx_buffer( int wwidth, int height )
{
	gfx_buffer *buffer = new gfx_buffer;
	buffer->pixels = new unsigned int [wwidth*height];
	buffer->wwidth = wwidth;
	buffer->height = height;
	buffer->wwidth2=wwidth/2;
	buffer->height2=height/2;
	return buffer;
}
void draw_gfx_buffer( gfx_buffer *dest, gfx_buffer *srce, int pos_x, int pos_y )
{
	for (int y=0; y<srce->height; y++)
		for (int x=0; x<srce->wwidth; x++)
			if (x+pos_x>=0)
				if (x+pos_x<dest->wwidth)
					if (y+pos_y>=0)
						if (y+pos_y<dest->height)
							dest->pixels[ (x+pos_x)+(y+pos_y) * dest->wwidth ]=srce->pixels[ x+y*srce->wwidth ];
	// next x.
	//next y
}
gfx_buffer *load_gfx_buffer(unsigned char *raw, unsigned char *pal, int wwidth, int height)
{	
	//
	// round width up to next multiple of 4.
	//
	wwidth += ( 4-( wwidth&3 )) & 3;
	//
	// create a new image.
	//
	gfx_buffer *buffer = create_gfx_buffer( wwidth, height );
	//
	// convert the palette to 32 bit.
	//
	unsigned int palette[256];
	int index;
	for ( index=0; index < 256; index++ )
		palette[ index ] = 0xff000000 | ( pal[ index*3 ] << 16) | ( pal[ index*3+1 ] << 8) | pal[ index*3+2 ];
	// next index
	//convert the pixels
	for ( index=0; index<(wwidth*height); index++)
		buffer->pixels[ index ] = palette[ *raw++ ];
	// next index
	return buffer;
}
anim_image *create_anim_images( gfx_buffer *srce, int wwidth, int height, int blank_wwidth, int min_wwidth, int spacing )
{
	int frame_w= srce->wwidth / wwidth;
	int frame_h= srce->height / height;
	int total_frames= frame_w * frame_h;
	anim_image *anim_buffer = new anim_image;
	anim_buffer->frame=new gfx_buffer *[ total_frames ];
	if (blank_wwidth==0) 
		blank_wwidth=wwidth;
	if (min_wwidth>wwidth) 
		min_wwidth=wwidth;
	int frame_number=0, x=0, y=0, test_l=0, test_r=0, x_test=0, y_test=0;
	for (y=0; y<frame_h*height; y+=height )
	{
		for (x=0; x<frame_w*wwidth; x+=wwidth )
		{
			//
			// test x.
			//
			test_r=x;
			for ( x_test=x; x_test<(x+wwidth); x_test+=1 )
			{
				for ( y_test=y; y_test<(y+height); y_test+=1 )
				{
					if (srce->pixels[ (x_test)+(y_test) * srce->wwidth]!=0xff000000)
						test_r=x_test;
				}	// next y_test.
			}	//next x_test.
			//
			// test l.
			//
			test_l=x+wwidth-1;
			for ( x_test=x+wwidth-1; x_test>=x; x_test-=1 )
			{
				for ( y_test=y; y_test<y+height; y_test+=1)
				{	
					if (srce->pixels[ (x_test)+(y_test)*srce->wwidth]!=0xff000000)
						test_l=x_test;
				}// next y_test.
			}// next x_test.
			//
			// bob the builder time! :)
			//
			if (test_r>=test_l)
			{    
				test_l-=spacing >> 1;
				test_r+=spacing-(spacing >> 1);
				if (test_r-test_l<min_wwidth)
				{ 
					x_test=min_wwidth-(test_r-test_l);
					test_r+=x_test >> 1 ;
					test_l-=x_test-(x_test >> 1); 
				} //end if
				if (test_r>x+wwidth-1) //then
					test_r=x+wwidth-1;
				// end if
				if (test_l<x) // then 				
					test_l=x;
				// end if
				anim_buffer->frame[frame_number]=create_gfx_buffer(test_r-test_l+1,height);
				draw_gfx_buffer( anim_buffer->frame[frame_number],srce,-test_l,-y);
			}
			else
			{
				anim_buffer->frame[frame_number]=create_gfx_buffer(blank_wwidth,height);
			} // end if
			frame_number+=1;
		}	 // next x
	} // next y
	anim_buffer->frame_wwidth = frame_w;
	anim_buffer->frame_height = frame_h;
	anim_buffer->total_frames = total_frames;
	return anim_buffer;
}
for( int index=0; index<(screen_buffer->wwidth*screen_buffer->height); index++)
			screen_buffer->pixels[index]=0x000000;
#include <string.h>
at the top, then replace the for loop withmemset(screen_buffer->pixels, 0, screen_buffer->wwidth*screen_buffer->height * sizeof(unsigned int));
float sinx;
int sinxx;
sinx=(float) sin( [i]insert_formula[/i] );
sinxx=(int) sinx;
draw( sinxx, 200, 0xFFFF0000 ); // ( usage - posx as int, posy as int, colour as unsigned int )
			#include <math.h>
You can ignore the warnings.  I have already explained to you in this thread about the loss of precision warnings.sinx=(float) sin( [i]insert_formula[/i] );   float sum= 0.0f;
   for (float x=0.0f;x<10.0f;x+=0.1f)
   {
      float y= sin(x);
      sum+=y;
   }
   printf("result: %f \n", sum);
| disassembly with fpu-precision "fast" Code: [Select] 00401006  fldz             result: 18.647397 | ...and "precise" Code: [Select] 00401009  fldz             result: 18.647362 | 
What is the correct process for creating a new windows 32 project without the console window? I opted for empty Win32 for the project thats uploaded, and added existing files for the bitmap1-4.cpp and graphics files.Copy all relevant source-files into your new project-folder before you're adding them to your new project.
You've mentioned this before, but none of us can replicate it because you haven't posted a complete project that will build that has the problem.Please follow the orders ;)
Can you post a complete buildable project, (libs, source, vcproj file) that shows the problem?
You need to send all the files that end in: .cpp, .c, .h, .lib, .vcproj
C:\Users\Jim\Desktop\Axium\Axium
C:\Users\Jim\Desktop\Axium\op.txt
C:\Users\Jim\Desktop\Axium\Axium\Axium
C:\Users\Jim\Desktop\Axium\Axium\Axium.ncb
C:\Users\Jim\Desktop\Axium\Axium\Axium.sln
C:\Users\Jim\Desktop\Axium\Axium\Debug
C:\Users\Jim\Desktop\Axium\Axium\Release
C:\Users\Jim\Desktop\Axium\Axium\Axium\Axium.vcproj
C:\Users\Jim\Desktop\Axium\Axium\Axium\Axium.vcproj.MIKES-GATEWAY.Mike Furlong.user
C:\Users\Jim\Desktop\Axium\Axium\Axium\Debug
C:\Users\Jim\Desktop\Axium\Axium\Axium\Release
C:\Users\Jim\Desktop\Axium\Axium\Axium\Debug\Axium.exe.embed.manifest
C:\Users\Jim\Desktop\Axium\Axium\Axium\Debug\Axium.exe.embed.manifest.res
C:\Users\Jim\Desktop\Axium\Axium\Axium\Debug\Axium.exe.intermediate.manifest
C:\Users\Jim\Desktop\Axium\Axium\Axium\Debug\bitmap scroller 1-4.obj
C:\Users\Jim\Desktop\Axium\Axium\Axium\Debug\BuildLog.htm
C:\Users\Jim\Desktop\Axium\Axium\Axium\Debug\us64x64_pal.obj
C:\Users\Jim\Desktop\Axium\Axium\Axium\Debug\us64x64_raw.obj
C:\Users\Jim\Desktop\Axium\Axium\Axium\Debug\vc90.idb
C:\Users\Jim\Desktop\Axium\Axium\Axium\Debug\vc90.pdb
C:\Users\Jim\Desktop\Axium\Axium\Axium\Release\Axium.exe.intermediate.manifest
C:\Users\Jim\Desktop\Axium\Axium\Axium\Release\bitmap scroller 1-4.obj
C:\Users\Jim\Desktop\Axium\Axium\Axium\Release\BuildLog.htm
C:\Users\Jim\Desktop\Axium\Axium\Axium\Release\mt.dep
C:\Users\Jim\Desktop\Axium\Axium\Axium\Release\us64x64_pal.obj
C:\Users\Jim\Desktop\Axium\Axium\Axium\Release\us64x64_raw.obj
C:\Users\Jim\Desktop\Axium\Axium\Axium\Release\vc90.idb
C:\Users\Jim\Desktop\Axium\Axium\Axium\Release\vc90.pdb
C:\Users\Jim\Desktop\Axium\Axium\Debug\Axium.pdb
C:\Users\Jim\Desktop\Axium\Axium\Release\Axium.exe
C:\Users\Jim\Desktop\Axium\Axium\Release\Axium.pdb
NOOO! Upload a file with the source code in!hehe :)
..\..\Bitmap Scroller 1-1\Bitmap Scroller 1-1\bitmap scroller 1-4.cpp
..\..\graphics\us64x64_pal.cpp
..\..\graphics\us64x64_raw.cpp
error LNK2001: unresolved external symbol _mainIn your project properties (that's what appears when you press Alt+F7) there's a tree on the left.
int main(int argc, char *argv[])
{
}int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
}Actually, I couldn't make this work either. I think libtinyptc_ext.lib already defines WinMain or WinMainCRTStartup and itself it calls main. Something to do with how it works in FB.Yes, that's how Gaffer did it
That's a bit odd, but it means that Clyde should use
int main(void)
{
}
even when he has his linker set to WINDOWS, but only when using libtinyptc_ext.
Maybe rbz can confirm?
Jim
#ifdef __PTC_WINMAIN_CRT__
    extern int main();
    void WinMainCRTStartup()
    {
        main();
    }
#endif#ifdef __PTC_WINMAIN_CRT__
    extern int main();
    void WinMainCRTStartup()
    {
        main();
    }
#endif
Absolutely Awesome!I can't let you give up! I want to see a Gravity C++ demo!
Are the .a files equivalents of a .lib ?Yes, I think it will work with either.