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

Author Topic: Using ogl for drawing  (Read 2892 times)

0 Members and 1 Guest are viewing this topic.

troopson

  • Newbie
  • *
  • Posts: 30
    • View Profile
Using ogl for drawing
« on: February 01, 2010, 05:12:05 pm »
Hi, im using SFML+OGL and i use SFML only for Window and Input stuff.

Ive got a problem

 here is my initgl function

Code: [Select]
int CGra::InitGL(GLvoid) // All Setup For OpenGL Goes Here
{
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping ( NEW )
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.5f);

return TRUE; // Initialization Went OK
}


 here is my drawing function
Code: [Select]

int CGra::DrawGLScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix();

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

glColor3f(1.0f,0.0f,0.0f);
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();
   glPopMatrix();
glFlush();


return TRUE;
}


ive got NO more functions that use GL(only bitmaps loading using SOIL lbirary)..
The triangle is not being drawn ;( If i draw sprites using OGL functions its okay, but simple primitives doesnt work :( why?

i use PreverveOpenGlStates

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Using ogl for drawing
« Reply #1 on: February 01, 2010, 05:42:22 pm »
Why do you use a sf::RenderWindow if you only use SFML for windo and input? Use a sf::Window instead.
Laurent Gomila - SFML developer

troopson

  • Newbie
  • *
  • Posts: 30
    • View Profile
Using ogl for drawing
« Reply #2 on: February 01, 2010, 06:16:01 pm »
is it rly so important? Renderwindow is useful for displaying Text,screencapture etc..... ??

btw i Found the Error - gluPerspective was uncorrect ..

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Using ogl for drawing
« Reply #3 on: February 01, 2010, 06:21:36 pm »
Quote
is it rly so important?

sf::Window doesn't mess up your OpenGL states, which can help for debugging :)
Laurent Gomila - SFML developer

troopson

  • Newbie
  • *
  • Posts: 30
    • View Profile
Using ogl for drawing
« Reply #4 on: February 01, 2010, 07:11:32 pm »
So is there any way to draw Text using SFML in sf::Window? :D

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Using ogl for drawing
« Reply #5 on: February 01, 2010, 07:22:00 pm »
No, but you solved your problem so you don't need to do that :P
Laurent Gomila - SFML developer

 

anything