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

Pages: [1]
1
Graphics / SFML2 and external gui library
« on: February 06, 2012, 10:11:53 pm »
Hi all,

I'm trying to work with librocket and sfml but I can't render both things...

Code: [Select]


void CGUIRenderInterface::resize()
{
mWindow->SetActive();

static sf::View View;
View.SetViewport(sf::FloatRect(0, (float)mWindow->GetWidth(), (float)mWindow->GetHeight(), 0));
mWindow->SetView(View);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, mWindow->GetWidth(), mWindow->GetHeight(), 0, -1, 1);
glMatrixMode(GL_MODELVIEW);

glViewport(0, 0, mWindow->GetWidth(), mWindow->GetHeight());
}

void CGUIRenderInterface::RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation)
{
mWindow->SetActive();

glPushMatrix();
glTranslatef(translation.x, translation.y, 0);

std::vector<Rocket::Core::Vector2f> Positions(num_vertices);
std::vector<Rocket::Core::Colourb> Colors(num_vertices);
std::vector<Rocket::Core::Vector2f> TexCoords(num_vertices);

for(int  i = 0; i < num_vertices; i++)
{
Positions[i] = vertices[i].position;
Colors[i] = vertices[i].colour;
TexCoords[i] = vertices[i].tex_coord;
};

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glVertexPointer(2, GL_FLOAT, 0, &Positions[0]);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, &Colors[0]);
glTexCoordPointer(2, GL_FLOAT, 0, &TexCoords[0]);

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

sf::Texture* image = (sf::Texture *)texture;

if(image)
{
image->Bind();
}
else
{
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glBindTexture(GL_TEXTURE_2D, 0);
};

glDrawElements(GL_TRIANGLES, num_indices, GL_UNSIGNED_INT, indices);

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);

glColor4f(1, 1, 1, 1);

glPopMatrix();
}


problem is here....

If I comment resize function sfml draw his things but librocket no.

2
System / SFML2 - GetInput (Solved)
« on: December 31, 2011, 03:17:00 pm »
Hi all,

I can't find any function similar to GetInput in SFML1  :(

3
Graphics / SFML2 - LoadFromPixels (Solved)
« on: December 31, 2011, 02:01:26 pm »
Hi all,

in sfml2 there is no LoadFromPixels
how can i convert it from sfml1 to sfml2?

4
Graphics / OpenGLImageLoader - myGUI (What's wrong?)
« on: December 28, 2011, 08:54:39 pm »
maybe a it's a myGUI bug?

5
Graphics / OpenGLImageLoader - myGUI (What's wrong?)
« on: December 28, 2011, 08:18:52 pm »
i'm looking an official example
and here is the code:

Code: [Select]
void* BaseManager::loadImage(int& _width, int& _height, MyGUI::PixelFormat& _format, const std::string& _filename)
{
std::string fullname = MyGUI::OpenGLDataManager::getInstance().getDataPath(_filename);

void* result = 0;

Gdiplus::Bitmap* image = Gdiplus::Bitmap::FromFile(MyGUI::UString(fullname).asWStr_c_str());
if (image)
{
_width = image->GetWidth();
_height = image->GetHeight();
Gdiplus::PixelFormat format = image->GetPixelFormat();

if (format == PixelFormat24bppRGB)
_format = MyGUI::PixelFormat::R8G8B8;
else if (format == PixelFormat32bppARGB)
_format = MyGUI::PixelFormat::R8G8B8A8;
else
_format = MyGUI::PixelFormat::Unknow;

if (_format != MyGUI::PixelFormat::Unknow)
{
Gdiplus::Rect rect(0, 0, _width, _height);
Gdiplus::BitmapData out_data;
image->LockBits(&rect, Gdiplus::ImageLockModeRead, format, &out_data);

size_t size = out_data.Height * out_data.Stride;
result = new unsigned char[size];

convertRawData(&out_data, result, size, _format);

image->UnlockBits(&out_data);
}

delete image;
}

return result;
}

btw let my try width*height*4
edit:

it give me

Code: [Select]
20:20:11  |  Platform  |  Critical  |  Error lock vertex buffer  |  MyGUI_OpenGLVertexBuffer.cpp  |  61


6
Graphics / OpenGLImageLoader - myGUI (What's wrong?)
« on: December 28, 2011, 05:54:06 pm »
Code: [Select]
void* ImgLoader::loadImage(int& _width, int& _height, MyGUI::PixelFormat& _format, const std::string& _filename)
{
if (!mImage.LoadFromFile(_filename))
return NULL;

_width = mImage.GetWidth();
_height = mImage.GetHeight();
_format = MyGUI::PixelFormat::R8G8B8A8;

size_t size = _width * _height ;
void* data = new unsigned char[size];
memcpy(data, mImage.GetPixelsPtr(), size);
return data;
}


it doesn't load the image

7
Graphics / OpenGLImageLoader - myGUI (What's wrong?)
« on: December 28, 2011, 04:27:15 pm »
Thanks

8
Graphics / OpenGLImageLoader - myGUI (What's wrong?)
« on: December 28, 2011, 04:01:37 pm »
Hi,

im going to use myGUI as gui library for a tiny project

but the problem is:
http://www7.escoflip.com/tikiwiki/OpenGL+Image+Loader+Using+DevIL+Image+Library&structure=Libraries

i have to change this with sfml functions

actually im doing this:

-loading image
-pass image.GetWidth(); to _width
-pass image.GetHeight(); to _height

but what about pixel format?
and getting raw image and return it?

Pages: [1]