View previous topic :: View next topic |
Author |
Message |
gekkonier
Joined: 27 Mar 2007 Posts: 28
|
Posted: Fri Jul 20, 2007 8:59 am Post subject: Problem with Tutorial (Font issue?) |
|
|
Hi,
I'm trying to figure out how ArcLib works.
First of all:
I tried to work through this tutorial:
http://dmedia.dprogramming.com/?n=Tutorials.ArcIntro
I'm sitting on a Windows Computer with dmd 1.018, dsss 0.67, and fresh fetched ArcLib (dsss net install arclib). Happy Hippie, it worked.
Then I tried to get the "Hello World" example of the previously mentioned tutorial working, but I had to change it to this:
Code: | module main;
import arc.all; // <- Look here!
int main()
{
arc.window.open("Hello World", 400,300,0);
arc.input.open();
Font f = new Font("Crisp.ttf", 12); // <- this ttf file resists in same dir as the source/bin
while (!arc.input.keyDown(ARC_QUIT))
{
arc.input.process();
arc.window.clear();
f.draw(cast(char[])"Text UTF16", Point(10,10), Color(100,200,50,50)); // <- Look here
arc.window.swap();
}
arc.window.close();
return 0;
} |
to get it compiled without errors.
Note here compared to the tutorial the f.draw line and the import statement.
With the original import (import arc.input, arc.window, arc.font;) my compiler didn't found Point, Color and so on. So I changed to import arc.all;
If i try to run the compiled executable, I get the following error message:
Code: | Error: Access Violation |
Can you point me to the solution for this issue?
(If i kick off all font stuff a window pops up as intended.)
Regards, Gregor |
|
Back to top |
|
|
gekkonier
Joined: 27 Mar 2007 Posts: 28
|
Posted: Fri Jul 20, 2007 9:31 am Post subject: |
|
|
Okay, i figured out, that it has something to do with the font-loading.
If i try this:
Code: | module main;
import arc.all;
int main()
{
arc.window.open("Hello World", 400,300,0);
arc.input.open();
Font f = new Font("Crisp.ttf", 12);
char[] text = "hello!";
while (!arc.input.keyDown(ARC_QUIT))
{
arc.input.process();
arc.window.clear();
// f.draw(text, Point(10,10), Color.Green);
// drawPixel(Point(10,10), Color.Green);
arc.window.swap();
}
arc.window.close();
return 0;
} |
I get the access violation, but if I comment out the Font f = new Font line, it works.
I tried also to work with absolute path, but also no luck.
Painting dots, rectangles works. |
|
Back to top |
|
|
ChristianK
Joined: 26 Sep 2006 Posts: 159 Location: Berlin, Germany
|
Posted: Sun Jul 22, 2007 5:02 am Post subject: |
|
|
Thanks for trying Arc!
I've never worked on the font code myself, but as there are arc.font.open/close methods, I expect adding the calls should help.
Clay: In addition to this, can you update the dmedia tutorial to fix the import and the font.draw overload issue? Also, we really got to fix the open/close annoyance for 0.3: I've added some comments to http://www.dsource.org/projects/arclib/ticket/33 |
|
Back to top |
|
|
gekkonier
Joined: 27 Mar 2007 Posts: 28
|
Posted: Sun Jul 22, 2007 11:57 pm Post subject: |
|
|
Thank you for your answer!
Now it looks like this and works: Code: | module main;
import arc.all;
int main()
{
arc.window.open("Hello World", 400,300,0);
arc.input.open();
arc.font.open();
Font f = new Font("Crisp.ttf", 16);
while (!arc.input.keyDown(ARC_QUIT))
{
arc.input.process();
arc.window.clear();
char[] text = "Hello, World!";
f.draw(text, Point(10,10), Color.Green);
// drawPixel(Point(10,10), Color.Green);
arc.window.swap();
}
arc.font.close();
arc.window.close();
return 0;
} |
|
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Mon Jul 30, 2007 11:34 am Post subject: |
|
|
You can also use
f.draw("text"c, Point(10,10), Color.Green)
tutorial is updated. |
|
Back to top |
|
|
gekkonier
Joined: 27 Mar 2007 Posts: 28
|
Posted: Mon Apr 07, 2008 5:53 am Post subject: |
|
|
Hello, it was a long time ago, and now i wanted to start again with d, tango and arclib.
I compiled a "hello world" program just to test if my setup works, but while compiling or executing of the resulting exe file there are no error messages, so i think it should be ok, but if i exec the exe i just see a window popping up, and closing immediately. If i start the same exe out of a shell, i just see no failure message. Okay, here are the steps to reproduce my problem (I tried this on a Windows XP Professional and a Windows 2000 Professional):
1. I downloaded the dmd+Tango bundle for Windows, installed it and tested it:
http://www.fsdev.net/wiki/dmd-snapshots
Here i tooked the version 0.4.0
2. Then i did a dsss net install arclib (everythink went through without errors.
3. I created a main.d with the following:
Code: | module main;
import
arc.input,
arc.window,
arc.font,
arc.math.point,
arc.draw.color;
int main()
{
arc.window.open("Hello World", 400,300,0);
arc.input.open();
arc.font.open();
Font font = new Font("Crisp.ttf", 32); // THIS FONT EXISTS IN SAME DIR AS THE MAIN.D
while (!arc.input.keyDown(ARC_QUIT))
{
arc.input.process();
arc.window.clear();
font.draw("Hello Arc World"c, Point(200,200),Color.Green);
arc.window.swap();
}
arc.font.close();
arc.window.close();
return 0;
}
|
Here I tooked the code from this site: http://dmedia.dprogramming.com/?n=Tutorials.ArcIntro
, it's the example from "Setting up Arc, part 2: hello world", stripped from all comments for the forum, and changed the (i've tested it in an other program) working font file line.
3. I placed the SDL.dll in the same dir.
I got the dll from here: http://www.libsdl.org/download-1.2.php
(Runtime Lib. for Win32)
4. I created a dsss.conf file with: [main.d] as content
5. dsss build in the directory.
Did i missed something important? Maybe a dll for fontloading or simething similiar?
Regards, Gregor
EDIT: I've also tried all examples above in this thread, also with no luck, it compiles well, but doesn't show any window or error on starting. |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
|
Back to top |
|
|
gekkonier
Joined: 27 Mar 2007 Posts: 28
|
Posted: Mon Apr 07, 2008 9:35 am Post subject: |
|
|
The dll's were missing. Now it works.
Thank you! |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|