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

Pages: [1]
1
Graphics / How to draw background(sf::Image) and cube(OpenGL)?
« on: January 12, 2010, 10:22:37 am »
I have already fixed.
Because I forgot this function
Code: [Select]
App.PreserveOpenGLStates(true);

2
Graphics / How to draw background(sf::Image) and cube(OpenGL)?
« on: January 12, 2010, 08:54:43 am »
I'm try to draw background(sf::Image) and cube(OpenGL) in same window.
And I have code from "Tutorial - Window - Using OpenGL". It's running ok.
But I can't draw background because sf::Window don't have Draw() function.
When I change
Code: [Select]
sf::Window App(sf::VideoMode(800, 600, 32), "SFML OpenGL"); to
Code: [Select]
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML OpenGL");
I can draw background but can't draw cube.

Code: [Select]

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
    // Create the main window
    sf::Window App(sf::VideoMode(800, 600, 32), "SFML OpenGL");

    // Create a clock for measuring time elapsed
    sf::Clock Clock;

    // Set color and depth clear value
    glClearDepth(1.f);
    glClearColor(0.f, 0.f, 0.f, 0.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);

    sf::Image BackgroundImage;
    if (!BackgroundImage.LoadFromFile("2uppaib.png"))
        return EXIT_FAILURE;
    sf::Sprite Background(BackgroundImage);
Background.Resize(850,625);
Background.SetPosition(Background.GetPosition().x-25,Background.GetPosition().y-12);

    // 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();

            // Escape key : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                App.Close();

            // Resize event : adjust viewport
            if (Event.Type == sf::Event::Resized)
                glViewport(0, 0, Event.Size.Width, Event.Size.Height);
        }

        // Set the active window before using OpenGL commands
        // It's useless here because active window is always the same,
        // but don't forget it if you use multiple windows or controls
        App.SetActive();


        // Clear color and depth buffer
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        // Apply some transformations
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslatef(0.f, 0.f, -200.f);
        glRotatef(Clock.GetElapsedTime() * 50, 1.f, 0.f, 0.f);
        glRotatef(Clock.GetElapsedTime() * 30, 0.f, 1.f, 0.f);
        glRotatef(Clock.GetElapsedTime() * 90, 0.f, 0.f, 1.f);

        // Draw a cube
        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();
        // Finally, display rendered frame on screen
        App.Display();
    }

    return EXIT_SUCCESS;
}


How to draw background(sf::Image) and cube(OpenGL)?

3
Graphics / sf::String : how to check collision
« on: January 12, 2010, 05:54:52 am »
Thank a lot.
It's work for me
Code: [Select]
a.GetRect().Intersects(b.GetRect())

4
Graphics / sf::String : how to check collision
« on: January 11, 2010, 06:37:24 am »
I have text create by sf::String and I want check collision between text.
But "Simple Collision Detection" on Wiki use for sf::Sprite.
How to use "Simple Collision Detection"  on Wiki  for sf::String.

5
Graphics / how to detect when mouseover an object
« on: January 11, 2010, 06:15:49 am »
Thank you for recommend,Now i use bool.

6
Graphics / how to detect when mouseover an object
« on: January 08, 2010, 11:29:32 am »
That's cool.
This's my code.
Code: [Select]

int MouseOver(int MouseX,int MouseY,sf::String Hello)
{

//return 0 = mouse over
//retunr 1 = mouse not over
if ( MouseX > Hello.GetRect().Left && MouseX < Hello.GetRect().Right)
{
if ( MouseY > Hello.GetRect().Top && MouseY < Hello.GetRect().Bottom)
return 0;
}
return 1;
}

7
Graphics / how to detect when mouseover an object
« on: January 08, 2010, 08:04:18 am »
how to detect when mouseover/click an object

Example:
I want to create my event when mouseover/click a string or image. How to?

8
Graphics / program crash when use sf::String
« on: January 07, 2010, 02:57:36 pm »
thank you
 :D

9
Graphics / program crash when use sf::String
« on: January 07, 2010, 10:15:04 am »
Hi all,
  i'm a new member for this forum. my problem is when i exit program by press ECS or click exit windows then i have error R6025 pure virtual function call.
  i test again by remove code sf::String. My program don't have error when exit.
  How to fix problem.
This is simple code from Tutorial
Code: [Select]


////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <iostream>


////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
    // Create the main rendering window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");

// Load a font from a file
    sf::Font MyFont;
    if (!MyFont.LoadFromFile("cheeseburger.ttf", 50))
        return EXIT_FAILURE;

    // Create a graphical string
    sf::String Hello;
    Hello.SetText("Hello !\nHow are you ?");
    Hello.SetFont(MyFont);
    Hello.SetColor(sf::Color(0, 128, 128));
    Hello.SetPosition(100.f, 100.f);
    Hello.SetRotation(15.f);
    Hello.SetSize(50.f);

// Process events
sf::Event Event;

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

            // A key has been pressed
            if (Event.Type == sf::Event::KeyPressed)
            {
                // Escape key : exit
                if (Event.Key.Code == sf::Key::Escape)
{
                    App.Close();
}

                // F1 key : capture a screenshot
                if (Event.Key.Code == sf::Key::F1)
                {
                    sf::Image Screen = App.Capture();
                    Screen.SaveToFile("screenshot.jpg");
                }
            }
        }

        // Clear the screen with red color
        App.Clear(sf::Color(200, 0, 0));

App.Draw(Hello);
        // Display window contents on screen
        App.Display();
    }
    return EXIT_SUCCESS;
}

i develop on Windows 7 Ultimate/VC++ 2008

Pages: [1]
anything