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

Pages: [1]
1
Window / Re: Is SFML Window Events Are Compatible WinForm Events
« on: September 20, 2015, 12:31:04 pm »
Thanks a lot, i replaced dll files again. Now mouse wheel press event matches There is one more mismatched event, and i know where to look :)

2
Window / Re: Is SFML Window Events Are Compatible WinForm Events
« on: September 20, 2015, 12:25:10 pm »
In addition: Your answer looks reasonable, i will check the libraries again now.

3
Window / Re: Is SFML Window Events Are Compatible WinForm Events
« on: September 20, 2015, 12:22:11 pm »
Thanks for the reply :)

Yes i updated the SFML libraries few days ago. But i didn't change the poll events calling functions.

4
Window / Is SFML Window Events Are Compatible WinForm Events
« on: September 20, 2015, 12:02:48 pm »
Hi,

I am using sfml nearly for 3 years, and i love it=) I am not an active form member since i can find nearly all answers about sfml. Now i am stuck in a situation.

I moved my sfml window into a winform control, following the way described here:
http://en.sfml-dev.org/forums/index.php?topic=9141.0

It works, i only had to cast hwnd like this (for those who might look for solution):

HWND hwnd = (HWND)(splitContainer1->Panel2->Handle.ToInt32());

After moving SFML RenderWindow into winControl, i didn't change the pollEvents function calls. I use them like this:

while (sfRenderWindow->pollEvent(event)){
  switch (event.type){
  case sf::Event::Closed:{
  sfRenderWindow->close();
  break;
  }
case sf::Event::KeyPressed:{
break;
}...

But it gets the events mismatched. When i move the mouse, renderWindow gets a leftMouse press event i guess.

How i can prevent this, or what i did wrong, thanks  :)

5
General / Re: How to get glyph coordinates from text
« on: December 20, 2014, 02:32:55 pm »
OK, thanks for reply :)

6
General / How to get glyph coordinates from text
« on: December 20, 2014, 01:10:31 pm »
Hi :),

      I have a question=)

 First, i want to get text as polygons, then i am going to tessellate those polygons. I need this type of approach because i am working on a CAD editor as a hobby, which needs text objects as polygons.

 With below code, i can get the contours of letters. Then i use contour coordinates for creating tessellated polygons.

My question is, is there a SFML way to get these tessellated polygons, or just contours?

                       

std::string::iterator end_it = utf8::find_invalid(mytextobj->text.begin(), mytextobj->text.end());

if(end_it != mytextobj->text.end()){
     std::cout << mytextobj->text<< "not a utf8 text\n";
     mytextobj->text = "???";
}

std::vector<unsigned int> utf32line;

utf8::utf8to32(mytextobj->text.begin(), end_it, std::back_inserter(utf32line));

filename = "c:/fonts/verdana.ttf";
unsigned int h = 12;

FT_Library library;
if(FT_Init_FreeType(&library))
      throw std::runtime_error("Freetype font error.");
FT_Face face;
if(FT_New_Face(library, filename.c_str(), 0, &face))
      throw std::runtime_error("file load error.");

FT_Select_Charmap(face, ft_encoding_unicode);

FT_Set_Char_Size(face, h * 64, h * 64, 1920, 1080);

double x_counter = 0;

for(unsigned int i = 0; i < utf32line.size(); i++){

     if(FT_Load_Glyph(face, FT_Get_Char_Index(face, utf32line[i]), FT_LOAD_DEFAULT )){
          throw std::runtime_error("load glyph not working./n");}

     FT_Glyph glyph;
     
     if(FT_Get_Glyph(face->glyph, &glyph))
          throw std::runtime_error("Glyph error.");

     std::vector<Point> pv;

     FT_GlyphSlot g = face->glyph;

     unsigned int c1 = 0, c2 = 0;

      if (utf32line.at(i) != ' ' && utf32line.at(i) != '\t'){
           for(c1 = 0; c1 <= g->outline.contours[g->outline.n_contours - 1]; c1++){
               pv.push_back(Point(x_counter + ((double)(g->outline.points[c1].x)), mytextobj->koordinat.y + ((double)(g->outline.points[c1].y)), mytextobj->koordinat.z));
         
               if(c1 == g->outline.contours[c2]){
                    c2++;
                    mytextobj->pvs.push_back(pv);
                    pv.clear();
               }
          }
     }
     else{
          x_counter += g->advance.x;
     }
     FT_BBox abbox;
     FT_Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_UNSCALED, &abbox);
     x_counter += abbox.xMax;

     FT_Done_Glyph(glyph);

}
FT_Done_Face(face);

FT_Done_FreeType(library);

7
Graphics / Re: Text Scale After Resizing
« on: March 09, 2013, 10:51:02 pm »
Hi,

You're right ::) I tried to reset view variables after resizing and it's ok now. Text is displayed perfect again.

Thank you :)

8
Graphics / Re: Text Scale After Resizing
« on: March 09, 2013, 04:14:17 pm »
In order to make my code more clear i can give an example:

When the window size.x  = 500;

The position.x = 10 * (1000/500) = 20;

And when the window size.x = 1000;

x position gets the value "10".

So if "20" in 500.x size equals 20 pixels, "10" in 1000.x size equals 20 pixels too. The position is safe.

I couldn't use this approach for y coordinate. Also couldn't prevent the deformation in y scale.

Sorry for my bad English :-[


9
Graphics / Text Scale After Resizing
« on: March 09, 2013, 04:05:04 pm »
Hi,

I am trying to display text using SFML 2.0.

Text is displayed very nice at first, but while resizing i recreate the text object and use this code for scaling:

sf::Text crd; // Create text object..
crd.setFont(My_Fonts::types[0]); // Select font..
crd.setString("Sample Text"); // Set string..
crd.setOrigin(0, 0);
crd.setPosition(10* 1000 / width, 400); // Set position using width variable so it remains at the same point after resizing.. I couldn't find a way to make y point remain unchanged, (400 * 1000/height) doesn't work..
// Variable 1000 is an experimental value i use to specify the gap between text and window border..

crd.setCharacterSize(12U);
crd.setColor(sf::Color(0,0,0));
crd.scale(height/width, 1.0f); // Set scale x according to y and leave y untouched..
texts.push_back(crd); // Put it into an array..

With this code i can save x scale but the y scale is deformed and after resizing the text is displayed stretched.

I hope i could explain my problem. Thanks in advance:)


Pages: [1]