PDA

View Full Version : What am I missing ?



bisthebis
02-07-2016, 10:09 AM
I recentrly switched my development environment, and I wanted to make a dummy openGL project to check all my libraries.
Everything works, except my drawing (well, you'd say it's far from everything if I can't draw :D)

I guess I made a stupid mistake, but I can't figure out what.
(I'm doing shaderless drawing just for my demo purpose.When problem gets solved I'll use them ofcourse ^^ )

glgeterror returns no_error, and my background color did change as intended.


#define GLEW_STATIC

#include <iostream>

#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>

#include <GL/glew.h>

using namespace std;

int main()
{

sf::ContextSettings settings;
settings.depthBits = 24;
settings.stencilBits = 8;
settings.antialiasingLevel = 2;
settings.majorVersion = 3;
settings.minorVersion = 3;


sf::Window window(sf::VideoMode(200, 200), "SFML works!", sf::Style::Default ,settings);

glewInit();
GLfloat vertices[] = {0.0,0.5, 0.5,-0.5, -0.5, -0.5};

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

glClearColor(0.0f, 0.5f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);

glVertexAttribPointer(0,2, GL_FLOAT, GL_FALSE, 0, vertices);
glEnableVertexAttribArray(0);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableVertexAttribArray(0);

window.display();

if(glGetError() != GL_NO_ERROR)
cout << "ERROR" << endl;

else
cout << "NO ERROR" << endl;
}

return 0;
}



EDIT : just to tell everything : I installed Ubuntu today (that's why I'm doing this dummy application, to check compiler and linking) and I have no idea how it deals with drivers. Could it be linked ? I should get glewerror otherwise, isn't it ?