On 10/22/16 5:34 PM, WhatMeWorry wrote:
On Saturday, 22 October 2016 at 20:51:14 UTC, Jonathan M Davis wrote:
On Saturday, October 22, 2016 20:35:27 WhatMeWorry via
Digitalmars-d-learn wrote:
[...]
Just put it in a separate module and then import it. e.g.
file: mypackage/constants.d
==================
module mypackage.constants;
GLfloat[] vertices =
[
// Positions // Texture Coords
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
0.5f, -0.5f, -0.5f, 1.0f, 0.0f,
.....
(lots and lots of values)
.....
];
I would make this:
immutable GLfloat[] vertices
If you can do it. This will make it so it's a) accessible from pure
functions, and b) will not create a separate thread-local copy for each
thread (if you use threading).
Ok, but now I'm getting these error in my new mypackage/constants.d
...\common\vertex_data.d(5,15): Error: undefined identifier 'GLfloat'
...\common\vertex_data.d(53,12): Error: undefined identifier 'vec3'
It's difficult to know why without more code hints, but it appears that
vertex_data.d needs to import the module that defines these types. Note
that if you want to have an imported module provide these definitions
from another module, then you need to public import the module.
So for instance (guessing at your code, since I don't know what you have
for import statements):
mypackage/my_types.d:
alias GLfloat = float;
alias vec3 = GLfloat[3];
mypackage/constants.d:
public import mypackage.my_types; // this allows importers of
constants.d to see the types used
GLfloat[] vertices = ...
vertex_data.d:
import mypackage.constants; // pulls in definitions from my_types.d
-Steve