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

Pages: [1]
1
General / Re: SFML+OpenGL Black Screen on Mac
« on: September 27, 2015, 08:08:21 am »
i wondered the same thing, but it still puzzles me why it works on xcode but not on eclipse, i've tried everything from every tutorial i have laid my hands on, it still displays a black screen, like i said before, i also changed the context to SDL, the same result, but as soon as i ported to xcode, it works without problems like a charm, so i still don't know whats happening

2
General / Re: SFML+OpenGL Black Screen on Mac
« on: September 24, 2015, 09:50:42 pm »
For anyone experiencing the same issue, it might be because you are using eclipse on mac, i switched the code base to xcode and it now works well, if i am able to come up with a solution for eclipse i would upload it here

3
General / SFML+OpenGL Black Screen on Mac
« on: September 20, 2015, 05:49:53 am »
Hi,
I have trying to use SFML as a window context for OpenGL, but i get a black screen when i run the code

I have tried different code, but i still get the same result, when i run the same code using glut, it displays
NB: this is the same thing that happens when i run SDL+OpenGL

/*
 * Main.cpp
 *
 *  Created on: Sep 20, 2015
 *      Author: Damian-Machine
 */

#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <math.h>
#include<iostream>
#define PI 3.14159265f

GLdouble clipAreaXLeft, clipAreaXRight, clipAreaYBottom, clipAreaYTop;

bool fullScreenMode = true; // Full-screen or windowed mode?

void initGL(){
        /*glClearColor(1.0 ,0.0, 0.0, .0);*/
        // Set color and depth clear value
        glClearDepth(1.f);
        glClearColor(1.f, 1.f, 1.f, 1.f);

        // Enable Z-buffer read and write
        glEnable(GL_DEPTH_TEST);
        glDepthMask(GL_TRUE);

        // Setup a perspective projection
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluPerspective(90.f, 1.f, 1.f, 500.f);
}


void display(){
        //glClear(GL_COLOR_BUFFER_BIT);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslatef(0.f, 0.f, -2.f);

        glBegin(GL_QUADS);

            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f(-50.f,  50.f, -50.f);
            glVertex3f( 50.f,  50.f, -50.f);
            glVertex3f( 50.f, -50.f, -50.f);

            glVertex3f(-50.f, -50.f, 50.f);
            glVertex3f(-50.f,  50.f, 50.f);
            glVertex3f( 50.f,  50.f, 50.f);
            glVertex3f( 50.f, -50.f, 50.f);

            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f(-50.f,  50.f, -50.f);
            glVertex3f(-50.f,  50.f,  50.f);
            glVertex3f(-50.f, -50.f,  50.f);

            glVertex3f(50.f, -50.f, -50.f);
            glVertex3f(50.f,  50.f, -50.f);
            glVertex3f(50.f,  50.f,  50.f);
            glVertex3f(50.f, -50.f,  50.f);

            glVertex3f(-50.f, -50.f,  50.f);
            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f( 50.f, -50.f, -50.f);
            glVertex3f( 50.f, -50.f,  50.f);

            glVertex3f(-50.f, 50.f,  50.f);
            glVertex3f(-50.f, 50.f, -50.f);
            glVertex3f( 50.f, 50.f, -50.f);
            glVertex3f( 50.f, 50.f,  50.f);

        glEnd();

}

void reshape(GLsizei width, GLsizei height){
        if(height == 0) height = 1;
        GLfloat aspect = (GLfloat)width / (GLfloat)height;
        glViewport(0, 0, width, height);

        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        if (width >= height) {
          clipAreaXLeft   = -1.0 * aspect;
          clipAreaXRight  = 1.0 * aspect;
          clipAreaYBottom = -1.0;
          clipAreaYTop    = 1.0;
   } else {
          clipAreaXLeft   = -1.0;
          clipAreaXRight  = 1.0;
          clipAreaYBottom = -1.0 / aspect;
          clipAreaYTop    = 1.0 / aspect;
   }
   gluOrtho2D(clipAreaXLeft, clipAreaXRight, clipAreaYBottom, clipAreaYTop);
   }

int main(){
        sf::ContextSettings settings;
        settings.depthBits = 32;
        settings.stencilBits = 8;
        settings.antialiasingLevel = 4;
        //settings.majorVersion = 2;
        //settings.minorVersion = 1;
        sf::Window window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, settings);
        window.setVerticalSyncEnabled(true);
        window.setActive(true);

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

        // run the main loop
        bool running = true;
        initGL();
        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);
                                reshape(event.size.width, event.size.height);

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

        // release resources...

        return 0;
}




 

Pages: [1]