Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
bugfix for non-square atlases. Added additional defines. Newline now
goes to the next line and not the previous >__>.
  • Loading branch information
esmelusina committed Nov 3, 2015
1 parent f6a3a67 commit 85e5f19
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Test/Test.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<Filter Include="Source Files\Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
Expand Down
4 changes: 4 additions & 0 deletions Test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ void main()
{
sfw::initContext(800,600,"NSFW Draw");

unsigned f = sfw::loadTextureMap("../res/tonc_font.png", 16, 6);
unsigned d = sfw::loadTextureMap("../res/fontmap.png",16,16);
unsigned r = sfw::loadTextureMap("../res/background.jpg");
unsigned u = sfw::loadTextureMap("../res/crosshair.png");
Expand All @@ -19,11 +20,14 @@ void main()

while (sfw::stepContext())
{
sfw::drawString(f, " !\"#$%&'()*+,./-\n0123456789:;<=>?\n@ABCDEFGHIJKLMNO\nPQRSTUVWXYZ[\\]^_\n`abcdefghijklmno\npqrstuvwxyz{|}~", 0, 600, 48, 48, 0, ' ');
sfw::drawTexture(r, 0, 600, 800, 600, 0, false,0, 0x88888888);

acc += sfw::getDeltaTime();
sfw::drawString(d, "TIME 4 FUN", 400, 300, 48, 48, -acc*24,'\0',MAGENTA);



sfw::drawString(d, "6", 400, 32, 24, 24);
sfw::drawString(d, "12", 400, 600 - 32, 24, 24);
sfw::drawString(d, "3", 800-32, 300, 24, 24);
Expand Down
Binary file added dep/lib/deb/glfw3.lib
Binary file not shown.
File renamed without changes.
4 changes: 2 additions & 2 deletions nsfw2draw/nsfw2draw.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<AdditionalDependencies>glfw3.lib;opengl32.lib</AdditionalDependencies>
</Lib>
<Lib>
<AdditionalLibraryDirectories>$(SolutionDir)dep\lib\</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)dep\lib\deb</AdditionalLibraryDirectories>
</Lib>
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
Expand Down Expand Up @@ -122,7 +122,7 @@
<AdditionalDependencies>glfw3.lib;opengl32.lib</AdditionalDependencies>
</Lib>
<Lib>
<AdditionalLibraryDirectories>$(SolutionDir)dep\lib\</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)dep\lib\rel</AdditionalLibraryDirectories>
</Lib>
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
Expand Down
9 changes: 5 additions & 4 deletions nsfw2draw/sfwdraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ namespace sfw
glm::mat4 model = glm::translate(a_x, a_y, 0.f) * glm::rotate(r, 0.f, 0.f, 1.f) * glm::scale(w, h, 0.f) * glm::translate(0.5f,-0.5f,0.f);
for (size_t i = 0; i < strlen(text); ++i)
{
if (text[i] == '\n' || text[i] == '\r') { y += 1; x = 0; }
if (text[i] == '\n' || text[i] == '\r') { y -= 1; x = 0; }
else if (text[i] == '\t') x += 4;
else
{
Expand Down Expand Up @@ -183,7 +183,7 @@ namespace sfw

quad = makeVAO(QuadVerts, 4, QuadTris, 6);

const char *vsourceTex = "#version 330\n\
const char *vsourceTex = "#version 330\n\
layout(location = 0) in vec4 Position;\
layout(location = 2) in vec2 TexCoord;\
out vec2 vTexCoord;\
Expand All @@ -195,8 +195,9 @@ namespace sfw
uniform int index = 0;\
void main()\
{\
float c = (index % cols) % cols; \
float r = (index / cols) % rows; \
int i = index % (rows*cols);\
float c = (i % rows); \
float r = (i / rows); \
vTexCoord = (vec2(c,r) + TexCoord) / vec2(rows,cols);\
gl_Position = Projection * View * Model * Position;\
}";
Expand Down
16 changes: 11 additions & 5 deletions nsfw2draw/sfwdraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ NOTE: YOU MUST CALL initContext for any of the functions to work!
************************/

// Uses GLFW keycodes, research for additional options.
#define KEY_UP 262
#define KEY_DOWN 263
#define KEY_LEFT 264
#define KEY_RIGHT 265
#define KEY_ESCAPE 256
#define KEY_ENTER 257
#define KEY_TAB 258
#define KEY_BACKSPACE 259

#define KEY_RIGHT 262
#define KEY_LEFT 263
#define KEY_DOWN 264
#define KEY_UP 265

#define MOUSE_BUTTON_RIGHT 1
#define MOUSE_BUTTON_LEFT 0

Expand All @@ -43,7 +49,7 @@ NOTE: YOU MUST CALL initContext for any of the functions to work!
#define CYAN 0x00ffffff
#define MAGENTA 0xff00ffff
#define YELLOW 0xffff00ff
#define RED 0xff0000ff
#define RED 0xff0000ff
#define GREEN 0x00ff00ff
#define BLUE 0x0000ffff
#define NONE 0x00000000
Expand Down
Binary file added res/tonc_font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 85e5f19

Please sign in to comment.