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

Pages: [1]
1
Graphics / Unbinded Font Texture Problem
« on: April 12, 2010, 01:39:37 pm »
Ok, thanks soooo much! I really really appreciate it! :D

2
Graphics / Unbinded Font Texture Problem
« on: April 12, 2010, 01:25:25 pm »
Wait, just one more question, so, everytime I call SFML, I have to restore the OpenGL state by myself right? (If I don't want to use those Draw() functions, cuz I only plan to use it for fonts).

3
Graphics / Unbinded Font Texture Problem
« on: April 12, 2010, 01:21:54 pm »
Oh! ><! Ok, thank you very much!

4
Graphics / Unbinded Font Texture Problem
« on: April 12, 2010, 01:07:50 pm »
That's some quick response!

Code: [Select]
sf::RenderWindow win(sf::VideoMode(800, 600, 32), "Untitled!", sf::Style::Close, sf::ContextSettings(24, 8, 0, 1, 5));
win.Show(true);
win.SetActive();

Timer myTime;
Uint32 fps = 0;
Str typed = (Char)20140;
typed += (Char)20540;
typed += (Char)20940;


sf::Image img;
img.LoadFromFile(Str("Data/Raw/image.png").GetFilePath());

sf::Font font;
font.LoadFromFile(Str("Data/Raw/font2.ttc").GetFilePath());

glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);

sf::Text text;

while(1)
{
++fps;
if(myTime.IsOver())
{
SetWindowText(GetActiveWindow(), StrHelper.Put("Untitled! - %@1 fps", fps).ToWCString());
fps = 0;
myTime.SetTimer(1.0f);
}
sf::Event e;
while(win.GetEvent(e))
{
if(e.Type == sf::Event::Closed)
{
win.Close();
return;
}
if(e.Type == sf::Event::TextEntered)
{
if(e.Text.Unicode == '\b')
typed = typed.Substr(0, typed.GetSize()-1);
else
typed += (Char)e.Text.Unicode;
}
}

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

//glViewport(0, 0, 400, 300);
// glMatrixMode(GL_PROJECTION);
// glLoadIdentity();
// gluPerspective(45.f, 1.333f, 1.f, 500.f);

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

// img.Bind();
// glBegin(GL_QUADS);

// glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
// //glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
// glTexCoord2f(0, 0);
// glVertex3f(-50.f, -50.f, -50.f);
// glTexCoord2f(1, 0);
// glVertex3f(-50.f,  50.f, -50.f);
// glTexCoord2f(1, 1);
// glVertex3f( 50.f,  50.f, -50.f);
// glTexCoord2f(0, 1);
// glVertex3f( 50.f, -50.f, -50.f);

// //glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
// glTexCoord2f(0, 0);
// glVertex3f(-50.f, -50.f, 50.f);
// glTexCoord2f(1, 0);
// glVertex3f(-50.f,  50.f, 50.f);
// glTexCoord2f(1, 1);
// glVertex3f( 50.f,  50.f, 50.f);
// glTexCoord2f(0, 1);
// glVertex3f( 50.f, -50.f, 50.f);

// //glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
// glTexCoord2f(0, 0);
// glVertex3f(-50.f, -50.f, -50.f);
// glTexCoord2f(1, 0);
// glVertex3f(-50.f,  50.f, -50.f);
// glTexCoord2f(1, 1);
// glVertex3f(-50.f,  50.f,  50.f);
// glTexCoord2f(0, 1);
// glVertex3f(-50.f, -50.f,  50.f);

// //glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
// glTexCoord2f(0, 0);
// glVertex3f(50.f, -50.f, -50.f);
// glTexCoord2f(1, 0);
// glVertex3f(50.f,  50.f, -50.f);
// glTexCoord2f(1, 1);
// glVertex3f(50.f,  50.f,  50.f);
// glTexCoord2f(0, 1);
// glVertex3f(50.f, -50.f,  50.f);

// //glColor4f(1.0f, 0.0f, 1.0f, 1.0f);
// glTexCoord2f(0, 0);
// glVertex3f(-50.f, -50.f,  50.f);
// glTexCoord2f(1, 0);
// glVertex3f(-50.f, -50.f, -50.f);
// glTexCoord2f(1, 1);
// glVertex3f( 50.f, -50.f, -50.f);
// glTexCoord2f(0, 1);
// glVertex3f( 50.f, -50.f,  50.f);

// //glColor4f(0.0f, 1.0f, 1.0f, 1.0f);
// glTexCoord2f(0, 0);
// glVertex3f(-50.f, 50.f,  50.f);
// glTexCoord2f(1, 0);
// glVertex3f(-50.f, 50.f, -50.f);
// glTexCoord2f(1, 1);
// glVertex3f( 50.f, 50.f, -50.f);
// glTexCoord2f(0, 1);
// glVertex3f( 50.f, 50.f,  50.f);

// glEnd();

glViewport(400, 300, 400, 300);
glDisable(GL_TEXTURE_2D);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.f, 1.333f, 1.f, 500.f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.f, 0.f, -200.f);
glRotatef(Time.GetElapsedTime() * 50, 1.f, 0.f, 0.f);
glRotatef(Time.GetElapsedTime() * 30, 0.f, 1.f, 0.f);
glRotatef(Time.GetElapsedTime() * 90, 0.f, 0.f, 1.f);

glBegin(GL_QUADS);

glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
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);

glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
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);

glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
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);

glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
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);

glColor4f(1.0f, 0.0f, 1.0f, 1.0f);
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);

glColor4f(0.0f, 1.0f, 1.0f, 1.0f);
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();
glEnable(GL_TEXTURE_2D);

glViewport(0, 0, 800, 600);
glDisable(GL_DEPTH_TEST);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, 800, 600, 0);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

text.SetFont(font);
text.SetString(typed.ToWCString());
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
win.Draw(text);

glEnable(GL_DEPTH_TEST);

win.Display();
}

5
Graphics / Unbinded Font Texture Problem
« on: April 12, 2010, 11:42:58 am »
Hi,

I was just testing the SFML graphics package (version 2.0), and I've found that, ...

Load an image
Load a font
Bind texture
Draw vertices
Set font
Draw text // shows the image instead of font

Then, when I remove bind texture, draw text works. If I'm not wrong, the internal font texture isn't binded during draw? Is it a bug, shouldn't it be binded?

Cheers!

6
Audio / Bug when reading OGG files?
« on: April 08, 2010, 04:02:10 am »
Hi,

Recently, I have updated to SFML 2.0. The sf::SoundBuffer works in SFML 1.5 and 1.6 with OGG files and WAV files. But, in 2.0, seems that it plays OGG files wrongly (feels like the sound is over amplified), but works fine with WAV files.

Just to make sure, this is my sound code.
Code: [Select]
struct Sound
{
sf::Sound *sound;
sf::SoundBuffer *buffer;
ByteArray data;
};

Sound sound;
Sound *sd = &sound;
Malloc(sd->buffer, sf::SoundBuffer);
if(!sd->buffer->LoadFromFile(file.GetFilePath()))
{
Free(sd->buffer); // Free
WriteLog3("Missing audio file: %@1", file.TrimFilePath());
return;
}

Malloc(sd->sound, sf::Sound);
mSoundList.push_back(sound);

// Play sound
sd->sound->SetBuffer(*sd->buffer);
sd->sound->SetVolume(mSoundVol);

if(Math.DistanceSq(pos, mEye) < 1)
{
// 2D
sd->sound->SetRelativeToListener(true);
sd->sound->SetPosition(0, 0, 0);
}
else
{
// 3D
sd->sound->SetPosition(pos.x, pos.y, pos.z);
}

sd->sound->SetMinDistance(mDistance);
sd->sound->SetAttenuation(mAttenuation);
sd->sound->Play();


In case you're wondering, Volume is 100, Distance is 1, Attenuation is 1. DistanceSq() is <1.

Am I doing anything wrong? Or is this a bug?

Cheers!

EDIT:
I reduced the OGG sound dB by a little bit in Audacity and the problem is solved. Seems that a max dB in OGG files would cause this problem.

Pages: [1]