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

Pages: [1] 2
1
DotNet / Input affecting image loading?
« on: March 12, 2011, 11:34:42 pm »
Quote from: "Laurent"
That reminds me an old bug that I had with the PostFx sample. As far as I remember, it only happened in the .Net binding, and I couldn't solve it (I didn't even find out what the hell was going on).


Okay, it's no problem though. Resources need to be loaded in the beginning anyway : )

Thanks for clearing that up. I was stumped for hours. : P

2
DotNet / Input affecting image loading?
« on: March 12, 2011, 07:30:21 am »
Here's something that I accidentally stumbled upon in SFML.net. I'm not sure if it has the same affect on other languages like C++. Though, I would assume the same outcome will occur since the .net is a binding.

Anyway, I have no idea why this happens:


Apparently the window's input function has some sort of affect on an image loading.

Here's some code:

Code: [Select]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SFML.Graphics;
using SFML.Window;
using System.Threading;

namespace Nature
{
    class Program
    {
        static public Random random;
        static public RenderWindow window;
        static public DateTime firsttick;

        static void Main(string[] args)
        {
            firsttick = DateTime.Now;
           
            random = new Random();
           
            ContextSettings antial = new ContextSettings();
           
            antial.AntialiasingLevel = 16;
           
            window = new RenderWindow(new VideoMode(800, 600), "Nature",Styles.Close, antial);
           
            window.SetFramerateLimit(60);
           
            window.Closed += new EventHandler(SFMLCloseEvent);

            if (window.Input.IsKeyDown(KeyCode.A))
            {
                //Somehow, this messes up image loading?
            }
            Image img = new Image("Res/Sprites/BurriedSprite.png");
           
            img.Smooth = false;
            Sprite spr = new Sprite(img);
            spr.Width = 100;
            spr.Height = 100;
            spr.Position = new Vector2(100, 100);

            while (window.IsOpened())
            {
                window.DispatchEvents();
                window.SetActive();
                window.Clear(new Color(100,200,100));



                window.Draw(spr);

                window.Display();
            }
        }

        static void SFMLCloseEvent(object obj, EventArgs arg)
        {
            window.Close();
        }

        public static TimeSpan ElapsedTime()
        {
            return DateTime.Now - firsttick;
        }
    }
}



Here's the outcome:



Pretty odd. But what made me believe that this is due to the input, here's the same affect with this code. All that's changed is that the input detection is commented out.

Code: [Select]


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SFML.Graphics;
using SFML.Window;
using System.Threading;

namespace Nature
{
    class Program
    {
        static public Random random;
        static public RenderWindow window;
        static public DateTime firsttick;

        static void Main(string[] args)
        {
            firsttick = DateTime.Now;
           
            random = new Random();
           
            ContextSettings antial = new ContextSettings();
           
            antial.AntialiasingLevel = 16;
           
            window = new RenderWindow(new VideoMode(800, 600), "Nature",Styles.Close, antial);
           
            window.SetFramerateLimit(60);
           
            window.Closed += new EventHandler(SFMLCloseEvent);

            /*if (window.Input.IsKeyDown(KeyCode.A))
            {
                //This is commented out, so it doesn't affect the image loading now?
            }*/
            Image img = new Image("Res/Sprites/BurriedSprite.png");
           
            img.Smooth = false;
            Sprite spr = new Sprite(img);
            spr.Width = 100;
            spr.Height = 100;
            spr.Position = new Vector2(100, 100);

            while (window.IsOpened())
            {
                window.DispatchEvents();
                window.SetActive();
                window.Clear(new Color(100,200,100));



                window.Draw(spr);

                window.Display();
            }
        }

        static void SFMLCloseEvent(object obj, EventArgs arg)
        {
            window.Close();
        }

        public static TimeSpan ElapsedTime()
        {
            return DateTime.Now - firsttick;
        }
    }
}


And the result:


Now, obviously you shouldn't load resources after a input. It's usually loaded at the start of the program. But me accidentally loading resources when needed caused me to get this.

And while I can just load the resources at the beginning, have everything working fine. I'd still like to know what causes this. :P

Many thanks in advanced! : )

3
Graphics / sf::RenderImage Anti aliasing not working?
« on: January 02, 2011, 11:31:06 pm »
I'm trying to draw objects to a RenderImage, and draw the RenderImage to the window.

The problem is that if I were to draw something to a render image, and draw the sprite of the render image to the window, there's no Anti aliasing.

If I were to draw the objects directly to the window, it has Anti aliasing. But it would really be a struggle with my class structure to do this, plus it would be a lot easier to do things with a render image.

Here's an example I made up with this happening:

Code: [Select]
int main(int argc,const char *argv[])
{
sf::ContextSettings cs;
cs.AntialiasingLevel = 12;
sf::RenderWindow window(sf::VideoMode(800,600), "Test",sf::Style::Close,cs);
window.SetFramerateLimit(60);

sf::RenderImage rimg;
rimg.Create(800,600);
rimg.Clear();
rimg.Draw(sf::Shape::Circle(100,100,50,sf::Color(255,255,255)));
rimg.Display();
sf::Sprite spr;
spr.SetImage(rimg.GetImage());
while(window.IsOpened())
{
while(window.GetEvent(event))
{
if(event.Type == sf::Event::Closed)
{
window.Close();
}
}
window.Clear();
window.Draw(spr);
window.Draw(sf::Shape::Circle(100,400,50,sf::Color(255,255,255)));
window.Display();
}
}


Here's what I get:


Any help is appreciated, and thanks a lot in advance. : )

4
Network / Sending a Request Problem
« on: October 29, 2010, 08:53:57 pm »
I'm trying to send a POST request to my site, then the site saves that info in a file. The problem is that it apparently isn't receiving the fields I set.


C++ Program:

Code: [Select]

#include <iostream>
#include <string>
#include <SFML/Network.hpp>

int main()
{
sf::Http http;
sf::Http::Request req;

req.SetMethod(sf::Http::Request::Post);

req.SetUri("/GetRequest.php");

req.SetField("firstname", "aus");
req.SetField("last", "tech");

http.SetHost("http://theaustech.110mb.com");

http.SendRequest(req);
}


GetRequest.php
Code: [Select]

<?php

$name 
$_POST["firstname"&#93;;
$lastname $_POST["last"&#93;;

$list fopen&#40;"savename.txt", 'a'&#41;;
fwrite&#40;$list, $name&#41;;
fwrite&#40;$list, " "&#41;;
fwrite&#40;$list, $lastname&#41;;
fwrite&#40;$list, "\n"&#41;;
fclose&#40;$list&#41;;
?>





The request is getting sent though, because every time I run this program, I check the savename.txt file and there's a new line added. So that means that the name nor the lastname field is being grabbed since it's outputting nothing but the new line.

Does anyone know what I did wrong? Or how I can go about fixing it?

5
SFML projects / Zombie Outrage 2
« on: September 23, 2010, 03:43:34 am »
Zombie outrage 2 is a Top Down Zombie Shooter game.

It's been in the works for about 3 weeks, going on 4. Though this week a barely did anything.

Some things that Zombie Outrage 2 have are:
    Box 2D For Physics
    SFML For Rendering
    Self made Dynamic Lighting + Shadows
    2 Types of Zombies
    Vehicles
    Various Weapons (Pistols, Automatics, Flame Thrower, Explosions, Turrets, Shotguns, ...)

    [/list]


    I don't plan on releasing anything before October, but here's some media (oldest to newest)








    Thanks for reading. Hope you liked it. : )

    6
    Graphics / Problem with Blending?
    « on: August 22, 2010, 09:55:51 pm »
    Quote from: "Laurent"
    A blend operation is between a source (the shape, the hidden box) and a target (the window), not between two separate sources. So, each call to Draw adds the alpha of the corresponding shape to the alpha of the window, which is 255.

    And I must say that I have no idea about what effect you're trying to achieve :D


    Oh my bad. What I was trying to simulate was when the circle was over the shape (hidden), it would show the part of the shape in which the circle is over.

    7
    Graphics / Problem with Blending?
    « on: August 22, 2010, 01:43:41 pm »
    Since I found out about blending in sfml. I decided to put it to the test with a little program that represents a flashlight.

    Code: [Select]
    while(1)
    {
    while(window.GetEvent(event))
    {
    if(event.Type == sf::Event::Closed)
    {
    window.Close();
    }
    }
    window.Clear();

    sf::Shape hidden = sf::Shape::Rectangle(0,0,100,100,sf::Color(255,0,0,0));
    hidden.SetBlendMode(sf::Blend::Add);

    sf::Shape circ = sf::Shape::Circle(window.GetInput().GetMouseX(),window.GetInput().GetMouseY(), 40,sf::Color(255,255,255,100));
    window.Draw(circ);
    window.Draw(hidden);
    window.Display();
    }


    I thought the Blend Mode, Add, would add the alpha of the hidden box, (0), to the alpha of the circle, (100). Wouldn't it?

    8
    Graphics / Odd problem with a Sprite or Image
    « on: March 26, 2010, 02:35:25 am »
    Okay, well I looked at what you said, and I also read up and refreshed my memory with Dynamic memory, but you seem more experienced than I am with this so I was wondering if I could check with you if this sounds right.

    In the TestClass2, I made the image a pointer, and I made a constructor that made the image equal a new sf::Image()

    Now when I create a TestClass2 and pass it in the vector, it's able to draw because the Image is able to be in a new memory address?

    Sorry I'm not that "experienced" with memory and things like that. But would that be any were near correct?

    9
    Graphics / Odd problem with a Sprite or Image
    « on: March 26, 2010, 01:30:01 am »
    This may sound pathetic of me, but I still don't understand completely. I tried even making the class like this:

    Code: [Select]

    class TestClass
    {
    public:

    void Foo();
    std::vector <TestClass2> Sprites;
    private:
    };

    void TestClass::Foo()
    {
    TestClass2 T2;
    T2.Img.LoadFromFile("SpriteSheet.png");
    T2.Spr.SetImage(T2.Img);

    Sprites.push_back(T2);
    }


    Yet it's still white. If I create a vector holding the TestClass2 (which holds the image and the sprite), how come when I try drawing it, it's still white?

    10
    Graphics / Odd problem with a Sprite or Image
    « on: March 26, 2010, 01:08:29 am »
    Wow, sorry, I can't believe I put this in the wrong section, should I re-create one or will it be moved?

    11
    Graphics / Odd problem with a Sprite or Image
    « on: March 26, 2010, 12:55:06 am »
    Okay, this has had me stumped for a good hour or two. And I can't seem to figure out why this is happening. I'm working on a game currently, and it involves vectors that hold sprites and things like that. Although, for some reason, the sprites are drawn to the window, and they're just white. They're the correct size, just no color. Obviously I didn't expect anyone to look at my whole game's source code and pick out a problem, so I made a mini program with fake classes that sort of simulate what happens in my game.

    Code: [Select]

    //TestClass.h
    #pragma once
    #include <SFML/Graphics.hpp>
    #include "TestClassTwo.h"

    class TestClass
    {
    public:

    void Foo();
    std::vector <sf::Sprite> Sprites;
    private:
    };

    void TestClass::Foo()
    {
    TestClass2 T2;
    T2.Img.LoadFromFile("SpriteSheet.png");
    T2.Spr.SetImage(T2.Img);

    Sprites.push_back(T2.Spr);
    }


    Code: [Select]

    //TestClassTwo.h

    #pragma once

    #include <SFML/Graphics.hpp>

    class TestClass2
    {
    public:
    sf::Sprite Spr;
    sf::Image Img;
    private:
    };


    Code: [Select]

    //main.cpp
    #include "TestClass.h"
    #include "TestClassTwo.h"

    int main()
    {
    sf::RenderWindow Win;
    Win.Create(sf::VideoMode(1000,800,32),"Test");
    sf::Event Event;

    TestClass T1;

    T1.Foo();

    while(Win.IsOpened())
    {
    while(Win.GetEvent(Event))
    {
    if(Event.Type == Event.Closed)
    {
    Win.Close();
    }
    }

    Win.Clear(sf::Color(0,0,0));
    Win.Draw(T1.Sprites[0]);
    Win.Display();
    }
    }


    As I said, these classes are short parts of the game that are most definitely causing the problems. I just can't figure out why. Huge thanks in advanced.

    12
    Graphics / Change pixel of a window?
    « on: March 12, 2010, 02:26:04 pm »
    Thank you very much, I was concidering doing that.

    13
    Graphics / Change pixel of a window?
    « on: March 12, 2010, 03:24:50 am »
    Sorry if this is in the tutorials, but I can't seem to find it. Is there a way to efficiently change a window's pixel's color. I would use rectangles to draw over it, but I'm planning on making a paint like program. So that would mean that I would need about 1000 * 800 rectangles which seems insane. So is there a efficient way to set a pixel color of a window?

    14
    Graphics / Scale a Sprite to fit a whole window?
    « on: February 01, 2010, 10:34:05 am »
    Thanks, the resize function worked perfectly.  :)

    15
    Graphics / Scale a Sprite to fit a whole window?
    « on: February 01, 2010, 09:52:19 am »
    Is there a mathematical way to scale a sprite to fit a whole window? I tried scaling it like:

    Scale(WindowWidth - ImageWidth,WindowHeight - ImageHeight);

    But It seems to scale way too big. So is there a way to do it?

    Once again thanks in advanced.

    Pages: [1] 2