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

Pages: [1]
1
Graphics / Re: Importing an .obj Model.
« on: August 08, 2012, 08:58:29 am »
So where can i find that .obj loader?
I have to make it myself?
And in the Tutorials there is no such thing which explains how to load a .obj model.

2
Graphics / Re: Importing an .obj Model.
« on: August 08, 2012, 08:21:04 am »
.obj is a 3d format. I'm looking for a tutorial which explains how to Load the .obj model and Render it into the SFML Window or any example.

3
Graphics / Importing an .obj Model.
« on: August 08, 2012, 06:57:59 am »
I have been searching a lot for a Tutorial or at least an Example to Load .obj model. Haven't  found any. ._.
Is there any one who can give me a link to a good Tutorial for Loading .obj in SFML or just an example?

or someone who can Explain it to me a bit.  >.<

4
Graphics / Re: Textured Cube.
« on: August 07, 2012, 08:02:28 pm »
Well It's working, But there is still one problem.
take a look at the code.

#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include<SFML/Graphics.hpp>
#include <GL/gl.h>
#include <GL/glu.h>
#include <iostream>


GLfloat     Rotate;

int width, height;
   
using namespace std;
int main()
{
    // create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, sf::ContextSettings(32));
    window.setVerticalSyncEnabled(true);
        width = 256;
    height = 256;
    glClearDepth(1.f);
    glClearColor(0.f, 0.f, 0.f, 0.f);
    glMatrixMode(GL_PROJECTION);
    glDepthMask(GL_TRUE);
    glEnable(GL_DEPTH_TEST);
    // load resources, initialize the OpenGL states, ...

    GLuint Texture = 0;
    {
        sf::Image Image;
        if (!Image.loadFromFile("Data/Crate.bmp"))
            return EXIT_FAILURE;
        glGenTextures(1, &Texture);
        glBindTexture(GL_TEXTURE_2D, Texture);
        gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, width, height, GL_RGBA, GL_UNSIGNED_BYTE, Image.getPixelsPtr());
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    }
    // run the main loop

    bool running = true;
    while (running)
    {
        // handle events
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                // end the program
                running = false;
            }
            else if (event.type == sf::Event::Resized)
            {
                // adjust the viewport when the window is resized
                glViewport(0, 0, event.size.width, event.size.height);
            }
        }

        // clear the buffers

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glLoadIdentity();
        gluPerspective(45.0f, 800.0f / 600.0f, 1.0f, 500.0f);
        // draw...

     glTranslatef(0.0f,0.0f,-5.0f);
     glRotatef(Rotate,1.0f,1.0f,1.0f);
         glEnable(GL_TEXTURE_2D);
     glBindTexture(GL_TEXTURE_2D, Texture);
     glColor4f(1.f, 1.f, 1.f, 1.f);

glBegin(GL_QUADS);
    // Front Face
    glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);  // Bottom Left Of The Texture and Quad
    glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);  // Bottom Right Of The Texture and Quad
    glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);  // Top Right Of The Texture and Quad
    glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);  // Top Left Of The Texture and Quad
    // Back Face
    glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);  // Bottom Right Of The Texture and Quad
    glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);  // Top Right Of The Texture and Quad
    glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);  // Top Left Of The Texture and Quad
    glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);  // Bottom Left Of The Texture and Quad
    // Top Face
    glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);  // Top Left Of The Texture and Quad
    glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,  1.0f,  1.0f);  // Bottom Left Of The Texture and Quad
    glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,  1.0f,  1.0f);  // Bottom Right Of The Texture and Quad
    glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);  // Top Right Of The Texture and Quad
    // Bottom Face
    glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);  // Top Right Of The Texture and Quad
    glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);  // Top Left Of The Texture and Quad
    glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);  // Bottom Left Of The Texture and Quad
    glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);  // Bottom Right Of The Texture and Quad
    // Right face
    glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);  // Bottom Right Of The Texture and Quad
    glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);  // Top Right Of The Texture and Quad
    glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);  // Top Left Of The Texture and Quad
    glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);  // Bottom Left Of The Texture and Quad
    // Left Face
    glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);  // Bottom Left Of The Texture and Quad
    glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);  // Bottom Right Of The Texture and Quad
    glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);  // Top Right Of The Texture and Quad
    glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);  // Top Left Of The Texture and Quad
glEnd();
 
     Rotate+=0.5f;


        // end the current frame (internally swaps the front and back buffers)
        window.display();
 
    }

    // release resources...


    return TRUE;
}

In this code line.
 gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, width, height, GL_RGBA, GL_UNSIGNED_BYTE, Image.getPixelsPtr());
I had to define width and height manually by using
int width, height;
width = 256;
height = 256;

In the sample which is old from 1.6 version.(I use 2.0)
It use Image.getWidth, Image.getHeight.
Which doesn't work in this version.
Is there any other way to do this? Instead of defining the size manually.
Like there was a way in 1.6 version.

5
Graphics / Re: Textured Cube.
« on: August 07, 2012, 07:36:57 pm »
The Samples are really helpful. I didn't know about them.
Thanks for your Help. :)

6
Graphics / Textured Cube.
« on: August 07, 2012, 03:02:54 am »
Hey there,
I'm trying to Texture this white cube but keep failing. Whenever i Run it no Texture appears on the cube. I tried different ways but its still not working.
The code is below that i'm using.

#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include<SFML/Graphics.hpp>
#include <GL/gl.h>
#include <GL/glu.h>
#include <iostream>


GLfloat     Rotate;


using namespace std;
int main()
{
    // create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, sf::ContextSettings(32));
    window.setVerticalSyncEnabled(true);

    glClearDepth(1.f);
    glClearColor(0.f, 0.f, 0.f, 0.f);
        glMatrixMode(GL_PROJECTION);

    glEnable(GL_DEPTH_TEST);
    // load resources, initialize the OpenGL states, ...

   sf::Texture texture;



    // run the main loop
    bool running = true;
    while (running)
    {
        // handle events
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                // end the program
                running = false;
            }
            else if (event.type == sf::Event::Resized)
            {
                // adjust the viewport when the window is resized
                glViewport(0, 0, event.size.width, event.size.height);
            }
        }

        // clear the buffers

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glLoadIdentity();
        gluPerspective(45.0f, 800.0f / 600.0f, 1.0f, 500.0f);
        // draw...

     glTranslatef(0.0f,0.0f,-5.0f);
     glRotatef(Rotate,1.0f,1.0f,1.0f);
         glBindTexture(GL_TEXTURE_2D, image.loadFromFile("test.png"));               // Select Our Texture


glBegin(GL_QUADS);
    // Front Face
    glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);  // Bottom Left Of The Texture and Quad
    glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);  // Bottom Right Of The Texture and Quad
    glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);  // Top Right Of The Texture and Quad
    glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);  // Top Left Of The Texture and Quad
    // Back Face
    glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);  // Bottom Right Of The Texture and Quad
    glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);  // Top Right Of The Texture and Quad
    glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);  // Top Left Of The Texture and Quad
    glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);  // Bottom Left Of The Texture and Quad
    // Top Face
    glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);  // Top Left Of The Texture and Quad
    glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,  1.0f,  1.0f);  // Bottom Left Of The Texture and Quad
    glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,  1.0f,  1.0f);  // Bottom Right Of The Texture and Quad
    glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);  // Top Right Of The Texture and Quad
    // Bottom Face
    glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);  // Top Right Of The Texture and Quad
    glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);  // Top Left Of The Texture and Quad
    glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);  // Bottom Left Of The Texture and Quad
    glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);  // Bottom Right Of The Texture and Quad
    // Right face
    glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);  // Bottom Right Of The Texture and Quad
    glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);  // Top Right Of The Texture and Quad
    glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);  // Top Left Of The Texture and Quad
    glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);  // Bottom Left Of The Texture and Quad
    // Left Face
    glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);  // Bottom Left Of The Texture and Quad
    glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);  // Bottom Right Of The Texture and Quad
    glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);  // Top Right Of The Texture and Quad
    glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);  // Top Left Of The Texture and Quad
glEnd();
 
     Rotate+=0.5f;


        // end the current frame (internally swaps the front and back buffers)
        window.display();
 
    }

    // release resources...


    return TRUE;
}

And just so you know I've putted the test.png file in the Project folder.

7
Graphics / Re: Setting Up Lightning in SFML OpenGL
« on: August 07, 2012, 01:39:43 am »
Would you recommend me a good Book on OpenGL Programming?

8
Graphics / Setting Up Lightning in SFML OpenGL
« on: August 06, 2012, 07:37:41 pm »
Just was wondering Can i get an Example for setting up light and shades in SFML.
I am having abit problem with lightning So it will be great if i get an example.

9
Graphics / Re: Windows Shows up Blank.
« on: August 06, 2012, 10:15:11 am »
Ehm well now i figured out everything.
Everything is working fine now.

Thanks for the help.
And sorry for being annoying. :P

10
Graphics / Re: Windows Shows up Blank.
« on: August 06, 2012, 10:00:36 am »
Well I'm keep getting this error while trying to set the glMatrixMode.

1>main.obj : error LNK2019: unresolved external symbol _gluPerspective@32 referenced in function _main

11
Graphics / Re: Windows Shows up Blank.
« on: August 06, 2012, 09:20:18 am »
Well What's wrong with the code i written above?
What should i do with it?
Why is it not working?
Why I always see a black screen?
That's all the questions on my mind rite now.

It will be great if I get an Answer for them.

12
Graphics / Re: Windows Shows up Blank.
« on: August 06, 2012, 09:04:17 am »
I tried Disabling it using glDisable(GL_DEPTH_TEST).
the Window is still Blank.
What can i do?
Is not there any good Tutorial for this?

I have seen a tutorial for the Cube in SFML 1.2.
But as i said I'm really new to OpenGL.
I can't convert this 1.2 code to the 2.0 version code.

13
Graphics / Re: Windows Shows up Blank.
« on: August 06, 2012, 08:21:53 am »
That's the new code.
As you said about glClearColor and glColor they both added in it now.
and its still blank.

#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include<SFML/Graphics.hpp>
#include <iostream>

int main()
{
    // create the window
    sf::Window window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, sf::ContextSettings(32));
    window.setVerticalSyncEnabled(true);

    glClearDepth(1.f);
    glClearColor(0.f, 0.f, 0.f, 0.f);

    // load resources, initialize the OpenGL states, ...


    // run the main loop
    bool running = true;
    while (running)
    {
        // handle events
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                // end the program
                running = false;
            }
            else if (event.type == sf::Event::Resized)
            {
                // adjust the viewport when the window is resized
                glViewport(0, 0, event.size.width, event.size.height);
            }
        }

        // clear the buffers

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glLoadIdentity();

        // draw...
       glTranslatef(3.0f,0.0f,0.0f);  
       glColor3f(0.5f,0.5f,1.0f);              // Set The Color To Blue One Time Only
       glBegin(GL_QUADS);                  // Start Drawing Quads
          glVertex3f(-1.0f, 1.0f, 0.0f);          // Left And Up 1 Unit (Top Left)
          glVertex3f( 1.0f, 1.0f, 0.0f);          // Right And Up 1 Unit (Top Right)
          glVertex3f( 1.0f,-1.0f, 0.0f);          // Right And Down One Unit (Bottom Right)
          glVertex3f(-1.0f,-1.0f, 0.0f);          // Left And Down One Unit (Bottom Left)
        glEnd();  

        // end the current frame (internally swaps the front and back buffers)
        window.display();
    }

    // release resources...

    return TRUE;
}

14
Graphics / Windows Shows up Blank.
« on: August 06, 2012, 07:20:09 am »
Hi there,
I am really new to OpenGL Programming and SFML.
I was trying to Draw a polygon in the Window.
I tried this code.
#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include<SFML/Graphics.hpp>
#include <iostream>

int main()
{
    // create the window
    sf::Window window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, sf::ContextSettings(32));
    window.setVerticalSyncEnabled(true);

    // load resources, initialize the OpenGL states, ...

    // run the main loop
    bool running = true;
    while (running)
    {
        // handle events
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                // end the program
                running = false;
            }
            else if (event.type == sf::Event::Resized)
            {
                // adjust the viewport when the window is resized
                glViewport(0, 0, event.size.width, event.size.height);
            }
        }

        // clear the buffers
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glLoadIdentity();

        glTranslatef(-1.5f,0.0f,-6.0f);

        // draw...
        glBegin(GL_TRIANGLES);                      // Drawing Using Triangles
           glVertex3f( 0.0f, 1.0f, 0.0f);              // Top
           glVertex3f(-1.0f,-1.0f, 0.0f);              // Bottom Left
           glVertex3f( 1.0f,-1.0f, 0.0f);              // Bottom Right
        glEnd();  

        // end the current frame (internally swaps the front and back buffers)
        window.display();
    }

    // release resources...

    return 0;
}

I know something is missing but what is it?
Whenever i try to debug it.
Only a Blank Window Shows Up.

Pages: [1]