I made a specific yet advanced game playing AI but I want to bring it to D to make it cross platform

2015-12-31 Thread Gan via Digitalmars-d
I've written an AI to play a game in Objective-C on Mac. The AI 
bits are mostly C++ code for performance. I want to make the AI 
cross platform because the game has a huge windows user base. My 
hope is to get other programmers interested in helping out 
because it is very time consuming to make perfect screen 
detection and AI decisions.


My question is, to write the Mac and Windows specific code in 
their respective languages(C# and Obj-C) for UI, screen capture 
and input simulation; can I have that code be usable from D? I 
don't know much about shared libraries or importing DLLs so I 
have no knowledge on the possibility. I would like to write all 
the AI code in D but have all the OS specific code written in 
their own languages that I can call from D. I am very familiar 
with writing C#, Obj-C and even D code. I just don't know how to 
make them all play nice. Maybe there's a way to compile the OS 
specific code in libraries and D can call them depending on which 
OS the D code gets compiled to?


Would anyone know how to do this? Or have basic examples?
To start I'd just like to write a D program that can call some 
specific already compiled C# or Obj-C code that will create a UI 
window but maintain full control in D such that D could issue 
further already compiled commands. Also receive input, like a 
button is clicked and that button sends an event notifier back to 
D.


Is this plausible?


Re: I made a specific yet advanced game playing AI but I want to bring it to D to make it cross platform

2015-12-31 Thread Gan via Digitalmars-d
On Thursday, 31 December 2015 at 10:29:42 UTC, Rikki Cattermole 
wrote:

On 31/12/15 11:20 PM, Gan wrote:

[...]


I'll start out by saying, this is more appropriate for D.learn 
not the main D Newsgroup.

What you have here is two separate issues.

- Interacting with Objective-C which over the next few years 
will become very easy (WIP currently). Otherwise you can 
interact with it via extern(C).
- Interacting with C#. This will be a good deal harder, but 
still do-able with the help of extern(C). You'll need to get 
good at interacting with unmanaged code from there, which I 
cannot help with since it is C# specific.


One thing to remember D is a native language meaning an exe 
cannot be ran on Linux and vice versa.
It won't be as simple as compiling as a shared library once and 
using it everywhere.


The shared library wouldn't be cross platform. I'd have to write 
one for each platform I target.


So what I got from this is that in theory it's possible but is 
there a lack of resources about the process?


Re: D audio playing and analysis library?

2015-04-28 Thread Gan via Digitalmars-d

On Tuesday, 28 April 2015 at 11:28:42 UTC, Dragos Carp wrote:

On Tuesday, 28 April 2015 at 11:18:14 UTC, Gan wrote:

I found this: https://github.com/p0nce/dplug

Which seems to be a good analysis library but I haven't found 
a library to play sounds.

Is there one?


https://github.com/D-Programming-Deimos/portaudio


Downloaded it, put the D example in a source folder, downloaded 
the official library, compiled the official library, stuck the 
libportaudio.la with the example, ran DUB and it can't the port 
audio library.

Undefined symbols for architecture x86_64:
  _Pa_CloseStream, referenced from:
  __Dmain in unknown.o

The source is 3 years old, probably why no dub.json file. Know 
how to fix the library problem?


D audio playing and analysis library?

2015-04-28 Thread Gan via Digitalmars-d

I found this: https://github.com/p0nce/dplug

Which seems to be a good analysis library but I haven't found a 
library to play sounds.

Is there one?


Re: Dgame revived

2015-03-04 Thread Gan via Digitalmars-d-announce

On Wednesday, 4 March 2015 at 09:24:55 UTC, Namespace wrote:

On Tuesday, 3 March 2015 at 23:01:21 UTC, Gan wrote:
Oh also the green circle anti alias isn't happening. Just a 
plain un-anti-alis circle.


Should be fixed now. Note that you now must specify the 
anti-aliasing, when you create the window. And you can now 
specify by yourself which opengl context version should be 
supported. See:

http://dgame-dev.de/?package=Windowmodule=GLSettings


Looks great. How do I use the new version in dub? Do I just set 
the dependency version to 0.5.0?


Re: Dgame revived

2015-03-03 Thread Gan via Digitalmars-d-announce
Oh also the green circle anti alias isn't happening. Just a plain 
un-anti-alis circle.


Re: Dgame revived

2015-03-03 Thread Gan via Digitalmars-d-announce

On Tuesday, 3 March 2015 at 16:59:35 UTC, Namespace wrote:

On Sunday, 1 March 2015 at 10:00:35 UTC, Namespace wrote:

On Sunday, 1 March 2015 at 00:10:22 UTC, stewarth wrote:
On Saturday, 28 February 2015 at 22:52:47 UTC, Namespace 
wrote:
On Saturday, 28 February 2015 at 11:02:31 UTC, Namespace 
wrote:
Next step is Font, Text and Spritesheet. Then I'll inspect 
Clock, Power and MessageBox and in the end I'll inspect 
Audio. I think the most breaking changes will happen here, 
because I'll use this time SDL_Audio instead of OpenAL.


Font, Text, Clock (renamed to StopWatch) and Power (renamed 
to Battery) were also ported. The Audio package also. 
Spritesheet should be redundant now, because Sprite has now 
a clipRect, to support the Spritesheet behaviour.


What is left: add missing comments / complete comments and 
renew the documentation. After that I will update the 
website.


We are moving forward! :)


Comments are finished so far - the documentation can be 
generated.
I've also begun to update the website and to update the 
tutorials, but I need at least a whole day to get ready. So 
I'll be ready in mid-March at the latest - because the next 
week I have to learn for my exams completely again.

But you can already begin with your tests. ;)


Thank you for updating Dgame so quickly. I'll give it a test 
later this week and report any issues on github.


Cheers,
stew


Forget to mention: until aldacron fixed DerelictSDL2 
(https://github.com/DerelictOrg/DerelictSDL2/issues/39) you 
have to manually annotate the makros and functions with @nogc. 
Maybe you should wait, until aldacron fixes this.


The most things are fixed now. But should I organize Dgame like 
the official DUB style: 'source/Dgame/...'?


I have no idea.

Looks good. Except for the text. It gets longer over time. I 
added an issue.


Re: Dgame revived

2015-02-28 Thread Gan via Digitalmars-d-announce

On Saturday, 28 February 2015 at 11:02:31 UTC, Namespace wrote:
Next step is Font, Text and Spritesheet. Then I'll inspect 
Clock, Power and MessageBox and in the end I'll inspect Audio. 
I think the most breaking changes will happen here, because 
I'll use this time SDL_Audio instead of OpenAL.


Font, Text, Clock (renamed to StopWatch) and Power (renamed to 
Battery) were also ported. The Audio package also. Spritesheet 
should be redundant now, because Sprite has now a clipRect, to 
support the Spritesheet behaviour.


What is left: add missing comments / complete comments and 
renew the documentation. After that I will update the website.


We are moving forward! :)


This is exciting. I'll test my space background in DGame to 
compare performance to SFML. If it's favorable, I'm immediately 
switching.


Re: Dgame revived

2015-02-26 Thread Gan via Digitalmars-d-announce

On Thursday, 26 February 2015 at 06:33:26 UTC, Gan wrote:

On Thursday, 26 February 2015 at 06:32:07 UTC, Gan wrote:

On Thursday, 26 February 2015 at 03:17:32 UTC, stewarth wrote:
On Thursday, 26 February 2015 at 03:01:42 UTC, Rikki 
Cattermole wrote:

On 26/02/2015 3:57 p.m., Gan wrote:
On Thursday, 26 February 2015 at 02:32:51 UTC, stewarth 
wrote:



I'd also try hacking in Window.d directly to see if even 
basic gl
commands work, e.g. immediately after window and context 
creation, try
rendering a triangle then tweak the context initialisation 
to see if

it affects anything.

It may help you track down exactly which part of the GL 
setup is

causing problems.

Cheers,
Stew


I know almost nothing about OpenGL but using your 
method(sorta):

void reportGLErrors() {
 GLenum errCode;
 const GLubyte *errString;
 if ((errCode = glGetError()) != GL_NO_ERROR)
 {
 writeln(OPEN GL ERROR: , errCode);
 }
}

I get error code 1282 repeatedly.

From a google search someone says:
First, glGetError() will return 1282 - invalid operation 
if the GL
context is not current (or not yet created). So, create 
your context
first, then call glGetError. And, verify that any parent 
class or member
class does not call GL functions in their constructors or 
prior to

context being created.

Can someone with more OpenGL knowledge clarify what this 
means?


1. Program starts
2. Window gets created
3. Context gets created
4. Context is activated
5. Profit???

Basically before the context is created and activated you 
cannot call any OpenGL functions. If you do, they will error 
out.


The bit about constructors ext. don't worry about it. Its 
just about e.g. where the calls to OpenGL can exist.


Yes, my bad sorry, but whatever works. The point is dive in 
and start printfing about in Window.d, checking error codes 
to try and figure out where things become stuffed up.



Cheers,
Stew


I did what you suggested. I added a bunch of writeln and 
reportGLErrors. These are the results:

glMatrixMode(GL_PROJECTION);
OPEN GL ERROR: 1282



glLoadIdentity();
OPEN GL ERROR: 1282



glShadeModel(GL_FLAT);
OPEN GL ERROR: 1282


glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
OPEN GL ERROR: 1280


glHint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
OPEN GL ERROR: 1280


glOrtho(0, vMode.width, vMode.height, 0, 1, -1);
OPEN GL ERROR: 1282


Each error happens after each line is called. I'm not sure why 
this happens or what it means.


According to docs: 1280 is GL_INVALID_ENUM


Figured it out. DGame wants OpenGL 3.0+ context. However it uses 
some functions in OpenGL 2.1 that have been depreciated. The mac 
OpenGL doesn't allow depreciated functions.


DGame's OpenGL code is too outdated to run on a 3.0+ GL context 
on mac.


Required fix: Either lower the context to 2.1 or upgrade the code 
to not use depreciated functions.


Re: Dgame revived

2015-02-26 Thread Gan via Digitalmars-d-announce

On Thursday, 26 February 2015 at 08:19:30 UTC, Namespace wrote:
Figured it out. DGame wants OpenGL 3.0+ context. However it 
uses some functions in OpenGL 2.1 that have been depreciated. 
The mac OpenGL doesn't allow depreciated functions.


DGame's OpenGL code is too outdated to run on a 3.0+ GL 
context on mac.


Required fix: Either lower the context to 2.1 or upgrade the 
code to not use depreciated functions.


Ah, indeed. I use some outdated constants and opengl functions. 
But I believe I'm using also functions which need OpenGL 3.0. 
Could you try to reduce the OpenGL Version to 2.1 and test it 
again?


Wouldaya look at that, it works. http://cl.ly/image/0Z000U0m1i3U

I wonder what features are broken.


Re: Dgame revived

2015-02-25 Thread Gan via Digitalmars-d-announce

On Tuesday, 24 February 2015 at 22:03:29 UTC, stewarth wrote:

On Tuesday, 24 February 2015 at 21:10:53 UTC, Gan wrote:

On Tuesday, 24 February 2015 at 21:07:04 UTC, stewarth wrote:

On Tuesday, 24 February 2015 at 19:32:08 UTC, Gan wrote:
On Tuesday, 24 February 2015 at 16:28:59 UTC, Namespace 
wrote:
I had to force dub to upgrade in order for it to pull the 
latest code from the master branch.


But on the plus side it runs.

On the downside it still only displays a blank white 
screen for Mac users.


As growlercab pointed out 
(https://github.com/Dgame/Dgame/pull/29), I think also that 
you should set the Version to 3.2 rather than 3.0. Could 
you give it a try and say if that works for you?


No dice. Running the shapes tutorial again, just a blank 
screen. Console output looks good though:

init openAL
Derelict loaded GL version: GL33 (GL33), available GL 
version: 3.3 INTEL-10.0.22

Quit Event
Finalize Sound (0)
 Sound Finalized
Text: Finalize Font
Font finalized
Close open Windows.
Open Windows closed.
Finalize Texture (0)
 Texture Finalized
quit sdl


Did you try commenting out the line that sets the forward 
compatibility flag as well?

(sorry it isn't clear from the posts)

if (style  Style.OpenGL) {
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 
SDL_GL_CONTEXT_PROFILE_CORE);

/*
* SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS,
*   SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
*/
}

This fixed a similar issue for me on Linux.

Cheers,
stew


Yeah I did that, doesn't show anything but a blank white 
screen.


OK, thanks for letting me know.


Is there anything more I can test to try to get it working on Mac?

Also anyone else have a Mac to test on? I wanna make sure it's 
not just me getting the blank white screen.


Re: Dgame revived

2015-02-25 Thread Gan via Digitalmars-d-announce

On Thursday, 26 February 2015 at 02:32:51 UTC, stewarth wrote:



I'd also try hacking in Window.d directly to see if even basic 
gl commands work, e.g. immediately after window and context 
creation, try rendering a triangle then tweak the context 
initialisation to see if it affects anything.


It may help you track down exactly which part of the GL setup 
is causing problems.


Cheers,
Stew


I know almost nothing about OpenGL but using your method(sorta):
void reportGLErrors() {
GLenum errCode;
const GLubyte *errString;
if ((errCode = glGetError()) != GL_NO_ERROR)
{
writeln(OPEN GL ERROR: , errCode);
}
}

I get error code 1282 repeatedly.

From a google search someone says:
First, glGetError() will return 1282 - invalid operation if the 
GL context is not current (or not yet created). So, create your 
context first, then call glGetError. And, verify that any parent 
class or member class does not call GL functions in their 
constructors or prior to context being created.


Can someone with more OpenGL knowledge clarify what this means?


Re: Dgame revived

2015-02-25 Thread Gan via Digitalmars-d-announce

On Thursday, 26 February 2015 at 03:17:32 UTC, stewarth wrote:
On Thursday, 26 February 2015 at 03:01:42 UTC, Rikki Cattermole 
wrote:

On 26/02/2015 3:57 p.m., Gan wrote:

On Thursday, 26 February 2015 at 02:32:51 UTC, stewarth wrote:



I'd also try hacking in Window.d directly to see if even 
basic gl
commands work, e.g. immediately after window and context 
creation, try
rendering a triangle then tweak the context initialisation 
to see if

it affects anything.

It may help you track down exactly which part of the GL 
setup is

causing problems.

Cheers,
Stew


I know almost nothing about OpenGL but using your 
method(sorta):

void reportGLErrors() {
   GLenum errCode;
   const GLubyte *errString;
   if ((errCode = glGetError()) != GL_NO_ERROR)
   {
   writeln(OPEN GL ERROR: , errCode);
   }
}

I get error code 1282 repeatedly.

From a google search someone says:
First, glGetError() will return 1282 - invalid operation if 
the GL
context is not current (or not yet created). So, create your 
context
first, then call glGetError. And, verify that any parent 
class or member
class does not call GL functions in their constructors or 
prior to

context being created.

Can someone with more OpenGL knowledge clarify what this 
means?


1. Program starts
2. Window gets created
3. Context gets created
4. Context is activated
5. Profit???

Basically before the context is created and activated you 
cannot call any OpenGL functions. If you do, they will error 
out.


The bit about constructors ext. don't worry about it. Its just 
about e.g. where the calls to OpenGL can exist.


Yes, my bad sorry, but whatever works. The point is dive in and 
start printfing about in Window.d, checking error codes to try 
and figure out where things become stuffed up.



Cheers,
Stew


I did what you suggested. I added a bunch of writeln and 
reportGLErrors. These are the results:

glMatrixMode(GL_PROJECTION);
OPEN GL ERROR: 1282



glLoadIdentity();
OPEN GL ERROR: 1282



glShadeModel(GL_FLAT);
OPEN GL ERROR: 1282


glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
OPEN GL ERROR: 1280


glHint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
OPEN GL ERROR: 1280


glOrtho(0, vMode.width, vMode.height, 0, 1, -1);
OPEN GL ERROR: 1282


Each error happens after each line is called. I'm not sure why 
this happens or what it means.


Re: Dgame revived

2015-02-25 Thread Gan via Digitalmars-d-announce

On Thursday, 26 February 2015 at 06:32:07 UTC, Gan wrote:

On Thursday, 26 February 2015 at 03:17:32 UTC, stewarth wrote:
On Thursday, 26 February 2015 at 03:01:42 UTC, Rikki 
Cattermole wrote:

On 26/02/2015 3:57 p.m., Gan wrote:
On Thursday, 26 February 2015 at 02:32:51 UTC, stewarth 
wrote:



I'd also try hacking in Window.d directly to see if even 
basic gl
commands work, e.g. immediately after window and context 
creation, try
rendering a triangle then tweak the context initialisation 
to see if

it affects anything.

It may help you track down exactly which part of the GL 
setup is

causing problems.

Cheers,
Stew


I know almost nothing about OpenGL but using your 
method(sorta):

void reportGLErrors() {
  GLenum errCode;
  const GLubyte *errString;
  if ((errCode = glGetError()) != GL_NO_ERROR)
  {
  writeln(OPEN GL ERROR: , errCode);
  }
}

I get error code 1282 repeatedly.

From a google search someone says:
First, glGetError() will return 1282 - invalid operation if 
the GL
context is not current (or not yet created). So, create your 
context
first, then call glGetError. And, verify that any parent 
class or member
class does not call GL functions in their constructors or 
prior to

context being created.

Can someone with more OpenGL knowledge clarify what this 
means?


1. Program starts
2. Window gets created
3. Context gets created
4. Context is activated
5. Profit???

Basically before the context is created and activated you 
cannot call any OpenGL functions. If you do, they will error 
out.


The bit about constructors ext. don't worry about it. Its 
just about e.g. where the calls to OpenGL can exist.


Yes, my bad sorry, but whatever works. The point is dive in 
and start printfing about in Window.d, checking error codes to 
try and figure out where things become stuffed up.



Cheers,
Stew


I did what you suggested. I added a bunch of writeln and 
reportGLErrors. These are the results:

glMatrixMode(GL_PROJECTION);
OPEN GL ERROR: 1282



glLoadIdentity();
OPEN GL ERROR: 1282



glShadeModel(GL_FLAT);
OPEN GL ERROR: 1282


glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
OPEN GL ERROR: 1280


glHint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
OPEN GL ERROR: 1280


glOrtho(0, vMode.width, vMode.height, 0, 1, -1);
OPEN GL ERROR: 1282


Each error happens after each line is called. I'm not sure why 
this happens or what it means.


According to docs: 1280 is GL_INVALID_ENUM


Re: Dgame revived

2015-02-24 Thread Gan via Digitalmars-d-announce

On Tuesday, 24 February 2015 at 09:24:17 UTC, Namespace wrote:

On Tuesday, 24 February 2015 at 09:07:19 UTC, Namespace wrote:
On Tuesday, 24 February 2015 at 00:53:49 UTC, Mike Parker 
wrote:

On 2/24/2015 8:18 AM, Gan wrote:



Doesn't work. Still gives the same OpenGL too low error. I 
think you

need to place the lines
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 
3);

  SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
SDL_GL_CONTEXT_PROFILE_CORE);
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS,
SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);

before window creation.


Yes. All SDL_GL_SetAttributes must be called before window 
creation for them to have any effect. I thought that was 
already understood.


You sound a little rude. :D
I thought that must precede the GLContext. That made the most 
sense to me. I will change it. ;)


It semms there is a problem with ma DUB package:

Branch ~beta: Got JSON of type undefined, expected object.
Branch ~tune: Got JSON of type undefined, expected object.


I deleted these branches, drafted a new tag and tried to 
trigger a manual update, but nothing happens.


I had to force dub to upgrade in order for it to pull the latest 
code from the master branch.


But on the plus side it runs.

On the downside it still only displays a blank white screen for 
Mac users.


Re: Dgame revived

2015-02-24 Thread Gan via Digitalmars-d-announce

On Tuesday, 24 February 2015 at 16:28:59 UTC, Namespace wrote:
I had to force dub to upgrade in order for it to pull the 
latest code from the master branch.


But on the plus side it runs.

On the downside it still only displays a blank white screen 
for Mac users.


As growlercab pointed out 
(https://github.com/Dgame/Dgame/pull/29), I think also that you 
should set the Version to 3.2 rather than 3.0. Could you give 
it a try and say if that works for you?


No dice. Running the shapes tutorial again, just a blank screen. 
Console output looks good though:

init openAL
Derelict loaded GL version: GL33 (GL33), available GL version: 
3.3 INTEL-10.0.22

Quit Event
Finalize Sound (0)
  Sound Finalized
Text: Finalize Font
Font finalized
Close open Windows.
Open Windows closed.
Finalize Texture (0)
  Texture Finalized
quit sdl


Re: Dgame revived

2015-02-23 Thread Gan via Digitalmars-d-announce

On Monday, 23 February 2015 at 23:24:02 UTC, Namespace wrote:
Doesn't work. Still gives the same OpenGL too low error. I 
think you need to place the lines

SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
			SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 
SDL_GL_CONTEXT_PROFILE_CORE);
			SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 
SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);


before window creation.


Could you try it and say if it helps?


Placing the lines before window creation actually allows it to 
run on a Mac. Though there's still the error of blank white 
screen:

http://cl.ly/image/382C28363U41


Re: Dgame revived

2015-02-23 Thread Gan via Digitalmars-d-announce

On Tuesday, 24 February 2015 at 00:53:49 UTC, Mike Parker wrote:

On 2/24/2015 8:18 AM, Gan wrote:



Doesn't work. Still gives the same OpenGL too low error. I 
think you

need to place the lines
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 
3);

SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS,
SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);

before window creation.


Yes. All SDL_GL_SetAttributes must be called before window 
creation for them to have any effect. I thought that was 
already understood.


Currently on the repo, these lines are after the window creation. 
That needs changed.


Re: Dgame revived

2015-02-23 Thread Gan via Digitalmars-d-announce

On Monday, 23 February 2015 at 16:03:47 UTC, Namespace wrote:
load will pull in 1.1 functions only, nothing more. reload 
will load in whatever is supported by the current context. So 
if your context only supports 2.1, only functions up to 2.1 
will be loaded. One of the earlier posts showed what needs to 
be done on Mac to get a 3.x context. In SDL, that means the 
following:


```
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 
SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 
SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);


Yes, that was my suggestion. But now where you confirm it, 
I'll add it.


Added


Doesn't work. Still gives the same OpenGL too low error. I think 
you need to place the lines

SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
			SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 
SDL_GL_CONTEXT_PROFILE_CORE);
			SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 
SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);


before window creation.


Re: Dgame revived

2015-02-22 Thread Gan via Digitalmars-d-announce

On Sunday, 22 February 2015 at 22:29:53 UTC, Namespace wrote:

On Sunday, 22 February 2015 at 22:24:59 UTC, Gan wrote:

On Sunday, 22 February 2015 at 21:58:13 UTC, John Colvin wrote:

On Sunday, 22 February 2015 at 21:34:03 UTC, Foo wrote:
I think you need to install the ogg libraries. Derelict, 
which Dgame uses, only provides bindings to the C/C++ 
libraries. You still need to get the those libraries for 
things to work.


Sorry I cannot help more. On linux it's just a matter of 
using the pkg manager (apt, pacman, yum etc.) On MAC I have 
not idea.



I can confirm Dgame 0.4.1 is now working on Linux (Debian 
x86_64) after I did a dub upgrade.


Thanks,
amber


That is nice to hear. It works for me on Windows 8.1. 
Someone with a Mac here?


I'll try tomorrow if no-one else has.


I have a Mac. OS Yosemite 10.10. Macbook Pro 2011. Intel HD 
3000, 16gb of ram, i5 CPU.


When I run one of your Dgame tutorials I get this error:
Derelict loaded GL version: GL21 (GL21), available GL version: 
2.1 INTEL-10.0.22
object.Exception@../.dub/packages/dgame-0.4.1/Window/Window.d(144): 
Your OpenGL version (21) is too low. Need at least GL 3.0.


That is strange. Every PC should be be capable to launch at 
least OpenGL 3.0. Did you try to update your graphic driver?


You can't really upgrade your graphics driver on a mac.


Re: Dgame revived

2015-02-22 Thread Gan via Digitalmars-d-announce

On Sunday, 22 February 2015 at 22:32:44 UTC, Gan wrote:

On Sunday, 22 February 2015 at 22:29:53 UTC, Namespace wrote:

On Sunday, 22 February 2015 at 22:24:59 UTC, Gan wrote:
On Sunday, 22 February 2015 at 21:58:13 UTC, John Colvin 
wrote:

On Sunday, 22 February 2015 at 21:34:03 UTC, Foo wrote:
I think you need to install the ogg libraries. Derelict, 
which Dgame uses, only provides bindings to the C/C++ 
libraries. You still need to get the those libraries for 
things to work.


Sorry I cannot help more. On linux it's just a matter of 
using the pkg manager (apt, pacman, yum etc.) On MAC I 
have not idea.



I can confirm Dgame 0.4.1 is now working on Linux (Debian 
x86_64) after I did a dub upgrade.


Thanks,
amber


That is nice to hear. It works for me on Windows 8.1. 
Someone with a Mac here?


I'll try tomorrow if no-one else has.


I have a Mac. OS Yosemite 10.10. Macbook Pro 2011. Intel HD 
3000, 16gb of ram, i5 CPU.


When I run one of your Dgame tutorials I get this error:
Derelict loaded GL version: GL21 (GL21), available GL 
version: 2.1 INTEL-10.0.22
object.Exception@../.dub/packages/dgame-0.4.1/Window/Window.d(144): 
Your OpenGL version (21) is too low. Need at least GL 3.0.


That is strange. Every PC should be be capable to launch at 
least OpenGL 3.0. Did you try to update your graphic driver?


You can't really upgrade your graphics driver on a mac.


Stackoverflow says it is possible. One guy's fix was something 
like:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

Cause apparently it supports it.


Re: Dgame revived

2015-02-22 Thread Gan via Digitalmars-d-announce

On Sunday, 22 February 2015 at 09:30:10 UTC, Namespace wrote:

On Sunday, 22 February 2015 at 09:05:16 UTC, Mike Parker wrote:

On 2/22/2015 2:43 PM, Gan wrote:





dub.json:
{
   name: game,
   description: game,
   dependencies:
   {
   dgame: ~master
   }
}


First, you need to change your dependency to something like 
this:


dependencies:
 {
 dgame: ~0.4.0
 }

Or you can use ==0.4.0, or =0.4.0. Just don't use 
branch-based dependencies anymore (like ~master) as those are 
deprecated.


Second, there's a bug in Dgame's dub.json, which is causing 
compilation to error out. I'll post a PR for it.


I have the PR merged, the problem should be fixed now. Thanks 
to you and growlercab.


Now it builds though crashes on run with this error:

init openAL
derelict.util.exception.SharedLibLoadException@../../.dub/packages/derelict-util-1.9.1/source/derelict/util/exception.d(35): 
Failed to load one or more shared libraries:

libogg.dylib - dlopen(libogg.dylib, 2): image not found
libogg.0.dylib - dlopen(libogg.0.dylib, 2): image not found
Error executing command run: Program exited with code 1


Press any key to continue...


Re: Dgame revived

2015-02-22 Thread Gan via Digitalmars-d-announce

On Sunday, 22 February 2015 at 22:49:16 UTC, Namespace wrote:
Stackoverflow says it is possible. One guy's fix was something 
like:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

Cause apparently it supports it.


Ok, you could try to use something identical in the Window 
constructor: 
https://github.com/Dgame/Dgame/blob/master/Window/Window.d#L124



SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);



Adding these lines before window creation make it load up to 
OpenGL 3.3:


SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
	SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 
SDL_GL_CONTEXT_PROFILE_CORE);



It runs now except it only displays a white screen. I'm testing 
your shapes tutorial.


Re: Dgame revived

2015-02-22 Thread Gan via Digitalmars-d-announce
On Monday, 23 February 2015 at 00:36:49 UTC, Rikki Cattermole 
wrote:

On 23/02/2015 11:33 a.m., Gan wrote:

On Sunday, 22 February 2015 at 22:32:44 UTC, Gan wrote:

On Sunday, 22 February 2015 at 22:29:53 UTC, Namespace wrote:

On Sunday, 22 February 2015 at 22:24:59 UTC, Gan wrote:
On Sunday, 22 February 2015 at 21:58:13 UTC, John Colvin 
wrote:

On Sunday, 22 February 2015 at 21:34:03 UTC, Foo wrote:
I think you need to install the ogg libraries. Derelict, 
which
Dgame uses, only provides bindings to the C/C++ 
libraries. You

still need to get the those libraries for things to work.

Sorry I cannot help more. On linux it's just a matter of 
using
the pkg manager (apt, pacman, yum etc.) On MAC I have 
not idea.



I can confirm Dgame 0.4.1 is now working on Linux 
(Debian x86_64)

after I did a dub upgrade.

Thanks,
amber


That is nice to hear. It works for me on Windows 8.1. 
Someone with

a Mac here?


I'll try tomorrow if no-one else has.


I have a Mac. OS Yosemite 10.10. Macbook Pro 2011. Intel HD 
3000,

16gb of ram, i5 CPU.

When I run one of your Dgame tutorials I get this error:
Derelict loaded GL version: GL21 (GL21), available GL 
version: 2.1

INTEL-10.0.22
object.Exception@../.dub/packages/dgame-0.4.1/Window/Window.d(144):
Your OpenGL version (21) is too low. Need at least GL 3.0.


That is strange. Every PC should be be capable to launch at 
least

OpenGL 3.0. Did you try to update your graphic driver?


You can't really upgrade your graphics driver on a mac.


Stackoverflow says it is possible. One guy's fix was something 
like:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

Cause apparently it supports it.


On OSX you can load either legacy version of OpenGL so 
1.x/2.x or 3.x+. Not both. I found this out for 
Devisualization.Window. Most likely dgame by default is loading 
it in legacy mode.


Text tutorial doesn't work either on Mac. Just a blank white 
screen.


Re: Dgame revived

2015-02-21 Thread Gan via Digitalmars-d-announce

On Sunday, 22 February 2015 at 01:56:59 UTC, amber wrote:

On Saturday, 21 February 2015 at 14:43:57 UTC, Namespace wrote:
Today I registered Dgame on DUB. Since I do not currently have 
much time (I'm currently in my exams period) I hope I did 
everything right. Let me know if not and what could be 
improved.


Since I left D a while ago, Dgame was also not maintained, but 
thanks to your demand I will maintain Dgame again. The current 
goal is to register Dgame successful on DUB. The next goal 
would be to adapt the webpage and the installation chapter and 
to re-register the domain dgame.dev.de
After that (and after my hopefully successful exams) I will 
rebuild Dgame from scratch with the goal of a more consistent 
and better structure and with the idea in mind to use @nogc 
wherever possible.


Cool, thanks for Dgame.


I can't seem to build a program with just the main method with 
DGame on DUB.

Error:
Building: game (Default)
Performing main compilation...
/usr/local/bin/dub build game --build=debug
Building package spacecraft in /Users/Matt/DGame Test/
Package dsfml can be installed with version ~master.
Package dgame can be upgraded from ~master to 0.4.0.
Use dub upgrade to perform those changes.
WARNING: A deprecated branch based version specification is used 
for the dependency dgame. Please use numbered versions instead. 
Also note that you can still use the dub.selections.json file to 
override a certain dependency to use a branch instead.
Building derelict-util 1.9.1 configuration library, build type 
debug.

Running dmd...
Error: unrecognized switch '-version=0.4.0'
FAIL 
../.dub/packages/derelict-util-1.9.1/.dub/build/library-debug-posix.osx-x86_64-dmd_2066-E0DFCC872C8A9F5E0383C82BBC088A37/ 
DerelictUtil staticLibrary

Error executing command build: dmd failed with exit code 1.

Exit code 2
Build complete -- 1 error, 0 warnings

-- Done --

Build: 1 error, 0 warnings



dub.json:
{
name: game,
description: game,
dependencies:
{
dgame: ~master
}
}


Re: Are there any 2D games libraries available for D2?

2015-02-20 Thread Gan via Digitalmars-d

On Friday, 20 February 2015 at 15:15:36 UTC, Jeremy DeHaan wrote:

On Friday, 20 February 2015 at 07:12:34 UTC, Gan wrote:

On Friday, 20 February 2015 at 04:52:29 UTC, Jeremy DeHaan

Chiming in with my own library. https://github.com/Jebbs/DSFML

Things are a bit of a mess, but I'm gearing up for a release 
soon and things will be all nice and tidy and structured.


I really want to check out DGame but I suggest withholding 
from it until it becomes actively maintained again.


I'm using DSFML and it is one of the easiest. Though I had 
strange issues like high ram usage and text not rendering. 
Though the ease of use and performance is phenomenal.


Thanks for the heads up. I'll open an issue to inspect RAM 
usage, but can you let me know when you were having Text 
rendering issues so I can inspect that too?


This link can give you more information about it:
http://en.sfml-dev.org/forums/index.php?topic=17550.0

I started getting text rendering issues when I was playing with 
my space background render textures. It's kinda strange cause 
they seem unrelated.


Re: How to make Application bundle from Executable? (Mac)

2015-02-20 Thread Gan via Digitalmars-d-learn
On Friday, 20 February 2015 at 17:28:48 UTC, Nicholas Wilson 
wrote:

On Friday, 20 February 2015 at 06:19:29 UTC, Gan wrote:
On Friday, 20 February 2015 at 06:10:51 UTC, Nicholas Wilson 
wrote:

On Friday, 20 February 2015 at 03:26:47 UTC, Gan wrote:
Also I can't get my application to load images that I place 
in the Resources folder(or any folder in the bundle for that 
matter).
I suggest to have a look at the projects generated by SFML 
regarding locating the resources in C++/ObjC and translate 
them to C/ObjC/D.
As for code (i.e frameworks and .dylibs) i don't know as 
shared libraries are still a murky area for D. Probably just 
better to stick to static libs.
Is there an official way to turn a D executable into a Mac 
Application Bundle?

Dunno

Good luck!


Frameworks aren't an issue, I put them into the Frameworks 
folder in my hand made bundle and they load fine.
When running the executable, it loads the image when it's in 
the same folder but when running the executable through the 
bundle, it doesn't find the image anywhere.


are you loading using relative or absolute addresses ( 
../../Resources/img.png or $BUNDLE_ROOT/Resources/img.png ) ?
also check the cwd when launched from the executable vs, the 
bundle. Also does Console give any output?


I fixed it by using:
string path = thisExePath();
int index = to!int(path.lastIndexOf(/));
if (!GameFont.loadFromFile(path[0 .. index]~/vertiup2.ttf)) {
writeln(Font failed to load);
}

Now my hand made bundle works fine and loads resources from 
inside the bundle.


Re: How to make Application bundle from Executable? (Mac)

2015-02-19 Thread Gan via Digitalmars-d-learn
On Friday, 20 February 2015 at 06:10:51 UTC, Nicholas Wilson 
wrote:

On Friday, 20 February 2015 at 03:26:47 UTC, Gan wrote:
Also I can't get my application to load images that I place in 
the Resources folder(or any folder in the bundle for that 
matter).
I suggest to have a look at the projects generated by SFML 
regarding locating the resources in C++/ObjC and translate them 
to C/ObjC/D.
As for code (i.e frameworks and .dylibs) i don't know as shared 
libraries are still a murky area for D. Probably just better to 
stick to static libs.
Is there an official way to turn a D executable into a Mac 
Application Bundle?

Dunno

Good luck!


Frameworks aren't an issue, I put them into the Frameworks folder 
in my hand made bundle and they load fine.
When running the executable, it loads the image when it's in the 
same folder but when running the executable through the bundle, 
it doesn't find the image anywhere.


Re: Are there any 2D games libraries available for D2?

2015-02-19 Thread Gan via Digitalmars-d

On Friday, 20 February 2015 at 04:52:29 UTC, Jeremy DeHaan wrote:

On Friday, 20 February 2015 at 00:07:20 UTC, Kingsley wrote:

On Thursday, 19 February 2015 at 23:59:14 UTC, Kingsley wrote:

I use Dgame which has a really nice and simple interface

http://rswhite.de/dgame4/

From the web page:

Dgame is a 2D framework which is based on the SDL and 
OpenGL, and is designed for the D programming language. The 
design is based on Pygame and as well on the SFML from the 
C++ programming language.


Cheers,
Stew


I'm looking at DGame - I'm on osx - so I guess I have to 
build all the dependencies myself sigh - Once I get it 
installed and working - it looks like it may be enough for 
what I want.


I guess I'll have to make it work with dub myself to make it 
easier to get started with.


DGame has a dependency on Derelict 3 - but going to the link 
provided says that project is no longer maintained and doesn't 
work with the latest DMD compiler. It points to a new location 
where there are multiple different Derelict libraries - I'm 
hoping DGame will work with one of those still.



Chiming in with my own library. https://github.com/Jebbs/DSFML

Things are a bit of a mess, but I'm gearing up for a release 
soon and things will be all nice and tidy and structured.


I really want to check out DGame but I suggest withholding from 
it until it becomes actively maintained again.


I'm using DSFML and it is one of the easiest. Though I had 
strange issues like high ram usage and text not rendering. Though 
the ease of use and performance is phenomenal.


How to make Application bundle from Executable? (Mac)

2015-02-19 Thread Gan via Digitalmars-d-learn
I managed to copy an application bundle and change stuff inside 
it to run my executable, but it was very manual and kinda 
hackish. Also I can't get my application to load images that I 
place in the Resources folder(or any folder in the bundle for 
that matter).



Is there an official way to turn a D executable into a Mac 
Application Bundle?


Re: Better native D 2D graphics library?

2015-02-08 Thread Gan via Digitalmars-d-learn

On Sunday, 8 February 2015 at 09:52:50 UTC, Namespace wrote:

On Sunday, 8 February 2015 at 01:39:19 UTC, Gan wrote:

On Saturday, 7 February 2015 at 23:29:01 UTC, Namespace wrote:

On Saturday, 7 February 2015 at 22:09:03 UTC, Gan wrote:

Is there a better D graphics library in the works?

I'm using SFML(which is very easy and has lots of features) 
but it seems to use a lot of ram(if you leave it running for 
a while on a graphic intensive scene) and trying to make it 
include the dependencies with the compiled executable is 
complicated.


Is there a D 2D graphics library that's just as easy, cross 
platform, doesn't use X11, allows drawing to off-screen 
buffers and drawing those to screen? (plus supports nice 
drawing of shapes, circles, rectangles, lines)


I'm probably asking too much- I doubt such a thing exists.


I once wrote such a library: https://github.com/Dgame/Dgame
But since I left D I don't maintain it. Maybe that will 
change in the next few weeks. But otherwise you are free to 
use or improve it.


That's really cool. Very very similar to SFML.

Only thing that makes me concerned is:
static immutable string Disk = D;
static immutable string Mode = Release;

pragma(lib, Disk ~ 
:\\D\\dmd2\\src\\ext\\derelict\\lib\\dmd\\DerelictSDL2.lib);
pragma(lib, Disk ~ 
:\\D\\dmd2\\src\\ext\\derelict\\lib\\dmd\\DerelictUtil.lib);
pragma(lib, Disk ~ 
:\\D\\dmd2\\src\\ext\\derelict\\lib\\dmd\\DerelictGL3.lib);


pragma(lib, Disk ~ :\\D\\dmd2\\src\\ext\\Dgame\\lib\\ ~ Mode 
~ \\DgameInternal.lib);
pragma(lib, Disk ~ :\\D\\dmd2\\src\\ext\\Dgame\\lib\\ ~ Mode 
~ \\DgameAudio.lib);
pragma(lib, Disk ~ :\\D\\dmd2\\src\\ext\\Dgame\\lib\\ ~ Mode 
~ \\DgameGraphics.lib);
pragma(lib, Disk ~ :\\D\\dmd2\\src\\ext\\Dgame\\lib\\ ~ Mode 
~ \\DgameSystem.lib);
pragma(lib, Disk ~ :\\D\\dmd2\\src\\ext\\Dgame\\lib\\ ~ Mode 
~ \\DgameMath.lib);
pragma(lib, Disk ~ :\\D\\dmd2\\src\\ext\\Dgame\\lib\\ ~ Mode 
~ \\DgameWindow.lib);


I'm not entirely sure what that is or if it's cross-compatible 
friendly or sharing-with-friends friendly.

Though I really hope you re-maintain it.


It worked on Mac, Linux and Windows so far without any problems.
Forget to add the documentation page I made: 
http://rswhite.de/dgame4/


Very cool. I was debating switching to SDL but now I'm only 
debating between switching from SFML to DGame.


When I leave my SFML game running for 7 hours, it uses 700mb of 
ram. Also my friend can't play my games due to missing dylibs(the 
SFML setup process is complicated). Those are the main reasons 
I'm looking for an alternative.
I'll do a DGame test, if it beats SFML on those issues- I'm 
hooked.


Re: Better native D 2D graphics library?

2015-02-07 Thread Gan via Digitalmars-d-learn

On Saturday, 7 February 2015 at 23:29:01 UTC, Namespace wrote:

On Saturday, 7 February 2015 at 22:09:03 UTC, Gan wrote:

Is there a better D graphics library in the works?

I'm using SFML(which is very easy and has lots of features) 
but it seems to use a lot of ram(if you leave it running for a 
while on a graphic intensive scene) and trying to make it 
include the dependencies with the compiled executable is 
complicated.


Is there a D 2D graphics library that's just as easy, cross 
platform, doesn't use X11, allows drawing to off-screen 
buffers and drawing those to screen? (plus supports nice 
drawing of shapes, circles, rectangles, lines)


I'm probably asking too much- I doubt such a thing exists.


I once wrote such a library: https://github.com/Dgame/Dgame
But since I left D I don't maintain it. Maybe that will change 
in the next few weeks. But otherwise you are free to use or 
improve it.


That's really cool. Very very similar to SFML.

Only thing that makes me concerned is:
static immutable string Disk = D;
static immutable string Mode = Release;

pragma(lib, Disk ~ 
:\\D\\dmd2\\src\\ext\\derelict\\lib\\dmd\\DerelictSDL2.lib);
pragma(lib, Disk ~ 
:\\D\\dmd2\\src\\ext\\derelict\\lib\\dmd\\DerelictUtil.lib);
pragma(lib, Disk ~ 
:\\D\\dmd2\\src\\ext\\derelict\\lib\\dmd\\DerelictGL3.lib);


pragma(lib, Disk ~ :\\D\\dmd2\\src\\ext\\Dgame\\lib\\ ~ Mode ~ 
\\DgameInternal.lib);
pragma(lib, Disk ~ :\\D\\dmd2\\src\\ext\\Dgame\\lib\\ ~ Mode ~ 
\\DgameAudio.lib);
pragma(lib, Disk ~ :\\D\\dmd2\\src\\ext\\Dgame\\lib\\ ~ Mode ~ 
\\DgameGraphics.lib);
pragma(lib, Disk ~ :\\D\\dmd2\\src\\ext\\Dgame\\lib\\ ~ Mode ~ 
\\DgameSystem.lib);
pragma(lib, Disk ~ :\\D\\dmd2\\src\\ext\\Dgame\\lib\\ ~ Mode ~ 
\\DgameMath.lib);
pragma(lib, Disk ~ :\\D\\dmd2\\src\\ext\\Dgame\\lib\\ ~ Mode ~ 
\\DgameWindow.lib);


I'm not entirely sure what that is or if it's cross-compatible 
friendly or sharing-with-friends friendly.

Though I really hope you re-maintain it.


Better native D 2D graphics library?

2015-02-07 Thread Gan via Digitalmars-d-learn

Is there a better D graphics library in the works?

I'm using SFML(which is very easy and has lots of features) but 
it seems to use a lot of ram(if you leave it running for a while 
on a graphic intensive scene) and trying to make it include the 
dependencies with the compiled executable is complicated.


Is there a D 2D graphics library that's just as easy, cross 
platform, doesn't use X11, allows drawing to off-screen buffers 
and drawing those to screen? (plus supports nice drawing of 
shapes, circles, rectangles, lines)


I'm probably asking too much- I doubt such a thing exists.


ubyte array to uint?

2015-02-05 Thread Gan via Digitalmars-d-learn

Is there a simple way of conversion? Something like:
uint length = to!uint(buffer[0 .. 4]);

Right now I have:
uint length = *cast(uint*)buffer[0 .. 4].ptr;

Which I'm not entirely sure is the correct way to do that.


Re: Trying to make a TCP server, client connects and disconnects immediately

2015-02-05 Thread Gan via Digitalmars-d-learn

On Friday, 6 February 2015 at 01:36:17 UTC, Mike Parker wrote:

On 2/6/2015 9:50 AM, Gan wrote:
On Friday, 6 February 2015 at 00:35:12 UTC, Adam D. Ruppe 
wrote:

On Friday, 6 February 2015 at 00:31:37 UTC, Gan wrote:
Or am I misunderstanding the receive function? Does it send 
whole

messages or just message chunks?


It sends as much as it can when you call it. So if there's 
only 12
bytes available when you send it with a 4096 buffer, it will 
fill the
first twelve bytes (and return 12) so you can slice it 
buffer[0 ..

returnedValue] to get the data.

If there's more available than the buffer will hold, that 
data will be
held on to until next time you call receive. If 5000 bytes 
come off
the network, it will return 4096 the first time, then next 
time

through the loop, it will return the remaining 904.


How can you distinguish between different packets that get 
sent? Won't

they all be merged to a giant blob of data?


You need to give each of your packets a header. At a minimum 
you'll want a message ID and message length. When a message 
comes in, you use the length field to determine where one 
packet ends and the next one begins.


Oh sweet. Though if one message length is off by even 1 byte, 
then all future messages get corrupted?


Trying to make a TCP server, client connects and disconnects immediately

2015-02-05 Thread Gan via Digitalmars-d-learn
I managed to get the client to connect but immediately on the 
server side, this happens:


long length = player.playerSocket.receive(buf);
if (length == 0) { //No longer connected
player.playerSocket.shutdown(SocketShutdown.BOTH);
player.playerSocket.close();
}

The player's socket receives a 0 length which means the 
connection is dead. Why does that happen?


Here's my full server-side networking code:

module server.networkingandio.networkingcontroller;
import server.server;
import server.player.player;

import std.socket;
import std.stdio;
import core.thread;
import std.range;
import std.traits;
import std.typecons;
import std.typetuple;
import std.algorithm;
import std.concurrency;

class NetworkingController
{
Server server;

Player[] players;

TcpSocket socket;

this(Server s)
{
server = s;
players = new Player[](0);
writeln(Server active on port );

socket = new TcpSocket();
socket.bind(new InternetAddress());
socket.listen(100);
socket.blocking = true;

spawn(handleNewConnectionsThread, cast(shared)socket);
}
void logic() {
//Check for new sockets
bool receivedNewSocket = true;
while (receivedNewSocket) {
receivedNewSocket = receiveTimeout(0.msecs,
(shared NewConnectionMsg message) {
NewConnectionMsg msg = 
cast(NewConnectionMsg)message;
newConnection(msg.socket);
},
(shared ReceiveDataMsg message) {
	//Convert data to MessageReader, send to server message 
handler

}
);
}

//Check for dead sockets
for (int i = 0; i  players.length; i++) {
Player p = players[i];
if (p.playerSocket.isAlive == false) {
players = players.remove(i);
i--;
server.removeConnection(p);
}
}
//Check for socket messages
}
void newConnection(Socket conn) {
Player p = new Player(conn, this);
players ~= p;
server.newConnection(p);
//Set up listener for player socket
spawn(handleReceiveDataThread, cast(shared)p);
}
}
class NewConnectionMsg {
Socket socket;
this(Socket socket) {
this.socket = socket;
}
}
class ReceiveDataMsg {
Player player;
ubyte[] data;
this(Player player, ubyte[] data) {
this.player = player;
this.data = data;
}
}

void handleNewConnectionsThread(shared TcpSocket s) {
Socket socket = cast(Socket)s;
while(socket.isAlive) {
Socket playerSocket = socket.accept();
if (playerSocket !is null  playerSocket.isAlive == true) {
playerSocket.blocking = true;
ownerTid.send(cast(shared) new 
NewConnectionMsg(playerSocket));
}
}
scope(exit)socket.close();
}

void handleReceiveDataThread(shared Player p) {
Player player = cast(Player)p;
while(player.playerSocket.isAlive) {
ubyte[] buf = new ubyte[](0);
long length = player.playerSocket.receive(buf);
if (length == 0) { //No longer connected
player.playerSocket.shutdown(SocketShutdown.BOTH);
player.playerSocket.close();
} else {
ownerTid.send(cast(shared) new ReceiveDataMsg(player, 
buf));
}
}
scope(exit)player.playerSocket.close();
}


Re: Trying to make a TCP server, client connects and disconnects immediately

2015-02-05 Thread Gan via Digitalmars-d-learn

On Friday, 6 February 2015 at 00:24:54 UTC, Adam D. Ruppe wrote:

On Friday, 6 February 2015 at 00:15:15 UTC, Gan wrote:

ubyte[] buf = new ubyte[](0);


This is your problem: receive fills a preexisting buffer, and 
you allocated zero bytes for it to fill, so it can't give you 
anything.


Give it a bigger buffer, I like to use 4096, and it will work 
better.


Will there ever be a message bigger than 4096 bytes?


Re: Trying to make a TCP server, client connects and disconnects immediately

2015-02-05 Thread Gan via Digitalmars-d-learn

On Friday, 6 February 2015 at 00:28:00 UTC, Gan wrote:

On Friday, 6 February 2015 at 00:24:54 UTC, Adam D. Ruppe wrote:

On Friday, 6 February 2015 at 00:15:15 UTC, Gan wrote:

ubyte[] buf = new ubyte[](0);


This is your problem: receive fills a preexisting buffer, and 
you allocated zero bytes for it to fill, so it can't give you 
anything.


Give it a bigger buffer, I like to use 4096, and it will work 
better.


Will there ever be a message bigger than 4096 bytes?


Or am I misunderstanding the receive function? Does it send whole 
messages or just message chunks?


Re: Trying to make a TCP server, client connects and disconnects immediately

2015-02-05 Thread Gan via Digitalmars-d-learn

On Friday, 6 February 2015 at 00:35:12 UTC, Adam D. Ruppe wrote:

On Friday, 6 February 2015 at 00:31:37 UTC, Gan wrote:
Or am I misunderstanding the receive function? Does it send 
whole messages or just message chunks?


It sends as much as it can when you call it. So if there's only 
12 bytes available when you send it with a 4096 buffer, it will 
fill the first twelve bytes (and return 12) so you can slice it 
buffer[0 .. returnedValue] to get the data.


If there's more available than the buffer will hold, that data 
will be held on to until next time you call receive. If 5000 
bytes come off the network, it will return 4096 the first time, 
then next time through the loop, it will return the remaining 
904.


How can you distinguish between different packets that get sent? 
Won't they all be merged to a giant blob of data?


Concurrent Thread Safe List?

2015-02-04 Thread Gan via Digitalmars-d-learn
I'm looking for a non-blocking way of a thread pushing objects 
into a list and another thread able to pull objects from the same 
list. Thread 1 pushes objects onto the list, Thread 2 pulls the 
oldest objects off the list.


Does D language have something like that?


Re: Concurrent Thread Safe List?

2015-02-04 Thread Gan via Digitalmars-d-learn

On Wednesday, 4 February 2015 at 22:14:31 UTC, Ali Çehreli wrote:

On 02/04/2015 12:10 PM, Gan wrote:
I'm looking for a non-blocking way of a thread pushing objects 
into a
list and another thread able to pull objects from the same 
list. Thread
1 pushes objects onto the list, Thread 2 pulls the oldest 
objects off

the list.

Does D language have something like that?


The std.concurrency module does exactly that:

  http://dlang.org/phobos/std_concurrency.html

And something I wrote:

  http://ddili.org/ders/d.en/concurrency.html

Ali


Cool article. First half of the article I was thinking, this 
isn't what I want. Then in the second half where you got into the 
mailbox analogy, that's exactly what I want.


Thanks.


Re: Concurrent Thread Safe List?

2015-02-04 Thread Gan via Digitalmars-d-learn

On Thursday, 5 February 2015 at 02:13:23 UTC, Gan wrote:
On Wednesday, 4 February 2015 at 22:14:31 UTC, Ali Çehreli 
wrote:

On 02/04/2015 12:10 PM, Gan wrote:
I'm looking for a non-blocking way of a thread pushing 
objects into a
list and another thread able to pull objects from the same 
list. Thread
1 pushes objects onto the list, Thread 2 pulls the oldest 
objects off

the list.

Does D language have something like that?


The std.concurrency module does exactly that:

 http://dlang.org/phobos/std_concurrency.html

And something I wrote:

 http://ddili.org/ders/d.en/concurrency.html

Ali


Cool article. First half of the article I was thinking, this 
isn't what I want. Then in the second half where you got into 
the mailbox analogy, that's exactly what I want.


Thanks.


If I want a non blocking receive call, would I do bool 
receiveTimeout(T...)(Duration duration, T ops); with a duration 
of 0?


Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Gan via Digitalmars-d-learn

On Tuesday, 27 January 2015 at 15:45:47 UTC, bearophile wrote:

Gan:


How can I make it use less CPU/RAM?


Most tiny classes probably should be structs. More generally, 
use a struct every time you don't need a class.


You can start with those two:

struct SBRange {
double left = 0.0, right = 0.0, top = 0.0, bottom = 0.0;
}

struct Point(T) {
T x, y;
}

This probably isn't enough to solve your problems, but it's a 
start.


Bye,
bearophile


Is there some special stuff I gotta do extra with structs? Do 
they need manually allocated and released?


On a second question, do I ever need to manually release objects 
I create with new?


Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Gan via Digitalmars-d-learn

On Tuesday, 27 January 2015 at 19:26:12 UTC, bearophile wrote:

Gan:

Is there some special stuff I gotta do extra with structs? Do 
they need manually allocated and released?


Most of your usages of tiny structs should be by value. So just 
keep in mind they are values. Even when you iterate with a 
foreach on a mutable array of them :-)



On a second question, do I ever need to manually release 
objects I create with new?


Usually not. How much advanced do you want to be? :-)

Bye,
bearophile


Thanks. I'll give structs a try.

When I start the program, it runs fine at 35mb of ram. It only 
keeps 15 objects stored in the arrays at a time so why do you 
think my ram usage increases to 700+ after many hours?


Re: DlangUI

2015-01-27 Thread Gan via Digitalmars-d-announce

On Saturday, 14 June 2014 at 19:40:58 UTC, Jim Hewes wrote:
Very nice, thanks. I'm looking forward to trying it out when I 
can find the time. I'm not a big fan of bindings/wrappers.


Jim


This is looks fantastic. I tried the demo but I get an error:
SDL_GL_CreateContext failed: Failed creating OpenGL context

Running Mac OS 10.10.2 on 2011 Macbook Pro


Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Gan via Digitalmars-d-learn

On Tuesday, 27 January 2015 at 19:59:08 UTC, Gan wrote:

On Tuesday, 27 January 2015 at 19:26:12 UTC, bearophile wrote:

Gan:

Is there some special stuff I gotta do extra with structs? Do 
they need manually allocated and released?


Most of your usages of tiny structs should be by value. So 
just keep in mind they are values. Even when you iterate with 
a foreach on a mutable array of them :-)



On a second question, do I ever need to manually release 
objects I create with new?


Usually not. How much advanced do you want to be? :-)

Bye,
bearophile


Thanks. I'll give structs a try.

When I start the program, it runs fine at 35mb of ram. It only 
keeps 15 objects stored in the arrays at a time so why do you 
think my ram usage increases to 700+ after many hours?


Curiously, my CPU usage went from 10% to 5% after I changed to 
structs on Point and Range. Though my memory still climbs high.


Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Gan via Digitalmars-d-learn

On Tuesday, 27 January 2015 at 22:30:13 UTC, Gan wrote:
On Tuesday, 27 January 2015 at 21:36:51 UTC, Rikki Cattermole 
wrote:

On 28/01/2015 9:59 a.m., Gan wrote:

On Tuesday, 27 January 2015 at 19:59:08 UTC, Gan wrote:
On Tuesday, 27 January 2015 at 19:26:12 UTC, bearophile 
wrote:

Gan:

Is there some special stuff I gotta do extra with structs? 
Do they

need manually allocated and released?


Most of your usages of tiny structs should be by value. So 
just keep
in mind they are values. Even when you iterate with a 
foreach on a

mutable array of them :-)


On a second question, do I ever need to manually release 
objects I

create with new?


Usually not. How much advanced do you want to be? :-)

Bye,
bearophile


Thanks. I'll give structs a try.

When I start the program, it runs fine at 35mb of ram. It 
only keeps
15 objects stored in the arrays at a time so why do you 
think my ram

usage increases to 700+ after many hours?


Curiously, my CPU usage went from 10% to 5% after I changed 
to structs

on Point and Range. Though my memory still climbs high.


Force a GC.collect() now and again. Disable it at the 
beginning too.


I did a test and ran GC.collect() every loop but my memory 
usage continues to rise. I can see how you'd be able to lower 
CPU usage by running GC.collect() every now and then but right 
now I'm stuck on the memory issue.


Perhaps my problem lies in the C++ library SFML?


I commented out some stuff and it appears my massive memory 
consumption comes from my tile.redraw function:


void redraw() {
undrawn = false;
canvas.clear();

//Add stars
for (int i = 0; i  controller.starsPerTile; i++) {
Random gen;
gen.seed(unpredictableSeed);
int x = uniform(0, controller.tileSize, gen);
int y = uniform(0, controller.tileSize, gen);
double s = uniform(0, 1, gen) / 1.0;
			double size = (s * (controller.starSizeMax - 
controller.starSizeMin)) + controller.starSizeMin;

if (x - size / 2  0) {
x += size / 2;
}
if (y - size / 2  0) {
y += size / 2;
}
if (x + size / 2  controller.tileSize) {
x -= size / 2;
}
if (y + size / 2  controller.tileSize) {
y -= size / 2;
}
drawStar(canvas, x, y, size, size);
}

canvas.display();
}
	void drawStar(RenderTarget target, int centerX, int centerY, 
double width, double height) {

CircleShape star;
if (controller.multiColor == false) {
star = controller.stars[0];
} else {
Random gen;
gen.seed(unpredictableSeed);
			star = controller.stars[uniform(0, controller.stars.length - 
1, gen)];

}
star.position = Vector2f(centerX, centerY);
star.origin = Vector2f(0.5, 0.5);
star.scale = Vector2f(width / 100.0, height / 100.0);
target.draw(star);
}


Would you know why this is using hundreds of mb of rams?


Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Gan via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 21:36:51 UTC, Rikki Cattermole 
wrote:

On 28/01/2015 9:59 a.m., Gan wrote:

On Tuesday, 27 January 2015 at 19:59:08 UTC, Gan wrote:

On Tuesday, 27 January 2015 at 19:26:12 UTC, bearophile wrote:

Gan:

Is there some special stuff I gotta do extra with structs? 
Do they

need manually allocated and released?


Most of your usages of tiny structs should be by value. So 
just keep
in mind they are values. Even when you iterate with a 
foreach on a

mutable array of them :-)


On a second question, do I ever need to manually release 
objects I

create with new?


Usually not. How much advanced do you want to be? :-)

Bye,
bearophile


Thanks. I'll give structs a try.

When I start the program, it runs fine at 35mb of ram. It 
only keeps
15 objects stored in the arrays at a time so why do you think 
my ram

usage increases to 700+ after many hours?


Curiously, my CPU usage went from 10% to 5% after I changed to 
structs

on Point and Range. Though my memory still climbs high.


Force a GC.collect() now and again. Disable it at the beginning 
too.


I did a test and ran GC.collect() every loop but my memory usage 
continues to rise. I can see how you'd be able to lower CPU usage 
by running GC.collect() every now and then but right now I'm 
stuck on the memory issue.


Perhaps my problem lies in the C++ library SFML?


Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Gan via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 22:42:25 UTC, Rikki Cattermole 
wrote:

On 28/01/2015 11:39 a.m., Gan wrote:

On Tuesday, 27 January 2015 at 22:30:13 UTC, Gan wrote:
On Tuesday, 27 January 2015 at 21:36:51 UTC, Rikki Cattermole 
wrote:

On 28/01/2015 9:59 a.m., Gan wrote:

On Tuesday, 27 January 2015 at 19:59:08 UTC, Gan wrote:
On Tuesday, 27 January 2015 at 19:26:12 UTC, bearophile 
wrote:

Gan:

Is there some special stuff I gotta do extra with 
structs? Do they

need manually allocated and released?


Most of your usages of tiny structs should be by value. 
So just keep
in mind they are values. Even when you iterate with a 
foreach on a

mutable array of them :-)


On a second question, do I ever need to manually release 
objects I

create with new?


Usually not. How much advanced do you want to be? :-)

Bye,
bearophile


Thanks. I'll give structs a try.

When I start the program, it runs fine at 35mb of ram. It 
only keeps
15 objects stored in the arrays at a time so why do you 
think my ram

usage increases to 700+ after many hours?


Curiously, my CPU usage went from 10% to 5% after I changed 
to structs

on Point and Range. Though my memory still climbs high.


Force a GC.collect() now and again. Disable it at the 
beginning too.


I did a test and ran GC.collect() every loop but my memory 
usage
continues to rise. I can see how you'd be able to lower CPU 
usage by
running GC.collect() every now and then but right now I'm 
stuck on the

memory issue.

Perhaps my problem lies in the C++ library SFML?


I commented out some stuff and it appears my massive memory 
consumption

comes from my tile.redraw function:

void redraw() {
undrawn = false;
canvas.clear();

//Add stars
for (int i = 0; i  controller.starsPerTile; i++) {
Random gen;
gen.seed(unpredictableSeed);
int x = uniform(0, controller.tileSize, gen);
int y = uniform(0, controller.tileSize, gen);
double s = uniform(0, 1, gen) / 1.0;
double size = (s * (controller.starSizeMax -
controller.starSizeMin)) + controller.starSizeMin;
if (x - size / 2  0) {
x += size / 2;
}
if (y - size / 2  0) {
y += size / 2;
}
if (x + size / 2  controller.tileSize) {
x -= size / 2;
}
if (y + size / 2  controller.tileSize) {
y -= size / 2;
}
drawStar(canvas, x, y, size, size);
}

canvas.display();
}
void drawStar(RenderTarget target, int centerX, int 
centerY, double

width, double height) {
CircleShape star;
if (controller.multiColor == false) {
star = controller.stars[0];
} else {
Random gen;
gen.seed(unpredictableSeed);
star = controller.stars[uniform(0, 
controller.stars.length

- 1, gen)];
}
star.position = Vector2f(centerX, centerY);
star.origin = Vector2f(0.5, 0.5);
star.scale = Vector2f(width / 100.0, height / 100.0);
target.draw(star);
}


Would you know why this is using hundreds of mb of rams?


Try with only drawStart stripped.
If it still does it, then its redraw. Also try with just a hard 
coded call to drawStart.

Something smells wrong here.


Without drawStar, my program starts at 24mb and slowly increases. 
With drawStar my program starts at 70mb and increases at twice 
the rate.


Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Gan via Digitalmars-d-learn

On Wednesday, 28 January 2015 at 02:50:11 UTC, FG wrote:

On 2015-01-28 at 03:04, Vladimir Panteleev wrote:

What type is CircleShape?
If it is a class, or otherwise contains pointers, then this is 
probably the source of your problem.


class CircleShape : Shape is defined in 
dsfml.graphics.circleshape, so there's no going around this...


- Building your program for x86_64 - 64 bits of address space 
will make fake pointer pinning very unlikely


The binary included in the zip was 64-bit, so fake pointers 
shouldn't be that much of a problem.


Oh, and I take back what I said about suspecting that 
SpaceBackground.stack grows infinitely. It probably doesn't. I 
don't have DSFML installed, and therefore couldn't recreate the 
behaviour.


Is there a way to set a variable to be cleared in the new GC 
collection or to forcibly release a variable?


I have an inkling that it might be the Sprite class or something 
with the RenderTextures.


I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Gan via Digitalmars-d-learn
I feel like the only way I can get better right now is if someone 
with more knowledge can give me some advice on the code I have 
written.


Here's the link: http://cl.ly/0s0Q1L1S3v0E

How can I make it use less CPU/RAM?
(Most code is in the Misc/SpaceBackground.d)


Re: Array List object?

2015-01-26 Thread Gan via Digitalmars-d-learn

On Tuesday, 27 January 2015 at 06:16:03 UTC, H. S. Teoh wrote:
On Tue, Jan 27, 2015 at 06:02:38AM +, Gan via 
Digitalmars-d-learn wrote:

On Tuesday, 27 January 2015 at 06:00:50 UTC, Gan wrote:
On Tuesday, 27 January 2015 at 05:32:09 UTC, Gan wrote:
Hey I'm using normal arrays for my project:
//Declaring the array
SBTile[] tiles;

//Initializing the array
tiles = new SBTile[](0);

//Clearing the array
tiles = [];

//Removing a tile at index i from the array
tiles.remove(i);

//Adding a tile to the array
tiles ~= tile;

But I think I'm doing something very wrong because my list 
of tiles
is growing larger and larger. Am I misusing the array or is 
there a

better way of doing those array list functions?

Found my problem. When you call remove, you need to set it.

tiles = tiles.remove(i);

Though isn't it incredibly inefficient to continually have it
re-create the arrays for adding and removing? I'm asking 
cause I'm

not very knowledgable on this subject.

On a side note, my program's ram usage is increasing very 
rapidly. All

I'm doing to adding and removing objects from an array.


The answers to your question can be found here:

http://dlang.org/d-array-article.html

In short, D arrays are actually not arrays directly, but 
slices of
arrays (i.e., pointer and length pairs to a segment of memory 
managed by
the GC).  Therefore, assigning the return value of .remove back 
to tiles
is extremely efficient, because all you're doing is updating 
the .ptr
and .length fields of tiles. There is no copying of array 
elements at

all (except what's already being done in .remove).

However, the problem comes when you call .remove immediately 
followed by
~=. Because the runtime doesn't know whether you have made 
other slices
of the same array in the meantime, it doesn't know whether you 
wish to
retain the original array elements, so to be safe, whenever the 
array
length shrinks it assumes that the next time you append 
something new,
it should reallocate. Thus, every time ~= follows .remove, the 
array
will be reallocated, which is extremely slow. The solution is 
to tell
the runtime that yes, you do wish to overwrite whatever may 
have been

there in GC memory before when you append:

tiles = tiles.remove(i);
assumeSafeAppend(tiles); // --- this is the secret
tiles ~= tile;  // now this won't reallocate everytime

Note that append to the array will still reallocate 
occasionally (e.g.,
when there is no more space in the currently allocated GC 
block, and the
array needs to be moved to a new memory location where a bigger 
block
can be allocated). But it should perform a lot better than 
reallocating

every single time you append.


T


Thanks! My project use to hover at 80mb ram usage, now it hovers 
at 35mb ram usage. Nevermind. It just climbed up to 65mb


Okay now I'm very confused. When I have my program fully hidden 
behind another window, my ram usage goes up without going down. 
Which my program is partly visible it goes up a few mb then 
returns to the past amount of mb.


Is this a bug?


Re: Array List object?

2015-01-26 Thread Gan via Digitalmars-d-learn

On Tuesday, 27 January 2015 at 05:32:09 UTC, Gan wrote:

Hey I'm using normal arrays for my project:
//Declaring the array
SBTile[] tiles;

//Initializing the array
tiles = new SBTile[](0);

//Clearing the array
tiles = [];

//Removing a tile at index i from the array
tiles.remove(i);

//Adding a tile to the array
tiles ~= tile;

But I think I'm doing something very wrong because my list of 
tiles is growing larger and larger. Am I misusing the array or 
is there a better way of doing those array list functions?


Found my problem. When you call remove, you need to set it.

tiles = tiles.remove(i);

Though isn't it incredibly inefficient to continually have it 
re-create the arrays for adding and removing? I'm asking cause 
I'm not very knowledgable on this subject.


Re: Array List object?

2015-01-26 Thread Gan via Digitalmars-d-learn

On Tuesday, 27 January 2015 at 06:00:50 UTC, Gan wrote:

On Tuesday, 27 January 2015 at 05:32:09 UTC, Gan wrote:

Hey I'm using normal arrays for my project:
//Declaring the array
SBTile[] tiles;

//Initializing the array
tiles = new SBTile[](0);

//Clearing the array
tiles = [];

//Removing a tile at index i from the array
tiles.remove(i);

//Adding a tile to the array
tiles ~= tile;

But I think I'm doing something very wrong because my list of 
tiles is growing larger and larger. Am I misusing the array or 
is there a better way of doing those array list functions?


Found my problem. When you call remove, you need to set it.

tiles = tiles.remove(i);

Though isn't it incredibly inefficient to continually have it 
re-create the arrays for adding and removing? I'm asking cause 
I'm not very knowledgable on this subject.


On a side note, my program's ram usage is increasing very 
rapidly. All I'm doing to adding and removing objects from an 
array.


Re: Conflicts with Import error - New to D, trying to build a new project

2015-01-25 Thread Gan via Digitalmars-d-learn

Thanks. I didn't realize that could conflict.

On Sunday, 25 January 2015 at 21:22:50 UTC, Ali Çehreli wrote:

On 01/25/2015 11:30 AM, Gan wrote:

Here's a screenshot: http://cl.ly/image/2n282v0B1X2M

The error is: 
/Users/Matt/Projects/spacecraft/source/Game/Game.d(0,0):
Error: class Game.Game.Game conflicts with import 
Game.Game.Game at

source/Game/Game.d(2) (spacecraft)

I figure it's because I did imports wrong or something. I'm 
still very

new to D. Can anyone help?


The problem is with having three constructs with the same name: 
package, module, and class.


I would use lowercase for package, and module names, and 
differentiate between the package and the module:


.../source/foogame/game.d

module foogame.game;

class Game
{
// ...
}

Ali




Question about Allocating

2015-01-25 Thread Gan via Digitalmars-d-learn
I've been working on my game and am getting some pretty gnarly 
memory problems. I think it's how I'm allocating.


Sometimes when I use variables I can do Color(255, 255, 255). But 
why is that different than new Color(255, 255, 255)?

Same when I'm making arrays. new int[](0) vs [].


What's the difference?


Re: Turning Executable into Application?

2015-01-25 Thread Gan via Digitalmars-d-learn

On Monday, 26 January 2015 at 06:37:34 UTC, tcak wrote:

On Monday, 26 January 2015 at 03:36:32 UTC, Gan wrote:
With Xamarin Studio I create a D project and run it. It runs 
an Executable Unix file through the terminal. How can I turn 
that into an Application that doesn't open the Terminal?


Thanks.


I use MonoDevelop. I haven't tried that but in Project Options 
(Not Solution Options), there is a checkbox saying Run on 
External Console. Uncheck that one maybe.


As far as I understand, you want to make a GUI program by 
saying application.


That's it! Thank you!


Turning Executable into Application?

2015-01-25 Thread Gan via Digitalmars-d-learn
With Xamarin Studio I create a D project and run it. It runs an 
Executable Unix file through the terminal. How can I turn that 
into an Application that doesn't open the Terminal?


Thanks.


Conflicts with Import error - New to D, trying to build a new project

2015-01-25 Thread Gan via Digitalmars-d-learn

Here's a screenshot: http://cl.ly/image/2n282v0B1X2M

The error is: 
/Users/Matt/Projects/spacecraft/source/Game/Game.d(0,0): Error: 
class Game.Game.Game conflicts with import Game.Game.Game at 
source/Game/Game.d(2) (spacecraft)


I figure it's because I did imports wrong or something. I'm still 
very new to D. Can anyone help?