Exemplo n.º 1
0
/* Destroy a pixmap*/
void
GsDestroyPixmap(GR_PIXMAP *pp)
{
	GR_PIXMAP	*prevpp;
	PSD			psd = pp->psd;

	/* deallocate mem gc*/
	psd->FreeMemGC(psd);

	/*
	 * Remove this pixmap from the complete list of pixmaps.
	 */
	prevpp = listpp;
	if (prevpp == pp)
		listpp = pp->next;
	else {
		while (prevpp->next != pp)
			prevpp = prevpp->next;
		prevpp->next = pp->next;
	}

	/*
	 * Forget various information if they related to this
	 * pixmap.  Then finally free the structure.
	 */
	if (pp == cachepp) {
		cachepixmapid = 0;
		cachepp = NULL;
	}
	free(pp);
}
Exemplo n.º 2
0
/* return NULL if no driver bitblit available*/
HDC WINAPI
CreateCompatibleDC(HDC hdc)
{
	HDC	hdcmem;
	PSD	psd;
	PSD	mempsd;

	/* allow NULL hdc to mean screen*/
	psd = hdc? hdc->psd: &scrdev;

	/* allocate memory device, if driver doesn't blit will fail*/
	mempsd = psd->AllocateMemGC(psd);
	if(!mempsd)
		return NULL;

	/* allocate a DC for DesktopWindow*/
	hdcmem = GetDCEx(NULL, NULL, DCX_DEFAULTCLIP);
	if(!hdcmem) {
		mempsd->FreeMemGC(mempsd);
		return NULL;
	}
	hdcmem->psd = mempsd;

	/* select in default bitmap to setup mem device parms*/
	SelectObject(hdcmem, (HGDIOBJ)&default_bitmap);
	return hdcmem;
}
Exemplo n.º 3
0
/**
 * Draw the mouse pointer.  Save the screen contents underneath
 * before drawing. Returns previous cursor state.
 *
 * @param psd Drawing surface.
 * @return 1 iff the cursor was visible, else <= 0
 */
int
GdShowCursor(PSD psd)
{
	MWCOORD 		x;
	MWCOORD 		y;
	MWPIXELVAL *	saveptr;
	MWIMAGEBITS *	cursorptr;
	MWIMAGEBITS *	maskptr;
	MWIMAGEBITS 	curbit, cbits = 0, mbits = 0;
	MWPIXELVAL 	oldcolor;
	MWPIXELVAL 	newcolor;
	int 		oldmode;
	int		prevcursor = curvisible;

	if(++curvisible != 1)
		return prevcursor;
	oldmode = gr_mode;
	gr_mode = MWROP_COPY;

	saveptr = cursavbits;
	cursavx = curminx;
	cursavy = curminy;
	cursavx2 = curmaxx;
	cursavy2 = curmaxy;
	cursorptr = cursorcolor;
	maskptr = cursormask;

	/*
	 * Loop through bits, resetting to firstbit at end of each row
	 */
	curbit = 0;
	for (y = curminy; y <= curmaxy; y++) {
		if (curbit != MWIMAGE_FIRSTBIT) {
			cbits = *cursorptr++;
			mbits = *maskptr++;
			curbit = MWIMAGE_FIRSTBIT;
		}
		for (x = curminx; x <= curmaxx; x++) {
			if(x >= 0 && x < psd->xvirtres &&
			   y >= 0 && y < psd->yvirtres) {
				oldcolor = psd->ReadPixel(psd, x, y);
				if (curbit & mbits) {
					newcolor = (curbit&cbits)? curbg: curfg;
					if (oldcolor != newcolor)
						psd->DrawPixel(psd, x, y, newcolor);
				}
				*saveptr++ = oldcolor;
			}
			curbit = MWIMAGE_NEXTBIT(curbit);
			if (!curbit) {	/* check > one MWIMAGEBITS wide*/
				cbits = *cursorptr++;
				mbits = *maskptr++;
				curbit = MWIMAGE_FIRSTBIT;
			}
		}
	}

	gr_mode = oldmode;
	return prevcursor;
}
Exemplo n.º 4
0
/*
 * Draw the mouse pointer.  Save the screen contents underneath
 * before drawing. Returns previous cursor state.
 */
int
GdShowCursor(PSD psd)
{
	MWCOORD 		x;
	MWCOORD 		y;
	MWPIXELVAL *	saveptr;
	MWIMAGEBITS *	cursorptr;
	MWIMAGEBITS *	maskptr;
	MWIMAGEBITS 	curbit, cbits, mbits;
	MWPIXELVAL 	oldcolor;
	MWPIXELVAL 	newcolor;
	int 		oldmode;
	int		prevcursor = curvisible;

	if(++curvisible != 1)
		return prevcursor;
	oldmode = gr_mode;
	gr_mode = MWMODE_COPY;

	saveptr = cursavbits;
	cursavx = curminx;
	cursavy = curminy;
	cursavx2 = curmaxx;
	cursavy2 = curmaxy;
	cursorptr = cursorcolor;
	maskptr = cursormask;

	for (y = curminy; y <= curmaxy; y++) {
		cbits = *cursorptr++;
		mbits = *maskptr++;
		curbit = MWIMAGE_FIRSTBIT;
		for (x = curminx; x <= curmaxx; x++) {
			if(x >= 0 && x < psd->xvirtres &&
			   y >= 0 && y < psd->yvirtres) {
				oldcolor = psd->ReadPixel(psd, x, y);
				if (curbit & mbits) {
					newcolor = (curbit&cbits)? curbg: curfg;
					if (oldcolor != newcolor)
					       psd->DrawPixel(psd, x, y, newcolor);
				}
				*saveptr++ = oldcolor;
			}
			curbit = MWIMAGE_NEXTBIT(curbit);
		}
	}

	gr_mode = oldmode;
	return prevcursor;
}
Exemplo n.º 5
0
void
gen_fillrect(PSD psd,MWCOORD x1, MWCOORD y1, MWCOORD x2, MWCOORD y2,
	MWPIXELVAL c)
{
	while(y1 <= y2)
		psd->DrawHorzLine(psd, x1, x2, y1++, c);
}
Exemplo n.º 6
0
/**
 * Restore the screen overwritten by the cursor.
 *
 * @param psd Drawing surface.
 * @return 1 iff the cursor was visible, else <= 0
 */
int
GdHideCursor(PSD psd)
{
	MWPIXELVAL *	saveptr;
	MWCOORD 		x, y;
	int 		oldmode;
	int		prevcursor = curvisible;

	if(curvisible-- <= 0)
		return prevcursor;
	oldmode = gr_mode;
	gr_mode = MWROP_COPY;

	saveptr = cursavbits;
	for (y = cursavy; y <= cursavy2; y++) {
		for (x = cursavx; x <= cursavx2; x++) {
			if(x >= 0 && x < psd->xvirtres &&
			   y >= 0 && y < psd->yvirtres) {
				psd->DrawPixel(psd, x, y, *saveptr++);
			}
		}
	}
 	gr_mode = oldmode;
	return prevcursor;
}
Exemplo n.º 7
0
/*
 * Generalized low level bitmap output routine, called
 * only if no clipping is required.  Only the set bits
 * in the bitmap are drawn, in the foreground color.
 */
void
gen_drawbitmap(PSD psd,COORD x, COORD y, COORD width, COORD height,
	const IMAGEBITS *table, PIXELVAL fgcolor)
{
  COORD minx;
  COORD maxx;
  IMAGEBITS bitvalue;	/* bitmap word value */
  int bitcount;			/* number of bits left in bitmap word */

  minx = x;
  maxx = x + width - 1;
  bitcount = 0;
  while (height > 0) {
	if (bitcount <= 0) {
		bitcount = IMAGE_BITSPERIMAGE;
		bitvalue = *table++;
	}
	if (IMAGE_TESTBIT(bitvalue))
		psd->DrawPixel(psd, x, y, fgcolor);
	bitvalue = IMAGE_SHIFTBIT(bitvalue);
	--bitcount;
	if (x++ == maxx) {
		x = minx;
		++y;
		--height;
		bitcount = 0;
	}
  }
}
Exemplo n.º 8
0
/*
 * Return about the screen.
 */
void
GdGetScreenInfo(PSD psd, PMWSCREENINFO psi)
{
	psd->GetScreenInfo(psd, psi);
	GdGetButtonInfo(&psi->buttons);
	GdGetModifierInfo(&psi->modifiers, NULL);
	GdGetCursorPos(&psi->xpos, &psi->ypos);
}
Exemplo n.º 9
0
/* Set dynamic screen portrait mode, return new mode*/
int
GdSetPortraitMode(PSD psd, int portraitmode)
{
	/* set portrait mode if supported*/
	if (psd->SetPortrait)
		psd->SetPortrait(psd, portraitmode);
	return psd->portrait;
}
Exemplo n.º 10
0
static void
fbportrait_fillrect(PSD psd,MWCOORD x1, MWCOORD y1, MWCOORD x2, MWCOORD y2,
	MWPIXELVAL c)
{
	y2 = psd->yvirtres-y2-1;
	y1 = psd->yvirtres-y1-1;
	x1 = psd->xvirtres-x2-1;
	x2 = psd->xvirtres-x1-1;
	while(y2 <= y1)
		psd->DrawHorzLine(psd, x1, x2, y2++, c);
}
Exemplo n.º 11
0
void TextureUpdate(const char *filename, int n)
{
	glBindTexture(GL_TEXTURE_2D, texture[n]);

	char fullname[256];
	PSD psdimage;
	CDDSImage image;
	int psd = 0;
	sprintf(fullname, "textures\\%s.psd", filename);
	if (psdimage.Load(fullname))
	{
		psdimage.Upload2D(texinfo[n].mipmap);
	}
	else
	{
		sprintf(fullname, "textures\\%s.dds", filename);

		if (image.load(fullname))
		{
			image.upload_texture2D();
		}
	}
}
Exemplo n.º 12
0
/* set the system palette section to the passed palette entries*/
void
GdSetPalette(PSD psd, int first, int count, MWPALENTRY *palette)
{
	int	i;

	/* no palette management needed if running truecolor*/
	if(psd->pixtype != MWPF_PALETTE)
		return;

	/* bounds check against # of device color entries*/
	if(first + count > (int)psd->ncolors)
		count = (int)psd->ncolors - first;
	if(count >= 0 && first < (int)psd->ncolors) {
		psd->SetPalette(psd, first, count, palette);

		/* copy palette for GdFind*Color*/
		for(i=0; i<count; ++i)
			gr_palette[i+first] = palette[i];
	}
}
Exemplo n.º 13
0
/**
 * Open low level graphics driver.
 *
 * @return The screen drawing surface.
 */
PSD
GdOpenScreen(void)
{
	PSD			psd;
	MWPALENTRY *		stdpal;

	psd = scrdev.Open(&scrdev);
	if (!psd)
		return NULL;

	/* assume no user changable palette entries*/
	gr_firstuserpalentry = (int)psd->ncolors;

	/* set palette according to system colors and devpalX.c*/
	switch((int)psd->ncolors) {

#if !defined(NOSTDPAL1) /* don't require stdpal1 if not needed */
	case 2:		/* 1bpp*/
	{
		extern MWPALENTRY	mwstdpal1[2];
		stdpal = mwstdpal1;
	}
	break;
#endif

#if !defined(NOSTDPAL2) /* don't require stdpal2 if not needed */
	case 4:		/* 2bpp*/
	{
		extern MWPALENTRY	mwstdpal2[4];
		stdpal = mwstdpal2;
	}
	break;
#endif

#if !defined(NOSTDPAL4)
	/* don't require stdpal4 if not needed */
	case 8:		/* 3bpp - not fully supported*/
	case 16:	/* 4bpp*/
	{
		extern MWPALENTRY	mwstdpal4[16];
		stdpal = mwstdpal4;
	}
	break;
#endif

#if !defined(NOSTDPAL8) /* don't require large stdpal8 if not needed */
	case 256:	/* 8bpp*/
	{
		extern MWPALENTRY	mwstdpal8[256];
#if UNIFORMPALETTE
		/* don't change uniform palette if alpha blending*/
		gr_firstuserpalentry = 256;
#else
		/* start after last system-reserved color*/
		gr_firstuserpalentry = FIRSTUSERPALENTRY;
#endif
		stdpal = mwstdpal8;
	} 
	break;
#endif	/* !defined(NOSTDPAL8)*/

	default:	/* truecolor*/
		/* no palette*/
		gr_firstuserpalentry = 0;
		stdpal = NULL;
	}

	/* reset next user palette entry, write hardware palette*/
	GdResetPalette();
	GdSetPalette(psd, 0, (int)psd->ncolors, stdpal);

	/* init local vars*/
	GdSetMode(MWROP_COPY);
	GdSetFillMode(MWFILL_SOLID);  /* Set the fill mode to solid */

	GdSetForegroundColor(psd, MWRGB(255, 255, 255));	/* WHITE*/
	GdSetBackgroundColor(psd, MWRGB(0, 0, 0));		/* BLACK*/
	GdSetUseBackground(TRUE);
	/* select first builtin font (usually MWFONT_SYSTEM_VAR)*/
	//GdSetFont(GdCreateFont(psd, NULL, 0, 0, NULL));

	GdSetDash(0, 0);  /* No dashing to start */
	GdSetStippleBitmap(0,0,0);  /* No stipple to start */

#if !NOCLIPPING
#if DYNAMICREGIONS
	GdSetClipRegion(psd, GdAllocRectRegion(0, 0, psd->xvirtres, psd->yvirtres));
#else
	GdSetClipRects(psd, 0, NULL);
#endif /* DYNAMICREGIONS*/
#endif /* NOCLIPPING*/

	/* fill black (actually fill to first palette entry or truecolor 0*/
	psd->FillRect(psd, 0, 0, psd->xvirtres-1, psd->yvirtres-1, 0);
	return psd;
}
Exemplo n.º 14
0
SCoord SCoord::operator+(SCoord const& other) const
{
    return SCoord(phi + other.phi, theta + other.theta);
}
Exemplo n.º 15
0
SCoord SCoord::operator-(SCoord const& other) const
{
    return SCoord(phi - other.phi, theta - other.theta);
}
Exemplo n.º 16
0
/*
 * Open low level graphics driver
 */
PSD
GdOpenScreen(void)
{
	PSD			psd;
	MWPALENTRY *		stdpal;
	MWSCREENINFO		sinfo;	    

	psd = scrdev.Open(&scrdev);
	if (!psd)
		return NULL;
	GdGetScreenInfo(psd, &sinfo);
	gr_pixtype = sinfo.pixtype;
	gr_ncolors = sinfo.ncolors;

	/* assume no user changable palette entries*/
	gr_firstuserpalentry = (int)psd->ncolors;

	/* set palette according to system colors and devpalX.c*/
	switch((int)psd->ncolors) {

#if !defined(NOSTDPAL1) /* don't require stdpal1 if not needed */
	case 2:		/* 1bpp*/
	{
		extern MWPALENTRY	mwstdpal1[2];
		stdpal = mwstdpal1;
	}
	break;
#endif

#if !defined(NOSTDPAL2) /* don't require stdpal2 if not needed */
	case 4:		/* 2bpp*/
	{
		extern MWPALENTRY	mwstdpal2[4];
		stdpal = mwstdpal2;
	}
	break;
#endif

#if !defined(NOSTDPAL4)
	/* don't require stdpal4 if not needed */
	case 8:		/* 3bpp - not fully supported*/
	case 16:	/* 4bpp*/
	{
		extern MWPALENTRY	mwstdpal4[16];
		stdpal = mwstdpal4;
	}
	break;
#endif

#if !defined(NOSTDPAL8) /* don't require large stdpal8 if not needed */
	case 256:	/* 8bpp*/
	{
		extern MWPALENTRY	mwstdpal8[256];
#if xxxALPHABLEND
		/* don't change uniform palette if alpha blending*/
		gr_firstuserpalentry = 256;
#else
		/* start after last system-reserved color*/
		gr_firstuserpalentry = FIRSTUSERPALENTRY;
#endif
		stdpal = mwstdpal8;
	} 
	break;
#endif	/* !defined(NOSTDPAL8)*/

	default:	/* truecolor*/
		/* no palette*/
		gr_firstuserpalentry = 0;
		stdpal = NULL;
	}

	/* reset next user palette entry, write hardware palette*/
	GdResetPalette();
	GdSetPalette(psd, 0, (int)psd->ncolors, stdpal);
#if xxxALPHABLEND
	/* one-time create alpha lookup table for 8bpp systems (takes ~1 sec)*/
	if(psd->ncolors == 256)
		init_alpha_lookup();
#endif

#if !NOFONTSORCLIPPING
	/* init local vars*/
	GdSetMode(MWMODE_COPY);
	GdSetForeground(GdFindColor(MWRGB(255, 255, 255)));	/* WHITE*/
	GdSetBackground(GdFindColor(MWRGB(0, 0, 0)));		/* BLACK*/
	GdSetUseBackground(TRUE);
	GdSetFont(GdCreateFont(psd, MWFONT_SYSTEM_VAR, 0, NULL));
#if DYNAMICREGIONS
	GdSetClipRegion(psd, 
		GdAllocRectRegion(0, 0, psd->xvirtres, psd->yvirtres));
#else
	GdSetClipRects(psd, 0, NULL);
#endif /* DYNAMICREGIONS*/
#endif /* NOFONTSORCLIPPING*/

	/* fill black (actually fill to first palette entry or truecolor 0*/
	psd->FillRect(psd, 0, 0, psd->xvirtres-1, psd->yvirtres-1, 0);
	return psd;
}
Exemplo n.º 17
0
/*
 * Close low level graphics driver
 */
void 
GdCloseScreen(PSD psd)
{
	psd->Close(psd);
}
Exemplo n.º 18
0
/*
 * Initialize the graphics and mouse devices at startup.
 * Returns nonzero with a message printed if the initialization failed.
 */
int
GsInitialize(void)
{
	GR_WINDOW	*wp;		/* root window */
	PSD		psd;
	GR_CURSOR_ID	cid;
	static MWIMAGEBITS cursorbits[16] = {
	      0xe000, 0x9800, 0x8600, 0x4180,
	      0x4060, 0x2018, 0x2004, 0x107c,
	      0x1020, 0x0910, 0x0988, 0x0544,
	      0x0522, 0x0211, 0x000a, 0x0004
	};
	static MWIMAGEBITS cursormask[16] = {
	      0xe000, 0xf800, 0xfe00, 0x7f80,
	      0x7fe0, 0x3ff8, 0x3ffc, 0x1ffc,
	      0x1fe0, 0x0ff0, 0x0ff8, 0x077c,
	      0x073e, 0x021f, 0x000e, 0x0004
	};

	/* If needed, initialize the server mutex. */
	SERVER_LOCK_INIT();

	setbuf(stdout, NULL);
	setbuf(stderr, NULL);

	wp = (GR_WINDOW *) malloc(sizeof(GR_WINDOW));
	if (wp == NULL) {
		EPRINTF("Cannot allocate root window\n");
		return -1;
	}

	startTicks = GsGetTickCount();

#ifndef MW_NOSIGNALS
	/* catch terminate signal to restore tty state*/
	signal(SIGTERM, (void *)GsTerminate);
#endif

#if MW_FEATURE_TIMERS
	screensaver_delay = 0;
#endif
	screensaver_active = GR_FALSE;

	selection_owner.wid = 0;
	selection_owner.typelist = NULL;

#if !NONETWORK
#ifndef MW_NOSIGNALS
	/* ignore pipe signal, sent when clients exit*/
	signal(SIGPIPE, SIG_IGN);
	signal(SIGHUP, SIG_IGN);
#endif

	if (GsOpenSocket() < 0) {
		EPRINTF("Cannot bind to named socket\n");
		free(wp);
		return -1;
	}
#endif

	if ((keyb_fd = GdOpenKeyboard()) == -1) {
		EPRINTF("Cannot initialise keyboard\n");
		/*GsCloseSocket();*/
		free(wp);
		return -1;
	}

#ifdef MW_FEATURE_TWO_KEYBOARDS
	if ((keyb2_fd = GdOpenKeyboard2()) == -1) {
		EPRINTF("Cannot initialise second keyboard\n");
		/*GsCloseSocket();*/
		free(wp);
		return -1;
	}
#endif

	if ((psd = GdOpenScreen()) == NULL) {
		EPRINTF("Cannot initialise screen\n");
		/*GsCloseSocket();*/
		GdCloseKeyboard();
		free(wp);
		return -1;
	}
	GdSetPortraitMode(psd, portraitmode);

	if ((mouse_fd = GdOpenMouse()) == -1) {
		EPRINTF("Cannot initialise mouse\n");
		/*GsCloseSocket();*/
		GdCloseScreen(psd);
		GdCloseKeyboard();
		free(wp);
		return -1;
	}

	/*
	 * Create std font.
	 */
#if (HAVE_BIG5_SUPPORT | HAVE_GB2312_SUPPORT | HAVE_JISX0213_SUPPORT | HAVE_KSC5601_SUPPORT)
	/* system fixed font looks better when mixed with builtin fixed fonts*/
	stdfont = GdCreateFont(psd, MWFONT_SYSTEM_FIXED, 0, NULL);
#else
	stdfont = GdCreateFont(psd, MWFONT_SYSTEM_VAR, 0, NULL);
#endif

	/*
	 * Initialize the root window.
	 */
	wp->psd = psd;
	wp->id = GR_ROOT_WINDOW_ID;
	wp->parent = NULL;		/* changed: was = NULL*/
	wp->owner = NULL;
	wp->children = NULL;
	wp->siblings = NULL;
	wp->next = NULL;
	wp->x = 0;
	wp->y = 0;
	wp->width = psd->xvirtres;
	wp->height = psd->yvirtres;
	wp->bordersize = 0;
	wp->background = BLACK;
	wp->bordercolor = wp->background;
	wp->nopropmask = 0;
	wp->bgpixmap = NULL;
	wp->bgpixmapflags = GR_BACKGROUND_TILE;
	wp->eventclients = NULL;
	wp->cursorid = 0;
	wp->mapped = GR_TRUE;
	wp->realized = GR_TRUE;
	wp->output = GR_TRUE;
	wp->props = 0;
	wp->title = NULL;
	wp->clipregion = NULL;

        listpp = NULL;
	listwp = wp;
	rootwp = wp;
	focuswp = wp;
	mousewp = wp;
	focusfixed = GR_FALSE;

	/*
	 * Initialize and position the default cursor.
	 */
	curcursor = NULL;
	cursorx = -1;
	cursory = -1;
	GdShowCursor(psd);
	GsMoveCursor(psd->xvirtres / 2, psd->yvirtres / 2);

	SERVER_UNLOCK();
	cid = GrNewCursor(16, 16, 0, 0, WHITE, BLACK, cursorbits, cursormask);
	GrSetWindowCursor(GR_ROOT_WINDOW_ID, cid);
	SERVER_LOCK();

	stdcursor = GsFindCursor(cid);

#if VTSWITCH
	MwInitVt();
	/* Check for VT change every 50 ms: */
	GdAddTimer(50, CheckVtChange, NULL);
#endif
	psd->FillRect(psd, 0, 0, psd->xvirtres-1, psd->yvirtres-1,
		GdFindColor(psd, wp->background));

	/*
	 * Tell the mouse driver some things.
	 */
	curbuttons = 0;
	GdRestrictMouse(0, 0, psd->xvirtres - 1, psd->yvirtres - 1);
	GdMoveMouse(psd->xvirtres / 2, psd->yvirtres / 2);

	/* Force root window screen paint*/
	GsRedrawScreen();

	/*
	 * Force the cursor to appear on the screen at startup.
	 * (not required with above GsRedrawScreen)
	GdHideCursor(psd);
	GdShowCursor(psd);
	 */

	/*
	 * All done.
	 */
	connectcount = 0;
	return 0;
}
Exemplo n.º 19
0
SCoord SCoord::operator*(SCoord const& other) const
{
    return SCoord(phi * other.phi, theta * other.theta);
}
Exemplo n.º 20
0
SCoord SCoord::operator/(SCoord const& other) const
{
    return SCoord(phi / other.phi, theta / other.theta);
}
Exemplo n.º 21
0
int CreateTexture(const char *filename, bool clamp, bool duplicate, unsigned int minfilter, unsigned int magfilter)
{
	if (!filename)
	{
//		return -1;
		return CreateTexture("default", false, false, GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);
	}

	if (duplicate == false)
	{
		for (int n = 0; n < textures; n++)
		{
			if (_stricmp(filename, texinfo[n].filename) == 0)
			{
				texinfo[n].refcount++;
				return n;
			}
		}
	}


	char fullname[256];
	PSD psdimage;
	CDDSImage image;
	int psd = 0;
	sprintf(fullname, "textures\\%s.psd", filename);
	if (psdimage.Load(fullname))
	{
		psd = 1;
	}
	else
	{
		sprintf(fullname, "textures\\%s.dds", filename);

		if (!image.load(fullname))
		{
	//		return -1;
			return CreateTexture("default", false, false, GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);
		}
	}


	texture = (unsigned int*)realloc(texture, sizeof(unsigned int) * (textures + 1));
	texinfo = (TexInfo*)realloc(texinfo, sizeof(TexInfo) * (textures + 1));


	int mipmap = 0;
	if (minfilter == GL_NEAREST_MIPMAP_NEAREST || minfilter == GL_LINEAR_MIPMAP_NEAREST || minfilter == GL_NEAREST_MIPMAP_LINEAR || minfilter == GL_LINEAR_MIPMAP_LINEAR)
		mipmap = 1;


	glGenTextures(1, &texture[textures]);
	glBindTexture(GL_TEXTURE_2D, texture[textures]);
	if (psd)
	{
		psdimage.Upload2D(mipmap);
	}
	else
	{
		image.upload_texture2D();
	}
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minfilter);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magfilter);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy);

	if (clamp)
	{
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	}

	strcpy(texinfo[textures].filename, filename);
	if (psd)
	{
		texinfo[textures].width = psdimage.width;
		texinfo[textures].height = psdimage.height;
	}
	else
	{
		texinfo[textures].width = image.get_width();
		texinfo[textures].height = image.get_height();
	}
	texinfo[textures].mipmap = mipmap;
	texinfo[textures].refcount = 1;

	psdimage.Clear();
	image.clear();

	textures++;

	return textures - 1;
}
Exemplo n.º 22
0
SCoord SCoord::operator/(int const other) const
{
    return SCoord(phi / static_cast<qreal>(other),
                  theta / static_cast<qreal>(other));
}