1. Post #1761
    Gold Member
    Naelstrom's Avatar
    June 2010
    2,758 Posts
    Hey guys, I'm currently working on Overv's openGL tutorial but when I run his drawing section's source code I get these annoying errors:

    1>main.obj : error LNK2001: unresolved external symbol ___glewDeleteVertexArrays
    1>main.obj : error LNK2001: unresolved external symbol ___glewBindFragDataLocation
    1>main.obj : error LNK2001: unresolved external symbol ___glewBindVertexArray
    1>main.obj : error LNK2001: unresolved external symbol ___glewGenVertexArrays

    When I comment them out, the program works fine.

    Still, any help?
    You need to link to the glew library. In linux you just compile with the -lglew flag, but I can't quite remember how to do it in windows. All I remember is that it was hell to do so.

    Good luck. :u
    Reply With Quote Edit / Delete Linux United States Show Events

  2. Post #1762
    Gold Member
    ShaunOfTheLive's Avatar
    November 2007
    9,905 Posts
    You need to link to the glew library. In linux you just compile with the -lglew flag, but I can't quite remember how to do it in windows. All I remember is that it was hell to do so.

    Good luck. :u
    Depends which Windows IDE/compiler you're using. If you're using a sane one like Code::Blocks/MinGW, you also just add -lglew. If, on the other hand, you're using Visual Studio, godspeed and may heaven have mercy on your soul.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events Informative Informative x 1 (list)

  3. Post #1763
    quality poster
    Dennab
    August 2009
    12,242 Posts
    Hey guys, I'm currently working on Overv's openGL tutorial but when I run his drawing section's source code I get these annoying errors:

    1>main.obj : error LNK2001: unresolved external symbol ___glewDeleteVertexArrays
    1>main.obj : error LNK2001: unresolved external symbol ___glewBindFragDataLocation
    1>main.obj : error LNK2001: unresolved external symbol ___glewBindVertexArray
    1>main.obj : error LNK2001: unresolved external symbol ___glewGenVertexArrays

    When I comment them out, the program works fine.

    Still, any help?
    gotta link glfw

    if youre using visual studio its like

    #pragma comment(lib, "glew.lib")

    or something

    Edited:

    #pragma comment(lib, "glew32.lib")

    and make sure you have glew in your library path
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  4. Post #1764
    Exxon's Avatar
    January 2012
    347 Posts
    My friend is using Norton antivirus, and I have tried compiling my C++ program in Dev-C++ and Code::Blocks and both of them make him detect my application as a virus and automatically remove it.

    What is baffling about this, is that I barely even know C++ and my code is extremely simple. I just wanted to send him the .exe to see if he could run it.

    I did an online scan, and 1/20 anti virusus detected it (forgot which one, it was a weird one) norton wasn't on the list though.

    http://pastebin.com/HttT4pid

    That's the entire code, all in main.cpp

    Any help would be great. Just curious as to why my simple c++ experiments are harboring virusus serious enough to need automatic deletion.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  5. Post #1765

    January 2012
    133 Posts
    Have you tried a simple hello world program? Or compiling on an another machine? If the antivirus doesn't complain about hello world it may be file system requests. Then you would only have to comment some lines one by one to pinpoint a cause.

    Also, I recommend you not to use dev-c++ it's pretty dead and it's libraries and headers are quite old. You can compare them to code::blocks' ones
    Reply With Quote Edit / Delete Russian Federation Show Events

  6. Post #1766
    ArgvCompany's Avatar
    June 2012
    549 Posts
    Can anyone critique this BubbleSort demo and if there are any more optimizations I can add to it apart from "use quicksort".

    It currently runs in about 9.544s
    Not necessarily an optimization, but you're hardcoding the size of the array in the completion percent mechanism at the same time as you're passing it in for another part of the algorithm. Pick one.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  7. Post #1767
    open.gl
    Overv's Avatar
    February 2007
    7,431 Posts
    Hey guys, I'm currently working on Overv's openGL tutorial but when I run his drawing section's source code I get these annoying errors:

    1>main.obj : error LNK2001: unresolved external symbol ___glewDeleteVertexArrays
    1>main.obj : error LNK2001: unresolved external symbol ___glewBindFragDataLocation
    1>main.obj : error LNK2001: unresolved external symbol ___glewBindVertexArray
    1>main.obj : error LNK2001: unresolved external symbol ___glewGenVertexArrays

    When I comment them out, the program works fine.

    Still, any help?
    Link with glew32s.lib and make sure to #define GLEW_STATIC before including GLEW.
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events

  8. Post #1768
    Gold Member
    conman420's Avatar
    January 2007
    1,795 Posts
    Anyone know why this is refusing to compile? I am forward declaring BaseObject in the header and then including it properly in the .cpp file but it just errors out with:


    1>c:\users\connor\documents\programming\projects\o se\ose\engine\Camera.h(9): error C2146: syntax error : missing ';' before identifier 'mTargetPos'

    No idea why I've done this kind of thing on all my other headers:

    
    #pragma once
    
    class BaseObject;
    
    class sCamera
    {
    private:
    	static BaseObject* mTarget;
    	static Vector2 mTargetPos;
    	static float mDamping;
    	static float mFollowSpeed;
    	static bool mIsFollowing;
    	static float mRot;
    	static float mZoom;
    	static float mTargetZoom;
    	static float mZoomDamping;
    	static Vector2 mCentre;
    public:
    	static void SetZoom(float z) {mTargetZoom = z;};
    	static float GetZoom() {return mZoom;};
    	static void SetZoomDamping(float z) {mZoomDamping = z;};
    	static float GetZoomDamping() {return mZoomDamping;};
    
    	static void ReSize(Vector2 Size);
    	static void SetCentre(Vector2 &pos) {mCentre = pos;};
    	static Vector2 GetCentre() {return mCentre;};
    	static void SetRotation(float rot) {mRot = rot;};
    	static float GetRotation() {return mRot;};
    	static void Rotate(float amount) {SetRotation(GetRotation() + amount);};
    	static void FollowEntity(BaseObject* ent) {mTarget=ent; mIsFollowing = true;};
    	static bool IsFollowing() {return mIsFollowing;};
    	static void SetDamping(float damp) {mDamping = damp;};
    	static float GetDamping() {return mDamping;};
    	static void UpdateView();
    };
    

    This is how I include everything in Camera.cpp:

    #include "Camera.h"
    #include "GameGlobals.h"
    #include "Bases/BaseObject.h"
    
    BaseObject* sCamera::mTarget;
    Vector2 sCamera::mTargetPos;
    float sCamera::mDamping;
    float sCamera::mFollowSpeed;
    bool sCamera::mIsFollowing;
    float sCamera::mRot;
    float sCamera::mZoom;
    float sCamera::mTargetZoom;
    float sCamera::mZoomDamping;
    Vector2 sCamera::mCentre;
    
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  9. Post #1769
    Gold Member
    BackwardSpy's Avatar
    May 2008
    6,563 Posts
    Kinda on topic; why do people find it so hard to link with stuff in Visual Studio? You just add the name of the lib file to the Linker > Inputs section of your project properties for the build configurations you want it to link on... If the library is in a non-standard directory then you add that to the relevant part of the 'VC++ Directories' section.
    It's not that difficult.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Agree Agree x 5Disagree Disagree x 1 (list)

  10. Post #1770
    Gold Member
    ShaunOfTheLive's Avatar
    November 2007
    9,905 Posts
    Anyone know why this is refusing to compile? I am forward declaring BaseObject in the header and then including it properly in the .cpp file but it just errors out with:


    1>c:\users\connor\documents\programming\projects\o se\ose\engine\Camera.h(9): error C2146: syntax error : missing ';' before identifier 'mTargetPos'

    No idea why I've done this kind of thing on all my other headers:
    Based on the position of the error, it looks like a problem with the "Vector2" type. Where/how is that declared?
    Reply With Quote Edit / Delete Canada Show Events Agree Agree x 1 (list)

  11. Post #1771
    Anthos's Avatar
    April 2012
    153 Posts
    Faggot visual c++ posted:
    error LNK2019: unresolved external symbol "class GraphicsMan __cdecl Rendering(void)" (?Rendering@@YA?AVGraphicsMan@@XZ) referenced in function "int __cdecl Load(void)" (?Load@@YAHXZ)
    D:\Documents and Settings\Fuck\My Documents\Visual Studio 2008\Projects\SS32\Debug\SSX.exe : fatal error LNK1120: 1 unresolved externals
    I've been trying to fix this damn Linker error for four hours now.



    As you can see I have everything linked though. Here's some code that might help:


    GraphicsMan.h - Graphics Manager class.
    class GraphicsMan
    {
    private:
    	sf::Image ImageBox[64]; //Images go here
    	sf::Sprite SpriteBox[64];  //Sprites go here
    	sf::Sprite RenderBox[64];  //Sprites to draw go here
    	int counter;
    public:
            GraphicsMan();
            GraphicsMan(sf::Image images[64]);
    	void LoadImages(sf::Image images[64]); //Load images into ImageBox
    };
    

    GraphicsMan.cpp - LoadImage function:
    void GraphicsMan::LoadImages(sf::Image images[64])
    {
           //Because a simple array[] = array[] doesn't work. Asshole.
    	for (int i=0;i<64;i++)
    	{
    		GraphicsMan::ImageBox[i] = images[i];
    	}
    }
    

    Main file.cpp - How I'm using it:
    GraphicsMan Rendering();
    int Load()
    {
    	sf::Image Images[64]; //Make an image array
    	Images[0].LoadFromFile("test.PNG"); //Put a single image in the first slot.
    	Rendering().LoadImages(Images); //Now load that shit.
    	return 1;
    }
    

    What the hell did I break?

    Edited:

    Could be some minor mistakes in there due to me having to rename my variables to something more SFW.
    Reply With Quote Edit / Delete Windows XP Netherlands Show Events

  12. Post #1772
    ArgvCompany's Avatar
    June 2012
    549 Posts
    Kinda on topic; why do people find it so hard to link with stuff in Visual Studio? You just add the name of the lib file to the Linker > Inputs section of your project properties for the build configurations you want it to link on... If the library is in a non-standard directory then you add that to the relevant part of the 'VC++ Directories' section.
    It's not that difficult.
    It's basically the same difficulty as Code::Blocks.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Agree Agree x 3 (list)

  13. Post #1773
    Richy19's Avatar
    May 2010
    5,411 Posts
    I've been trying to fix this damn Linker error for four hours now.



    As you can see I have everything linked though. Here's some code that might help:


    Could be some minor mistakes in there due to me having to rename my variables to something more SFW.
    you need to link graphics then window then system in that order.
    Reply With Quote Edit / Delete Linux United Kingdom Show Events Disagree Disagree x 1Dumb Dumb x 1 (list)

  14. Post #1774
    Anthos's Avatar
    April 2012
    153 Posts
    you need to link graphics then window then system in that order.
    Nope, sorry. Same error.

    Edited:

    I stand corrected:


    Error 1 error LNK2019: unresolved external symbol "class GraphicsMan __cdecl Renderer(void)" (?Renderer@@YA?AVGraphicsMan@@XZ) referenced in function "int __cdecl Load(void)" (?Load@@YAHXZ) SSX.obj
    ...Wha.
    Reply With Quote Edit / Delete Windows XP Netherlands Show Events

  15. Post #1775
    Richy19's Avatar
    May 2010
    5,411 Posts
    Im trying to be able to have multiple images in a shader with non deprecated(and glsl 120),
    frag shader being:
    #version 120
    uniform sampler2D TEXTURE0;
    uniform sampler2D TEXTURE1;
    uniform sampler2D TEXTURE2;
    uniform sampler2D TEXTURE3;
    uniform sampler2D TEXTURE4;
    uniform sampler2D TEXTURE5;
    uniform sampler2D TEXTURE6;
    
    varying vec4 position;
    varying vec2 uv;
    varying vec3 normal;
    varying float imageindex;
    
    void main()
    {
        vec4 color = vec4(1.0f, 1.0f, 1.0f, 1.0f);
        if(((int)imageindex) == 0)      color = texture2D(TEXTURE0, uv);
        if(((int)imageindex) == 1)      color = texture2D(TEXTURE1, uv);
        if(((int)imageindex) == 2)      color = texture2D(TEXTURE2, uv);
        if(((int)imageindex) == 3)      color = texture2D(TEXTURE3, uv);
        if(((int)imageindex) == 4)      color = texture2D(TEXTURE4, uv);
        if(((int)imageindex) == 5)      color = texture2D(TEXTURE5, uv);
        if(((int)imageindex) == 6)      color = texture2D(TEXTURE6, uv);
    
        gl_FragColor = color;
    }

    But I keep getting this error:
    0:19(10): error: syntax error, unexpected ')', expecting '('
    Reply With Quote Edit / Delete Linux United Kingdom Show Events

  16. Post #1776
    Team Hamster
    Mordi's Avatar
    January 2012
    312 Posts
    I'm still having trouble with OpenGL blending and framebuffers. If anyone wants to help, I've made a question on StackOverflow and made a git-repository for it.

    http://stackoverflow.com/questions/11083333
    https://github.com/Landeplage/Amigo
    Reply With Quote Edit / Delete Windows 7 Norway Show Events

  17. Post #1777
    flayne's Avatar
    January 2011
    1,628 Posts
    You need to link to the glew library. In linux you just compile with the -lglew flag, but I can't quite remember how to do it in windows. All I remember is that it was hell to do so.

    Good luck. :u
    If you're using G++ you use the -lglew flag :P.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 1Informative Informative x 1 (list)

  18. Post #1778
    Richy19's Avatar
    May 2010
    5,411 Posts
    I have this frag shader:
    
    #version 120
    uniform sampler2D TEXTURE0;
    uniform sampler2D TEXTURE1;
    uniform sampler2D TEXTURE2;
    uniform sampler2D TEXTURE3;
    uniform sampler2D TEXTURE4;
    uniform sampler2D TEXTURE5;
    uniform sampler2D TEXTURE6;
    
    varying vec4 position;
    varying vec2 uv;
    varying vec3 normal;
    varying float imageindex;
    
    void main()
    {
        vec4 color = vec4(1.0f, 1.0f, 1.0f, 1.0f);
        if(int(imageindex) == 0)      color = texture2D(TEXTURE0, uv);
        if(int(imageindex) == 1)      color = texture2D(TEXTURE1, uv);
        if(int(imageindex) == 2)      color = texture2D(TEXTURE2, uv);
        if(int(imageindex) == 3)      color = texture2D(TEXTURE3, uv);
        if(int(imageindex) == 4)      color = texture2D(TEXTURE4, uv);
        if(int(imageindex) == 5)      color = texture2D(TEXTURE5, uv);
        if(int(imageindex) == 6)      color = texture2D(TEXTURE6, uv);
    
        gl_FragColor = color;
    }
    

    And I create the images and send them to the gpu like this:
    SOGLF::Texture bitmap;
    bitmap.LoadFromFile("./Resources/"+mimg);
    bitmaps.push_back(bitmap);
    

    and

    for(int i = 0; i < bitmaps.size(); i++ )
        {
            glActiveTexture(GL_TEXTURE0 + i);
            bitmaps[i].Bind();
            std::string textureName = "TEXTURE";    textureName += SOGLF::Util::toString(i);
            glUniform1i( shader.GetUniform(textureName.c_str()) , i);
    
        }
    

    Im not getting any openGL errors however "color" gets turned into black.
    Anything im missing?
    Reply With Quote Edit / Delete Linux United Kingdom Show Events

  19. Post #1779
    Gold Member
    Naelstrom's Avatar
    June 2010
    2,758 Posts
    If you're using G++ you use the -lglew flag :P.
    Sorry, I guess I meant Visual studio c++. I wanted to gain some converts so I generalized windows.

    Which by the way, if you're still using windows and have never tried a development environment like Linux, I highly recommend it.


    I'm still having trouble with OpenGL blending and framebuffers. If anyone wants to help, I've made a question on StackOverflow and made a git-repository for it.

    http://stackoverflow.com/questions/11083333
    https://github.com/Landeplage/Amigo
    Do you have blending enabled when you clear the fbo? Sounds like opengl is blending
    glClearColor(0.0, 0.0, 0.0, 0.0);
    and none of it is reaching the buffer (because it has 0 alpha).

    You probably want to check if the frame buffer was successfully created as well using glCheckFramebufferStatus
    That's all I can think of looking at your code. You're doing lots of weird stuff, but I can't say that's wrong. Feel free to add me on steam if you want to chat.
    I have a bit of experience with FBO's from the lighting system in my game.
    Reply With Quote Edit / Delete Linux United States Show Events Friendly Friendly x 1Agree Agree x 1 (list)

  20. Post #1780
    Richy19's Avatar
    May 2010
    5,411 Posts
    I got it partially working but the image selection isnt working right.
    I made a simple example:
    #include "./Program.hpp"
    #include <iostream>
    Program::Program()
    {
        //Set window settings
    }
    Program::~Program()
    {
    glDeleteBuffers(4, buffers);
        for(int i = 0; i < bitmaps.size(); i++ )
        {
            delete bitmaps[i];
        }
    }
    
    bool Program::Initialize()
    {
        //Initialize base class at start to create window
        bool initBaseResult = BaseProgram::Initialize();
        //Init some stuff here
    
    
    //glEnable(GL_CULL_FACE);
      //  glEnable(GL_DEPTH_TEST);
      //  glEnable (GL_BLEND);
      //  glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    
    shader.LoadShaderFiles("./basic.vert" , "./basic.frag");
    
    /*
    #version 120
    
    uniform mat4 Model;
    uniform mat4 MVP;
    uniform mat4 View;
    
    attribute vec3 Position;
    attribute vec3 Normals;
    attribute vec2 UV;
    attribute float ImageIndex;
    
    varying vec4 position;
    varying vec2 uv;
    varying vec3 normal;
    varying float imageindex;
    
    void main()
    {
        imageindex = ImageIndex;
        normal = normalize( (View * Model * vec4(Normals, 0.0f)).xyz );
        uv = UV;
        position = MVP * vec4(Position,1.0);
        gl_Position = position;
    }
    
    */
    
    
    /*
    #version 120
    uniform sampler2D TEXTURE0;
    uniform sampler2D TEXTURE1;
    uniform sampler2D TEXTURE2;
    uniform sampler2D TEXTURE3;
    uniform sampler2D TEXTURE4;
    uniform sampler2D TEXTURE5;
    
    varying vec4 position;
    varying vec2 uv;
    varying vec3 normal;
    varying float imageindex;
    
    void main()
    {
        int index = int(imageindex);
        vec4 color = vec4(1.0f, 1.0f, 1.0f, 1.0f);
    
    
        if(index == 0)      color = texture2D(TEXTURE0, uv);
        if(index == 1)      color = texture2D(TEXTURE1, uv);
        if(index == 2)      color = texture2D(TEXTURE2, uv);
        if(index == 3)      color = texture2D(TEXTURE3, uv);
        if(index == 4)      color = texture2D(TEXTURE4, uv);
        if(index == 5)      color = texture2D(TEXTURE5, uv);
    
        gl_FragColor = color;
    }
    
    */
    
        glm::mat4 pos = glm::translate(glm::mat4(1.0f), 0.0f, 0.0f, -5.0f);
        glm::mat4 ang = glm::rotate(glm::mat4(1.0f),-90.0f,glm::vec3(0,0,1));
        ang = glm::rotate(ang, -90.0f,glm::vec3(0,1,0));
        ang = glm::rotate(ang, 0.0f,glm::vec3(1,0,0));
        glm::mat4 sca = glm::scale(glm::mat4(1.0f),1.0f, 1.0f,1.0f);
        model = pos*ang*sca;
    
        glGenBuffers(4, buffers);
    
        return initBaseResult;
    }
    
    bool Program::LoadContent()
    {
        //Load content here
        for(int i = 0; i<5; i++)
        {
    
            PosList.push_back(glm::vec3( 0 + i, 0, -1));
            PosList.push_back(glm::vec3( 0 + i, 1, -1));
            PosList.push_back(glm::vec3( 1 + i, 0, -1));
    
            PosList.push_back(glm::vec3( 1 + i, 0, -1));
            PosList.push_back(glm::vec3( 0 + i, 1, -1));
            PosList.push_back(glm::vec3( 1 + i, 1, -1));
    
    
    
            UVList.push_back(glm::vec2(0,0));
            UVList.push_back(glm::vec2(0,1));
            UVList.push_back(glm::vec2(1,0));
    
            UVList.push_back(glm::vec2(1,0));
            UVList.push_back(glm::vec2(0,1));
            UVList.push_back(glm::vec2(1,1));
    
            int b = 0;
            if((i % 2) == 0) b = 1;
            ImageIndexList.push_back(b);
            ImageIndexList.push_back(b);
            ImageIndexList.push_back(b);
    
            ImageIndexList.push_back(b);
            ImageIndexList.push_back(b);
            ImageIndexList.push_back(b);
        }
    
        SOGLF::Texture *bitmap = new SOGLF::Texture();
            bitmap->LoadFromFile("./4141.jpg");
            bitmaps.push_back(bitmap);
    
            SOGLF::Texture *bitmap2 = new SOGLF::Texture();
            bitmap2->LoadFromFile("./4242.jpg");
            bitmaps.push_back(bitmap2);
    
        glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
        glBufferData(GL_ARRAY_BUFFER, PosList.size() * sizeof(glm::vec3), &PosList[0], GL_STATIC_DRAW);
    
        glBindBuffer(GL_ARRAY_BUFFER, buffers[1]);
        glBufferData(GL_ARRAY_BUFFER, UVList.size() * sizeof(glm::vec2), &UVList[0], GL_STATIC_DRAW);
    
        glBindBuffer(GL_ARRAY_BUFFER, buffers[2]);
        glBufferData(GL_ARRAY_BUFFER, NormList.size() * sizeof(glm::vec3), &NormList[0], GL_STATIC_DRAW);
    
        glBindBuffer(GL_ARRAY_BUFFER, buffers[3]);
        glBufferData(GL_ARRAY_BUFFER, ImageIndexList.size() * sizeof(unsigned char), &ImageIndexList[0], GL_STATIC_DRAW);
        return  true;
    }
    
    void Program::Update()
    {
        //Update stuff here
        if(SOGLF::Keyboard::IsKeyDown(SOGLF::Keyboard::Escape)) SOGLF::WindowClass::Window.Close();
        if(SOGLF::Keyboard::IsKeyDown(SOGLF::Keyboard::F1))
        {
            std::string file = SOGLF::Util::CurrentDate().str();
            SOGLF::WindowClass::Window.Capture("blah_" + file + "_.bmp");
        }
    }
    
    void Program::Draw()
    {
        SOGLF::WindowClass::Window.Clear();
    
        //Draw stuff here
        const glm::mat4 &c = SOGLF::Matrices::Matrix.Camera;
    
        MVP = SOGLF::Matrices::Matrix.GetProjection() *c* model;
    
        shader.Bind();
    
        glUniformMatrix4fv( shader.GetUniform("MVP") , 1, GL_FALSE, &MVP[0][0]);
    
        glUniformMatrix4fv( shader.GetUniform("Model") , 1, GL_FALSE, &model[0][0]);
    
        glUniformMatrix4fv( shader.GetUniform("View") , 1, GL_FALSE, &c[0][0]);
    
        for(int i = 0; i < bitmaps.size(); i++ )
        {
            glActiveTexture(GL_TEXTURE0 + i);
            bitmaps[i]->Bind();
            std::string textureName = "TEXTURE";    textureName += SOGLF::Util::toString(i);
            glUniform1i( shader.GetUniform(textureName.c_str()) , i);
    
        }
    
        glEnableVertexAttribArray( shader.GetAttribute("ImageIndex") );
        glBindBuffer(GL_ARRAY_BUFFER, buffers[3]);
        glVertexAttribPointer(
            shader.GetAttribute("ImageIndex"),                  // attribute 0. No particular reason for 0, but must match the layout in the shader.
            1,                  // size
            GL_FLOAT,           // type
            GL_FALSE,           // normalized?
            0,                  // stride
            (void*)0            // array buffer offset
        );
    
        glEnableVertexAttribArray( shader.GetAttribute("Position") );
        glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
        glVertexAttribPointer(
            shader.GetAttribute("Position"),                  // 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
        );
    
    
    
    
        glEnableVertexAttribArray( shader.GetAttribute("UV") );
        glBindBuffer(GL_ARRAY_BUFFER, buffers[1]);
        glVertexAttribPointer(
            shader.GetAttribute("UV"),                  // attribute 0. No particular reason for 0, but must match the layout in the shader.
            2,                  // size
            GL_FLOAT,           // type
            GL_FALSE,           // normalized?
            0,                  // stride
            (void*)0            // array buffer offset
        );
    
    
    
        glEnableVertexAttribArray(shader.GetAttribute("Normals"));
        glBindBuffer(GL_ARRAY_BUFFER, buffers[2]);
        glVertexAttribPointer(
            shader.GetAttribute("Normals"),                  // 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
        );
    
    
    
        // Index buffer
        glDrawArrays(GL_TRIANGLES, 0, PosList.size());
    
        glDisableVertexAttribArray(shader.GetAttribute("Normals"));
        glDisableVertexAttribArray(shader.GetAttribute("UV"));
        glDisableVertexAttribArray(shader.GetAttribute("Position"));
        glDisableVertexAttribArray(shader.GetAttribute("ImageIndex"));
    
        SOGLF::Texture::Unbind();
        SOGLF::Shader::Unbind();
    
        SOGLF::WindowClass::Window.Display();
        GLenum errCode;
        const GLubyte *errString;
    
        if ((errCode = glGetError()) != GL_NO_ERROR)
        {
            errString = gluErrorString(errCode);
            std::cout << "OpenGL Error: " << errString << std::endl;
        }
    }
    
    

    Reply With Quote Edit / Delete Linux United Kingdom Show Events

  21. Post #1781
    Gold Member
    conman420's Avatar
    January 2007
    1,795 Posts
    Based on the position of the error, it looks like a problem with the "Vector2" type. Where/how is that declared?
    It isn't the vector2 type, I managed to get it compiling by swapping the order of includes in Camera.cpp to:

    #include "Bases/BaseObject.h"
    #include "Camera.h"
    #include "GameGlobals.h"
    

    Although I am curious to know why this worked, and I don't like this solution it seems hacky.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  22. Post #1782
    ArgvCompany's Avatar
    June 2012
    549 Posts
    I have this frag shader:
    
    #version 120
    uniform sampler2D TEXTURE0;
    uniform sampler2D TEXTURE1;
    uniform sampler2D TEXTURE2;
    uniform sampler2D TEXTURE3;
    uniform sampler2D TEXTURE4;
    uniform sampler2D TEXTURE5;
    uniform sampler2D TEXTURE6;
    
    varying vec4 position;
    varying vec2 uv;
    varying vec3 normal;
    varying float imageindex;
    
    void main()
    {
        vec4 color = vec4(1.0f, 1.0f, 1.0f, 1.0f);
        if(int(imageindex) == 0)      color = texture2D(TEXTURE0, uv);
        if(int(imageindex) == 1)      color = texture2D(TEXTURE1, uv);
        if(int(imageindex) == 2)      color = texture2D(TEXTURE2, uv);
        if(int(imageindex) == 3)      color = texture2D(TEXTURE3, uv);
        if(int(imageindex) == 4)      color = texture2D(TEXTURE4, uv);
        if(int(imageindex) == 5)      color = texture2D(TEXTURE5, uv);
        if(int(imageindex) == 6)      color = texture2D(TEXTURE6, uv);
    
        gl_FragColor = color;
    }
    

    And I create the images and send them to the gpu like this:
    SOGLF::Texture bitmap;
    bitmap.LoadFromFile("./Resources/"+mimg);
    bitmaps.push_back(bitmap);
    

    and

    for(int i = 0; i < bitmaps.size(); i++ )
        {
            glActiveTexture(GL_TEXTURE0 + i);
            bitmaps[i].Bind();
            std::string textureName = "TEXTURE";    textureName += SOGLF::Util::toString(i);
            glUniform1i( shader.GetUniform(textureName.c_str()) , i);
    
        }
    

    Im not getting any openGL errors however "color" gets turned into black.
    Anything im missing?
    My guess is that there's something wrong loading the texture or perhaps assigning it to a sampler since there are no other cases I can think of where the samplers return black. If you aren't sampling anything, the fragment should be white.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  23. Post #1783
    Anthos's Avatar
    April 2012
    153 Posts
    So I fixed the linker errors in my previous post but now these two guys have popped up, I'm getting the feeling my Visual studio might be broken or something because I never had any of these kind of linking problems before I downgraded to XP. Anyone that knows if I'm just doing something really stupid or it's just Visual C++ being a bitch?

    Error 2 error LNK2019: unresolved external symbol "private: class std::vector<class sf::Sprite,class std::allocator<class sf::Sprite> > __thiscall GraphicsMan::RenderBox(void)" (?RenderBox@GraphicsMan@@AAE?AV?$vector@VSprite@sf @@V?$allocator@VSprite@sf@@@std@@@std@@XZ) referenced in function "public: class sf::Sprite __thiscall GraphicsMan::GiveRender(int)" (?GiveRender@GraphicsMan@@QAE?AVSprite@sf@@H@Z) Graphics.obj
    //Using this to loop through the renderbox and Draw() all sprites
    sf::Sprite GraphicsMan::GiveRender(int num)
    {
    	return GraphicsMan::RenderBox().at(num);
    }
    

    Error 1 error LNK2019: unresolved external symbol "private: class std::vector<class sf::Image,class std::allocator<class sf::Image> > __thiscall GraphicsMan::ImageBox(void)" (?ImageBox@GraphicsMan@@AAE?AV?$vector@VImage@sf@@ V?$allocator@VImage@sf@@@std@@@std@@XZ) referenced in function "public: class std::vector<int,class std::allocator<int> > __thiscall GraphicsMan::LoadTileMap(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?LoadTileMap@GraphicsMan@@QAE?AV?$vector@HV?$allo cator@H@std@@@std@@V?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@3@H@Z) Graphics.obj
    //Turn a single image into a fuckload of sprites.
    std::vector<int> GraphicsMan::LoadTileMap(std::string imgloc,int size)
    {
            //Load the image into the first-available image slot
    	int x = GraphicsMan::counter;
    	GraphicsMan::ImageBox()[x].LoadFromFile(imgloc);
    
            //Define all variables
    	int Size	= size;
    	int Height	= GraphicsMan::ImageBox()[x].GetHeight();
    	int Width	= GraphicsMan::ImageBox()[x].GetWidth();
    	int Total	= Height+Height+Width+Width/Size;
    
    	//This is where we'll contain all the tiles in
    	std::vector<sf::Sprite> TileList(Total);
    
    	//We fill the entire vector with sprites first.
    	for (int i=0;i<Total;i++)
    	{
    		TileList[i].SetImage(GraphicsMan::ImageBox()[x]);
    	}
    
    	//Now we subrect all the individual tiles.
    	for (int i=0;i<Width;i+=Size)
    	{
    		TileList[i].SetSubRect(sf::IntRect(i,0,i+32,i));
    	}
    
            //Add one to counter
    	GraphicsMan::counter++;
    
    	std::vector<int> Temp(10);
    	return Temp;
    }
    

    GraphicsMan.h if that's of any help:

    //Everything that has to do with graphics goes here
    
    class GraphicsMan
    {
    private:
    	std::vector<sf::Image> ImageBox(); //Storage of images
    	std::vector<sf::Sprite> SpriteBox(); //Storage for sprites that aren't used
    	std::vector<sf::Sprite> RenderBox(); //Storage for sprites I want to render on-screen
    	
    	int counter; //Counts the amount of images
    	int RendCounter; //Counts the amount of renders
    	
    public:
    	GraphicsMan();
    	sf::Sprite  GiveRender(int i);
    	std::vector<int> LoadTileMap(std::string imgloc,int size);
    	void SetSprite(int id,int x,int y);
    	//void RemSprite(int id);
    	//void MoveSprite(int id,int x,int y);
    
    };
    
    Reply With Quote Edit / Delete Windows XP Netherlands Show Events

  24. Post #1784
    AlienCat's Avatar
    October 2011
    508 Posts
    You sure you fixed the linker errors? You need to add both libraries and headers to the project.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  25. Post #1785
    Anthos's Avatar
    April 2012
    153 Posts
    You sure you fixed the linker errors? You need to add both libraries and headers to the project.
    Well I didn't actually fix it, I found a way around.

    Includes and linkers:



    Main file
    // SSX.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    #include "Graphics.h"
    

    Graphics.cpp
    #include "stdafx.h"
    #include "Graphics.h"
    

    stdafx.h
    #pragma once
    #include "targetver.h"
    #include <SFML/System.hpp>
    #include <SFML/Graphics.hpp>
    #include <stdio.h>
    #include <tchar.h>
    
    Reply With Quote Edit / Delete Windows XP Netherlands Show Events

  26. Post #1786
    Gold Member
    MrBob1337's Avatar
    September 2008
    1,678 Posts
    My compiled program (using SFML) keeps crashing with the message "The application was unable to start correctly (0xc0150002)." In the event viewer, I get the following message:
    Activation context generation failed for "C:\Users\[my name]\Documents\Visual Studio 2010\Projects\Framework\Debug\sfml-graphics-d.dll".
    with the source being "SideBySide". Obviously this is something to do with the Windows 7 re-installation I performed recently where I switched from 32-bit to 64-bit. However there doesn't seem to be a 64-bit version of SFML or anything that would help me. I DID install the 64-bit version of Visual Studio Express though. I have sfml-windows-d.lib, sfml-system-d.lib, and sfml-graphics-d.lib in the linker's input and have put SFML_DYNAMIC in the preprocessor. What is the problem?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  27. Post #1787
    T3hGamerDK's Avatar
    January 2011
    2,551 Posts
    My compiled program (using SFML) keeps crashing with the message "The application was unable to start correctly (0xc0150002)." In the event viewer, I get the following message:

    with the source being "SideBySide". Obviously this is something to do with the Windows 7 re-installation I performed recently where I switched from 32-bit to 64-bit. However there doesn't seem to be a 64-bit version of SFML or anything that would help me. I DID install the 64-bit version of Visual Studio Express though. I have sfml-windows-d.lib, sfml-system-d.lib, and sfml-graphics-d.lib in the linker's input and have put SFML_DYNAMIC in the preprocessor. What is the problem?
    Just re-compile SFML yourself? Problem solved?
    Reply With Quote Edit / Delete Linux Denmark Show Events

  28. Post #1788
    Anthos's Avatar
    April 2012
    153 Posts
    My compiled program (using SFML) keeps crashing with the message "The application was unable to start correctly (0xc0150002)." In the event viewer, I get the following message:

    with the source being "SideBySide". Obviously this is something to do with the Windows 7 re-installation I performed recently where I switched from 32-bit to 64-bit. However there doesn't seem to be a 64-bit version of SFML or anything that would help me. I DID install the 64-bit version of Visual Studio Express though. I have sfml-windows-d.lib, sfml-system-d.lib, and sfml-graphics-d.lib in the linker's input and have put SFML_DYNAMIC in the preprocessor. What is the problem?
    Are you using Visual studio 2010? Don't. I downgraded to 2008 just to use SFML.
    Reply With Quote Edit / Delete Windows XP Netherlands Show Events

  29. Post #1789
    flayne's Avatar
    January 2011
    1,628 Posts
    Are you using Visual studio 2010? Don't. I downgraded to 2008 just to use SFML.
    If that's his problem he should probably just use G++ (MingW) and forget visual all together (only using it as a code editor and just ignoring the compiler part of it).
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  30. Post #1790
    Gold Member
    MrBob1337's Avatar
    September 2008
    1,678 Posts
    I compiled the dlls and lib files in debug configuration. It runs without crashing now, but even when I comment everything inside driver.cpp ( the actual program) leaving just this:
    Code:
    /*bunch of commented includes and 'using' directives*/
    
    include <iostream>
    
    int main()
    {
    /*bunch of commented logic and declares*/
    std::cout << "Hello World!";
    system("pause");
    return 0;
    }
    nothing appears in the console window and the program takes a while to close. Debug shows literally nothing happening, even with a breakpoint immediately after the std::cout statement. The program exits with 0, though. What the hell is up with this program?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  31. Post #1791
    Anthos's Avatar
    April 2012
    153 Posts
    -snip for rage-

    Problem solved.
    Reply With Quote Edit / Delete Windows XP Netherlands Show Events Disagree Disagree x 1Dumb Dumb x 1 (list)

  32. Post #1792
    Gold Member
    Blackwheel's Avatar
    April 2005
    682 Posts
    guys I think I successfully built a sfml 2.0 snapshot on my Ubuntu VM using this tutorial (http://sfmlcoder.wordpress.com/2011/...-make-for-gcc/)

    but when I try to open a window,
    it spits this out:


    /tmp/cc2G7R2X.o: In function `main':
    rlx.cpp:(.text+0x86): undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
    rlx.cpp:(.text+0xc2): undefined reference to `sf::Window::Window(sf::VideoMode, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, sf::ContextSettings const&)'
    rlx.cpp:(.text+0xf0): undefined reference to `sf::Window::close()'
    rlx.cpp:(.text+0x104): undefined reference to `sf::Window::pollEvent(sf::Event&)'
    rlx.cpp:(.text+0x114): undefined reference to `sf::Window::isOpen() const'
    rlx.cpp:(.text+0x129): undefined reference to `sf::Window::~Window()'
    rlx.cpp:(.text+0x152): undefined reference to `sf::Window::~Window()'
    rlx.cpp:(.text+0x17a): undefined reference to `sf::Window::~Window()'
    collect2: ld returned 1 exit status
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  33. Post #1793
    NovembrDobby's Avatar
    April 2007
    1,157 Posts
    Are you linking properly?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  34. Post #1794
    Gold Member
    Blackwheel's Avatar
    April 2005
    682 Posts
    tried a different sample program from the site:

    Code:
    #include <SFML/Graphics.hpp>
    
    int main()
    {
        sf::RenderWindow window(sf::VideoMode(300, 200), "SFML works!");
        sf::Text text("Hello SFML");
    
        while (window.isOpen())
        {
            sf::Event event;
            while (window.pollEvent(event))
            {
                if (event.type == sf::Event::Closed)
                    window.close();
            }
    
            window.clear();
            window.draw(text);
            window.display();
        }
    
        return 0;
    }

    That generated a .o file.
    So then I'm supposed to punch this in:
    Code:
    g++ rlx.o -o sfml-app -Lhome/Home/Dev/SFML/lib -lsfml-graphics -lsfml-window -lsfml-system
    is that right?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  35. Post #1795
    flayne's Avatar
    January 2011
    1,628 Posts
    I got it partially working but the image selection isnt working right.
    I made a simple example:
    ...
    Ought you to be using else if directives rather than just ifs. Obviously its not causing the problems unless something is really f-ed up but it would increase performance drastically.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  36. Post #1796
    open.gl
    Overv's Avatar
    February 2007
    7,431 Posts
    That generated a .o file.
    So then I'm supposed to punch this in:
    Code:
    g++ rlx.o -o sfml-app -Lhome/Home/Dev/SFML/lib -lsfml-graphics -lsfml-window -lsfml-system
    is that right?
    Looks correct to me.
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events

  37. Post #1797
    Richy19's Avatar
    May 2010
    5,411 Posts
    Ought you to be using else if directives rather than just ifs. Obviously its not causing the problems unless something is really f-ed up but it would increase performance drastically.
    GLSL 120 doesnt seem to support "else if"
    BTW the initial problem has been fixed
    Reply With Quote Edit / Delete Linux United Kingdom Show Events

  38. Post #1798
    flayne's Avatar
    January 2011
    1,628 Posts
    tried a different sample program from the site:

    Code:
    #include <SFML/Graphics.hpp>
    
    int main()
    {
        sf::RenderWindow window(sf::VideoMode(300, 200), "SFML works!");
        sf::Text text("Hello SFML");
    
        while (window.isOpen())
        {
            sf::Event event;
            while (window.pollEvent(event))
            {
                if (event.type == sf::Event::Closed)
                    window.close();
            }
    
            window.clear();
            window.draw(text);
            window.display();
        }
    
        return 0;
    }

    That generated a .o file.
    So then I'm supposed to punch this in:
    Code:
    g++ rlx.o -o sfml-app -Lhome/Home/Dev/SFML/lib -lsfml-graphics -lsfml-window -lsfml-system
    is that right?
    Alternatively you can just use rlx.cpp and skip running g++ once. But that should be correct.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 1 (list)

  39. Post #1799
    Gold Member
    Blackwheel's Avatar
    April 2005
    682 Posts
    Everything I did up above works,
    but then I try:

    Code:
    export LD_LIBRARY_PATH=home/Home/Dev/SFML/lib && ./sfml-app
    and I get:

    ./sfml-app: error while loading shared libraries: libsfml-graphics.so.2: cannot open shared object file: No such file or directory
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  40. Post #1800
    flayne's Avatar
    January 2011
    1,628 Posts
    GLSL 120 doesnt seem to support "else if"
    BTW the initial problem has been fixed
    Doesn't support else if? How quant. I don't suppose it supports texture arrays .

    Edited:

    Everything I did up above works,
    but then I try:

    Code:
    export LD_LIBRARY_PATH=home/Home/Dev/SFML/lib && ./sfml-app
    and I get:

    ./sfml-app: error while loading shared libraries: libsfml-graphics.so.2: cannot open shared object file: No such file or directory
    Does the file actually end with .2? Because that could be related to the problem.
    Reply With Quote Edit / Delete Windows 7 United States Show Events