Jump to content

  • Log In with Google      Sign In   
  • Create Account


Prot

Member Since 05 Jul 2013
Offline Last Active Yesterday, 06:20 AM

Posts I've Made

In Topic: How to react on KeyPress + Release?

19 August 2014 - 04:39 AM


There's between being called once and being called regularly. GLUT will only issue a call to the display function when the contents is invalidated which typically happens when for example, the window is created, the window is resized, or when the window is moved behind other windows. Otherwise, the display callback is not called again unless you explicitly force a redisplay.



So, your display function is called once which explains why something is rendered, but not regularly which explains why nothing more is happening after that. You need to use the idle callback to keep the program busy all the time instead of idling when there's nothing new to display.



Quick solution:

void idle()
{
glutPostRedisplay();
}

int main()
{
...
glutIdleCallback(idle);
glutMainLoop();
}
As soon as there's nothing else for GLUT to do, it calls the idle callback which then forces GLUT to redraw the window.

 

Hey this advice did the job! Maybe two more things I noticed here:

 

  1. I implemented a concole application which copied one array to another under the very same circumstances and it did work.
  2. I had to assign the idle()-function using glutIdleFunc() not glutIdleCallback() (this one wasn't even suggested by VS).

But now it works thanks a lot. You were right coming from XNA I assumed that display here would be somehow similar to the Draw() function which is called in regular intervals.


In Topic: How to react on KeyPress + Release?

19 August 2014 - 04:06 AM

Is the display routine invoked regularly at all? Set a breakpoint into the display() routine and look what happens.

 

Yes it is, otherwise it would not draw anything I guess. But while stepping through the method something strange happened. When the debugger hit the memcpy() line it VS opened a OpenFileDialog and said that it was missing a memcpy.asm file.

 

What does that mean it didn't throw any errors when compiling without breakpoints.


In Topic: How to react on KeyPress + Release?

19 August 2014 - 03:34 AM

After the first run through display() both keyStates and keyPreviousState point to the same memory area. You probably want to use memcpy to copy the memory area pointed to by keyStates to the memory area pointed to by keyPreviousStates, but actually you copy the pointer keyStates to keyPreviousStates.

 

EDIT: To avoid such problems and clearly denote the situation, you should use const to make the variables read-only, in this case

bool* const keyStates = new bool[256]();
bool* const keyPreviousStates = new bool[256]();

Notice that this does not make the array elements read-only but just the pointers themselves.

 

So now I declared the pointers as constants and tried the following in order to cpoy the actual array:

memcpy(keyPreviousStates,keyStates, sizeof(keyStates));

Also tried:

memcpy(keyPreviousStates,keyStates, 256 * sizeof(bool));

It still does not work. Any suggestions?


In Topic: How to manipulate Normals in Blender?

26 November 2013 - 12:57 PM

How to build this in Blender:

 

1) Add a cube if you don't already have one

2) Go to edit mode (TAB)

3) Mesh -> Edges -> Edge Split (CTRL+E)

4) Triangulate faces (CTRL+T)

 

You can now see in the top info row: Verts:24/24 | Edges:30/30 | Faces:12/12 | Tris: 12 and the model should be like you need in the tutorial.

 

I think the tutorial might have served more as an introduction to concept of vertices, edges, faces, normals in this case smile.png

 

 

Hey there this actually worked! Thanks for that. Everything works fine. One important thing to mention here is, one should first apply textures and triangulate and edgesplit later. Otherwise UVs seem to screw up.

 

Thanks again


In Topic: How to manipulate Normals in Blender?

21 November 2013 - 10:24 AM

If the tutorial in question says you need 24 normals, that probably means you need to "explode" the cube into 6 non-connected polygons. You can do this in Blender by tabbing into edit mode for the cube, choosing edge selection, selecting all, and using Mesh -> Edges -> Edge Split. That way you get 4*6 = 24 vertices and you should now have 24 vertex normals as well. Looking at the vertex normals now, you have 3 normals at each corner because they are now 3 separate vertices. The vertex normal that was previously [1,1,1] is now 3 normals [1,0,0], [0,1,0] and [0,0,1] so it's been divided into components for each of the 3 faces.

 

 

Your solution seems to work. This is how I do it.

 

  1. Take the predefined Cube which has only 6 faces, 8 vertices and 8 normals at first.
  2. Now I go to Mesh->Faces->Triangulate Faces. This is because I need the faces to be triangles.
  3. Now Mesh->Edges(with all edges selected)->Edge Split

Well this actually does the trick. Now I have 12 faces and normals for each vertex which look right to me. The problem is, in the entire process somehow more vertices were generated. I end up with 36 vertices. I can't see them. Tried to go to Mesh->Vetrtices->Remove Duplicates. But this deletes the normals and even the edges I created with triangulation.


PARTNERS