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.


Topics - Austech

Pages: [1]
1
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! : )

2
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. : )

3
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?

4
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. : )

    5
    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?

    6
    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.

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

    8
    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.

    9
    Graphics / Set the outline color of a shape?
    « on: January 18, 2010, 12:43:58 am »
    Hello, sorry if there's an answer on the tutorials, but I couldn't seem to find what I'm looking for. I have a rectangle, and I'm trying to figure out how to change the outline color. There's a "SetColor" function but apparently no "SetOutlineColor" function. Maby it's named differently or something. So my question is if there's a way to set the outline color of a rectangle?

    Thanks in advanced.  :wink:

    10
    Graphics / Getting Position of a Sprite after it rotated?
    « on: December 06, 2009, 08:41:50 am »
    Sorry for all the questions, but Is there a way to get the position of a sprite after it rotated? Because when I try it gets it's original position, not the area that it rotated to.

    11
    Graphics / Setting an Axis point for a Sprite to Rotate around?
    « on: December 03, 2009, 09:03:35 pm »
    Is there a way to set a point for a sprite to rotate around? For example, if I rotated a sprite, it would rotate around it's X and Y position. But is there a way to get a sprite to rotate around a larger area? Sorry if you don't know what I'm talking about, it's kind of hard for me to explain.

    12
    Audio / Is there a way to Change Pitch while having the same speed
    « on: November 21, 2009, 07:36:40 pm »
    I'm messing with the audio part of the SFML library. And one of the functions called SetPitch() I have a question about. Is there a way to change a pitch of the sound without changing the speed? Because when I do it it speeds it up or down depending on the value I give it.

    Thanks in advanced.

    13
    Audio / Is there a way to play audio through a device
    « on: November 12, 2009, 01:18:09 am »
    Is there a way to play audio through a device using the audio section of the SFML library? For example, lets say I was in a voice chat with someone, could I play audio my device (microphone) to were the person I'm talking to could hear it?

    14
    Network / Problem sending a request
    « on: September 27, 2009, 11:13:56 pm »
    Hello, I'm trying to send a request using the HTTP part of the network package, but I get a linker error. I'm linking sfml-network.lib in my project. Has anyone else had this problem and does anyone know a fix for it?

    Pages: [1]
    anything