Permalink
Browse files

Use harfbuzz

  • Loading branch information...
vlj committed Sep 4, 2016
1 parent 7821a9c commit 270c8e1dd30bcc0e2c38bf204d7e918866d3bf21
@@ -138,6 +138,28 @@ inline void ImageMerge::arrange()
}
}
IMAGEFILE *iV_CreateEmptyTexPage(size_t width, size_t height)
{
assert(width == height); // Unfortunatly all texture must be square atm
IMAGEFILE *imageFile = new IMAGEFILE;
imageFile->pages.resize(1);
imageFile->pages[0].size = width;
iV_Image image{};
image.depth = 4;
image.width = width;
image.height = height;
image.bmp = (unsigned char *)malloc(width * height * 4); // MUST be malloc, since this is free()d later by pie_AddTexPage().
memset(image.bmp, -1, width * height * 4);
// ssprintf(arbitraryName, "%s-%03u", fileName, p);
// Now we can set imageFile->pages[p].id. This free()s the ivImages[p].bmp array!
imageFile->pages[0].id = pie_AddTexPage(&image, "internal", false);
files.append(imageFile);
return imageFile;
}
IMAGEFILE *iV_LoadImageFile(const char *fileName)
{
// Find the directory of images.
@@ -51,6 +51,7 @@ static inline WZ_DECL_PURE short iV_GetImageYOffset(const IMAGEFILE *ImageFile,
}
ImageDef *iV_GetImage(const QString &filename);
IMAGEFILE *iV_CreateEmptyTexPage(size_t width, size_t height);
IMAGEFILE *iV_LoadImageFile(const char *FileData);
void iV_FreeImageFile(IMAGEFILE *ImageFile);
@@ -189,6 +189,8 @@
<Import Project="..\..\win32\packages\libiconv.1.14.0.10\build\native\libiconv.targets" Condition="Exists('..\..\win32\packages\libiconv.1.14.0.10\build\native\libiconv.targets')" />
<Import Project="..\..\win32\packages\libintl.redist.0.18.2.10\build\native\libintl.redist.targets" Condition="Exists('..\..\win32\packages\libintl.redist.0.18.2.10\build\native\libintl.redist.targets')" />
<Import Project="..\..\win32\packages\libintl.0.18.2.10\build\native\libintl.targets" Condition="Exists('..\..\win32\packages\libintl.0.18.2.10\build\native\libintl.targets')" />
<Import Project="..\..\win32\packages\freetype2.2.6.0.1\build\native\freetype2.targets" Condition="Exists('..\..\win32\packages\freetype2.2.6.0.1\build\native\freetype2.targets')" />
<Import Project="..\..\win32\packages\harfbuzz.0.9.41.1\build\native\harfbuzz.targets" Condition="Exists('..\..\win32\packages\harfbuzz.0.9.41.1\build\native\harfbuzz.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
@@ -204,5 +206,7 @@
<Error Condition="!Exists('..\..\win32\packages\libiconv.1.14.0.10\build\native\libiconv.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\win32\packages\libiconv.1.14.0.10\build\native\libiconv.targets'))" />
<Error Condition="!Exists('..\..\win32\packages\libintl.redist.0.18.2.10\build\native\libintl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\win32\packages\libintl.redist.0.18.2.10\build\native\libintl.redist.targets'))" />
<Error Condition="!Exists('..\..\win32\packages\libintl.0.18.2.10\build\native\libintl.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\win32\packages\libintl.0.18.2.10\build\native\libintl.targets'))" />
<Error Condition="!Exists('..\..\win32\packages\freetype2.2.6.0.1\build\native\freetype2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\win32\packages\freetype2.2.6.0.1\build\native\freetype2.targets'))" />
<Error Condition="!Exists('..\..\win32\packages\harfbuzz.0.9.41.1\build\native\harfbuzz.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\win32\packages\harfbuzz.0.9.41.1\build\native\harfbuzz.targets'))" />
</Target>
</Project>
@@ -1,10 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="freetype2" version="2.6.0.1" targetFramework="native" />
<package id="glew.v140" version="1.12.0" targetFramework="native" />
<package id="libiconv" version="1.14.0.10" targetFramework="native" />
<package id="libiconv.redist" version="1.14.0.10" targetFramework="native" />
<package id="libintl" version="0.18.2.10" targetFramework="native" />
<package id="libintl.redist" version="0.18.2.10" targetFramework="native" />
<package id="harfbuzz" version="0.9.41.1" targetFramework="native" />
<package id="libpng" version="1.6.23.1" targetFramework="native" />
<package id="libpng.redist" version="1.6.23.1" targetFramework="native" />
<package id="physfs.v140" version="2.0.3.1" targetFramework="native" />
@@ -249,6 +249,27 @@ void pie_BoxFill(int x0, int y0, int x1, int y1, PIELIGHT colour)
pie_DrawRect(x0, y0, x1, y1, colour);
}
void iV_DrawImage(GLuint TextureID, Vector2i Position, Vector2i size, REND_MODE mode, PIELIGHT colour)
{
pie_SetRendMode(mode);
pie_SetTexturePage(TEXPAGE_EXTERN);
glBindTexture(GL_TEXTURE_2D, TextureID);
glColor4ubv(colour.vector);
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0.f, 0.f);
glVertex2f(Position.x, Position.y);
glTexCoord2f(1.f, 0.f);
glVertex2f(Position.x + size.x, Position.y);
glTexCoord2f(0., 1.);
glVertex2f(Position.x, Position.y + size.y);
glTexCoord2f(1., 1.);
glVertex2f(Position.x + size.x, Position.y + size.y);
glEnd();
}
/***************************************************************************/
void iV_TransBoxFill(float x0, float y0, float x1, float y1)
@@ -343,7 +364,7 @@ void iV_DrawImage2(const QString &filename, float x, float y, float width, float
glEnd();
}
void iV_DrawImage(IMAGEFILE *ImageFile, UWORD ID, int x, int y)
void iV_DrawImage(IMAGEFILE *ImageFile, UWORD ID, int x, int y, REND_MODE mode, PIELIGHT colour)
{
if (!assertValidImage(ImageFile, ID))
{
@@ -353,9 +374,9 @@ void iV_DrawImage(IMAGEFILE *ImageFile, UWORD ID, int x, int y)
PIERECT dest;
Vector2i pieImage = makePieImage(ImageFile, ID, &dest, x, y);
pie_SetRendMode(REND_ALPHA);
pie_SetRendMode(mode);
pie_DrawImage(ImageFile, ID, pieImage, &dest);
pie_DrawImage(ImageFile, ID, pieImage, &dest, colour);
}
void iV_DrawImageTc(Image image, Image imageTc, int x, int y, PIELIGHT colour)
@@ -34,6 +34,7 @@
#include "lib/framework/frame.h"
#include "lib/framework/string_ext.h"
#include "piedef.h"
#include "piepalette.h"
/***************************************************************************/
/*
@@ -111,7 +112,8 @@ static inline void iV_Box(int x0, int y0, int x1, int y1, PIELIGHT first)
iV_Box2(x0, y0, x1, y1, first, first);
}
extern void pie_BoxFill(int x0, int y0, int x1, int y1, PIELIGHT colour);
extern void iV_DrawImage(IMAGEFILE *ImageFile, UWORD ID, int x, int y);
extern void iV_DrawImage(GLuint TextureID, Vector2i position, Vector2i size, REND_MODE mode, PIELIGHT colour);
extern void iV_DrawImage(IMAGEFILE *ImageFile, UWORD ID, int x, int y, REND_MODE mode = REND_ALPHA, PIELIGHT colour = WZCOL_WHITE);
void iV_DrawImage2(const QString &filename, float x, float y, float width = -0.0f, float height = -0.0f);
void iV_DrawImageTc(Image image, Image imageTc, int x, int y, PIELIGHT colour);
void iV_DrawImageRepeatX(IMAGEFILE *ImageFile, UWORD ID, int x, int y, int Width);
@@ -610,6 +610,11 @@ void pie_SetRendMode(REND_MODE rendMode)
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
break;
case REND_TEXT:
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
break;
default:
ASSERT(false, "Bad render state");
break;
@@ -72,6 +72,7 @@ enum REND_MODE
REND_OPAQUE,
REND_MULTIPLICATIVE,
REND_PREMULTIPLIED,
REND_TEXT,
};
enum DEPTH_MODE
View
@@ -227,6 +227,7 @@ bool replaceTexture(const QString &oldfile, const QString &newfile)
void pie_TexShutDown(void)
{
return;
// TODO, lazy deletions for faster loading of next level
debug(LOG_TEXTURE, "Cleaning out %u textures", _TEX_PAGE.size());
int _TEX_INDEX = _TEX_PAGE.size() - 1;
Oops, something went wrong.

0 comments on commit 270c8e1

Please sign in to comment.