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 - Me-Myself-And-I

Pages: [1] 2 3 4
1
Graphics / Re: invisible window border causes smaller top of window
« on: February 04, 2024, 10:11:29 pm »
Ok.Nevermind.I found a solution. It seems this happens because the window is set to create in the center of the screen.All that was needed was to move the window to point 0,0 after creating it.

2
Graphics / (solved)invisible window border causes smaller top of window
« on: February 04, 2024, 08:40:27 pm »
I have a program that gets the desktops workarea size then makes a window with that size and it works good for displaying the window as large as the screen and not cover up the taskbar but either this or sfml's window class is causing a transparent border to shrink the window at the top.

Here's my code:



IntRect getWorkArea()
{
        RECT rcWorkArea = { 0 };
        SystemParametersInfo( SPI_GETWORKAREA, 0, &rcWorkArea, 0 );
        return IntRect(int(rcWorkArea.left),int(rcWorkArea.top),int(rcWorkArea.right),int(rcWorkArea.bottom));
}


int main()
{
        IntRect workarea;
        workarea=getWorkArea();
        RenderWindow window(VideoMode(workarea.width,workarea.height),"Blupi Desktop",Style::None);
       
       //loop stuff
}
 

3
I thought I should mention what solved my problem in case anyone wants to know. The solution was to load the entire picture into an sf::image then to load the necessary rect from that into the amount of textures needed.  That way the texture doesn't have to be loading a rect directly from file and instead make the texture reusable by allowing the rect to change as its loading from the memory of sf::image. I don't know if this is a dummy solution or not but hey, it works. :P

4
Thankyou for your help.

5
Hello all.

I know I have asked about this before but I still haven't found a solution. My biggest problem is trying to load dimentionally large animations into a game without causing performance lagging or having an overabundance of texture objects. If I put any large dimention animations into a spritesheet its too large to load to texture. Recently I heard something about it being possible to load large textures using vertices. Is this correct? If so, How? My game isn't so dimentionally large.Its only 960x540 at most. There must be a way to display large frames without hitting performance issues. If I split up an animation thats large into dimentionally small frame rects and save each as files,and load each into the game,it still requires either loading a lot into memory or lloading from file as its needed. Loading from file as needed definitely causes lag I know.  Would it be possible to create several textures when they are needed for preloading and delete them after its done playing the animation?Or would this still cause lag?Also I know that each texture is loaded into memory anyways so why can't it treat one large image as memory the same way that it treats several loaded images as the same amount of memory?

6
Graphics / Re: Image doesn't save but gives no error report.
« on: November 17, 2023, 05:09:49 am »
Thanks for the advice.

7
Graphics / Re: Image doesn't save but gives no error report.
« on: November 17, 2023, 01:57:15 am »
I figured out why it wasn't showing any error. Directly after this section,the window closes and no messages are sent to the console.
        for(int x=0;x<numberOfFrames;x++)
        {      
               
                currentsize.x+=rect[x].width;
               

       
                if(currentsize.x<=totalsize.x)
                {
                        //
                        for(int x1=currentsize.x-rect[x].width;x1<currentsize.x;x1++)
                        {
                                for(int y=currentsize.y-rect[x].height;y<currentsize.y;y++)
                                {
                                        saveimage.setPixel(x1,y,image[x].getPixel(x1-currentsize.x,y-currentsize.y));
                                }
                        }      
                }
                else
                {
                        currentsize.y+=rect[x].height;
                        currentsize.x=0;
                }
        }


I commented this out.
I'm guessing the applied changes are out of the image's size scope? Does this seem to be what would normally happen if the set pixel was out of scope?

The error that does show now is "Failed to save image "test/sheet.png""




8
Graphics / Image doesn't save but gives no error report.
« on: November 16, 2023, 05:21:37 am »
I searched and searched for an existing topic about this problem because I think I made a similar topic previously. I just couldn't find it.
 
I keep running into this problem every time I make a program that is manipulating images.
Eventually the image does not save as a file and no error report shows up. I just can't figure why it doesn't save. Previous attempts have shown extreme flippancy by influence of non related changes that only sometimes fix it every other time it runs. With this specific program I'm not experiencing any flippancies yet.



string sframe[100];
int numberOfFrames;
RectangleShape shape;
Crop::loadcrop(string filetype)
{
       
        ifstream framelist("frames/frame list.txt");
        for(int a=0;a<100;a++)
        {
                getline (framelist,sframe[a]);
               
                if(sframe[a]=="")
                {
                        numberOfFrames=a-1;
                        break;
                }
                sframe[a]+=filetype;
        }
       
        shape.setOutlineColor(Color::Red);
        shape.setFillColor(Color::Transparent);
        shape.setOutlineThickness(2.f);
        shape.setSize(Vector2f(0,0));
}

int  currentframe=0;
Texture texture;
Sprite sprite;
IntRect rect[100];
IntRect selectrect;
bool firstclick=false; 
bool firsttap=false;   
Crop::setcrop(RenderWindow &window)
{
        if(currentframe<numberOfFrames)
        {
                texture.loadFromFile("frames/"+sframe[currentframe]);
                sprite.setTexture(texture);

                Vector2f MPosition=window.mapPixelToCoords(Mouse::getPosition(window));
               
                if(Mouse::isButtonPressed(Mouse::Left))
                {
                        shape.setPosition(MPosition.x,MPosition.y);
                       
                }
                if(Keyboard::isKeyPressed(Keyboard::Space))
                {
                        shape.setPosition(MPosition.x-shape.getSize().x,MPosition.y-shape.getSize().y);
                }
                shape.setSize(Vector2f(MPosition.x-shape.getPosition().x,MPosition.y-shape.getPosition().y));
                selectrect=IntRect(shape.getPosition().x,shape.getPosition().y,shape.getSize().x,shape.getSize().y);
                if(Keyboard::isKeyPressed(Keyboard::Return))
                {
                        if(firsttap==false)
                        {
                               
                                currentframe++;
                                firsttap=true;
                                rect[currentframe]=selectrect; 
                       
                        }
                }
                else
                {
                        firsttap=false;
                }
               
        window.draw(sprite);
        window.draw(shape);    
        }
        else
        {
                save();
                window.close();
        }
       
}





Crop::save()
{
        Image image[numberOfFrames];
        Vector2i totalsize;


        for(int x=1;x<numberOfFrames+1;x++)
        {
               
                image[x].loadFromFile("frames/"+sframe[x]);
               
               
        }
       
       
       
       
        Image saveimage;

        Vector2i currentsize;
        bool row=true;
        Vector2i sizecheck;
        for(int x=0;x<numberOfFrames;x++)
        {
                if(totalsize.x<1000)
                {
                        totalsize.x+=rect[x].width;
                }
               
                if(sizecheck.x<1000)
                {
                        sizecheck.x+=rect[x].width;
                }
                else
                {
                       
                        totalsize.y+=rect[x].height;
                        sizecheck.x=0; 
                }
               
        }

        saveimage.create(totalsize.x,totalsize.y,Color::Transparent);
       

        for(int x=0;x<numberOfFrames;x++)
        {      
               
                currentsize.x+=rect[x].width;
               

       
                if(currentsize.x<=totalsize.x)
                {
                        //
                        for(int x1=currentsize.x-rect[x].width;x1<currentsize.x;x1++)
                        {
                                for(int y=currentsize.y-rect[x].height;y<currentsize.y;y++)
                                {
                                        saveimage.setPixel(x1,y,image[x].getPixel(x1-currentsize.x,y-currentsize.y));
                                }
                        }      
                }
                else
                {
                        currentsize.y+=rect[x].height;
                        currentsize.x=0;
                }
        }
 
        saveimage.saveToFile("test/sheet.png");
        //WHY DO I KEEP RUNNING INTO THIS PROBLEM WHERE IMAGES DONT SAVE AND SHOW NO ERROR?!
       
}

Ok.So my code is extremely confusing to anyone not familiar with my terms but i'm absolutely certain that the save() function is where the problem is. And it is certain that the images are loaded  into 
Image image[numberOfFrames];
without any problems since these images have been saved as separate files before I tried combining them into one image.The important thing is getting the image called "saveimage" to save to file.

Any ideas what wrong here?

9
Window / Re: ffplay causes sfml window to freeze and crash.
« on: October 23, 2023, 11:10:06 pm »
I figured out the problem.

Ffplay was run by running a batch file using system();
Inside the batch file was this which took parameters that were sent through system();.

@echo off

cd VIDEOS

ffplay -autoexit  -left %1  -top %2  -x %3 -y %4  %5

pause


Having pause at the end of the batch file was making the sfml window freeze until a key was pressed while the console was selected.I solved the issue by replacing pause with EXIT /B.


10
Audio / Re: Playing sound causes frame or line skips.
« on: October 19, 2023, 04:45:26 pm »
I'm thinkin it gets the variables messed up because it causes large variable changing sections of code to be skipped.I tried making it local but that didn't work.I did however find out that moving that calling function fixes it.It would be good though to know why this changes anything.
So I moved it directly past the function it was skipping the rest of.
       


bool click(int left,int top,int width,int height)
{
                if(Mouse::isButtonPressed(Mouse::Left))
                {
                       
                        if(IntRect(left,top,width,height).contains(MPosition.x,MPosition.y))
                        {
                                if(released)
                                {
                                        released=false;
                                       
                                       
                                        //playsound() was here
                                       
                                       
                                        return true;
                                }
                        }
                        else
                        {
                                if(released)
                                {
                                       
                                       
                                }
                        }
                       
                        released=false;
                       
                }
                else
                {
                        released=true;
                        return false;
                       
                }
       
}      

void loop()
{
       
        MPosition=window.mapPixelToCoords(Mouse::getPosition(window));
       
        if(room==1)
        {
                if(leave)
                        tback.loadFromFile("1.png");
                leave=false;
       
                if(click(501,256,104,54))//click function
                {
                        playsound(0,"room.wav");//moved to here
                        room=2;
                        leave=true;
                }
               
        }
}

11
Window / ffplay causes sfml window to freeze and crash.
« on: October 19, 2023, 03:11:54 pm »
Just  like the title says"ffplay causes sfml window to freeze and crash".Any ideas how to bypass or fix this problem?

12
Audio / Re: Playing sound causes frame or line skips.
« on: October 17, 2023, 07:54:14 pm »
I only played the sound once and the function only loads the file once every start. Could that alone be too much to handle?

Update:
I tried it without using any arrays and theres no change.

13
Audio / Playing sound causes frame or line skips.
« on: October 15, 2023, 03:58:39 am »
I'm having a problem with a function I made and I was wondering if anyone could help me figure out the problem.I have a file called playsound.h,and a .cpp file for that. When the function runs,a sound plays as wanted but it causes a problem. I'm not sure if it causes a lag or a line skip,or a frame skip or what.All I know is that it causes image skips and it causes the program to get its variables all messed up so I assume it has something to do with skipping some code. So the question is" Why does it do this?".


playsound.h

#pragma once
#include <SFML\Graphics.hpp>
#include <SFML/Audio.hpp>
using namespace sf;
#include <string>
using namespace std;


extern Sound channel[50];
extern SoundBuffer noise[50];
extern string lastsound[50];
void playsound(int channelnumber,string soundDirectory);



playsound.cpp

#include <SFML\Audio.hpp>
using namespace sf;
#include "playsound.h"
#include <string>
using namespace std;

Sound channel[50];
SoundBuffer noise[50];
string lastsound[50];

void playsound(int channelnumber,string soundDirectory)
{

        if(soundDirectory!=lastsound[channelnumber])
        {
                noise[channelnumber].loadFromFile(soundDirectory);
                channel[channelnumber].setBuffer(noise[channelnumber]);

                if(channel[channelnumber].getStatus()!=Sound::Playing)
                {
                        channel[channelnumber].play();
                        lastsound[channelnumber]=soundDirectory;
                }
        }
        if(channel[channelnumber].getStatus()!=Sound::Playing)
        {
                lastsound[channelnumber]="";
        }
}

 


14
Graphics / Re: Issue with converting Texture to Image
« on: September 18, 2023, 01:58:53 am »
I believe it's "copyToImage" not "copyFromImage".

15
General / Re: drawing Text array to screen crashes window.
« on: August 26, 2023, 09:26:41 pm »
Yeah,I think I'll be better off if I just make a habit of defining my variables on declaration no matter what. ::)Thanks again.

Pages: [1] 2 3 4
anything