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

Author Topic: OpenGL and SFML  (Read 14569 times)

0 Members and 1 Guest are viewing this topic.

molmasepic

  • Newbie
  • *
  • Posts: 43
    • View Profile
OpenGL and SFML
« on: February 09, 2011, 12:06:41 am »
hey i heard that i can use normal opengl tutorials with SFML, but the thing is:
im not sure on which tutorials are good...

im wondering if maybe someone knows a good tutorial site for opengl(with sfml would be even better) just so i dont get super confused ._.


thanks in advance!  :D


EDIT: my IDE is Code Blocks and my Compiler is MinGW if that helps

Oneiros

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
OpenGL and SFML
« Reply #1 on: February 09, 2011, 01:06:26 am »
There is sample named "OpenGL" you can start here :p
And : http://www.sfml-dev.org/tutorials/1.6/window-opengl-fr.php

May be this site can help you
http://nehe.gamedev.net/

Good luck ;)

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
OpenGL and SFML
« Reply #2 on: February 09, 2011, 01:31:15 am »
I support Oneiros' proposal. (Except I wouldn't link to the French tutorial  :P )

Read carefully «SFML and Code::Blocks (MinGW)» from «Getting started» then jump to «Window package» section and focus on SFML code (possibly skip OpenGL stuff from now).

Then I recommend you to read lesson 2 from nehe (and the next ones) skip the Windows related code and try to adapt the code for handling events to use SFML (like the «Finally change the code to toggle window / fullscreen mode..» part from lesson 2). (Well, focus on the OpenGL functions.)

An also interesting book is this one : the red book. It's maybe a better choice than nehe tutorial because it focus on OGL stuff.

But you might be interested by using SFML Graphics module.  :wink:
SFML / OS X developer

molmasepic

  • Newbie
  • *
  • Posts: 43
    • View Profile
OpenGL and SFML
« Reply #3 on: February 09, 2011, 01:33:18 am »
ok ive tried the sample but i got a small error..


|undefined reference to `gluPerspective@32'|


any ideas? did i miss something?

@ Hiura, by "windows related" you mean like the OS? thats what im using

Oneiros

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
OpenGL and SFML
« Reply #4 on: February 09, 2011, 01:35:48 am »
Oups sorry for french link (i'm french ^^)

I think you've not link openGl lib

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
OpenGL and SFML
« Reply #5 on: February 09, 2011, 01:36:41 am »
You forget to link against opengl lib. ;-)

see http://www.sfml-dev.org/forum/viewtopic.php?p=26330#26330
SFML / OS X developer

molmasepic

  • Newbie
  • *
  • Posts: 43
    • View Profile
OpenGL and SFML
« Reply #6 on: February 09, 2011, 01:37:54 am »
Quote from: "Oneiros"
Oups sorry for french link (i'm french ^^)

I think you've not link openGl lib


okay i got it to work(it was glu32)

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
OpenGL and SFML
« Reply #7 on: February 09, 2011, 01:37:57 am »
Quote
@ Hiura, by "windows related" you mean like the OS? thats what im using
Yes. Because if you use SFML to handle the window you won't have to use any Windows specific code.
SFML / OS X developer

molmasepic

  • Newbie
  • *
  • Posts: 43
    • View Profile
OpenGL and SFML
« Reply #8 on: February 09, 2011, 01:40:23 am »
Quote from: "Hiura"
Quote
@ Hiura, by "windows related" you mean like the OS? thats what im using
Yes. Because if you use SFML to handle the window you won't have to use any Windows specific code.




ah so window(the app)

i thought the operating system(windows) xD

ok i better get started, thanks

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
OpenGL and SFML
« Reply #9 on: February 09, 2011, 01:45:01 am »
I think there is still a little bit of misunderstanding, Sorry  ^^'

-by window or windows (lower case) I'm speaking of user interface

-by Windows (capital w) I'm referring to the OS.

But it's pretty much the same as the window related code is for Windows in the nehe tutorials... Ok I shut up!  :lol:
SFML / OS X developer

molmasepic

  • Newbie
  • *
  • Posts: 43
    • View Profile
OpenGL and SFML
« Reply #10 on: February 09, 2011, 02:08:02 am »
ohhhh ok i get you

molmasepic

  • Newbie
  • *
  • Posts: 43
    • View Profile
OpenGL and SFML
« Reply #11 on: February 13, 2011, 08:50:25 pm »
hey ive been working (or trying to work) with OpenGL for some time now. and i have a couple new questions.

a tutorial i found is videotutorialsrock.com because i like video tutorials xD

but i noticed when i put the opengl stuff into my current sfml project, it never renders right...

trying to say that when i clear window(glClear) only one or two sfml sprites show up.


does this mean that im going to have to start over with opengl fully? or maybe im doing this wrong..?

if anyone needs more info please let me know, i will pull up some code also if that is needed.

thanks again for the tutorials

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
OpenGL and SFML
« Reply #12 on: February 13, 2011, 09:17:14 pm »
Can you post the relevant part of your code here ?
SFML / OS X developer

molmasepic

  • Newbie
  • *
  • Posts: 43
    • View Profile
OpenGL and SFML
« Reply #13 on: February 13, 2011, 09:23:12 pm »
Code: [Select]
//sfml stuff(main function)
    glClearDepth(1.f);
    glClearColor(0.f,0.f,0.f,0.f);
    /////z buffer
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_COLOR_MATERIAL);
    glDepthMask(GL_TRUE);
    /////perspective projection
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(-20.f,1.f,1.f,200.f);
//sfml loading/first placement
//sfml main loop
//input
        GameWind.SetActive();
        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        glBegin(GL_QUADS);
        glVertex3f(3.f,3.f,3.f);
        glVertex3f(3.f,6.f,3.f);
        glVertex3f(6.f,6.f,3.f);
        glVertex3f(6.f,3.f,3.f);
        glColor3f(0.5f,0.8f,0.f);
        glEnd();
//some subrect updating and then the drawing



the only thing that actually drew was the stuff that i set positions for BEFORE i cleared the gl window


if this is too vague then ill update xD
[/code]

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
OpenGL and SFML
« Reply #14 on: February 13, 2011, 09:24:55 pm »
I might have an idea but I'd like the full main to be sure.
SFML / OS X developer