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 - Richy19

Pages: 1 ... 3 4 [5] 6 7 ... 13
61
Graphics / sf::Texture and OpenGL
« on: December 01, 2011, 03:22:42 am »
Do you know how you would use a sf::Texture with openGL?
The only way I can think of is converting it to a sf::Image and then
Code: [Select]
// Give the image to OpenGL
    glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, TextureResourceManager::textureResourceManager.getFile("./Data/Pedro.png").GetWidth(), TextureResourceManager::textureResourceManager.getFile("./Data/Pedro.png").GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE,TextureResourceManager::textureResourceManager.getFile("./Data/Pedro.png").CopyToImage().GetPixelsPtr() );
 

62
Graphics / sf::Texture and OpenGL
« on: November 30, 2011, 01:24:39 am »
Just wondering but does SFML mess up the openGL calls of other contexts?
I.e. can I render to a renderTarget without worrying about other openGL contexts such as the window?

63
General / Linux failed to build SFML
« on: November 21, 2011, 09:21:08 pm »
Sorry will try to cut it down as much as possible.

64
General / Linux failed to build SFML
« on: November 21, 2011, 04:35:26 pm »
Well I think this should work but it gives segmentation fault when building the shader.

Main.cpp
Code: [Select]
#include <iostream>
#include <sstream>
#include <GL/glew.h>
#include <SFML/Graphics.hpp>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "../codeblocks/Legend of Pedro/src/LoPIcon.h"
 
#include "3dSprite.hpp"
 
int main()
{
    glm::mat4 orthoMatrix;
    glm::mat4 perspectiveMatrix;
    glm::mat4 cameraMatrix;
 
    sf::RenderWindow App;
    sf::ContextSettings Settings;
    Settings.DepthBits         = 24; // Request a 24 bits depth buffer
    Settings.StencilBits       = 8;  // Request a 8 bits stencil buffer
    Settings.AntialiasingLevel = 8;  // Request 2 levels of antialiasing
    Settings.MajorVersion = 2;
    Settings.MinorVersion = 1;
 
    std::cout << "Building sprite" << std::endl;
    d3Sprite hi;
 
    if(false)//fullscreen
        App.Create(sf::VideoMode(800, 600, sf::VideoMode::GetDesktopMode().BitsPerPixel), "Legend Of Pedro", sf::Style::Fullscreen ,Settings);
    else
        App.Create(sf::VideoMode(800, 600, sf::VideoMode::GetDesktopMode().BitsPerPixel), "Legend Of Pedro", sf::Style::Default ,Settings);
 
    App.SetActive();
 
    App.EnableVerticalSync(false);
    App.SetFramerateLimit(0);
    App.ShowMouseCursor(false);
    std::cout << "Using resolution: "<< App.GetWidth() << "x" << App.GetHeight() << std::endl;
    App.SetIcon( LoPIcon.width,  LoPIcon.height,  LoPIcon.pixel_data );
 
    try
    {
        std::cout << "Using OpenGL " << App.GetSettings().MajorVersion << "." << App.GetSettings().MinorVersion << std::endl;
 
        if ((App.GetSettings().MajorVersion < Settings.MajorVersion) || (App.GetSettings().MajorVersion == Settings.MajorVersion && App.GetSettings().MinorVersion < Settings.MinorVersion))
        {
            std::cout << "Sorry but a minimum of OpenGL "<< Settings.MajorVersion <<"."<< Settings.MinorVersion <<" is required"<<std::endl;
            std::cout << "Try updating your drivers." << std::endl;
            return false;
        }
 
    }
    catch(int e)
    {
        std::cout << "Failed to get OpenGL version. " << e << std::endl;
 
        return false;
    }
    //*/
    GLenum err = glewInit();
    if (GLEW_OK != err)
    {
        // Problem: glewInit failed, something is seriously wrong.
        std::cout << "Error: " << glewGetErrorString(err) << std::endl;
        return false;
    }
    else
    {
        std::cout << "Using GLEW " << glewGetString(GLEW_VERSION) << std::endl;
    }
 
    std::cout << "Using an " << glGetString(GL_VENDOR) <<" graphics card."<< std::endl;
 
    if(8 != App.GetSettings().AntialiasingLevel)
    {
        std::cout << "Antialiasing Level of " << 8 << " was unavailable, using level " << App.GetSettings().AntialiasingLevel << " instead." << std::endl;
    }
 
 
    glEnable(GL_DEPTH_TEST);
    // Accept fragment if it closer to the camera than the former one
    glDepthFunc(GL_LESS);
    // Cull triangles which normal is not towards the camera
    glEnable(GL_CULL_FACE);
 
    glEnable (GL_BLEND);
    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
 
    float width = App.GetWidth();
    float height = App.GetHeight();
    orthoMatrix = glm::ortho<float>(0.0f, width, height, 0.0f, 0.0f, 1.0f);
    perspectiveMatrix = glm::perspective<float>(75, (width / height) ,0.1f,100.0f);
    cameraMatrix = glm::lookAt(glm::vec3(0.0f, 3.0f, 5.0f),           // Camera is here  glm::vec3( 0, 0, 5 );
                               glm::vec3(0.0f), // and looks here : at the same position, plus "direction"
                               glm::vec3( 0, 1, 0 )                 // Head is up (set to 0,-1,0 to look upside-down)
                              );
 
 
 
    hi.Initiate(&perspectiveMatrix, &cameraMatrix);
 
 
 
 
    while(App.IsOpened())
    {
        sf::Event Event;
        while (App.PollEvent(Event))
        {
            if (Event.Type == sf::Event::Closed)
                App.Close();
 
            // Escape key pressed
            //if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Escape))
            //  App.Close();
 
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::F5))
                App.Capture().SaveToFile("screenshot.png");
 
            if (Event.Type == sf::Event::Resized)
                glViewport(0, 0, Event.Size.Width, Event.Size.Height);
        }
 
        if(!App.IsOpened())  break;
 
        hi.Update(App, true);
//            Update(App.GetFrameTime()/1000.f);
 
        App.SetActive();
        glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
 
        hi.Draw();
 
        //if(gameStateManager->States()[gameStateManager->States().size() - 1] == m_GameState)
        //Draw();
        //else
        //{
        App.SaveGLStates();
        // glDisable(GL_CULL_FACE);
        glDisable(GL_DEPTH_TEST);
        glDisable(GL_BLEND);
 
 
        std::stringstream ss;
        ss << App.GetFrameTime();
        ss << " ms";
        sf::Text fps(ss.str(), sf::Font::GetDefaultFont(), 15);
        fps.SetPosition(5.0f,5.0f);
 
        App.Draw(fps);
 
 
        App.RestoreGLStates();
        // glEnable(GL_CULL_FACE);
        glEnable(GL_DEPTH_TEST);
        glEnable (GL_BLEND);
        glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
        //}
        App.Display();
    }
}


Shader.hpp
Code: [Select]
#ifndef SHADER_HPP_INCLUDE
#define SHADER_HPP_INCLUDE
#pragma once

#include <GL/glew.h>
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <glm/glm.hpp>


class Shader
{
    GLuint VertexShaderID;
    GLuint FragmentShaderID;
    std::string FragmentShaderCode;
    std::string VertexShaderCode;
public:
    Shader();
    Shader(const std::string &vertFileName, const std::string &fragFileName);
    ~Shader();
    GLuint shaderID;
    void LoadVertexShader(std::string &fileName);
    void LoadFragmentShader(std::string &fileName);
    void CompileVertexShader(GLint &Result, int &InfoLogLength);
    void CompileFragmentShader(GLint &Result, int &InfoLogLength);
};

#endif //SHADER_HPP_INCLUDE


Shader.cpp
Code: [Select]
#include "Shader.hpp"
#include <glm/glm.hpp>

Shader::Shader() {}

Shader::Shader(const std::string &vertFileName, const std::string &fragFileName)
{

    // Create the shaders
    VertexShaderID = glCreateShader(GL_VERTEX_SHADER);
    FragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);

    // Read the Vertex Shader code from the file
    std::string VertexShaderCode;
    std::ifstream VertexShaderStream(vertFileName.c_str(), std::ios::in);
    if(VertexShaderStream.is_open())
    {
        std::string Line = "";
        while(getline(VertexShaderStream, Line))
            VertexShaderCode += "\n" + Line;
        VertexShaderStream.close();
    }

    // Read the Fragment Shader code from the file
    std::string FragmentShaderCode;
    std::ifstream FragmentShaderStream(fragFileName.c_str(), std::ios::in);
    if(FragmentShaderStream.is_open())
    {
        std::string Line = "";
        while(getline(FragmentShaderStream, Line))
            FragmentShaderCode += "\n" + Line;
        FragmentShaderStream.close();
    }

    GLint Result = GL_FALSE;
    int InfoLogLength;

    // Compile Vertex Shader
    printf("Compiling shader : %s\n", vertFileName.c_str());
    char const * VertexSourcePointer = VertexShaderCode.c_str();
    glShaderSource(VertexShaderID, 1, &VertexSourcePointer , NULL);
    glCompileShader(VertexShaderID);

    // Check Vertex Shader
    glGetShaderiv(VertexShaderID, GL_COMPILE_STATUS, &Result);
    glGetShaderiv(VertexShaderID, GL_INFO_LOG_LENGTH, &InfoLogLength);
    std::vector<char> VertexShaderErrorMessage(InfoLogLength);
    glGetShaderInfoLog(VertexShaderID, InfoLogLength, NULL, &VertexShaderErrorMessage[0]);
    fprintf(stdout, "%s\n", &VertexShaderErrorMessage[0]);

    // Compile Fragment Shader
    printf("Compiling shader : %s\n", fragFileName.c_str());
    char const * FragmentSourcePointer = FragmentShaderCode.c_str();
    glShaderSource(FragmentShaderID, 1, &FragmentSourcePointer , NULL);
    glCompileShader(FragmentShaderID);

    // Check Fragment Shader
    glGetShaderiv(FragmentShaderID, GL_COMPILE_STATUS, &Result);
    glGetShaderiv(FragmentShaderID, GL_INFO_LOG_LENGTH, &InfoLogLength);
    std::vector<char> FragmentShaderErrorMessage(InfoLogLength);
    glGetShaderInfoLog(FragmentShaderID, InfoLogLength, NULL, &FragmentShaderErrorMessage[0]);
    fprintf(stdout, "%s\n", &FragmentShaderErrorMessage[0]);

    // Link the program
    fprintf(stdout, "Linking program\n");
    GLuint ProgramID = glCreateProgram();
    glAttachShader(ProgramID, VertexShaderID);
    glAttachShader(ProgramID, FragmentShaderID);
    glLinkProgram(ProgramID);

    // Check the program
    glGetProgramiv(ProgramID, GL_LINK_STATUS, &Result);
    glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, &InfoLogLength);
    std::vector<char> ProgramErrorMessage( glm::max(InfoLogLength, int(1)) );
    glGetProgramInfoLog(ProgramID, InfoLogLength, NULL, &ProgramErrorMessage[0]);
    fprintf(stdout, "%s\n", &ProgramErrorMessage[0]);

    Shader::shaderID = ProgramID;




}

Shader::~Shader()
{
    glDeleteProgram(shaderID);
    glDeleteShader(VertexShaderID);
    glDeleteShader(FragmentShaderID);
}

void Shader::LoadVertexShader(std::string &fileName)
{
    try
    {
        std::ifstream VertexShaderStream(fileName.c_str(), std::ios::in);
        if(VertexShaderStream.is_open())
        {
            std::string Line = "";
            while(getline(VertexShaderStream, Line))
                VertexShaderCode += "\n" + Line;
            VertexShaderStream.close();
        }
    }
    catch(int e)
    {
        std::cout << "Failed to open Vertex shader, using basic shader." << std::endl << e << std::endl;
        //VertexShaderCode =
    }
}

void Shader::LoadFragmentShader(std::string &fileName)
{
    try
    {
        std::ifstream FragmentShaderStream(fileName.c_str(), std::ios::in);
        if(FragmentShaderStream.is_open())
        {
            std::string Line = "";
            while(getline(FragmentShaderStream, Line))
                FragmentShaderCode += "\n" + Line;
            FragmentShaderStream.close();
        }
    }
    catch(int e)
    {
        std::cout << "Failed to open Frag shader, using basic shader." << std::endl << e << std::endl;
        FragmentShaderCode = "void main(){  gl_FragColor = vec4(1,1,1,1); }";
    }
}

void Shader::CompileVertexShader(GLint &Result, int &InfoLogLength)
{
// Compile Vertex Shader
    std::cout << "Compiling Vertex Shader" << std::endl;
    char const * VertexSourcePointer = VertexShaderCode.c_str();
    glShaderSource(VertexShaderID, 1, &VertexSourcePointer , NULL);
    glCompileShader(VertexShaderID);

    // Check Vertex Shader
    glGetShaderiv(VertexShaderID, GL_COMPILE_STATUS, &Result);
    glGetShaderiv(VertexShaderID, GL_INFO_LOG_LENGTH, &InfoLogLength);
    std::vector<char> VertexShaderErrorMessage(InfoLogLength);
    glGetShaderInfoLog(VertexShaderID, InfoLogLength, NULL, &VertexShaderErrorMessage[0]);
    std::cout << &VertexShaderErrorMessage[0] << std::endl;

}

void Shader::CompileFragmentShader(GLint &Result, int &InfoLogLength)
{
    // Compile Fragment Shader
    std::cout << "Compiling Fragment Shader" << std::endl;
    char const * FragmentSourcePointer = FragmentShaderCode.c_str();
    glShaderSource(FragmentShaderID, 1, &FragmentSourcePointer , NULL);
    glCompileShader(FragmentShaderID);

    // Check Fragment Shader
    glGetShaderiv(FragmentShaderID, GL_COMPILE_STATUS, &Result);
    glGetShaderiv(FragmentShaderID, GL_INFO_LOG_LENGTH, &InfoLogLength);
    std::vector<char> FragmentShaderErrorMessage(InfoLogLength);
    glGetShaderInfoLog(FragmentShaderID, InfoLogLength, NULL, &FragmentShaderErrorMessage[0]);
    std::cout << &FragmentShaderErrorMessage[0] << std::endl;

}


LoPIcon.h
Code: [Select]
ifndef LOPICON_H_INCLUDED
#define LOPICON_H_INCLUDED
#pragma once

static const struct
{
    unsigned int width;
    unsigned int height;
    unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */
    unsigned char pixel_data[32 * 32 * 4 + 1];
} LoPIcon =
{
    32, 32, 4,
    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\273\252|\0\273\252|\0\0\0\0\0\0\0\0\0\0"
    "\0\0\0\0\0\0\0\0\0\ ...",
};

#endif //LOPICON_H_INCLUDED


Drawable.hpp
Code: [Select]
#ifndef DRAWABLE_HPP_INCLUDE
#define DRAWABLE_HPP_INCLUDE
#pragma once

#include <glm/glm.hpp>
// glm::translate, glm::rotate, glm::scale
#include <glm/gtc/matrix_transform.hpp>
// glm::value_ptr
#include <glm/gtc/type_ptr.hpp>

#include <iostream>

class Drawable
{
protected:
    glm::mat4 *perspectiveMatrix;
    glm::mat4 *cameraMatrix;

    glm::mat4 MVP;
    void printMat4x4(const glm::mat4 & mat);

public:
    glm::mat4 modelMatrix;
    Drawable();
    virtual ~Drawable();
    virtual void Initiate(glm::mat4 *persMat, glm::mat4 *camMat);
    virtual void Update();
    virtual void Draw();
};

#endif
#ifndef DRAWABLE_HPP_INCLUDE
#define DRAWABLE_HPP_INCLUDE
#pragma once

#include <glm/glm.hpp>
// glm::translate, glm::rotate, glm::scale
#include <glm/gtc/matrix_transform.hpp>
// glm::value_ptr
#include <glm/gtc/type_ptr.hpp>

#include <iostream>

class Drawable
{
protected:
    glm::mat4 *perspectiveMatrix;
    glm::mat4 *cameraMatrix;

    glm::mat4 MVP;
    void printMat4x4(const glm::mat4 & mat);

public:
    glm::mat4 modelMatrix;
    Drawable();
    virtual ~Drawable();
    virtual void Initiate(glm::mat4 *persMat, glm::mat4 *camMat);
    virtual void Update();
    virtual void Draw();
};

#endif[/code]

Drawable.cpp
Code: [Select]
#include "Drawable.hpp"

Drawable::Drawable()
{

}

Drawable::~Drawable()
{

}

void Drawable::Initiate(glm::mat4 *persMat, glm::mat4 *camMat)
{
    perspectiveMatrix = persMat;
    cameraMatrix = camMat;
    modelMatrix = glm::mat4(1.0f);

    MVP = (*perspectiveMatrix) * (*cameraMatrix) * modelMatrix;
}

void Drawable::Update()
{
    MVP = (*perspectiveMatrix) * (*cameraMatrix) * modelMatrix;
}

void Drawable::Draw()
{

}

void Drawable::printMat4x4(const glm::mat4 & mat)
{
    std::cout << mat[0].x << "|" << mat[0].y << "|" << mat[0].z << "|" << mat[0].w << std::endl;
    std::cout << mat[1].x << "|" << mat[1].y << "|" << mat[1].z << "|" << mat[1].w << std::endl;
    std::cout << mat[2].x << "|" << mat[2].y << "|" << mat[2].z << "|" << mat[2].w << std::endl;
    std::cout << mat[3].x << "|" << mat[3].y << "|" << mat[3].z << "|" << mat[3].w << std::endl;
}


Quad.hpp
Code: [Select]
#ifndef QUAD_HPP_INCLUDE
#define QUAD_HPP_INCLUDE
#pragma once

#include <GL/glew.h>
#include <glm/glm.hpp>

class Quad
{
protected:
    GLfloat vertexList[3*6];
    // This will identify our vertex buffer
    GLuint vertexbuffer;
public:
    Quad();
    Quad(glm::vec3 *eVertexList);
    ~Quad();
    void Initiate();
    void Draw();

};

#endif


Quad.cpp
Code: [Select]
#include "Quad.hpp"

Quad::Quad()
{
    vertexList[0] = 0.5f;
    vertexList[1] = 1.0f;
    vertexList[2] = 0.0f;

    vertexList[3] = -0.5f;
    vertexList[4] = 1.0f;
    vertexList[5] = 0.0f;

    vertexList[6] = -0.5f;
    vertexList[7] = 0.0f;
    vertexList[8] = 0.0f;

    vertexList[9] = 0.5f;
    vertexList[10] = 1.0f;
    vertexList[11] = 0.0f;

    vertexList[12] = -0.5f;
    vertexList[13] = 0.0f;
    vertexList[14] = 0.0f;

    vertexList[15] = 0.5f;
    vertexList[16] = 0.0f;
    vertexList[17] = 0.0f;

    // Generate 1 buffer, put the resulting identifier in vertexbuffer
    glGenBuffers(1, &vertexbuffer);

    // The following commands will talk about our 'vertexbuffer' buffer
    glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);

    // Give our vertices to OpenGL.
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertexList), vertexList, GL_STATIC_DRAW);
}

Quad::Quad(glm::vec3 *eVertexList)
{
    vertexList[0] = eVertexList[0].x;
    vertexList[1] = eVertexList[0].y;
    vertexList[2] = eVertexList[0].z;

    vertexList[3] = eVertexList[1].x;
    vertexList[4] = eVertexList[1].y;
    vertexList[5] = eVertexList[1].z;

    vertexList[6] = eVertexList[2].x;
    vertexList[7] = eVertexList[2].y;
    vertexList[8] = eVertexList[2].z;

    vertexList[9] = eVertexList[3].x;
    vertexList[10] = eVertexList[3].y;
    vertexList[11] = eVertexList[3].z;

    vertexList[12] = eVertexList[4].x;
    vertexList[13] = eVertexList[4].y;
    vertexList[14] = eVertexList[4].z;

    vertexList[15] = eVertexList[5].x;
    vertexList[16] = eVertexList[5].y;
    vertexList[17] = eVertexList[5].z;
}

Quad::~Quad()
{

}

void Quad::Initiate()
{

}

void Quad::Draw()
{

}


d3Sprite.hpp
Code: [Select]
#ifndef D3SPRITE_HPP_INCLUDED
#define D3SPRITE_HPP_INCLUDED
#pragma once

#include <GL/glew.h>
#include <SFML/Graphics.hpp>
#include <glm/glm.hpp>
// glm::translate, glm::rotate, glm::scale
#include <glm/gtc/matrix_transform.hpp>
// glm::value_ptr
#include <glm/gtc/type_ptr.hpp>

#include "./Drawable.hpp"
#include "../codeblocks/Legend of Pedro/src/Shader.hpp"


class d3Sprite : public Drawable
{
public:
    d3Sprite(glm::vec3 pos = glm::vec3(0.0f));
    ~d3Sprite();
    virtual void Initiate(glm::mat4 *persMat, glm::mat4 *camMat);
    virtual void Update(sf::RenderWindow &App, bool blah = false);
    virtual void Draw();

    glm::vec3 position;
    glm::vec3 rotation;
private:
    GLuint MatrixID;
    GLuint positionID;
    GLuint UVID;
    GLuint AlphaID;
    GLfloat alphaAmount;
    Shader shader;
    GLfloat vertexList[3*6];
    GLfloat UVList[6*2];
    // This will identify our vertex buffer
    GLuint vertexbuffer;
    GLuint texturebuffer;
    GLuint uvbuffer;
    GLuint TextureID;
    glm::vec3 mRotation;
    glm::vec3 mPosition;
    bool rotating;

};

#endif


d3Sprite.cpp
Code: [Select]
#include "./3dSprite.hpp"
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/transform.hpp>
#include <math.h>

d3Sprite::d3Sprite( glm::vec3 pos)
{



std::cout << "Building shader" << std::endl;
    shader = Shader("./vert.vert" ,"./frag.frag");


std::cout << "Building img" << std::endl;
    sf::Image img;
    img.LoadFromFile("./pedro.png");

    position = pos;
    mPosition = glm::vec3(0.0f);
    alphaAmount = 0.0f;
    rotation = glm::vec3(0.0f);
    mRotation = glm::vec3(0.0f);
    rotating = false;

    //img.FlipVertically();
    UVList[0] = 1.0f;
    UVList[1] = 0.0f;

    UVList[2] = 0.0f;
    UVList[3] = 0.0f;

    UVList[4] = 0.0f;
    UVList[5] = 1.0f;

    UVList[6] = 1.0f;
    UVList[7] = 0.0f;

    UVList[8] = 0.0f;
    UVList[9] = 1.0f;

    UVList[10] = 1.0f;
    UVList[11] = 1.0f;

    vertexList[0] = 0.5f;
    vertexList[1] = 1.0f;
    vertexList[2] = 0.0f;

    vertexList[3] = -0.5f;
    vertexList[4] = 1.0f;
    vertexList[5] = 0.0f;

    vertexList[6] = -0.5f;
    vertexList[7] = 0.0f;
    vertexList[8] = 0.0f;

    vertexList[9] = 0.5f;
    vertexList[10] = 1.0f;
    vertexList[11] = 0.0f;

    vertexList[12] = -0.5f;
    vertexList[13] = 0.0f;
    vertexList[14] = 0.0f;

    vertexList[15] = 0.5f;
    vertexList[16] = 0.0f;
    vertexList[17] = 0.0f;


std::cout << "Building buffers" << std::endl;

    // Generate 1 buffer, put the resulting identifier in vertexbuffer
    glGenBuffers(1, &vertexbuffer);

    // The following commands will talk about our 'vertexbuffer' buffer
    glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);

    // Give our vertices to OpenGL.
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertexList), vertexList, GL_STATIC_DRAW);

    MatrixID = glGetUniformLocation(shader.shaderID, "MVP");
    AlphaID = glGetUniformLocation(shader.shaderID, "Alpha");

    positionID = glGetAttribLocation(shader.shaderID, "Position");
    TextureID  = glGetUniformLocation(shader.shaderID, "myTexture");
    UVID = glGetAttribLocation(shader.shaderID, "UV");

    glGenBuffers(1, &uvbuffer);
    glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(UVList), UVList, GL_STATIC_DRAW);



    glGenTextures(1, &texturebuffer);

    // "Bind" the newly created texture : all future texture functions will modify this texture
    glBindTexture(GL_TEXTURE_2D, texturebuffer);

    // Give the image to OpenGL
    glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, img.GetWidth(), img.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE,img.GetPixelsPtr() );

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);


}

d3Sprite::~d3Sprite()
{
    // Cleanup VBO and shader
    glDeleteBuffers(1, &vertexbuffer);
    glDeleteBuffers(1, &uvbuffer);
    glDeleteTextures(1, &texturebuffer);

}

void d3Sprite::Initiate(glm::mat4 *persMat, glm::mat4 *camMat)
{
    Drawable::Initiate(persMat, camMat);
}

void d3Sprite::Update(sf::RenderWindow &App, bool blah )
{

    if(alphaAmount < 0.0f) alphaAmount = 0.0f;
    if(alphaAmount > 1.0f) alphaAmount = 1.0f;




    if(rotation.y > 1.0f)
    {
        rotating = true;
        rotation.y -= 0.5f * App.GetFrameTime();
        mRotation.y += 0.5f * App.GetFrameTime();
    }
    else if(rotation.y < -1.0f)
    {
        rotating = true;
        rotation.y += 0.5f * App.GetFrameTime();
        mRotation.y -= 0.5f * App.GetFrameTime();
    }
    else
    {
        mRotation.y += rotation.y;
        rotation.y = 0.0f;

        rotating = false;


    }

    if(rotating == false) mPosition = position;
    else position = mPosition;






    glm::mat4 modelTranslate = glm::translate( glm::mat4(1.0f), mPosition) ;
    glm::mat4 modelRotate = glm::rotate(  glm::mat4(1.0f), mRotation.y, glm::vec3(0.0f, 1.0f, 0.0f));


    modelMatrix = (modelTranslate * modelRotate) * modelRotate;


    if(blah)
    {


        /*glm::mat4 camTranslate = glm::translate( modelTranslate ,   glm::vec3(0.0f, 3.0f, 5.0f) );

        glm::mat4 lookAtCam = glm::lookAt(
        glm::vec3(0.0f, 3.0f, 5.0f),           // Camera is here  glm::vec3( 0, 0, 5 );
        glm::vec3(0.0f), // and looks here : at the same position, plus "direction"
        glm::vec3( 0, 1, 0 )                 // Head is up (set to 0,-1,0 to look upside-down)
        );

        glm::mat4 camRotate = glm::rotate(  glm::mat4(1.0f) , mRotation.y * -1, glm::vec3(0.0f, 1.0f, 0.0f));

        engine->cameraMatrix = modelTranslate * lookAtCam * camRotate;// camRotate;// (camTranslate);
        */

        if((((int)(mRotation.y / 90.0f)) % 2) == 0)
        {
            *cameraMatrix = glm::lookAt(
                                       mPosition + glm::vec3(0.0f, 3.0f, 5.0f),           // Camera is here  glm::vec3( 0, 0, 5 );
                                       mPosition, // and looks here : at the same position, plus "direction"
                                       glm::vec3( 0, 1, 0 )                 // Head is up (set to 0,-1,0 to look upside-down)
                                   );
        }
        else
        {
            *cameraMatrix = glm::lookAt(
                                       mPosition + glm::vec3(0.0f, 3.0f, -5.0f),           // Camera is here  glm::vec3( 0, 0, 5 );
                                       mPosition, // and looks here : at the same position, plus "direction"
                                       glm::vec3( 0, 1, 0 )                 // Head is up (set to 0,-1,0 to look upside-down)
                                   );
        }


    }

    Drawable::Update();
    modelMatrix = glm::mat4(1.0f);
}

void d3Sprite::Draw()
{

    glUseProgram(shader.shaderID);

    glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
    glUniform1f(AlphaID , alphaAmount);
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, texturebuffer);
    glUniform1i(TextureID, 0);

    // 1rst attribute buffer : vertices
    glEnableVertexAttribArray(positionID);
    glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
    glVertexAttribPointer(
        positionID,                  // attribute 0. No particular reason for 0, but must match the layout in the shader.
        3,                  // size
        GL_FLOAT,           // type
        GL_FALSE,           // normalized?
        0,                  // stride
        (void*)0            // array buffer offset
    );


    // 2nd attribute buffer : UVs
    glEnableVertexAttribArray(UVID);
    glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
    glVertexAttribPointer(
        UVID,                                // attribute. No particular reason for 1, but must match the layout in the shader.
        2,                                // size : U+V => 2
        GL_FLOAT,                         // type
        GL_FALSE,                         // normalized?
        0,                                // stride
        (void*)0                          // array buffer offset
    );

    // Send our transformation to the currently bound shader,
    // in the "MVP" uniform
    // For each model you render, since the MVP will be different (at least the M part)
    // Draw the triangle !
    glDrawArrays(GL_TRIANGLES, 0, 6); // Starting from vertex 0; 3 vertices total -> 1 triangle

    glDisableVertexAttribArray(UVID);
    glDisableVertexAttribArray(positionID);


}

65
General / Linux failed to build SFML
« on: November 21, 2011, 03:36:33 pm »
Appart from the shader exampple which gives a seg fault they all work fine.

just to check this is correctly setup right?
Code: [Select]
bool Engine::SetupOpenGL()
{
    sf::ContextSettings Settings;
    Settings.DepthBits         = 24; // Request a 24 bits depth buffer
    Settings.StencilBits       = 8;  // Request a 8 bits stencil buffer
    Settings.AntialiasingLevel = WindowSettings::AntiAliasing;  // Request 2 levels of antialiasing
    Settings.MajorVersion = 2;
    Settings.MinorVersion = 1;



    if(WindowSettings::FullScreen)
        App.Create(sf::VideoMode(WindowSettings::WindowWidth, WindowSettings::WindowHeight, 32), "LOP", sf::Style::Fullscreen ,Settings);
    else
        App.Create(sf::VideoMode(WindowSettings::WindowWidth, WindowSettings::WindowHeight, 32), "LOP", sf::Style::Default ,Settings);

    App.SetActive();

    WindowSettings::WindowWidth = App.GetWidth();
    WindowSettings::WindowHeight = App.GetHeight();
    WindowSettings::AntiAliasing = App.GetSettings().AntialiasingLevel;

    App.EnableVerticalSync(WindowSettings::VSync);
    App.SetFramerateLimit(WindowSettings::FrameRateLimit);
    App.ShowMouseCursor(false);
    std::cout << "Using resolution: "<< App.GetWidth() << "x" << App.GetHeight() << std::endl;
    App.SetIcon( LoPIcon.width,  LoPIcon.height,  LoPIcon.pixel_data );

    try
    {
        std::cout << "Using OpenGL " << App.GetSettings().MajorVersion << "." << App.GetSettings().MinorVersion << std::endl;

        if ((App.GetSettings().MajorVersion < Settings.MajorVersion) || (App.GetSettings().MajorVersion == Settings.MajorVersion && App.GetSettings().MinorVersion < Settings.MinorVersion))
        {
            std::cout << "Sorry but a minimum of OpenGL "<< Settings.MajorVersion <<"."<< Settings.MinorVersion <<" is required"<<std::endl;
            std::cout << "Try updating your drivers." << std::endl;
            return false;
        }

    }
    catch(int e)
    {
        std::cout << "Failed to get OpenGL version. " << e << std::endl;

        return false;
    }
    //*/
    GLenum err = glewInit();
    if (GLEW_OK != err)
    {
        // Problem: glewInit failed, something is seriously wrong.
        std::cout << "Error: " << glewGetErrorString(err) << std::endl;
        return false;
    }
    else
    {
        std::cout << "Using GLEW " << glewGetString(GLEW_VERSION) << std::endl;
    }

    std::cout << "Using an " << glGetString(GL_VENDOR) <<" graphics card."<< std::endl;

    if(WindowSettings::AntiAliasing != App.GetSettings().AntialiasingLevel)
    {
        std::cout << "Antialiasing Level of " << WindowSettings::AntiAliasing << " was unavailable, using level " << App.GetSettings().AntialiasingLevel << " instead." << std::endl;
    }


    glEnable(GL_DEPTH_TEST);
    // Accept fragment if it closer to the camera than the former one
    glDepthFunc(GL_LESS);
    // Cull triangles which normal is not towards the camera
    glEnable(GL_CULL_FACE);

    glEnable (GL_BLEND);
    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);


    return true;
}

66
General / Linux failed to build SFML
« on: November 21, 2011, 02:53:53 pm »
I seem to be getting the same error I got a while back again, the window doesnt draw/redraw. This only happens on linux..

This time I ran valgrind to see if I can spot anything this is the log:

Code: [Select]
==30830== Memcheck, a memory error detector
==30830== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==30830== Using Valgrind-3.6.1-Debian and LibVEX; rerun with -h for copyright info
==30830== Command: /home/richy/codeblocks/LoP/bin/Debug/LoP
==30830==
==30830== Invalid read of size 4
==30830==    at 0x04c730f2: _mesa_make_extension_string (in /usr/lib/i386-linux-gnu/dri/libdricore.so)
==30830==    by 0x04c4d5f7: _mesa_make_current (in /usr/lib/i386-linux-gnu/dri/libdricore.so)
==30830==    by 0x04b73850: intelMakeCurrent (in /usr/lib/i386-linux-gnu/dri/i965_dri.so)
==30830==    by 0x04b6796e: ??? (in /usr/lib/i386-linux-gnu/dri/i965_dri.so)
==30830==    Address 0x484f3c8 is 0 bytes inside a block of size 1 alloc'd
==30830==    at 0x0402732c: calloc (vg_replace_malloc.c:467)
==30830==    by 0x04c732be: _mesa_make_extension_string (in /usr/lib/i386-linux-gnu/dri/libdricore.so)
==30830==    by 0x04c4d5f7: _mesa_make_current (in /usr/lib/i386-linux-gnu/dri/libdricore.so)
==30830==    by 0x04b73850: intelMakeCurrent (in /usr/lib/i386-linux-gnu/dri/i965_dri.so)
==30830==
==30830== Invalid write of size 4
==30830==    at 0x04ced6a2: ??? (in /usr/lib/i386-linux-gnu/dri/libdricore.so)
==30830==    by 0x04cee5d4: _mesa_texstore (in /usr/lib/i386-linux-gnu/dri/libdricore.so)
==30830==    by 0x04b86c5f: ??? (in /usr/lib/i386-linux-gnu/dri/i965_dri.so)
==30830==    by 0x04b8717a: ??? (in /usr/lib/i386-linux-gnu/dri/i965_dri.so)
==30830==    Address 0xb7855000 is not stack'd, malloc'd or (recently) free'd
==30830==
==30830== Syscall param writev(vector[...]) points to uninitialised byte(s)
==30830==    at 0x04321d84: writev (writev.c:51)
==30830==    by 0x00040004: ???
==30830==    Address 0x6ec2f9c is 36 bytes inside a block of size 16,384 alloc'd
==30830==    at 0x0402732c: calloc (vg_replace_malloc.c:467)
==30830==    by 0x04594551: XOpenDisplay (in /usr/lib/i386-linux-gnu/libX11.so.6.3.0)
==30830==    by 0x041080d0: sf::priv::WindowImplX11::WindowImplX11(sf::VideoMode, std::string const&, unsigned long) (WindowImplX11.cpp:114)
==30830==    by 0x04103524: sf::priv::WindowImpl::New(sf::VideoMode, std::string const&, unsigned int) (WindowImpl.cpp:60)
==30830==
==30830== Mismatched free() / delete / delete []
==30830==    at 0x04027c02: free (vg_replace_malloc.c:366)
==30830==    by 0x0458cb18: ??? (in /usr/lib/i386-linux-gnu/libX11.so.6.3.0)
==30830==    by 0x0410322a: sf::Window::SetIcon(unsigned int, unsigned int, unsigned char const*) (Window.cpp:288)
==30830==    by 0x080585c4: Engine::SetupOpenGL() (Engine.cpp:94)
==30830==    Address 0x8bae388 is 0 bytes inside a block of size 4,096 alloc'd
==30830==    at 0x04027f65: operator
==30830==    by 0x041089b6: sf::priv::WindowImplX11::SetIcon(unsigned int, unsigned int, unsigned char const*) (WindowImplX11.cpp:352)
==30830==    by 0x0410322a: sf::Window::SetIcon(unsigned int, unsigned int, unsigned char const*) (Window.cpp:288)
==30830==    by 0x080585c4: Engine::SetupOpenGL() (Engine.cpp:94)
==30830==
==30830== Invalid read of size 4
==30830==    at 0x04cca9d4: ??? (in /usr/lib/i386-linux-gnu/dri/libdricore.so)
==30830==    by 0x04cd5bba: _mesa_get_teximage (in /usr/lib/i386-linux-gnu/dri/libdricore.so)
==30830==    by 0x04b84fe7: ??? (in /usr/lib/i386-linux-gnu/dri/i965_dri.so)
==30830==    by 0x04cd6995: _mesa_GetnTexImageARB (in /usr/lib/i386-linux-gnu/dri/libdricore.so)
==30830==    Address 0xb7853000 is not stack'd, malloc'd or (recently) free'd
==30830==
==30830== Invalid write of size 4
==30830==    at 0x04ced6a2: ??? (in /usr/lib/i386-linux-gnu/dri/libdricore.so)
==30830==    by 0x04cee5d4: _mesa_texstore (in /usr/lib/i386-linux-gnu/dri/libdricore.so)
==30830==    by 0x04b8555c: ??? (in /usr/lib/i386-linux-gnu/dri/i965_dri.so)
==30830==    by 0x04b862ca: ??? (in /usr/lib/i386-linux-gnu/dri/i965_dri.so)
==30830==    Address 0xb7852000 is not stack'd, malloc'd or (recently) free'd
==30830==
==30830== Conditional jump or move depends on uninitialised value(s)
==30830==    at 0x04075609: sf::Renderer::SetShader(sf::Shader const*) (Renderer.cpp:255)
==30830==    by 0x040770dc: sf::RenderTarget::Draw(sf::Drawable const&) (RenderTarget.cpp:83)
==30830==    by 0x0805e6d4: IntroState::DrawSFML() (IntroState.cpp:86)
==30830==    by 0x0805d880: IGameStateManager::DrawSFML() (IGameStateManager.cpp:93)
==30830==
==30830== Conditional jump or move depends on uninitialised value(s)
==30830==    at 0x0407510d: sf::Renderer::SetBlendMode(sf::Blend::Mode) (Renderer.cpp:190)
==30830==    by 0x0405c965: sf::Drawable::Draw(sf::RenderTarget&, sf::Renderer&)
==30830==    by 0x040770f8: sf::RenderTarget::Draw(sf::Drawable const&) (RenderTarget.cpp:86)
==30830==    by 0x0805e6d4: IntroState::DrawSFML() (IntroState.cpp:86)
==30830==
==30830== Conditional jump or move depends on uninitialised value(s)
==30830==    at 0x040754e1: sf::Renderer::SetTexture(sf::Texture const*) (Renderer.cpp:236)
==30830==    by 0x0407f289: sf::Sprite::Render(sf::RenderTarget&, sf::Renderer&)
==30830==    by 0x0405c985: sf::Drawable::Draw(sf::RenderTarget&, sf::Renderer&)
==30830==    by 0x040770f8: sf::RenderTarget::Draw(sf::Drawable const&) (RenderTarget.cpp:86)
==30830==

67
General / Linux failed to build SFML
« on: November 21, 2011, 12:49:40 pm »
Thought i would add to this instead of making a new thread, when I use dynamic linkng on linux i get:

error while loading shared libraries: libsfml-graphics-d.so.2: cannot open shared object file: No such file or directory

The only thing I have been able to do to fix it is to delete all the syslink librarie and rename the originals. Is there anything that can be done?

68
General / Linux failed to build SFML
« on: November 21, 2011, 02:40:42 am »
Runing make I get the following error:

Quote
/home/richy/Desktop/LaurentGomila-SFML-ac16c85/src/SFML/Network/Unix/SocketImpl.cpp:39:13: error: prototype for ‘sockaddr_in sf::priv::SocketImpl::CreateAddress(sf::Uint32, short unsigned int)’ does not match any in class ‘sf::priv::SocketImpl’
/home/richy/Desktop/LaurentGomila-SFML-ac16c85/src/SFML/Network/Unix/SocketImpl.hpp:68:24: error: candidate is: static sockaddr_in sf::priv::SocketImpl::CreateAddress(long unsigned int, short unsigned int)
make[2]: *** [src/SFML/Network/CMakeFiles/sfml-network.dir/Unix/SocketImpl.cpp.o] Error 1
make[1]: *** [src/SFML/Network/CMakeFiles/sfml-network.dir/all] Error 2
make: *** [all] Error 2

69
Graphics / sf::Texture and OpenGL
« on: November 18, 2011, 07:38:44 pm »
I thought that calling copytoimage would make it unavailable for openGL textures

70
Graphics / sf::Texture and OpenGL
« on: November 18, 2011, 03:06:38 pm »
Also just wondering but does this mean I cant render stuff to a rendertarget via SFML functions and then draw the rendertarget onto an openGL quad?

71
Graphics / sf::Texture and OpenGL
« on: November 18, 2011, 02:51:23 pm »
Ohhh, thats the problem.
I was usig this as a reference which states the bottom left as 0,0
Thanks :)


72
Graphics / sf::Texture and OpenGL
« on: November 18, 2011, 11:53:26 am »
Ahh that fixed it, however the image is upside down.
Is there a reason for this do you know?

73
Graphics / sf::Texture and OpenGL
« on: November 18, 2011, 03:38:10 am »
trying to use SFML to load images and to use with OpenGL textures, but when I draw the quad its just black.
I know the UV is right so im pretty sure its the texture its self.

The main problem is im not sure how I should be using sf::Texture in an openGL way

Code: [Select]

#include "./3dSprite.hpp"

#include "./Engine.hpp"


d3Sprite::d3Sprite(Engine *mEngine)
{
engine = mEngine;
shader = new Shader("./Data/vert.vert" ,"./Data/frag.frag");

UVList[0] = 1.0f;
UVList[1] = 1.0f;

UVList[2] = 0.0f;
UVList[3] = 1.0f;

UVList[4] = 0.0f;
UVList[5] = 0.0f;

UVList[6] = 1.0f;
UVList[7] = 1.0f;

UVList[8] = 0.0f;
UVList[9] = 0.0f;

UVList[10] = 1.0f;
UVList[11] = 0.0f;

vertexList[0] = 0.5f;
vertexList[1] = 1.0f;
vertexList[2] = 0.0f;

vertexList[3] = -0.5f;
vertexList[4] = 1.0f;
vertexList[5] = 0.0f;

vertexList[6] = -0.5f;
vertexList[7] = 0.0f;
vertexList[8] = 0.0f;

vertexList[9] = 0.5f;
vertexList[10] = 1.0f;
vertexList[11] = 0.0f;

vertexList[12] = -0.5f;
vertexList[13] = 0.0f;
vertexList[14] = 0.0f;

vertexList[15] = 0.5f;
vertexList[16] = 0.0f;
vertexList[17] = 0.0f;
 
// Generate 1 buffer, put the resulting identifier in vertexbuffer
glGenBuffers(1, &vertexbuffer);
 
// The following commands will talk about our 'vertexbuffer' buffer
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
 
// Give our vertices to OpenGL.
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexList), vertexList, GL_STATIC_DRAW);

MatrixID = glGetUniformLocation(shader->shaderID, "MVP");
    positionID = glGetAttribLocation(shader->shaderID, "Position");
TextureID  = glGetUniformLocation(shader->shaderID, "myTexture");
UVID = glGetAttribLocation(shader->shaderID, "UV");

//std::cout << MatrixID << ":" << positionID << ":" << TextureID << ":" << UVID << std::endl;
//TextureID prints out 65526 for some reason


glGenBuffers(1, &uvbuffer);
    glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(UVList), UVList, GL_STATIC_DRAW);



glGenTextures(1, &texturebuffer);
 
// "Bind" the newly created texture : all future texture functions will modify this texture
glBindTexture(GL_TEXTURE_2D, texturebuffer);
 
// Give the image to OpenGL
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, TextureResourceManager::textureResourceManager.getFile("./Data/Pedro.png").GetWidth(), TextureResourceManager::textureResourceManager.getFile("./Data/Pedro.png").GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE,TextureResourceManager::textureResourceManager.getFile("./Data/Pedro.png").CopyToImage().GetPixelsPtr() );
 
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);


}

d3Sprite::~d3Sprite()
{
// Cleanup VBO and shader
    glDeleteBuffers(1, &vertexbuffer);
    glDeleteBuffers(1, &uvbuffer);
glDeleteTextures(1, &texturebuffer);
delete shader;
}

void d3Sprite::Initiate(glm::mat4 *persMat, glm::mat4 *camMat)
{


*camMat =  glm::lookAt(
glm::vec3( 0, 0, 5 ),           // Camera is here  glm::vec3( 0, 0, 5 );
glm::vec3( 0, 0, 0 ), // and looks here : at the same position, plus "direction"
glm::vec3( 0, 1, 0 )                 // Head is up (set to 0,-1,0 to look upside-down)
);


Drawable::Initiate(persMat, camMat);
}

void d3Sprite::Update(float deltaTime)
{
Drawable::Update();
}

void d3Sprite::Draw()
{

glUseProgram(shader->shaderID);

glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);

glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, texturebuffer);
    glUniform1i(TextureID, 0);

// 1rst attribute buffer : vertices
    glEnableVertexAttribArray(positionID);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
  positionID,                  // attribute 0. No particular reason for 0, but must match the layout in the shader.
  3,                  // size
  GL_FLOAT,           // type
  GL_FALSE,           // normalized?
  0,                  // stride
  (void*)0            // array buffer offset
);
 

// 2nd attribute buffer : UVs
                glEnableVertexAttribArray(UVID);
                glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
                glVertexAttribPointer(
                        UVID,                                // attribute. No particular reason for 1, but must match the layout in the shader.
                        2,                                // size : U+V => 2
                        GL_FLOAT,                         // type
                        GL_FALSE,                         // normalized?
                        0,                                // stride
                        (void*)0                          // array buffer offset
                );

// Send our transformation to the currently bound shader,
// in the "MVP" uniform
// For each model you render, since the MVP will be different (at least the M part)
    // Draw the triangle !
    glDrawArrays(GL_TRIANGLES, 0, 6); // Starting from vertex 0; 3 vertices total -> 1 triangle

glDisableVertexAttribArray(UVID);
    glDisableVertexAttribArray(positionID);


}

74
Graphics / 3d ~ Or SFML + Irrlicht
« on: November 17, 2011, 08:31:47 pm »
If anything it would probably be easier to implement what you need from SFML in irrlitch

75
Graphics / GL_INVALID_VALUE, when using SaveGLStates
« on: November 17, 2011, 07:37:40 pm »
In that case it must be something to do with my OpenGL, i do have a suspicion that its to do with the shaders or somehting.

Pages: 1 ... 3 4 [5] 6 7 ... 13