Page 1 of 1

Game Architecture Dev Environment

PostPosted: Thu Feb 09, 2012 1:43 pm
by MarcDestefano
Assuming computer has video card that can handle OpenGL 3.x, possibilities are:

GLEW + freeglut + DevIL

SFML 2.0 + CMake

GLEW + GLFW 2.7.2

PyOpenGL (last resort)

Please post working solutions (CMakeLists.txt, derp.vcproj, etc.)

Re: Game Architecture Dev Environment

PostPosted: Thu Feb 09, 2012 4:36 pm
by MarcDestefano
Linker inputs to VC:
glew32.lib glfw.lib opengl32.lib glu32.lib

Using GLFW:

Re: Game Architecture Dev Environment

PostPosted: Thu Feb 09, 2012 4:51 pm
by LordSupremePerson
Windows SFML Mingw+MSYS Instructions
  1. Download and install Mingw+MSYS http://sourceforge.net/projects/mingw/f ... e/download
  2. Be sure to select C Compiler, C++ Compiler, and MSYS Basic System
  3. Download and install CMake http://www.cmake.org/files/v2.8/cmake-2 ... 32-x86.exe
  4. Make sure you select the option to add CMake to PATH
  5. Download SFML https://github.com/LaurentGomila/SFML/tarball/master and extract it
  6. Run MSYS (C:\MinGW\msys\1.0\msys.bat)
  7. Navigate in MSYS to the first folder in SFML that contains “CMakeLists.txt”
  8. run cmake -G “MSYS Makefiles” .
  9. run make
  10. copy the files now located in sfml’s lib folder to C:\MinGW\lib
  11. copy the files now located in sfml’s include folder to C:\MinGW\include
  12. copy the files now located in sfml’s extlibs/headers folder to C:\MinGW\include
  13. copy the files located in sfml’s cmake/modules folder to C:\Program Files (x86)\CMake 2.8\share\cmake-2.8\Modules
  14. copy the files located in sfml's extlibs/libs-mingw to your project's folder
  15. Add C:\MinGW\lib to path
  16. Reboot
  17. open msys again
  18. navigate to folder containing project
  19. run cmake -G “MSYS Makefiles” .
  20. run make
  21. run program
  22. Happy dance

Re: Game Architecture Dev Environment

PostPosted: Thu Feb 09, 2012 5:22 pm
by LordSupremePerson
Windows SFML Visual Studio CMake Instructions:

  1. Make sure you have visual studio installed and add Visual Studio's bin folder to the PATH environment variable (mine was C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin)
  2. Add C:\SFML\lib to the PATH environment variable
  3. Download and install CMake http://www.cmake.org/files/v2.8/cmake-2 ... 32-x86.exe
  4. Reboot
  5. Download SFML https://github.com/LaurentGomila/SFML/tarball/master and extract it
  6. copy the files located in sfml’s cmake/modules folder to C:\Program Files (x86)\CMake 2.8\share\cmake-2.8\Modules
  7. Run CMake
  8. Point the source code option to the top level directory containing CMakeLists.txt and point the build directory anywhere you would like
    Image
  9. Select your version of visual studio (Mine is Visual Studio 10)
    Image
  10. Click Finish and let it run, it should say something similar to this:
    Code: Select all
    Check for working C compiler using: Visual Studio 10
    Check for working C compiler using: Visual Studio 10 -- works
    Detecting C compiler ABI info
    Detecting C compiler ABI info - done
    Check for working CXX compiler using: Visual Studio 10
    Check for working CXX compiler using: Visual Studio 10 -- works
    Detecting CXX compiler ABI info
    Detecting CXX compiler ABI info - done
    Looking for sys/types.h
    Looking for sys/types.h - found
    Looking for stdint.h
    Looking for stdint.h - found
    Looking for stddef.h
    Looking for stddef.h - found
    Check size of void*
    Check size of void* - done
    Found OpenGL: opengl32
    Found Freetype: C:/Users/craftkiller/Downloads/LaurentGomila-SFML-e3d75f6/extlibs/libs-msvc/x86/freetype.lib
    Found GLEW: C:/Users/craftkiller/Downloads/LaurentGomila-SFML-e3d75f6/extlibs/libs-msvc/x86/glew.lib
    Found JPEG: C:/Users/craftkiller/Downloads/LaurentGomila-SFML-e3d75f6/extlibs/libs-msvc/x86/jpeg.lib
    Found OpenAL: C:/Users/craftkiller/Downloads/LaurentGomila-SFML-e3d75f6/extlibs/libs-msvc/x86/openal32.lib
    Found SNDFILE: C:/Users/craftkiller/Downloads/LaurentGomila-SFML-e3d75f6/extlibs/libs-msvc/x86/sndfile.lib
    Configuring done
  11. Open the folder you chose as the build path, you should now see a visual studio project
    Image
  12. Double click on SFML.sln to open the project is visual studio
  13. At the top of the visual studio window change the "Debug" dropdown box to "Release" and click the green arrow
  14. When the build completes (don't worry if it has an error about "ALL_BUILD") Close visual studio
  15. Make a new folder C:\SFML
  16. Inside C:\SFML create the folders lib and include
  17. Inside your build folder copy everything from lib\Release to C:\SFML\lib
  18. Inside SFML's source directory copy everything from include to C:\SFML\include
  19. Inside SFML's source directory copy everything from extlibs\headers to C:\SFML\include
  20. Inside SFML's source directory copy everything from extlibs\libs-msvc\x86 to C:\SFML\lib
  21. Open CMake again, this time point the source directory to your project (see attached zip) and select a new build directory
  22. Point SFML_INCLUDE_DIR to C:\SFML\include
  23. Click Configure and Generate
  24. In your build folder there should now be a visual studio project, open hw4.sln
    Image
  25. You may want to set hw4 as your start up project, otherwise when building you may get an error about "ALL_BUILD" not existing
    Image
  26. Run the project
    Image

If it did not work, make sure your C:/SFML folder contains the right files, below is a dump of the file structure
Code: Select all
C:/SFML
C:/SFML/include
C:/SFML/include/AL
C:/SFML/include/AL/al.h
C:/SFML/include/AL/alc.h
C:/SFML/include/AL/alext.h
C:/SFML/include/freetype
C:/SFML/include/freetype/config
C:/SFML/include/freetype/config/ftconfig.h
C:/SFML/include/freetype/config/ftheader.h
C:/SFML/include/freetype/config/ftmodule.h
C:/SFML/include/freetype/config/ftoption.h
C:/SFML/include/freetype/config/ftstdlib.h
C:/SFML/include/freetype/freetype.h
C:/SFML/include/freetype/ftbitmap.h
C:/SFML/include/freetype/fterrdef.h
C:/SFML/include/freetype/fterrors.h
C:/SFML/include/freetype/ftglyph.h
C:/SFML/include/freetype/ftimage.h
C:/SFML/include/freetype/ftmoderr.h
C:/SFML/include/freetype/ftoutln.h
C:/SFML/include/freetype/ftsystem.h
C:/SFML/include/freetype/fttypes.h
C:/SFML/include/freetype/internal
C:/SFML/include/freetype/internal/internal.h
C:/SFML/include/ft2build.h
C:/SFML/include/GL
C:/SFML/include/GL/glew.h
C:/SFML/include/GL/glxew.h
C:/SFML/include/GL/wglew.h
C:/SFML/include/jpeg
C:/SFML/include/jpeg/jconfig.h
C:/SFML/include/jpeg/jerror.h
C:/SFML/include/jpeg/jmorecfg.h
C:/SFML/include/jpeg/jpeglib.h
C:/SFML/include/libsndfile
C:/SFML/include/libsndfile/osx
C:/SFML/include/libsndfile/osx/sndfile.h
C:/SFML/include/libsndfile/windows
C:/SFML/include/libsndfile/windows/sndfile.h
C:/SFML/include/SFML
C:/SFML/include/SFML/Audio
C:/SFML/include/SFML/Audio/Export.hpp
C:/SFML/include/SFML/Audio/Listener.hpp
C:/SFML/include/SFML/Audio/Music.hpp
C:/SFML/include/SFML/Audio/Sound.hpp
C:/SFML/include/SFML/Audio/SoundBuffer.hpp
C:/SFML/include/SFML/Audio/SoundBufferRecorder.hpp
C:/SFML/include/SFML/Audio/SoundRecorder.hpp
C:/SFML/include/SFML/Audio/SoundSource.hpp
C:/SFML/include/SFML/Audio/SoundStream.hpp
C:/SFML/include/SFML/Audio.hpp
C:/SFML/include/SFML/Config.hpp
C:/SFML/include/SFML/Graphics
C:/SFML/include/SFML/Graphics/BlendMode.hpp
C:/SFML/include/SFML/Graphics/CircleShape.hpp
C:/SFML/include/SFML/Graphics/Color.hpp
C:/SFML/include/SFML/Graphics/ConvexShape.hpp
C:/SFML/include/SFML/Graphics/Drawable.hpp
C:/SFML/include/SFML/Graphics/Export.hpp
C:/SFML/include/SFML/Graphics/Font.hpp
C:/SFML/include/SFML/Graphics/Glyph.hpp
C:/SFML/include/SFML/Graphics/Image.hpp
C:/SFML/include/SFML/Graphics/PrimitiveType.hpp
C:/SFML/include/SFML/Graphics/Rect.hpp
C:/SFML/include/SFML/Graphics/Rect.inl
C:/SFML/include/SFML/Graphics/RectangleShape.hpp
C:/SFML/include/SFML/Graphics/RenderStates.hpp
C:/SFML/include/SFML/Graphics/RenderTarget.hpp
C:/SFML/include/SFML/Graphics/RenderTexture.hpp
C:/SFML/include/SFML/Graphics/RenderWindow.hpp
C:/SFML/include/SFML/Graphics/Shader.hpp
C:/SFML/include/SFML/Graphics/Shape.hpp
C:/SFML/include/SFML/Graphics/Sprite.hpp
C:/SFML/include/SFML/Graphics/Text.hpp
C:/SFML/include/SFML/Graphics/Texture.hpp
C:/SFML/include/SFML/Graphics/Transform.hpp
C:/SFML/include/SFML/Graphics/Transformable.hpp
C:/SFML/include/SFML/Graphics/Vertex.hpp
C:/SFML/include/SFML/Graphics/VertexArray.hpp
C:/SFML/include/SFML/Graphics/View.hpp
C:/SFML/include/SFML/Graphics.hpp
C:/SFML/include/SFML/Network
C:/SFML/include/SFML/Network/Export.hpp
C:/SFML/include/SFML/Network/Ftp.hpp
C:/SFML/include/SFML/Network/Http.hpp
C:/SFML/include/SFML/Network/IpAddress.hpp
C:/SFML/include/SFML/Network/Packet.hpp
C:/SFML/include/SFML/Network/Socket.hpp
C:/SFML/include/SFML/Network/SocketHandle.hpp
C:/SFML/include/SFML/Network/SocketSelector.hpp
C:/SFML/include/SFML/Network/TcpListener.hpp
C:/SFML/include/SFML/Network/TcpSocket.hpp
C:/SFML/include/SFML/Network/UdpSocket.hpp
C:/SFML/include/SFML/Network.hpp
C:/SFML/include/SFML/OpenGL.hpp
C:/SFML/include/SFML/System
C:/SFML/include/SFML/System/Clock.hpp
C:/SFML/include/SFML/System/Err.hpp
C:/SFML/include/SFML/System/Export.hpp
C:/SFML/include/SFML/System/InputStream.hpp
C:/SFML/include/SFML/System/Lock.hpp
C:/SFML/include/SFML/System/Mutex.hpp
C:/SFML/include/SFML/System/NonCopyable.hpp
C:/SFML/include/SFML/System/Sleep.hpp
C:/SFML/include/SFML/System/String.hpp
C:/SFML/include/SFML/System/Thread.hpp
C:/SFML/include/SFML/System/Thread.inl
C:/SFML/include/SFML/System/ThreadLocal.hpp
C:/SFML/include/SFML/System/ThreadLocalPtr.hpp
C:/SFML/include/SFML/System/ThreadLocalPtr.inl
C:/SFML/include/SFML/System/Time.hpp
C:/SFML/include/SFML/System/Utf.hpp
C:/SFML/include/SFML/System/Utf.inl
C:/SFML/include/SFML/System/Vector2.hpp
C:/SFML/include/SFML/System/Vector2.inl
C:/SFML/include/SFML/System/Vector3.hpp
C:/SFML/include/SFML/System/Vector3.inl
C:/SFML/include/SFML/System.hpp
C:/SFML/include/SFML/Window
C:/SFML/include/SFML/Window/Context.hpp
C:/SFML/include/SFML/Window/ContextSettings.hpp
C:/SFML/include/SFML/Window/Event.hpp
C:/SFML/include/SFML/Window/Export.hpp
C:/SFML/include/SFML/Window/GlResource.hpp
C:/SFML/include/SFML/Window/Joystick.hpp
C:/SFML/include/SFML/Window/Keyboard.hpp
C:/SFML/include/SFML/Window/Mouse.hpp
C:/SFML/include/SFML/Window/VideoMode.hpp
C:/SFML/include/SFML/Window/Window.hpp
C:/SFML/include/SFML/Window/WindowHandle.hpp
C:/SFML/include/SFML/Window/WindowStyle.hpp
C:/SFML/include/SFML/Window.hpp
C:/SFML/lib
C:/SFML/lib/freetype.lib
C:/SFML/lib/glew.lib
C:/SFML/lib/jpeg.lib
C:/SFML/lib/openal32.lib
C:/SFML/lib/sfml-audio-2.dll
C:/SFML/lib/sfml-audio.exp
C:/SFML/lib/sfml-audio.lib
C:/SFML/lib/sfml-graphics-2.dll
C:/SFML/lib/sfml-graphics.exp
C:/SFML/lib/sfml-graphics.lib
C:/SFML/lib/sfml-main.lib
C:/SFML/lib/sfml-network-2.dll
C:/SFML/lib/sfml-network.exp
C:/SFML/lib/sfml-network.lib
C:/SFML/lib/sfml-system-2.dll
C:/SFML/lib/sfml-system.exp
C:/SFML/lib/sfml-system.lib
C:/SFML/lib/sfml-window-2.dll
C:/SFML/lib/sfml-window.exp
C:/SFML/lib/sfml-window.lib
C:/SFML/lib/sndfile.lib


Finally, attached is the required CMake files and source code

Re: Game Architecture Dev Environment

PostPosted: Thu Feb 09, 2012 5:54 pm
by eawerbaneth
I managed to get the code to work using SFML 2.0 and Visual Studio on Windows. I also got it working with freeglut and glew, but both of my solutions display the Retarded Red Triangle that has been seen on several other W500s. To get SFML working with VS:

1. Follow the online tutorial to compile and install SFML 2.0 (http://www.sfml-dev.org/tutorials/2.0/compile-with-cmake.php). I generated using regular Visual Studio 10, not the 64-bit version. Also, when you build it, build the "BUILD ALL" option, then also build the "INSTALL" option.
2. When you're setting up your new project, there are a lot of annoying configuration properties you have to deal with:
NOTE - I'm using ... instead of correct path, which will change depending on where you installed everything.
A)In Project Properties, under VC++ Directories, add "...\SFML\include" and "...\glew-1.7.0\include" to "Include Directories", include being where your cmake project installed it to. For me, it was under C:\ProgramFiles(x86)\. Similarly, you need to include "...\SFML\lib" under "Library Directories".
B)In Project Properties/C/C++/General, under Additional Include Directories, add "...\glew-1.7.0\lib"
C)In Project Properties/C/C++/Preprocessor, add SFML_DYNAMIC to "Preprocessor Definitions"
D)In Project Properties/Linker/General, add "...\glew-1.7.0\lib" to "Additional Library Dependencies"
E) In Project Properties/Linker/Input, add the following:
sfml-system-d.lib
sfml-main-d.lib
sfml-graphics-d.lib
sfml-audio-d.lib
sfml-network-d.lib
sfml-window-d.lib
glew32.lib
opengl32.lib
glu32.lib
This is actually more than you need for this particular code, but it covers all of SFML's bases.

3) Now you're done editing Project Properties. All you have to do now is drop the .dll's that are in that same installed folder to where they should go. You may be able to drop them in System32 (sloppy). I have them in my project folder (also sloppy). Remember, the folder you downloaded and built from is not necessarily the correct one, mine only worked when I linked with the folder that was created when I installed the project.

Here is the code that I got from Tom:
Code: Select all
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <GL/glew.h>
#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#define WINDOW_TITLE_PREFIX "Getting Started"



bool exiting = false;




typedef struct
{
    float XYZW[4];
    float RGBA[4];
} Vertex;




int CurrentWidth = 600,
    CurrentHeight = 600,
    WindowHandle = 0;




unsigned FrameCount = 0;




GLuint
VertexShaderId,
    FragmentShaderId,
    ProgramId,
    VaoId,
    BufferId,
    IndexBufferId[2],
    ActiveIndexBuffer = 0;




const GLchar* VertexShader =
{
    "#version 130\n"\




    "in vec4 in_Position;\n"\
    "in vec4 in_Color;\n"\
    "out vec4 ex_Color;\n"\




    "void main(void)\n"\
    "{\n"\
    "   gl_Position = in_Position;\n"\
    "   ex_Color = in_Color;\n"\
    "}\n"
};




const GLchar* FragmentShader =
{
    "#version 130\n"\




    "in vec4 ex_Color;\n"\
    "out vec4 out_Color;\n"\




    "void main(void)\n"\
    "{\n"\
    "   out_Color = ex_Color;\n"\
    "}\n"
};




void Initialize(sf::Window* & app, sf::Clock* & clock); void InitWindow(sf::Window* & app, sf::Clock* & clock); void ResizeFunction(sf::Event & event); void RenderFunction(sf::Window* & app); void TimerFunction(sf::Window* & app, int time); void IdleFunction(void); void KeyboardFunction(sf::Window* & app, sf::Event & event); void Cleanup(void); void CreateVBO(void); void DestroyVBO(void); void CreateShaders(void); void DestroyShaders(void);




int main(int argc, char* argv[])
{
    sf::Window* app;
    sf::Clock* clock;
    Initialize(app, clock);




    int last_tick = clock->GetElapsedTime().AsMilliseconds();
    while(app->IsOpen())
    {
        //Process Events
        sf::Event event;
        while (app->PollEvent(event))
        {
            if (event.Type == sf::Event::Closed)
            {
                app->Close();
                break;
            }
            KeyboardFunction(app, event);
            ResizeFunction(event);
        }
        if (exiting)
            break;

        //Draw
        int new_tick = clock->GetElapsedTime().AsMilliseconds();
        TimerFunction(app, new_tick-last_tick);
        last_tick = new_tick;
        RenderFunction(app);




        // Finally, display rendered frame on screen
        //app->Display();
    }

    Cleanup();

    exit(EXIT_SUCCESS);
}




void Initialize(sf::Window* & app, sf::Clock* & clock) {
    //GLenum GlewInitResult;


    InitWindow(app, clock);




GLenum GlewInitResult;
    glewExperimental = GL_TRUE;
    GlewInitResult = glewInit();




    if (GLEW_OK != GlewInitResult) {
        fprintf(
            stderr,
            "ERROR: %s\n",
            glewGetErrorString(GlewInitResult)
            );
        exit(EXIT_FAILURE);
    }

    fprintf(
        stdout,
        "INFO: OpenGL Version: %s\n",
        glGetString(GL_VERSION)
        );




    CreateShaders();
    CreateVBO();




    glClearColor(0.0f, 0.0f, 0.0f, 0.0f); }




void InitWindow(sf::Window* & app, sf::Clock* & clock) {
    app = new sf::Window(sf::VideoMode(CurrentWidth, CurrentHeight, 32), WINDOW_TITLE_PREFIX);
    clock = new sf::Clock();
    app->SetActive();
    app->Display();
}




void KeyboardFunction(sf::Window* & app, sf::Event & event) {
    if (event.Type == sf::Event::KeyPressed)
    {
        switch(event.Key.Code)
        {
          case sf::Keyboard::T:
          {
              ActiveIndexBuffer = (ActiveIndexBuffer == 1 ? 0 : 1);
              glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
IndexBufferId[ActiveIndexBuffer]);
              break;
          }
          case sf::Keyboard::Escape:
          {
              app->Close();
              exiting = true;
          }
          default:
            break;
        }
    }
}




void ResizeFunction(sf::Event & event)
{
    if (event.Type == sf::Event::Resized)
    {
        CurrentWidth = event.Size.Width;
        CurrentHeight = event.Size.Height;
        glViewport(0, 0, CurrentWidth, CurrentHeight);
    }
}




void RenderFunction(sf::Window* & app)
{
    app->SetActive();
    ++FrameCount;




    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);




    if (ActiveIndexBuffer == 0) {
        glDrawElements(GL_TRIANGLES, 48, GL_UNSIGNED_BYTE, NULL);
    } else {
        glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_BYTE, NULL);
    }

    app->Display();
}




void TimerFunction(sf::Window* & app, int time) {
    static int time_elapsed = 0;
    time_elapsed += time;
    if (time_elapsed >= 250)
    {
        char* TempString = (char*)
            malloc(512 + strlen(WINDOW_TITLE_PREFIX));




        sprintf(
            TempString,
            "%s: %d Frames Per Second @ %d x %d",
            WINDOW_TITLE_PREFIX,
            FrameCount * 4,
            CurrentWidth,
            CurrentHeight
            );




        app->SetTitle(TempString);
        free(TempString);
        FrameCount = 0;
        time_elapsed -= 250;
    }
}




void Cleanup(void)
{
    DestroyShaders();
    DestroyVBO();
}




void CreateVBO(void)
{
    Vertex Vertices[] =
        {
            { { 0.0f, 0.0f, 0.0f, 1.0f }, { 1.0f, 1.0f, 1.0f, 1.0f } }, // 0




            // Top
            { { -0.2f, 0.8f, 0.0f, 1.0f }, { 0.0f, 1.0f, 0.0f, 1.0f } }, // 1
            { { 0.2f, 0.8f, 0.0f, 1.0f }, { 0.0f, 0.0f, 1.0f, 1.0f } }, // 2
            { { 0.0f, 0.8f, 0.0f, 1.0f }, { 0.0f, 1.0f, 1.0f, 1.0f } }, //3
            { { 0.0f, 1.0f, 0.0f, 1.0f }, { 1.0f, 0.0f, 0.0f, 1.0f } }, // 4




            // Bottom
            { { -0.2f, -0.8f, 0.0f, 1.0f }, { 0.0f, 0.0f, 1.0f, 1.0f } }, // 5
            { { 0.2f, -0.8f, 0.0f, 1.0f }, { 0.0f, 1.0f, 0.0f, 1.0f } }, // 6
            { { 0.0f, -0.8f, 0.0f, 1.0f }, { 0.0f, 1.0f, 1.0f, 1.0f } }, //7
            { { 0.0f, -1.0f, 0.0f, 1.0f }, { 1.0f, 0.0f, 0.0f, 1.0f } },    // 8




            // Left
            { { -0.8f, -0.2f, 0.0f, 1.0f }, { 0.0f, 1.0f, 0.0f, 1.0f } }, // 9
            { { -0.8f, 0.2f, 0.0f, 1.0f }, { 0.0f, 0.0f, 1.0f, 1.0f } }, // 10
            { { -0.8f, 0.0f, 0.0f, 1.0f }, { 0.0f, 1.0f, 1.0f, 1.0f } }, //11
            { { -1.0f, 0.0f, 0.0f, 1.0f }, { 1.0f, 0.0f, 0.0f, 1.0f } },    // 12




            // Right
            { { 0.8f, -0.2f, 0.0f, 1.0f }, { 0.0f, 0.0f, 1.0f, 1.0f } }, // 13
            { { 0.8f, 0.2f, 0.0f, 1.0f }, { 0.0f, 1.0f, 0.0f, 1.0f } }, // 14
            { { 0.8f, 0.0f, 0.0f, 1.0f }, { 0.0f, 1.0f, 1.0f, 1.0f } }, //15
            { { 1.0f, 0.0f, 0.0f, 1.0f }, { 1.0f, 0.0f, 0.0f, 1.0f } }  // 16
        };




    GLubyte Indices[] = {
        // Top
        0, 1, 3,
        0, 3, 2,
        3, 1, 4,
        3, 4, 2,




        // Bottom
        0, 5, 7,
        0, 7, 6,
        7, 5, 8,
        7, 8, 6,




        // Left
        0, 9, 11,
        0, 11, 10,
        11, 9, 12,
        11, 12, 10,




        // Right
        0, 13, 15,
        0, 15, 14,
        15, 13, 16,
        15, 16, 14
    };




    GLubyte AlternateIndices[] = {
        // Outer square border:
        3, 4, 16,
        3, 15, 16,
        15, 16, 8,
        15, 7, 8,
        7, 8, 12,
        7, 11, 12,
        11, 12, 4,
        11, 3, 4,




        // Inner square
        0, 11, 3,
        0, 3, 15,
        0, 15, 7,
        0, 7, 11
    };




    GLenum ErrorCheckValue = glGetError();
    const size_t BufferSize = sizeof(Vertices);
    const size_t VertexSize = sizeof(Vertices[0]);
    const size_t RgbOffset = sizeof(Vertices[0].XYZW);

    glGenVertexArrays(1, &VaoId);
    glBindVertexArray(VaoId);

    glGenBuffers(1, &BufferId);
    glBindBuffer(GL_ARRAY_BUFFER, BufferId);
    glBufferData(GL_ARRAY_BUFFER, BufferSize, Vertices, GL_STATIC_DRAW);




    glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, VertexSize, 0);
    glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, VertexSize, (GLvoid*)RgbOffset);




    glEnableVertexAttribArray(0);
    glEnableVertexAttribArray(1);




    glGenBuffers(2, IndexBufferId);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IndexBufferId[0]);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Indices), Indices, GL_STATIC_DRAW);




    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IndexBufferId[1]);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(AlternateIndices), AlternateIndices, GL_STATIC_DRAW);




    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IndexBufferId[0]);




    ErrorCheckValue = glGetError();
    if (ErrorCheckValue != GL_NO_ERROR)
    {
        fprintf(
            stderr,
            "ERROR: Could not create a VBO: %s \n",
            gluErrorString(ErrorCheckValue)
            );




        exit(-1);
    }
}




void DestroyVBO(void)
{
    GLenum ErrorCheckValue = glGetError();




    glDisableVertexAttribArray(1);
    glDisableVertexAttribArray(0);

    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glDeleteBuffers(1, &BufferId);




    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
    glDeleteBuffers(2, IndexBufferId);




    glBindVertexArray(0);
    glDeleteVertexArrays(1, &VaoId);




    ErrorCheckValue = glGetError();
    if (ErrorCheckValue != GL_NO_ERROR)
    {
        fprintf(
            stderr,
            "ERROR: Could not destroy the VBO: %s \n",
            gluErrorString(ErrorCheckValue)
            );




        exit(-1);
    }
}




void CreateShaders(void)
{
    GLenum ErrorCheckValue = glGetError();

    VertexShaderId = glCreateShader(GL_VERTEX_SHADER);
    glShaderSource(VertexShaderId, 1, &VertexShader, NULL);
    glCompileShader(VertexShaderId);




    FragmentShaderId = glCreateShader(GL_FRAGMENT_SHADER);
    glShaderSource(FragmentShaderId, 1, &FragmentShader, NULL);
    glCompileShader(FragmentShaderId);




    ProgramId = glCreateProgram();
    glAttachShader(ProgramId, VertexShaderId);
    glAttachShader(ProgramId, FragmentShaderId);
    glLinkProgram(ProgramId);
    glUseProgram(ProgramId);




    ErrorCheckValue = glGetError();
    if (ErrorCheckValue != GL_NO_ERROR)
    {
        fprintf(
            stderr,
            "ERROR: Could not create the shaders: %s \n",
            gluErrorString(ErrorCheckValue)
            );




        exit(-1);
    }
}




void DestroyShaders(void)
{
    GLenum ErrorCheckValue = glGetError();




    glUseProgram(0);




    glDetachShader(ProgramId, VertexShaderId);
    glDetachShader(ProgramId, FragmentShaderId);




    glDeleteShader(FragmentShaderId);
    glDeleteShader(VertexShaderId);




    glDeleteProgram(ProgramId);




    ErrorCheckValue = glGetError();
    if (ErrorCheckValue != GL_NO_ERROR)
    {
        fprintf(
            stderr,
            "ERROR: Could not destroy the shaders: %s \n",
            gluErrorString(ErrorCheckValue)
            );




        exit(-1);
    }
}


Re: Game Architecture Dev Environment

PostPosted: Sat Feb 11, 2012 1:53 am
by griffyboy0
Yo.

Linux GLFW.

Needs GLFW 2.7+ (The one in the Fedora repo isn't new enough. Download it and build it yourself.)

-Griff

Re: Game Architecture Dev Environment

PostPosted: Sun Feb 12, 2012 7:10 pm
by Ahumm
Using Tom's SFML method I was also receiving the Retarded Red Triangles on my W500, I also tried the solution on my desktop with an ATI card with the same result. This seemed odd to me so I started poking around in the code and doing some research. I have narrowed the problem down to the shaders as commenting out the call the CreateShaders() in the Initialize() function causes the four petal flower thing to render properly (albeit without the rainbow effect). I'll continue looking into the issue later today.

Stupid ATI.

Re: Game Architecture Dev Environment

PostPosted: Mon Feb 13, 2012 3:35 am
by Ahumm
Found the error and have it "fully" working now (Still throws me a GL_INVALID_VALUE error in the glDeleteShader() calls but it works otherwise). Problem was that the attribute indices weren't properly bound before the call to glLinkProblem so the shaders didn't know where to begin, from what I understand this is a problem on ATI and not Nvidia due to ATI's GLSL usage being much stricter than Nvidia's.

Corrected version of Tom's code is attached.

Re: Game Architecture Dev Environment

PostPosted: Mon Feb 13, 2012 6:20 am
by LordSupremePerson
Just want to point out that the error in that code is from Dr. Marc's code and not from mine. I never touched anything involving the shaders, just converted the GUI calls over to SFML.

Re: Game Architecture Dev Environment

PostPosted: Tue Feb 14, 2012 5:17 am
by BenChang
griffyboy0 wrote:Yo.

Linux GLFW.

Needs GLFW 2.7+ (The one in the Fedora repo isn't new enough. Download it and build it yourself.)

-Griff


Works in Ubuntu too.