Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Where Did you learn OpenGL?  (Read 9499 times)

0 Members and 1 Guest are viewing this topic.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Where Did you learn OpenGL?
« Reply #15 on: December 06, 2010, 07:05:46 am »
Beginning OpenGL Game Programming is a great book they could get you.
And I still recommend that you use SFML instead of GLUT. In order to use OpenGL with SFML all you need to do is... Create a sf::Window and then call OpenGL functions and then tell your window "Display", if I remember correctly. Also you can use sf::Image as textures for anything you draw in OpenGL.

For example sf::Sprite and sf::Shape and so on uses OpenGL in the background to display something in a RenderWindow.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Where Did you learn OpenGL?
« Reply #16 on: December 06, 2010, 04:58:53 pm »
Quote from: "Groogy"
Beginning OpenGL Game Programming is a great book they could get you.
And I still recommend that you use SFML instead of GLUT. In order to use OpenGL with SFML all you need to do is... Create a sf::Window and then call OpenGL functions and then tell your window "Display", if I remember correctly. Also you can use sf::Image as textures for anything you draw in OpenGL.

For example sf::Sprite and sf::Shape and so on uses OpenGL in the background to display something in a RenderWindow.


Alright I think I will use sfml but I cant seem to get the downloaded project to work from the tutorial... I am using sfml 2..

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Where Did you learn OpenGL?
« Reply #17 on: December 06, 2010, 06:16:13 pm »
Quote from: "Fierce_Dutch"
Quote from: "Groogy"
Beginning OpenGL Game Programming is a great book they could get you.
And I still recommend that you use SFML instead of GLUT. In order to use OpenGL with SFML all you need to do is... Create a sf::Window and then call OpenGL functions and then tell your window "Display", if I remember correctly. Also you can use sf::Image as textures for anything you draw in OpenGL.

For example sf::Sprite and sf::Shape and so on uses OpenGL in the background to display something in a RenderWindow.


Alright I think I will use sfml but I cant seem to get the downloaded project to work from the tutorial... I am using sfml 2..


SFML2 is a bit different from the tutorial in SFML1.6

I got an example here:
Code: [Select]
class Something : public sf::Drawable
{
protected:
void Render( sf::RenderTarget& target, sf::Renderer& renderer ) const
{
sf::Shape shape = sf::Shape::Circle( 0, 0, 100, sf::Color::Blue );
target.Draw( shape );
renderer.Begin( sf::Renderer::QuadList );
renderer.AddVertex( 0, 0 );
renderer.AddVertex( 0, 100);
renderer.AddVertex( 100, 100 );
renderer.AddVertex( 100, 0 );
renderer.AddVertex( 200, 200 );
renderer.AddVertex( 200, 300);
renderer.AddVertex( 300, 300 );
renderer.AddVertex( 300, 200 );
renderer.End();
}
};

int main()
{
    sf::RenderWindow application( sf::VideoMode(800, 600), "SFML Cube" );
    Something something;
    something.SetPosition( 100, 100 );

    while( application.IsOpened() )
    {
    sf::Event event;
    while( application.GetEvent( event ) )
    {
    if( event.Type == sf::Event::Closed )
    {
    application.Close();
    }
    }

application.Clear();
sf::View view = application.GetView();
view.Move( -1, -1 );
application.SetView( view );
application.Draw( something );
    application.Display();

    something.Rotate( 0.5 );
    }
    return 0;
}
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

AlexM

  • Newbie
  • *
  • Posts: 18
    • View Profile
Where Did you learn OpenGL?
« Reply #18 on: December 06, 2010, 06:18:04 pm »

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Where Did you learn OpenGL?
« Reply #19 on: December 07, 2010, 03:21:09 am »
Quote from: "Groogy"
Quote from: "Fierce_Dutch"
Quote from: "Groogy"
Beginning OpenGL Game Programming is a great book they could get you.
And I still recommend that you use SFML instead of GLUT. In order to use OpenGL with SFML all you need to do is... Create a sf::Window and then call OpenGL functions and then tell your window "Display", if I remember correctly. Also you can use sf::Image as textures for anything you draw in OpenGL.

For example sf::Sprite and sf::Shape and so on uses OpenGL in the background to display something in a RenderWindow.


Alright I think I will use sfml but I cant seem to get the downloaded project to work from the tutorial... I am using sfml 2..


SFML2 is a bit different from the tutorial in SFML1.6

I got an example here:
Code: [Select]
class Something : public sf::Drawable
{
protected:
void Render( sf::RenderTarget& target, sf::Renderer& renderer ) const
{
sf::Shape shape = sf::Shape::Circle( 0, 0, 100, sf::Color::Blue );
target.Draw( shape );
renderer.Begin( sf::Renderer::QuadList );
renderer.AddVertex( 0, 0 );
renderer.AddVertex( 0, 100);
renderer.AddVertex( 100, 100 );
renderer.AddVertex( 100, 0 );
renderer.AddVertex( 200, 200 );
renderer.AddVertex( 200, 300);
renderer.AddVertex( 300, 300 );
renderer.AddVertex( 300, 200 );
renderer.End();
}
};

int main()
{
    sf::RenderWindow application( sf::VideoMode(800, 600), "SFML Cube" );
    Something something;
    something.SetPosition( 100, 100 );

    while( application.IsOpened() )
    {
    sf::Event event;
    while( application.GetEvent( event ) )
    {
    if( event.Type == sf::Event::Closed )
    {
    application.Close();
    }
    }

application.Clear();
sf::View view = application.GetView();
view.Move( -1, -1 );
application.SetView( view );
application.Draw( something );
    application.Display();

    something.Rotate( 0.5 );
    }
    return 0;
}


I think I will just stick with glut because this looks nothing like open gl. Also I think GLUT is crossplatform... What windowing system is crosspaltform because then I will use that...

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Where Did you learn OpenGL?
« Reply #20 on: December 07, 2010, 03:34:42 am »
Quote from: "Fierce_Dutch"
Quote from: "Groogy"
Quote from: "Fierce_Dutch"
Quote from: "Groogy"
Beginning OpenGL Game Programming is a great book they could get you.
And I still recommend that you use SFML instead of GLUT. In order to use OpenGL with SFML all you need to do is... Create a sf::Window and then call OpenGL functions and then tell your window "Display", if I remember correctly. Also you can use sf::Image as textures for anything you draw in OpenGL.

For example sf::Sprite and sf::Shape and so on uses OpenGL in the background to display something in a RenderWindow.


Alright I think I will use sfml but I cant seem to get the downloaded project to work from the tutorial... I am using sfml 2..


SFML2 is a bit different from the tutorial in SFML1.6

I got an example here:
Code: [Select]
class Something : public sf::Drawable
{
protected:
void Render( sf::RenderTarget& target, sf::Renderer& renderer ) const
{
sf::Shape shape = sf::Shape::Circle( 0, 0, 100, sf::Color::Blue );
target.Draw( shape );
renderer.Begin( sf::Renderer::QuadList );
renderer.AddVertex( 0, 0 );
renderer.AddVertex( 0, 100);
renderer.AddVertex( 100, 100 );
renderer.AddVertex( 100, 0 );
renderer.AddVertex( 200, 200 );
renderer.AddVertex( 200, 300);
renderer.AddVertex( 300, 300 );
renderer.AddVertex( 300, 200 );
renderer.End();
}
};

int main()
{
    sf::RenderWindow application( sf::VideoMode(800, 600), "SFML Cube" );
    Something something;
    something.SetPosition( 100, 100 );

    while( application.IsOpened() )
    {
    sf::Event event;
    while( application.GetEvent( event ) )
    {
    if( event.Type == sf::Event::Closed )
    {
    application.Close();
    }
    }

application.Clear();
sf::View view = application.GetView();
view.Move( -1, -1 );
application.SetView( view );
application.Draw( something );
    application.Display();

    something.Rotate( 0.5 );
    }
    return 0;
}


I think I will just stick with glut because this looks nothing like open gl. Also I think GLUT is crossplatform... What windowing system is crosspaltform because then I will use that...
You can use the SFML Window Library and do all of the OpenGL yourself.
I use the latest build of SFML2

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Where Did you learn OpenGL?
« Reply #21 on: December 07, 2010, 05:47:33 am »
Quote from: "OniLink10"
Quote from: "Fierce_Dutch"
Quote from: "Groogy"
Quote from: "Fierce_Dutch"
Quote from: "Groogy"
Beginning OpenGL Game Programming is a great book they could get you.
And I still recommend that you use SFML instead of GLUT. In order to use OpenGL with SFML all you need to do is... Create a sf::Window and then call OpenGL functions and then tell your window "Display", if I remember correctly. Also you can use sf::Image as textures for anything you draw in OpenGL.

For example sf::Sprite and sf::Shape and so on uses OpenGL in the background to display something in a RenderWindow.


Alright I think I will use sfml but I cant seem to get the downloaded project to work from the tutorial... I am using sfml 2..


SFML2 is a bit different from the tutorial in SFML1.6

I got an example here:
Code: [Select]
class Something : public sf::Drawable
{
protected:
void Render( sf::RenderTarget& target, sf::Renderer& renderer ) const
{
sf::Shape shape = sf::Shape::Circle( 0, 0, 100, sf::Color::Blue );
target.Draw( shape );
renderer.Begin( sf::Renderer::QuadList );
renderer.AddVertex( 0, 0 );
renderer.AddVertex( 0, 100);
renderer.AddVertex( 100, 100 );
renderer.AddVertex( 100, 0 );
renderer.AddVertex( 200, 200 );
renderer.AddVertex( 200, 300);
renderer.AddVertex( 300, 300 );
renderer.AddVertex( 300, 200 );
renderer.End();
}
};

int main()
{
    sf::RenderWindow application( sf::VideoMode(800, 600), "SFML Cube" );
    Something something;
    something.SetPosition( 100, 100 );

    while( application.IsOpened() )
    {
    sf::Event event;
    while( application.GetEvent( event ) )
    {
    if( event.Type == sf::Event::Closed )
    {
    application.Close();
    }
    }

application.Clear();
sf::View view = application.GetView();
view.Move( -1, -1 );
application.SetView( view );
application.Draw( something );
    application.Display();

    something.Rotate( 0.5 );
    }
    return 0;
}


I think I will just stick with glut because this looks nothing like open gl. Also I think GLUT is crossplatform... What windowing system is crosspaltform because then I will use that...
You can use the SFML Window Library and do all of the OpenGL yourself.


Do you have an example for that? Because the 1.6 one isnt working but I will search around.

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Where Did you learn OpenGL?
« Reply #22 on: December 07, 2010, 05:50:29 am »
Quote from: "Fierce_Dutch"
Quote from: "OniLink10"
Quote from: "Fierce_Dutch"
Quote from: "Groogy"
Quote from: "Fierce_Dutch"
Quote from: "Groogy"
Beginning OpenGL Game Programming is a great book they could get you.
And I still recommend that you use SFML instead of GLUT. In order to use OpenGL with SFML all you need to do is... Create a sf::Window and then call OpenGL functions and then tell your window "Display", if I remember correctly. Also you can use sf::Image as textures for anything you draw in OpenGL.

For example sf::Sprite and sf::Shape and so on uses OpenGL in the background to display something in a RenderWindow.


Alright I think I will use sfml but I cant seem to get the downloaded project to work from the tutorial... I am using sfml 2..


SFML2 is a bit different from the tutorial in SFML1.6

I got an example here:
Code: [Select]
class Something : public sf::Drawable
{
protected:
void Render( sf::RenderTarget& target, sf::Renderer& renderer ) const
{
sf::Shape shape = sf::Shape::Circle( 0, 0, 100, sf::Color::Blue );
target.Draw( shape );
renderer.Begin( sf::Renderer::QuadList );
renderer.AddVertex( 0, 0 );
renderer.AddVertex( 0, 100);
renderer.AddVertex( 100, 100 );
renderer.AddVertex( 100, 0 );
renderer.AddVertex( 200, 200 );
renderer.AddVertex( 200, 300);
renderer.AddVertex( 300, 300 );
renderer.AddVertex( 300, 200 );
renderer.End();
}
};

int main()
{
    sf::RenderWindow application( sf::VideoMode(800, 600), "SFML Cube" );
    Something something;
    something.SetPosition( 100, 100 );

    while( application.IsOpened() )
    {
    sf::Event event;
    while( application.GetEvent( event ) )
    {
    if( event.Type == sf::Event::Closed )
    {
    application.Close();
    }
    }

application.Clear();
sf::View view = application.GetView();
view.Move( -1, -1 );
application.SetView( view );
application.Draw( something );
    application.Display();

    something.Rotate( 0.5 );
    }
    return 0;
}


I think I will just stick with glut because this looks nothing like open gl. Also I think GLUT is crossplatform... What windowing system is crosspaltform because then I will use that...
You can use the SFML Window Library and do all of the OpenGL yourself.


Do you have an example for that? Because the 1.6 one isnt working but I will search around.
I would recommend looking at the docs for SFML2 and the examples that come in SFML2's svn repo.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Where Did you learn OpenGL?
« Reply #23 on: December 07, 2010, 07:55:37 am »
Hey guys, you don't need to quote 2 kilometers of posts every time you reply, these posts are just above ;)
Laurent Gomila - SFML developer

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Where Did you learn OpenGL?
« Reply #24 on: December 08, 2010, 02:59:32 am »
Quote from: "Laurent"
Hey guys, you don't need to quote 2 kilometers of posts every time you reply, these posts are just above ;)


Ok sorry lol, also I still can't get OpenGL to work with SFML.....

Terrydil

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Where Did you learn OpenGL?
« Reply #25 on: December 08, 2010, 05:17:44 am »
Quote from: "Fierce_Dutch"
I still can't get OpenGL to work with SFML.....


At the simplest level, all you have to do is create an SFML window like you normally would and then make OpenGL calls and call Display() on the SFML window to display it.

Just make sure you are linking to and including the OpenGL library since you will be calling it directly.

Here is an simple example (based on the SFML 1.6 Xcode template) that uses SFML to create a window, clears the screen w/ OpenGL (makes it red), and then displays it by calling Display() on the SFML window.  Note that instead of using sf::RenderWindow.Clear() like you normally would I'm using 2 calls directly to OpenGL to do the same thing.  glClearColor sets the color you want and glClear actually calls it.

Code: [Select]
#include <SFML/Graphics.hpp>
#include <OpenGL/OpenGL.h>

int main()
{
    // Create main window
    sf::RenderWindow App(sf::VideoMode(640, 480), "SFML Test w/ OpenGL calls");

glClearColor(255, 0, 0, 255);

    // Start game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        // Clear screen
        //App.Clear();

       glClear(GL_COLOR_BUFFER_BIT);

       

        // Finally, display the rendered frame on screen
        App.Display();
    }

    return EXIT_SUCCESS;
}


I simply commented out App.Clear() but left it in there so you could see that I am literally just replacing the SFML drawing calls with OpenGL ones.

If you can get that far you can start plugging in stuff from various OpenGL tutorials and do more interesting things than simply making the screen different colors. :)

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Where Did you learn OpenGL?
« Reply #26 on: December 08, 2010, 06:05:10 am »
Quote from: "Terrydil"
Quote from: "Fierce_Dutch"
I still can't get OpenGL to work with SFML.....


At the simplest level, all you have to do is create an SFML window like you normally would and then make OpenGL calls and call Display() on the SFML window to display it.

Just make sure you are linking to and including the OpenGL library since you will be calling it directly.

Here is an simple example (based on the SFML 1.6 Xcode template) that uses SFML to create a window, clears the screen w/ OpenGL (makes it red), and then displays it by calling Display() on the SFML window.  Note that instead of using sf::RenderWindow.Clear() like you normally would I'm using 2 calls directly to OpenGL to do the same thing.  glClearColor sets the color you want and glClear actually calls it.

Code: [Select]
#include <SFML/Graphics.hpp>
#include <OpenGL/OpenGL.h>

int main()
{
    // Create main window
    sf::RenderWindow App(sf::VideoMode(640, 480), "SFML Test w/ OpenGL calls");

glClearColor(255, 0, 0, 255);

    // Start game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        // Clear screen
        //App.Clear();

       glClear(GL_COLOR_BUFFER_BIT);

       

        // Finally, display the rendered frame on screen
        App.Display();
    }

    return EXIT_SUCCESS;
}


I simply commented out App.Clear() but left it in there so you could see that I am literally just replacing the SFML drawing calls with OpenGL ones.

If you can get that far you can start plugging in stuff from various OpenGL tutorials and do more interesting things than simply making the screen different colors. :)


Thanks! How would I draw a shape? Make a Draw() function and then put my shape and it's vertices in that function and then just call it? Also I just tried this code and got this, btw I changed the include don't worry about that..

Code: [Select]
1>main.obj : error LNK2001: unresolved external symbol __imp__glClear@4
1>main.obj : error LNK2001: unresolved external symbol __imp__glClearColor@16
1>main.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (??1RenderWindow@sf@@UAE@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::ContextSettings const &)" (??0RenderWindow@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KABUContextSettings@1@@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: void __thiscall sf::Window::Display(void)" (?Display@Window@sf@@QAEXXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: bool __thiscall sf::Window::GetEvent(class sf::Event &)" (?GetEvent@Window@sf@@QAE_NAAVEvent@2@@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: bool __thiscall sf::Window::IsOpened(void)const " (?IsOpened@Window@sf@@QBE_NXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: void __thiscall sf::Window::Close(void)" (?Close@Window@sf@@QAEXXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (??0VideoMode@sf@@QAE@III@Z)



BTW I did link OpenGL32 and I checked for ti in my VC directory which is where Visual studio looks for stuff.

Zweistein

  • Newbie
  • *
  • Posts: 29
    • View Profile
Where Did you learn OpenGL?
« Reply #27 on: December 08, 2010, 09:03:28 am »
I learned it complete at nehes tutorials. Back in the old days it was the only Ressource i got.

Later i bought a book. but didn t read too much :) And 2 years ago i bought an advanced book, but never read it :) But i have s.th. to look, when i need to know s.th.

 

anything