Re: DerelictGL program draw nothing

2012-09-03 Thread Zhenya

On Monday, 3 September 2012 at 18:47:25 UTC, Ivan Agafonov wrote:

On Monday, 3 September 2012 at 15:21:59 UTC, Zhenya wrote:

Why this simple program don't show white square?

import std.stdio;

import derelict.opengl3.gl;
import derelict.glfw3.glfw3;

const uint width = 200;
const uint height = 200;

void init()
{
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-width,width,-height,height,-1,1);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}

void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glVertex2d(0,0);
glVertex2d(0,height);
glVertex2d(width,height);
glVertex2d(height,0);
glEnd();
}

void main()
{
DerelictGL.load();
DerelictGLFW3.load();
glfwInit();
GLFWwindow window;
	window = glfwCreateWindow(width,height,GLFW_WINDOWED,"Hello 
DerelictGLFW3",null);

init();
bool opened = true;
while(opened)
{
		opened = !glfwGetWindowParam(window,GLFW_CLOSE_REQUESTED) && 
!glfwGetKey(window,GLFW_KEY_ESC);

display();
glfwSwapBuffers(window);
glfwWaitEvents();
}
glfwTerminate();
}


width and height must be int, not uint.
After window = glfwCreateWindow();
put glfwMakeContextCurrent(window);
And it will work!

Thank you very much)




Re: DerelictGL program draw nothing

2012-09-03 Thread Ivan Agafonov

On Monday, 3 September 2012 at 15:21:59 UTC, Zhenya wrote:

Why this simple program don't show white square?

import std.stdio;

import derelict.opengl3.gl;
import derelict.glfw3.glfw3;

const uint width = 200;
const uint height = 200;

void init()
{
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-width,width,-height,height,-1,1);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}

void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glVertex2d(0,0);
glVertex2d(0,height);
glVertex2d(width,height);
glVertex2d(height,0);
glEnd();
}

void main()
{
DerelictGL.load();
DerelictGLFW3.load();
glfwInit();
GLFWwindow window;
	window = glfwCreateWindow(width,height,GLFW_WINDOWED,"Hello 
DerelictGLFW3",null);

init();
bool opened = true;
while(opened)
{
		opened = !glfwGetWindowParam(window,GLFW_CLOSE_REQUESTED) && 
!glfwGetKey(window,GLFW_KEY_ESC);

display();
glfwSwapBuffers(window);
glfwWaitEvents();
}
glfwTerminate();
}


width and height must be int, not uint.
After window = glfwCreateWindow();
put glfwMakeContextCurrent(window);
And it will work!


Re: DerelictGL program draw nothing

2012-09-03 Thread cal

On Monday, 3 September 2012 at 17:16:54 UTC, Zhenya wrote:

I added it to this code,but nothing changed(


Its a puzzler then, FWIW the following code works for me (I don't 
use GLFW, I have my own window routines, but the opengl-specific 
calls are the same).


Window("window1", WindowState(0,0,200,200), Flag!"Create".yes, 
Flag!"Show".yes);

Window.makeCurrent("window1");

glViewport(0,0,200,200);
glClearColor(0,0,0,1);

bool finish = false;
while (!finish)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-200, 200, -200, 200, -1, 1);
glClear( GL_COLOR_BUFFER_BIT );
glBegin(GL_POLYGON);
glVertex2d(0, 0);
glVertex2d(0, 200);
glVertex2d(200, 200);
glVertex2d(200, 0);
glEnd();
Window().swapBuffers();

if (Window().keyState().keys[KEY.KC_ESCAPE])
finish = true;
}

Perhaps something in the GLFW init is modyfying some OpenGL 
defaults or something, you might like to ask on their forum.


Re: CTFE question

2012-09-03 Thread Philippe Sigaud
On Mon, Sep 3, 2012 at 4:08 PM, bearophile  wrote:

>> Worth a bug report?
>
>
> Yeah. CTFE must give the same results when CTFE works.

http://d.puremagic.com/issues/show_bug.cgi?id=8614


Re: DerelictGL program draw nothing

2012-09-03 Thread Zhenya

On Monday, 3 September 2012 at 17:12:04 UTC, cal wrote:

On Monday, 3 September 2012 at 17:08:55 UTC, cal wrote:

On Monday, 3 September 2012 at 17:02:46 UTC, Zhenya wrote:

that dosn't work


How large is your window?

glViewport(0,0,width,height);

should really be setting to the window size - so if you make 
your window 800,800, this should be


glViewport(0,0,800,800);


Just saw it, never mind. Also, I think before you draw, you 
need to set the matrix mode to modelview, and load identity...


glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
display();


const uint width = 200;
const uint height = 200;


glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
display();


I added it to this code,but nothing changed(


Re: DerelictGL program draw nothing

2012-09-03 Thread cal

On Monday, 3 September 2012 at 17:08:55 UTC, cal wrote:

On Monday, 3 September 2012 at 17:02:46 UTC, Zhenya wrote:

that dosn't work


How large is your window?

glViewport(0,0,width,height);

should really be setting to the window size - so if you make 
your window 800,800, this should be


glViewport(0,0,800,800);


Just saw it, never mind. Also, I think before you draw, you need 
to set the matrix mode to modelview, and load identity...


glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
display();



Re: DerelictGL program draw nothing

2012-09-03 Thread cal

On Monday, 3 September 2012 at 17:02:46 UTC, Zhenya wrote:

that dosn't work


How large is your window?

glViewport(0,0,width,height);

should really be setting to the window size - so if you make your 
window 800,800, this should be


glViewport(0,0,800,800);



Re: DerelictGL program draw nothing

2012-09-03 Thread Zhenya

On Monday, 3 September 2012 at 16:57:08 UTC, cal wrote:

On Monday, 3 September 2012 at 15:21:59 UTC, Zhenya wrote:

Why this simple program don't show white square?
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glVertex2d(0,0);
glVertex2d(0,height);
glVertex2d(width,height);
glVertex2d(height,0); glVertex2d(width, 0)
glEnd();
}


If that doesn't work, maybe you need to wind the vertices the 
other way to avoid backface culling, ie:


glVertex2d(0, 0)
glVertex2d(width, 0)
glVertex2d(width, height)
glVertex2d(0, height)


that dosn't work


Re: DerelictGL program draw nothing

2012-09-03 Thread cal

On Monday, 3 September 2012 at 15:21:59 UTC, Zhenya wrote:

Why this simple program don't show white square?
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glVertex2d(0,0);
glVertex2d(0,height);
glVertex2d(width,height);
glVertex2d(height,0); glVertex2d(width, 0)
glEnd();
}


If that doesn't work, maybe you need to wind the vertices the 
other way to avoid backface culling, ie:


glVertex2d(0, 0)
glVertex2d(width, 0)
glVertex2d(width, height)
glVertex2d(0, height)



DerelictGL program draw nothing

2012-09-03 Thread Zhenya

Why this simple program don't show white square?

import std.stdio;

import derelict.opengl3.gl;
import derelict.glfw3.glfw3;

const uint width = 200;
const uint height = 200;

void init()
{
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-width,width,-height,height,-1,1);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}

void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glVertex2d(0,0);
glVertex2d(0,height);
glVertex2d(width,height);
glVertex2d(height,0);
glEnd();
}

void main()
{
DerelictGL.load();
DerelictGLFW3.load();
glfwInit();
GLFWwindow window;
	window = glfwCreateWindow(width,height,GLFW_WINDOWED,"Hello 
DerelictGLFW3",null);

init();
bool opened = true;
while(opened)
{
		opened = !glfwGetWindowParam(window,GLFW_CLOSE_REQUESTED) && 
!glfwGetKey(window,GLFW_KEY_ESC);

display();
glfwSwapBuffers(window);
glfwWaitEvents();
}
glfwTerminate();
}



Re: CTFE question

2012-09-03 Thread bearophile

Philippe Sigaud:


Worth a bug report?


Yeah. CTFE must give the same results when CTFE works.

A simpler test case for Bugzilla:

import std.stdio;
int[] foo(int[] data) {
 foreach (i, ref x; data) {
 x++;
 i++;
 }
 return data;
}
void main() {
enum result1 = foo([10, 20, 30, 40]);
auto result2 = foo([10, 20, 30, 40]);
writeln(result1); // [11, 21, 31, 41]
writeln(result2); // [11, 20, 31, 40]
}

Bye,
bearophile


Re: CTFE question

2012-09-03 Thread Philippe Sigaud
On Mon, Sep 3, 2012 at 1:27 PM, Don Clugston  wrote:


>> Godd adivce, except beware of using ++ and --, they don't work at
>> compile-time. I'm regularly caught unaware by this, particularly while
>> looping.
>
>
> Really? That's scary. Is there a bug report for this?

I re-tried this and I was mistaken: it's not ++ or --, it's changing
an iteration index at compile-time. My bad.

int[] indices(string s)
{
int[] store;
foreach(i,ch; s[0..$-1])
{
store ~= i;
if (s[i..i+2] == "aa")
i += 1; // also ++i or i++, no difference here
}
return store;
}

void main()
{
enum result1 = indices("aaabc");
auto result2 = indices("aaabc");

writeln(result1); // [0,1,2,3]
writeln(result2); // [0,2,3]
}

I know changing 'i' while iterating is not a good idea, but at least
in this case, CT-executed and RT-execution give a different result.
All my other tests with ++ and -- give correct results, sorry for the
bad publicity.

Worth a bug report?


Re: demangling (Ubuntu 64bit 12.04, dmd 64bit 2.060)

2012-09-03 Thread Carl Sturtivant

On Sunday, 26 August 2012 at 19:24:03 UTC, Carl Sturtivant wrote:
Here are some examples that are not demangled by 
std.demangle.demangle :


_D13libd_demangle12__ModuleInfoZ
_D15TypeInfo_Struct6__vtblZ
_D3std5stdio12__ModuleInfoZ
_D3std6traits15__T8DemangleTkZ8Demangle6__initZ
_D47TypeInfo_S3std6traits15__T8DemangleTkZ8Demangle6__initZ




Ah, just what I needed all along: this D ABI definition
http://dlang.org/abi.html
contains the exact definition of mangling.



Re: CTFE question

2012-09-03 Thread Don Clugston

On 28/08/12 19:40, Philippe Sigaud wrote:

On Tue, Aug 28, 2012 at 2:07 PM, Chris Cain  wrote:

On Tuesday, 28 August 2012 at 11:39:20 UTC, Danny Arends wrote:


Ahhh I understand...

As a follow up, is it then possible to 'track' filling a
large enum / immutable on compile time by outputting a msg
every for ?

I'm generating rotation matrices for yaw, pitch and roll
at compile time which can take a long time depending on
how fine grained I create them.



I'm pretty sure there isn't. However, if you're just trying to develop/test
your algorithm, you could write a program that runs it as a normal function
(and just use writeln) as you develop it. After it's done, you remove the
writelns, mark the function as pure and it should work exactly the same in
CTFE.


Godd adivce, except beware of using ++ and --, they don't work at
compile-time. I'm regularly caught unaware by this, particularly while
looping.


Really? That's scary. Is there a bug report for this?


Re: Recipe and best practice for accessing COM

2012-09-03 Thread Kagamin

The diagnostic message can definitely be better.