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

Pages: [1]
1
General / Having trouble trying to make SFML and OpenGL work.
« on: December 28, 2023, 07:39:37 am »
I am having trouble making SFML and OPENGL to work together.

The program boots but I cant get a shape to show in the window.

Here is the code:

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

const GLint SCREEN_WIDTH = 500, SCREEN_HEIGHT = 500;



int main()
{
    std::cout << "Hello World!\n";

    sf::ContextSettings settings;
    settings.depthBits = 24;
    settings.stencilBits = 8;
    settings.majorVersion = 4.5;
    //settings.minorVersion = 0;
   // settings.majorVersion = 3;
    settings.minorVersion = 3;
    settings.attributeFlags = sf::ContextSettings::Core;

    sf::Window window(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32), "WINDOW", sf::Style::Titlebar | sf::Style::Close | sf::Style::Resize, settings);

    glewExperimental = GL_TRUE;

    if (GLEW_OK != glewInit())
    {
        std::cout << "GLEW FAIL" << std::endl; std::cout << "GLEW FAIL" << std::endl; std::cout << "GLEW FAIL" << std::endl;

        return EXIT_FAILURE;
    }

    bool RUN = true;

    while (RUN)
    {
        sf::Event windowEvent;

        while (window.pollEvent(windowEvent))
        {
            switch (windowEvent.type)
            {
            case sf::Event::Closed:
                    RUN = false;

                    break;
            }
        }

     

       // glClearColor(0, 0, 0, 0);
       // glClear(GL_COLOR_BUFFER_BIT);
      //  window.clear();
       

         /* Render here */
        glClear(GL_COLOR_BUFFER_BIT);


        glBegin(GL_TRIANGLES);
        glVertex2f(-0.7, -0.5);
        glVertex2f(0.7, -0.5);
        glVertex2f(0, 0.7);
        glEnd();



        window.display();

    }

    window.close();

    return EXIT_SUCCESS;

}


2
System / Re: Mouse detected when using sf::Event::TextEntered
« on: November 06, 2023, 03:02:15 pm »
If I move getch into the while pollevent it seems to work holycrap
anywho Im late for work if
I'll confirm later if any problems arrive

3
System / Re: Mouse detected when using sf::Event::TextEntered
« on: November 06, 2023, 02:54:49 pm »
#include <iostream>
#include <SFML\Graphics.hpp>
#include <sstream>
#include <conio.h>


int screen_width = 640, screen_height = 480;

sf::RenderWindow window(sf::VideoMode(screen_width, screen_height), "SFML works!", sf::Style::Default);





sf::Event event;
bool  test_ = false;
void GETCH()
{

       

        if (event.type == sf::Event::TextEntered)
        {
                if (test_ == false)
                {
                        std::cout << "pass";
                       
                }
                test_ = true;
        }
        else
        {
                test_ = false;
        }


       

}



int main()
{
       
        std::stringstream ss;
       

        while (window.isOpen())
        {


                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();



                       
                }
                window.clear(sf::Color(0, 0, 0, 255));
               

                GETCH();
               
                window.display();
               

        }

        return 0;
}


There you go friend copy paste.
As I said before I'm if you hold down a key and move the mouse over the screen it starts to skip the function and repeat the letters.

1 Type the code into a compiler
2 compile
3 hold down any key to so that "pass" shows in the compiler only once
4 now here's the tricky part GRAB THE MOUSE AND MOVE IT ACCROSS THE SCREEN
5 pass will show up REPEATEDLY while you are holding the button
6 It's super simple, it's a glitch, and the problem is that if I want to have both keyboard and mouse I either have to cash the entire library and find a different one, or modify the library and delete the mouse function and use a third party mouse detection but probably the former.

4
System / Mouse detected when using sf::Event::TextEntered
« on: November 06, 2023, 08:13:42 am »
Hello people.

I am having issues I am trying to create an in game console which works but every time the mouse crosses the screen it activates and repeats letters that are held down
here's the code

if (event.type == sf::Event::TextEntered)
{
        if (test_ == false)
        {
                std::cout << "pass";           
        }
        test_ = true;
}
else
{
        test_ = false;
}

So it supposed to detect the letter once but if you hold down the letter and move the mouse it repeats the letter which is sub optimal

What I need is for sf::Event::TextEntered to ignore the mouse

Pages: [1]
anything