# Getting Started

**URL:** <https://discourse.glfw.org/t/getting-started/828>\
**Category:** support\
**Created:** [January 10, 2017, 11:34am UTC](https://discourse.glfw.org/t/getting-started/828 "2017-01-10T11:34:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DirtyBlasion](https://avatars.discourse-cdn.com/v4/letter/d/53a042/32.png) [@DirtyBlasion](https://discourse.glfw.org/u/DirtyBlasion)\
**Post date:** [January 10, 2017, 11:34am UTC](https://discourse.glfw.org/t/getting-started/828/1 "2017-01-10T11:34:54Z")

</div>

So, I documented my self, I instaled it to codeblocks, it work.

Here is what I want to get knowing:

1. When I first created the window it crashed it.  
2)I did vectors at school, and I know math, my problem is I don’t know the terms in english, but I learn fast.  
3)How I can make a fps camera???  
4)How I can draw a cube? At a x, y, z?

I forgot to mention I work on c++ and I know, the basics, and object oriented

---

<div class="post-metadata">

**Author:** ![mmozeiko](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/mmozeiko/32/29_2.png) [@mmozeiko](https://discourse.glfw.org/u/mmozeiko)\
**Post date:** [January 10, 2017, 11:58am UTC](https://discourse.glfw.org/t/getting-started/828/2 "2017-01-10T11:58:57Z")

</div>

Where did it crash? Run your program under debugger and examine call stack to see the location and from where it was called. Usually this happens because you pass wrong values to some functions, so examine local variables to figure out what values you have used.

3 and 4 are really not GLFW questions. GLFW only opens window and provides you input events. Everything else (camera, drawing, etc…) you do thorugh OpenGL or Vulkan. I suggest you visit [https://www.khronos.org/opengl/wiki/](https://www.khronos.org/opengl/wiki/) to learn more about OpenGL.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [January 10, 2017, 12:01pm UTC](https://discourse.glfw.org/t/getting-started/828/3 "2017-01-10T12:01:43Z")

</div>

Q: Are you still having problems with the window crashing?

OpenGL has many different levels of API. If you want to study ‘modern’ OpenGL with shaders then I would look for tutorials for OpenGL 3 or OpenGL 4.

I found what seems to be a decent tutorial for OpenGL 4 here: [http://antongerdelan.net/opengl/](http://antongerdelan.net/opengl/), the basics are available there for free with a fair priced eBook download for the rest of the tutorials and code on Github [https://github.com/capnramses/antons\_opengl\_tutorials\_book](https://github.com/capnramses/antons_opengl_tutorials_book)

---

<div class="post-metadata">

**Author:** ![DirtyBlasion](https://avatars.discourse-cdn.com/v4/letter/d/53a042/32.png) [@DirtyBlasion](https://discourse.glfw.org/u/DirtyBlasion)\
**Post date:** [January 10, 2017, 12:38pm UTC](https://discourse.glfw.org/t/getting-started/828/4 "2017-01-10T12:38:47Z")

</div>

```cpp
#include <iostream>
#include <GLFW/glfw3.h>

using namespace std;

int main(void)
{
    if(!glfwInit())
    {
        //glfwTerminate();
        cout << "Failed to launch";
        return -1;
    }

    GLFWwindow* window = glfwCreateWindow(640, 480, "Minecraft", NULL, NULL);

    if(!window)
        glfwTerminate();

    glfwMakeContextCurrent(window);

    while(!glfwWindowShouldClose(window))
    {
        glfwSwapBuffers(window);
        glfwPollEvents();// if this line is missing it crash
    }

    glfwTerminate();
}

```

Tell me if is missing something? About cube I know how to make it from 3d vertex, and rotate it with cos and sin.

---

<div class="post-metadata">

**Author:** ![tombsar](https://avatars.discourse-cdn.com/v4/letter/t/db5fbb/32.png) [@tombsar](https://discourse.glfw.org/u/tombsar)\
**Post date:** [January 10, 2017, 4:23pm UTC](https://discourse.glfw.org/t/getting-started/828/5 "2017-01-10T16:23:19Z")

</div>

A couple of code review points:

```
cout << "Failed to launch";

```

Errors should probably be sent to `cerr` rather than `cout`. You should also send a `endl` after your message to flush the buffer, otherwise it will not be printed immediately (or at all).

```
if(!window)
    glfwTerminate();

```

You should also end your program in this circumstance, otherwise your code continues to try and use the null pointer in the following lines.

```
glfwPollEvents();// if this line is missing it crash

```

You need to call either `glfwPollEvents()` or `glfwWaitEvents()` regularly to receive important messages from the operating system. It is less than ideal, but I am not surprised that the program crashes without that line.

I recommend setting an error callback to notify you if/when errors are generated within GLFW. See [http://www.glfw.org/docs/latest/group\_\_init.html#gaa5d796c3cf7c1a7f02f845486333fb5f](http://www.glfw.org/docs/latest/group__init.html#gaa5d796c3cf7c1a7f02f845486333fb5f) for information.

Your other questions are quite complex, and will require OpenGL knowledge. I suggest finding a tutorial and starting there before trying to do everything from scratch.

---

<div class="post-metadata">

**Author:** ![0joshuaolson1](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/0joshuaolson1/32/79_2.png) [@0joshuaolson1](https://discourse.glfw.org/u/0joshuaolson1)\
**Post date:** [January 22, 2017, 10:59pm UTC](https://discourse.glfw.org/t/getting-started/828/6 "2017-01-22T22:59:52Z")

</div>

It’s all I got, but [here’s](https://github.com/0joshuaolson1/opengl-camera-demo) my old minimal example of a single-threaded 3D ‘game’. It uses OpenGL 1(!) and GLFW2 (a couple changes required) to draw lines, react to input, move a camera, and block the main loop between frames.
