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

Pages: [1]
1
Graphics / SFML2 deriving the Drawable class
« on: April 19, 2012, 05:02:59 am »
I'm probably going to get shot down for this (given my level of ignorance), but I'll ask away.

I'm trying to derive the drawable class with an object that makes calls to OpenGL directly.
And I'm trying to render a real basic sprite (for starters).

draw function definition
Code: [Select]
void BaseSprite::draw(sf::RenderTarget & target, sf::RenderStates states) const
{
glEnable(GL_TEXTURE_2D);
// Set the primitive color to white
glColor4f(1.f, 1.f, 1.f, 1.f);
// Bind the texture
glBindTexture(GL_TEXTURE_2D, myTexture->id());

glPushMatrix();  // Save modelview matrix

acl::PointF center = myBounds.center();

glTranslatef(center.x, center.y, 0.f);
glRotatef(0.f, 0.f, 0.f, 0.f);
glTranslatef(myBounds.x - center.x, myBounds.y - center.y, 0.f);

glBegin(GL_QUADS);
glTexCoord2f(0.f              , myTextureBounds.h);
glVertex2f  (0.f              , 0.f              );
glTexCoord2f(myTextureBounds.w, myTextureBounds.h);
glVertex2f  (myBounds.w       , 0.f              );
glTexCoord2f(myTextureBounds.w, 0.f              );
glVertex2f  (myBounds.w       , myBounds.h       );
glTexCoord2f(0.f              , 0.f              );
glVertex2f  (0.f              , myBounds.h       );
glEnd();

glPopMatrix();
}

Start up, which just sets up OpenGL
Code: [Select]
Graphics::instance().enable2d();

Main Loop code:
Code: [Select]
app.draw(txt); // a test sf::Text object
app.pushGLStates();
app.draw(bs); // which is a BaseSprite object
app.popGLStates();

I'm not sure what I'm missing (do I need setup for rendering something this? I'm not sure what to do). I do see it (the BaseSprite) flashing but then disappearing afterwords.

Is anyone willing to suggest anything?
Please don't angry with me, if this post is undeserving just tell me and I'll move on (eventually, hopefully).

Thanks for tips

2
General / Linker Problems GNU/Linux x64 cannot find debug libraries
« on: January 19, 2011, 08:27:30 pm »
Hi I'm having linker issues. I'm using the Code::Blocks IDE.

I've installed SFML using synaptic package manager on an Ubuntu distro (10.10).
I've also tried installing it via the SDK from the website.
I've haven't had this problem with Ubuntu 10.04 (my previous install).
LD can find the release options but not the debug options and gives me this
cannot find -lsfml-system-d
cannot find -lsfml-graphics-d
cannot find -lsfml-window-d
cannot find -lsfml-audio-d

I've tried searching for a solution, but to no avail.

Thanks and,
Please forgive my ignorance.

3
Graphics / [Sloved] On deleting an image - GL_INVALID_OPERATION
« on: November 18, 2010, 11:14:03 pm »
I'm gonna get laughed at, but what the heck...

When an object dynamically allocates an sf::image and then deletes it, I get the following error:
Code: [Select]

An internal OpenGL call failed in Image.cpp (769) : GL_INVALID_OPERATION, the specified operation is not allowed in the current state


Posting the whole code wouldn't really be feasible, so I'll post the relevant stuff.

Object using the Wrapper Object,
please note that Image is in this case is not the sf::Image, but a "wrapper-class":
Code: [Select]

rect = _rect;
img.remake(rect.toSize(), clr);

        Rectangle destBar(2, 2, rect.w - 2, rect.h - 2);
/// background
        Image(*api, Size(rect.w - 4, 20), Color(0x00, 0x20, 0x60)).copyImageTo(img, destBar);
title.location = PointF((float)rect.x + 4, (float)rect.y + 4);
/// title seperator

Image(*api, Size(rect.w - 6, rect.h - 27), Color(0x00, 0xB0, 0xF0)).copyImageTo(img, Rectangle(3, 24, rect.w - 4, rect.h - 27));


code from the "wrapper-class"
Code: [Select]

Image::~Image(){
if (imageHandle){
std::cout << "info: " << info << std::endl << toString() << std::endl;
api->deleteImage(this);
std::cout << "image dtor called\n";
}
}
void Image::loadImage(const char * filename){
api->loadImage(this, filename);
info = filename;
}


and finally the code from the api-plugin:
loading an Image:
Code: [Select]

    void PCOUT loadImage(fsa::Image * image, const char * filename){
        debugReport << "Atempting to load " << filename << std::endl;
        bool sucess;
if (image->imageHandle)
deleteImage(image);
image->imageHandle = new sf::Image;
        sucess = image->imageHandle->LoadFromFile(filename);
        if (sucess){
            //masterFrames.push_back(newFrame);
            //image->imageHandle->LoadFromFile(filename) = &masterFrames.at(masterFrames.size() - 1);
            debugReport << "Loaded to address: " << image->imageHandle << std::endl;
        } else {
/// image has value, won't get here without allocation taking place for the image
deleteImage(image);
            debugReport << "Cannot load image: " << filename << std::endl;
        }
    }

the blank image, other images seem ok but deleting images this function generates seems to cause the error.
Code: [Select]

void PCOUT blankImage(fsa::Image * img, const fsaHelps::Size & sz, const fsaHelps::Color & clr){
if (img->imageHandle)
deleteImage(img);
debugReport << "Making blank image size of " << sz.toString() << " with color " << clr.toString() << std::endl;
img->imageHandle = new sf::Image(fsaHelps::fsa_abs(sz.w), fsaHelps::fsa_abs(sz.h), *(sf::Color *)(&clr));
}

deleting an Image:
Code: [Select]

    void PCOUT deleteImage(fsa::Image * image){
        debugReport << "Deleting Image\n";
delete image->imageHandle;
    }


Is the problem visible? Being s--- code that it is, please send your criticisms (It helps :P).
How should I fix this error?

Lemme know if you need access to the full source (GPLv3/LGPLv3 w/ static exception).

Thanks for your time, your criticisms and any ideas to fix this issue.
-Andy

4
Graphics / Draw image directly?
« on: October 03, 2010, 02:25:58 am »
I've been working on a project and I'm trying to step it up so it can use multiple APIs.

Is there a way I can draw images directly (based on a rectangle class which is written for the engine)? Obviously I'm not trying to use an image per sprite, but I am trying to render a sprite without using the sf::Sprite class.

I've tried using OpenGL code in conjunction with SFML to draw a sprite, I've been very unsuccessful so far.

I'd post code, but they're just the wrong answers.

Using a class like to following:
Code: [Select]

class RectangleF{
    public:
        RectangleF();
        RectangleF(float _x, float _y, float _w, float _h);
        float x, y, width, height;
        float right();
        float bottom();
};


-thanks for the help in advance[/code]

5
SFML projects / FSA - [revitalization?]
« on: September 01, 2010, 06:04:42 am »
This is an old project I'm trying to bring back to life.

https://sourceforge.net/projects/andyfsa/

But I need help, I'm not sure how to develop a project this "large". I've seen incredible works present on this site and elsewhere. Being a C++ noobie is hard, this project has seen large periods of inactivity. I've been setting up plans about how to go about this project, but even then I'm not sure how to proceed.

I'm still plugging away at it though whenever I get the chance. I know this is no help forum, but any guidance is greatly appreciated.

I'll post some binaries ASAP for anyone to try, and maybe start a manual for the command terminal triggered by the "`" key.

Thanks for your time kindly,
-Andy

6
General discussions / [Windows-x64] Building SFML?
« on: March 20, 2010, 01:19:03 am »
Hi, New guy here!

First off I want to extend my personal thanks to Laurent for making this library.  I'm developing an open-source (BSD-modified) game engine to act as a way for me to learn C++ and to make something on a "metal-level" that would run and lightly.

As the title states, is there a way to compile the library for windows-x64?

Btw, I'm using MSVC 2008 (acquired form MSDNAA) so I can build 64-bit binaries with it.

Pages: [1]
anything