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

Pages: [1] 2
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
// 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);

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       );


Start up, which just sets up OpenGL
Code: [Select]

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

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

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.

Graphics / [Sloved] On deleting an image - GL_INVALID_OPERATION
« on: November 19, 2010, 08:51:03 pm »
Your (Mr. Gomila) sf::Image and sf::Font classes don't like anonymous namespaces. (Curious to know why, but anything I would say would just be speculation.)

relevant code:
Code: [Select]

#include "apis.h"
using namespace
    sf::Image test;
void run(){
    .... run app code ....

I've encountered it before, however this was under a different context so I didn't catch it.

I'm thinking of just using a pointer in the anon namespace to the vector of Images, so the dtors for these classes aren't called in such a weird way (out of context).

Rather anti-climatic I'm afraid, but I'd say that the simply the social interaction helped me think of this angle for solving the issue.

Thanks for your patience.

Graphics / [Sloved] On deleting an image - GL_INVALID_OPERATION
« on: November 19, 2010, 07:47:43 pm »
Thanks for the response.

This application as a whole is just one thread. The error occurs during the global exit. Not all the dtors involved seems to be called (using a cout in the dtor to determine this).

I'll get a minimal code deal worked up later. I've got a lot to take care of atm.

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]

if (imageHandle){
std::cout << "info: " << info << std::endl << toString() << std::endl;
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)
image->imageHandle = new sf::Image;
        sucess = image->imageHandle->LoadFromFile(filename);
        if (sucess){
            //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
            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)
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.

Graphics / Draw image directly?
« on: October 07, 2010, 04:11:00 am »
Thank you for pointing that out, I'm still a C++ newbie.
I'll get standards help elsewhere (as this is not the appropriate place).
That statement realize far behind I am still.
Google hasn't been nice about find information on the standard, however I remain hopeful I'll find something.

Graphics / Draw image directly?
« on: October 06, 2010, 08:16:28 pm »
I think I'm seeing what you're doing there!

For instance with the x property.
Appearence in header:
Code: [Select]

class backsprite{
    float &x();

Appearence in module:
Code: [Select]

float &backsprite::x(){
    return sprite.GetPosition().x;

Thanks for the helpful advice! :D[/code]

Graphics / Draw image directly?
« on: October 05, 2010, 05:04:14 am »
I agree.

I still may have to use a void * just to point to a data structure.
Oh wait, or just do that in the private class.

I thinking how for image works, but what about sprite? A good puzzle me thinks however some things just don't seem to directly correlate. I'm gonna do some more brainstorming, but thanks for the input.

Graphics / Draw image directly?
« on: October 04, 2010, 01:35:09 am »
Ok, I just had to be sure you weren't one of those people (though in a place like this it seems hard). I don't want to be involved in no flame war.

But for the sake of the argument, :P
I want to draw images directly for these reasons:

Every API I've seen so far seems to have a texture/image/surface class that can be used to blit to the screen, however not every API uses a sprite class.

This engine is setup in two distinct parts the "BackStage" modules and the "ForStage" module, the backstage part may refer to "ForStage" objects in a vague manner (e.g. void *). They are intensionally vague so preprocessors for any backstage object becomes unnecessary. Since the API objects are unmixed and no API-specific objects are used in the backstage, it makes for cleaner code.

The ForStage module uses every object, though this makes "messy" code easy, it limits all the preprocessors and pointer casts to module.

Arguably using vague types can make way to easy segfaults, but I believe this can be prevented with a little bit of labeling.

The ForStage module is used in a way so that no API information needs to be used with the backstage objects. The backstage objects may call any forstage function as necessary.

The ForStage functions takes whatever information is necessary to draw a sprite, string or other. By using references, the weight of these calls can be limited.

Also in the future I may make it so the engine is more plugin based, in hopes that'll be more universal.

Graphics / Draw image directly?
« on: October 03, 2010, 03:59:10 pm »
That's ok, for now I'll just use a single "facilitator" sprite for all my sprites.

The reason I'm avoiding the Sprite class is because I want the engine to be able to use multiple APIs, so using sf::Sprite becomes difficult, since I don't always have use of this class with other APIs.

I just don't want to continually declare another sprite class just for one API and it'll mean more code.

I could continue to try OpenGL in conjunction with SFML until I get it working. I've gotten close, but no cigar.

I think it would be pointless to argue it, so thanks but no thanks.

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{
        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]

SFML projects / "The Standard Engine"
« on: September 08, 2010, 03:24:32 am »
Can one use the Creative Commons Zero license in place of public domain?
Will it work internationally?

There is also code I have that I want to release into the "public domain".

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.


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,

SFML projects / Open Source 2d shooter
« on: June 11, 2010, 09:38:54 am »
modifications done to port this game:
It was pretty easy, I just followed the G++ errors pretty much.

in globals.h (like... lines 3-9):
Code: [Select]

#include <lua5.1/lua.hpp> // contains all includes
/* commented out these
extern "C" {
  #include "lua.h"
  #include "lauxlib.h"

in Boss2.h (line 11ish):
Code: [Select]

#include "Boss2Minion.h"

Code: [Select]

#include "Boss2minion.h" // linux filesystems are case-sensitive

in cGameEngine.h
Code: [Select]

#include <lua5.1/lua.hpp>
 same-ish as globals.h
extern "C" {
  #include "lua.h"
  #include "lauxlib.h"
  #include "lualib.h"

I also had to change the luabind header (as root) to point to the lua5.1 headers. (I don't know whether this is "playing with fire" or not)[/code]

SFML projects / Open Source 2d shooter
« on: June 11, 2010, 04:26:04 am »
ported to GNU/Linux-x64


I just had to adjust the header files.
The file just has the release binary and the readme.

Canni get a cookie now? :3

I almost forgot!
All the dependencies can be found in the repository, I built it on Ubuntu and with lua5.1
...I hope this helps.
and yes, I'd like to do what I can to help/contribute to this project. (though I'm an amateur C++ programmer)

Pages: [1] 2