Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - cppxor2arr

Pages: [1]
1
General / Re: OpenGL basic program triangle isn't visible
« on: September 08, 2017, 04:14:04 pm »
`sudo lspci -vnn | grep VGA -A 12` (GPU)

Output:

00:02.0 VGA compatible controller [0300]: Intel Corporation Broadwell-U Integrated Graphics [8086:1616] (rev 09) (prog-if 00 [VGA controller])
   Subsystem: Acer Incorporated [ALI] Device [1025:0899]
   Flags: bus master, fast devsel, latency 0, IRQ 48
   Memory at c0000000 (64-bit, non-prefetchable) [size=16M]
   Memory at b0000000 (64-bit, prefetchable) [size=256M]
   I/O ports at 4000 [size=64]
   [virtual] Expansion ROM at 000c0000 [disabled] [size=128K]
   Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit-
   Capabilities: [d0] Power Management version 2
   Capabilities: [a4] PCI Advanced Features
   Kernel driver in use: i915

00:03.0 Audio device [0403]: Intel Corporation Broadwell-U Audio Controller [8086:160c] (rev 09)

---

glew.cpp (117) glCheckError();
glew.cpp (123) glCheckError();

jamesL's code defined a macro so glCheckError() calls glCheckError_(const char* file, int line)

2
General / Re: OpenGL basic program triangle isn't visible
« on: September 08, 2017, 11:38:46 am »
I ran the code (had to comment out the two lines relating to attribute flags since I have SFML 2.1). The result is the same (black screen) and the output is this:

version: 3.0
depth bits: 24
stencil bits: 8
antialiasing level: 0
INVALID OPERATION | glew.cpp (117)
INVALID OPERATION | glew.cpp (123)

3
General / Re: OpenGL basic program triangle isn't visible
« on: September 07, 2017, 03:34:24 pm »
I tried that, but I still get a black screen. Is there a complete example (code) for drawing a triangle with SFML and OpenGL 3.0 (no immediate mode)? I'm starting to think the problem is with my laptop/OS.

4
General / Re: OpenGL basic program triangle isn't visible
« on: September 06, 2017, 11:37:55 am »
So I installed glew `sudo aptitude install libglew-dev`and copy/pasted the code. When I run it the same thing happens (black screen, no triangle). Any ideas?

5
General / Re: OpenGL basic program triangle isn't visible
« on: September 06, 2017, 01:21:48 am »
I don't have glew but I will install it and try to run the original code.

6
General / OpenGL basic program triangle isn't visible
« on: September 05, 2017, 05:06:57 pm »
Following this tutorial https://open.gl/ (specifically this one: https://open.gl/drawing) I tried to compile my first OpenGL program. The program is supposed to show a triangle on the screen. I'm not sure if this is a problem about SFML or OpenGL. When I run the code nothing is shown (just a black screen). What needs to be changed to display the triangle correctly?

SFML version: 2.1
OpenGL version used (checked in windows.getSettings()): 3.0
OS: Linux (Debian Jessie 8.7) 64-bit

#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include <vector>

int main()
{
    sf::ContextSettings settings;
    settings.depthBits = 24;
    settings.stencilBits = 8;
    settings.antialiasingLevel = 2;
    settings.majorVersion = 3;
    settings.minorVersion = 2;
    sf::Window window{sf::VideoMode{800, 600}, "opengl", sf::Style::Default, settings};
    window.setActive();

    GLuint vao;
    glGenVertexArrays(1, &vao);
    glBindVertexArray(vao);

    std::vector<float> vertices
    {
        0.0f, 0.5f,
        0.5f, -0.5f,
        -0.5f, -0.5f
    };
    GLuint vbo;
    glGenBuffers(1, &vbo);
    glBindBuffer(GL_ARRAY_BUFFER, vbo);
    glBufferData(GL_ARRAY_BUFFER, vertices.size(), &vertices[0], GL_STATIC_DRAW);

    const char* vertexSource
    {
        R"glsl(
            #version 150 core
            in vec2 position;
            void main()
            {
                gl_Position = vec4(position, 0.0, 1.0);
            }
        )glsl"

    };
    GLuint vertexShader{glCreateShader(GL_VERTEX_SHADER)};
    glShaderSource(vertexShader, 1, &vertexSource, nullptr);
    glCompileShader(vertexShader);

    const char* fragmentSource
    {
        R"glsl(
            #version 150 core
            out vec4 outColor;
            void main()
            {
                outColor = vec4(1.0, 1.0, 1.0, 1.0);
            }
        )glsl"

    };
    GLuint fragmentShader{glCreateShader(GL_FRAGMENT_SHADER)};
    glShaderSource(fragmentShader, 1, &fragmentSource, nullptr);
    glCompileShader(fragmentShader);

    GLuint shaderProgram{glCreateProgram()};
    glAttachShader(shaderProgram, vertexShader);
    glAttachShader(shaderProgram, fragmentShader);
    glBindFragDataLocation(shaderProgram, 0, "outColor");
    glLinkProgram(shaderProgram);
    glUseProgram(shaderProgram);

    GLint posAttrib{glGetAttribLocation(shaderProgram, "position")};
    glEnableVertexAttribArray(posAttrib);
    glVertexAttribPointer(posAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0);

    bool running{true};
    while (running)
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                running = false;
            else if (event.type == sf::Event::KeyPressed)
                if (event.key.code == sf::Keyboard::Return)
                    running = false;
        }
        glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glDrawArrays(GL_TRIANGLES, 0, 3);
        window.display();
    }

    glDeleteProgram(shaderProgram);
    glDeleteShader(fragmentShader);
    glDeleteShader(vertexShader);
    glDeleteBuffers(1, &vbo);
    glDeleteVertexArrays(1, &vao);
    window.close();
}
 

7
Graphics / Re: Boundaries of X, Y coordinates in window
« on: August 15, 2017, 04:15:09 pm »
Thanks a lot!

8
Graphics / Boundaries of X, Y coordinates in window
« on: August 15, 2017, 03:36:01 pm »
In this code:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window{sf::VideoMode{300, 300}, "Window Title"};

    sf::VertexArray points{sf::Points, 4};

    // which two of these are the top left and bottom right corner

    points[0].position = sf::Vector2f{0, 0};
    points[1].position = sf::Vector2f{1, 1};
    points[2].position = sf::Vector2f{299,  299};
    points[3].position = sf::Vector2f{300, 300};

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
            if (event.type == sf::Event::Closed)
                window.close();
        window.clear(); window.draw(points); window.display();
    }
}

What are the boundaries? 0-299 or 1-300 (width or height)? Also, the question in the comment.

Pages: [1]
anything