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

Pages: [1]
1
Graphics / Texture's LoadFromStream won't load pngs
« on: August 25, 2011, 01:43:26 am »
I've been trying to write my own InputStream and testing trying to load png files. I eventually wrote a 'reference stream' which just loads the file as is to make sure it was working, and I discovered it seems loading anything except a png works fine, but I get an invalid header error if I load a png with it. Loading the png file with LoadFromFile works fine but I can't use that as I need a custom stream.
Here is my reference stream that works on everything (Fonts, .tgas, etc.) but not pngs:

Code: [Select]
#pragma once

#include <SFML/Graphics.hpp>

class ReferenceStream : public InputStream {
public:
ReferenceStream(string filename);
~ReferenceStream();
virtual Int64 Read(char* data, Int64 size);
    virtual Int64 Seek(Int64 position);
    virtual Int64 Tell();
    virtual Int64 GetSize();
private:
Int64 position;
char* buffer;
Int64 bufferLen;
};


Code: [Select]

#include "ReferenceStream.h"
#include <fstream>

ReferenceStream::ReferenceStream(string filename) : position(0), buffer(nullptr), bufferLen(-1) {
ifstream file(filename, ios::binary | ios::in);
// [snipped] App-specific error handling
file.seekg(0, ios::end);
bufferLen = (Int64)file.tellg();
file.seekg(0, ios::beg);
buffer = new char[(int)bufferLen];
memset(buffer, 0, sizeof(buffer));
file.read(buffer, bufferLen);
file.close();
}

Int64 ReferenceStream::Read(char* data, Int64 size) {
if (position + size > bufferLen) {
size = bufferLen - position;
}
for (Int64 i = position; i < (position + size); i++) {
data[i-position] = buffer[i];
}
return size;
}

Int64 ReferenceStream::Seek(Int64 position) {
this->position = position;
if (position >= bufferLen) {
this->position = bufferLen - 1;
}
return this->position;
}

Int64 ReferenceStream::Tell() {
return position;
}

Int64 ReferenceStream::GetSize() {
return bufferLen;
}

ReferenceStream::~ReferenceStream() {
delete[] buffer;
}


If I save the output of reading my full stream manually to a file it creates a valid png file, so a bug in SFML or stbimage is the only thing I can come up with...

2
Graphics / [SFML2] [MAC] EXC_BAD_ACCESS loading images
« on: April 08, 2011, 01:57:30 am »
My code compiles and runs perfectly on Windows however on Mac I'm getting the error "EXC_BAD_ACCESS" the first time I try to load a texture. The texture dimensions are powers of two and here is the stack trace:
Code: [Select]
#0 0x7fff83b223e2 in glGetIntegerv
#1 0x100092283 in sf::Image::GetMaximumSize at Image.cpp:539
#2 0x100094001 in sf::Image::CreateTexture at Image.cpp:600
#3 0x1000950f3 in sf::Image::LoadFromFile at Image.cpp:103
#4 0x10000c912 in cman::GetImage at cman.cpp:15
#5 0x10000b1cf in intro_load at main.cpp:81
#6 0x10000f708 in sf::priv::ThreadFunctorWithArg<void (*)(LoadFuncData*), LoadFuncData*>::Run at Thread.inl:48
#7 0x10024fae4 in sf::Thread::Run at Thread.cpp:83
#8 0x10025007c in sf::priv::ThreadImpl::EntryPoint at ThreadImpl.cpp:74
#9 0x7fff88cf54f6 in _pthread_start


Can I not load images from another thread on Mac or something?

3
General / [SFML2] [MAC] Adding menubar entries?
« on: March 26, 2011, 03:52:51 pm »
What would the best way to add entries the game's menu bar, at least quit so that the menu has one item as it reacts oddly with none.

4
General / [SFML2][OSX] Setting up project
« on: February 27, 2011, 09:01:45 pm »
How do I link the compiled dylibs to my project and specify the include path for the SFML files? The old templates don't work since SFML2 doesn't compile to frameworks.

5
General / [OSX][SFML2] _sf_open, _sf_open_virtual, etc.
« on: February 26, 2011, 11:43:40 pm »
I'm trying to compile SFML2 in Snow Leopard but I'm getting the following errors:

Code: [Select]
Build sfml-audio of project SFML with configuration Release

Ld lib/lib/Release/libsfml-audio.dylib normal x86_64
cd /Users/name/Downloads/sfml2
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/g++-4.2 -arch x86_64 -dynamiclib -isysroot /Developer/SDKs/MacOSX10.6.sdk -L/Users/name/Downloads/sfml2/lib/lib/Release -F/Users/name/Downloads/sfml2/lib/lib/Release -F/Users/name/Downloads/sfml2/extlibs/libs-osx/Frameworks -filelist /Users/name/Downloads/sfml2/lib/src/SFML/Audio/SFML.build/Release/sfml-audio.build/Objects-normal/x86_64/sfml-audio.LinkFileList -install_name /libsfml-audio.dylib -mmacosx-version-min=10.6 -dynamiclib -Wl,-headerpad_max_install_names -install_name libsfml-audio.dylib /Users/name/Downloads/sfml2/lib/lib/Release/libsfml-system.dylib -framework OpenAL -framework sndfile -lpthread -single_module -compatibility_version 2.0.0 -current_version 2.0.0 -o /Users/name/Downloads/sfml2/lib/lib/Release/libsfml-audio.dylib

ld: warning: in /Users/name/Downloads/sfml2/extlibs/libs-osx/Frameworks/sndfile.framework/sndfile, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols:
  "_sf_open", referenced from:
      sf::priv::SoundFile::OpenRead(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in SoundFile.o
      sf::priv::SoundFile::OpenWrite(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, unsigned int)in SoundFile.o
  "_sf_open_virtual", referenced from:
      sf::priv::SoundFile::OpenRead(void const*, unsigned long)in SoundFile.o
  "_sf_seek", referenced from:
      sf::priv::SoundFile::Seek(float)in SoundFile.o
  "_sf_write_short", referenced from:
      sf::priv::SoundFile::Write(short const*, unsigned long)in SoundFile.o
  "_sf_strerror", referenced from:
      sf::priv::SoundFile::OpenRead(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in SoundFile.o
      sf::priv::SoundFile::OpenWrite(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, unsigned int)in SoundFile.o
      sf::priv::SoundFile::OpenRead(void const*, unsigned long)in SoundFile.o
  "_sf_read_short", referenced from:
      sf::priv::SoundFile::Read(short*, unsigned long)in SoundFile.o
  "_sf_close", referenced from:
      sf::priv::SoundFile::~SoundFile()in SoundFile.o
      sf::priv::SoundFile::~SoundFile()in SoundFile.o
      sf::priv::SoundFile::OpenRead(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in SoundFile.o
      sf::priv::SoundFile::OpenWrite(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, unsigned int)in SoundFile.o
      sf::priv::SoundFile::OpenRead(void const*, unsigned long)in SoundFile.o
ld: symbol(s) not found
collect2: ld returned 1 exit status


I'm new to Macs (but experienced in programming in general) so I'm unsure how to resolve this.

6
SFML website / Can't download SFML2
« on: January 28, 2011, 02:03:36 am »
The links for SFML 1.7 and SFML 2.0 won't load for me, even manually browsing on SourceForge.

7
Graphics / Drawing of Shape very slow?
« on: January 23, 2011, 04:35:43 am »
I'm trying to use Shape to draw random noise in 8x8 blocks but it's running at about 11FPS. This is my code:
Code: [Select]
//PIXEL_SIZE is defined to 8
size_t h = (engine::Window->GetHeight() / PIXEL_SIZE) + 1;
size_t w = (engine::Window->GetWidth() / PIXEL_SIZE) + 1;
Shape s;
for (size_t y = 0; y < h; y++) {
for (size_t x = 0; x < w; x++) {
s = Shape::Rectangle(FloatRect(float(x * PIXEL_SIZE), float(y * PIXEL_SIZE), float(PIXEL_SIZE), float(PIXEL_SIZE) ), Color(utils::Rand(5,10), utils::Rand(10,14), utils::Rand(200,255) ) );
rt.Draw(s);
}
}
rt.Display();
engine::Window->Draw( Sprite( rt.GetImage() ) );


What is a better way to draw noise like this?

In case it helps this is what it renders, albeit slowly:


If there is no way to do this with Shape, can someone give me an example of how to do this with a shader?

8
General / Crash on closing window [SFML2]
« on: January 17, 2011, 07:18:49 pm »
I found someone else with this issue in the French forum but as I don't know French well enough to communicate effectively I made a new thread here.

Upon closing my game I get an error:
Code: [Select]
The thread 'Win32 Thread' (0x1ca8) has exited with code 0 (0x0).
First-chance exception at 0x6903a4ca in Test.exe: 0xC0000005: Access violation reading location 0x00000054.
Unhandled exception at 0x6903a4ca in Test.exe: 0xC0000005: Access violation reading location 0x00000054.


This error occurs after main returns, eg. if I breakpoint return EXIT_SUCCESS; it hits the breakpoint before the error occurs, but once it exits main whatever code it jumps off into (a destructor?) throws an error. This happens even if I haven't allocated any Images or Fonts etc, and I don't have any custom destructors for my objects yet so I'm not entirely sure what's going on here.

The stack frame contains: opengl32.dll MakeNoCurrent and atiolgxx.dll with an unknown function.

My graphics card is an ATI Mobility Radeon HD 5870.

This wasn't happening to me with SFML 1.6 but I had to switch to SFML 2 due to the bug with sprite SubRects that made tilesets unusable.

In the French thread you mentioned needing to expose a cleanup call to the user to fix this, if I was going to modify the SFML code myself to fix this what do I need to do exactly in this cleanup function?

9
Graphics / Sprite colors bleeding when using subrect
« on: January 08, 2011, 11:48:05 pm »
I'm trying to draw 32x32 tiles from a tileset using sprite subrects, but the very edge of the tiles shows some of the tile next to it. Smoothing is disabled. Even with subrect set to 0,0,32,32 I see bleeding into the next tile at the border.
This is the result I get drawing a tilemap of pure color tiles: (notice the apparent 'gridlines'


This is the tileset:


I have confirmed the rectangle my code generates it correct and the location the tiles draw to is correct so I' m unsure why this happens.

Drawing the same map with actual tiles gives me this:

I don't understand why the 'grid' of darkened tile appears.

Pages: [1]
anything