The code is a little dirty, but I'll guide you.
#define GLEW_STATIC
#include <glew.h>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include "../UnforeseenCosmosCore/Math/Matrix4x4.h"
#include "../UnforeseenCosmosCore/Math/Vector3.h"
#define PI 3.14159
int main()
{
sf::WindowSettings Settings;
Settings.DepthBits = 24; // Request a 24 bits depth buffer
Settings.StencilBits = 8; // Request a 8 bits stencil buffer
Settings.AntialiasingLevel = 2; // Request 2 levels of antialiasing
// Create the main window
sf::RenderWindow App(sf::VideoMode(600, 600, 32), "SFML window", sf::Style::Close, Settings);
// App.PreserveOpenGLStates(true);
App.UseVerticalSync(false);
App.SetActive();
// Load a sprite to display
sf::Image Image;
if (!Image.LoadFromFile("cb.bmp"))
return EXIT_FAILURE;
sf::Font MyFont;
// Load from a font file on disk
if (!MyFont.LoadFromFile("uni05_54.ttf"))
{
// Error...
}
sf::String text("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's\n"
"sktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.", MyFont, 16);
sf::Sprite Sprite(Image); // HERE
Sprite.SetPosition(400.f - Sprite.GetSize().x / 2.f, 300.f - Sprite.GetSize().y / 2.f);
// Set color and depth clear value
glClearColor(0.f, 0.f, 0.f, 0.f);
// Enable Z-buffer read and write
glEnable(GL_DEPTH_TEST);
glEnable(GL_COLOR);
glDepthMask(GL_TRUE);
glClearDepth(1.f);
// Setup a perspective projection
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glEnable(GL_TEXTURE_2D);
gluPerspective(90.f, 1.f, 0.1f, 5000.f);
gluLookAt(50.f, 50.f, 50.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f);
/*const float vertices[] =
{
20.f, 0.f, 10.f,
30.f, 20.f, 10.f,
40.f, 0.f, 10.f
};*/
UCC::Vector3<float> v1(0.f, 10.f, 0.f), v2(10.f, -10.f, 0.f), v3( -10.f, -10.f, 0.f);
UCC::Matrix4x4<float> matrix;
matrix = UCC::Matrix4x4<float>::CreateFromRotationXYZ_S(PI / 6000.f, PI / 6000.f, PI / 6000.f);
// Start the game loop
while (App.IsOpened())
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
}
// Draw the sprite
// App.Draw(Sprite);
glEnable(GL_DEPTH_TEST);
glEnable(GL_COLOR);
glDepthMask(GL_TRUE);
glClearDepth(1.f);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glEnable(GL_TEXTURE_2D);
gluPerspective(90.f, 1.f, 0.1f, 5000.f);
gluLookAt(50.f, 50.f, 50.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glBegin(GL_TRIANGLES);
glColor3d(1.0, 0.0, 0.0);
glVertex3f(v1.x, v1.y, v1.z);
glColor3d(0.0, 1.0, 0.0);
glVertex3f(v2.x, v2.y, v2.z);
glColor3d(0.0, 0.0, 1.0);
glVertex3f(v3.x, v3.y, v3.z);
glEnd();
v1.Transform(matrix);
v2.Transform(matrix);
v3.Transform(matrix);
App.Draw(Sprite);
// Update the window
App.Display();
}
return EXIT_SUCCESS;
}
If you take the variable App for exemple, you'll notice that I use two functions: Draw() and Display(). I had to search them on Internet because CB wasn't telling me the members/functions of App. Usually, in CB, you can call auto-completion with ctrl-j or sometimes with ctrl-space. It just doesn't work for me because, as I explained, I can't see members/functions, except for static ones. For exemple, before I write anything, I can see members/functions in the function main. As an other exemple, I can search with auto-complete the variable App, but not its members/functions.