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

Pages: [1]
1
Window / event for keypresses
« on: March 27, 2011, 12:23:17 am »
i had my Event in a class derived from RenderWindow and used a pointer to the event in a class to process the events, my "scenes" were derived from the event class i made so i just overload those functions for when events were triggered.

uh yea seems weird to me that checking letter and number keys outside the class event was created didnt work but f and other keys still worked :-/
unless im just missing something fundamental which could be possible lol

i just moved a sf::Event in my "scenes" and seems to work now although unsure if that will cause issues in future when i try switch between them

2
Window / event for keypresses
« on: March 26, 2011, 06:28:39 pm »
okay... letter and number keys work with a sf::Event::TextEntered.

so is it possible to get letter and number keys from sf::Event::KeyPressed?

3
Window / Load texture
« on: March 25, 2011, 08:20:43 pm »
this is how i do it

Code: [Select]
GLuint LoadGLTexture(const std::string &path) {
    GLuint texture;
    sf::Image img;

    img.LoadFromFile(path);

    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img.GetWidth(), img.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, img.GetPixelsPtr());

    return texture;
}


prolly better to check if texture power of 2 and all that

4
Window / event for keypresses
« on: March 25, 2011, 07:54:23 pm »
Code: [Select]
      switch (event->Type) {
          case sf::Event::KeyPressed:
            OnKeyPress(event->Key.Code, event->Key.Alt, event->Key.Control, event->Key.Shift);
            break;
       }


Code: [Select]
   void OnKeyPress(sf::Key::Code key, bool alt, bool ctrl, bool shift) {
        // doesnt work
        if (key == sf::Key::Num1) {
            DoSomething();
        }
        // does work
        if (key == sf::Key::F1) {
            DoSomethingElse();
        }
    }


is there some reason doing it the way i am that will cause F1 to work but none the others ive tested?
tried Num1, Numpad1, & A but testing for any F key will work...

5
Graphics / leak while minimized with multiple images
« on: October 12, 2010, 08:18:04 am »
ok thanks for the info

yea it is the graphics driver..
checked out older versions and all the ones that support 1440x900 resolution are bugged this way but ones before that dont allow resolutions higher than 1280x1024 are fine..

6
Graphics / leak while minimized with multiple images
« on: October 12, 2010, 07:13:50 am »
hm would anyone have any advice on how to resolve this aside from getting modern video card?
i know its not that big a problem but just dont like the idea if my program would do this on others older computers if it ever got to the point of a release...

7
Graphics / leak while minimized with multiple images
« on: October 11, 2010, 10:28:12 am »
yea nevermind sdl has this problem too on this hardware

8
Graphics / leak while minimized with multiple images
« on: October 11, 2010, 10:11:56 am »
hm.. guess it may be this old computer/drivers

i have the lastest updates but they were from 2007 while the hardware itself is from 2002.

apparently my opengl version is below 1.2 since GL_BGR/GL_BGRA are not even defined :(

edit:
well apparently a program called OpenGLView said its using 1.3 tho :-/

9
Graphics / leak while minimized with multiple images
« on: October 11, 2010, 09:07:36 am »
im using windows xp sp3 with mingw32 and sfml and having an issue with this program that appears to steadily eat up memory while minimized.
everything runs fine and doesnt appear to be leaking when the window visible, its only when its minimized to taskbar AND when trying to draw more than 1 image, but it is fine with only 1 image.

Code: [Select]
#include <SFML/Graphics.hpp>
#include <GL/gl.h>

void InitOpenGL(){
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glViewport(0, 0, 640, 480);

glEnable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glEnable(GL_ALPHA_TEST) ;
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glMatrixMode( GL_PROJECTION );
glLoadIdentity();

glOrtho(0.0f, 640.0f, 480.0f, 0.0f, -1.0f, 1.0f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

void DrawImage(GLuint texture, GLfloat x, GLfloat y, GLfloat w, GLfloat h){
glBindTexture(GL_TEXTURE_2D, texture);

glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glVertex2f(x, y);

glTexCoord2f(1.0f, 0.0f);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glVertex2f(x+w, y);

glTexCoord2f(1.0f, 1.0f);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glVertex2f(x+w, y+h);

glTexCoord2f(0.0f, 1.0f);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glVertex2f(x, y+h);
glEnd();
}

GLuint CreateTexture(std::string image_path){
sf::Image temp_image;
temp_image.LoadFromFile(image_path);

GLuint temp_texture;

    glGenTextures(1, &temp_texture);
    glBindTexture(GL_TEXTURE_2D, temp_texture);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, temp_image.GetWidth(), temp_image.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, temp_image.GetPixelsPtr());

    return temp_texture;
}

int main (){
sf::RenderWindow app;
bool is_running = true;
sf::Event event;

app.Create(sf::VideoMode(640, 480, 32), "Test App");
InitOpenGL();

GLuint test1, test2;
test1 = CreateTexture("test1.png");
test2 = CreateTexture("test2.png");

while (is_running){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

app.GetEvent(event);
if (event.Type == sf::Event::Closed)
is_running = false;

DrawImage(test1, 0, 0, 64, 64);
DrawImage(test2, 320, 0, 64, 64);

app.Display();
}

return 0;
}


i am aware of the sf::Sprite class but i would rather use opengl myself if i can. been trying to only use sfml for window creation, events, and image loading.

would greatly appreciate if someone can point out my error or something.

Pages: [1]
anything