Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Making a shape with textures, how?  (Read 6814 times)

0 Members and 1 Guest are viewing this topic.

hayer

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Making a shape with textures, how?
« on: April 04, 2011, 11:39:26 am »
Hi

I want to make a sf::Shape that can have like 4 different textures.. After a bit of research I realized that couldn't be done straight out of the box.

So I was thinking of doing like I did when I made my DBPro map edtior.
Have 4 textuers and a shader. Then the polygon is painted with four different colors. Each colors represents a texture.

ex:
255, 000, 000 - Grass
000, 255, 000 - Stone
000, 000, 255 - Blood
255, 255, 255 - Gravel

Then the shader would do its magic. But as far is I know this neither is doable with SFML because it only takes whole-fcking-screen shaders, right?

Sooo.. any help?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Making a shape with textures, how?
« Reply #1 on: April 04, 2011, 12:12:40 pm »
SFML 2 has shaders that can be applied to individual drawables.
Laurent Gomila - SFML developer

hayer

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Making a shape with textures, how?
« Reply #2 on: April 04, 2011, 01:15:57 pm »
Okey, two questions then..

1. How do I compile SFML 2?

2. How can I add my own classes?
At the moment I'm using version 1.6 and tried to add my own class, but when I recompiled it, it still didn't show up..


Edit..

Don't know who or what cmake is, but it seems to fail cause of a user-input. >_>

Log
Code: [Select]

agrualon@mikkel-laptop:~/SFML-2.0-snapshot$ cmake CMakeLists.txt
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void*
-- Check size of void* - done
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/libX11.so
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:70 (MESSAGE):
  Could NOT find Freetype (missing: FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS)
Call Stack (most recent call first):
  /usr/share/cmake-2.8/Modules/FindFreetype.cmake:92 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  src/SFML/Graphics/CMakeLists.txt:62 (find_package)


-- Configuring incomplete, errors occurred!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Making a shape with textures, how?
« Reply #3 on: April 04, 2011, 01:26:58 pm »
Quote
1. How do I compile SFML 2?

http://www.sfml-dev.org/tutorials/2.0/compile-with-cmake.php

Quote
2. How can I add my own classes?

To SFML? Why would you do that?

Quote
Could NOT find Freetype

You must install FreeType ;)
And all other libraries SFML depends on, if you don't have them.
Laurent Gomila - SFML developer

hayer

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Making a shape with textures, how?
« Reply #4 on: April 04, 2011, 01:38:17 pm »
After installing libopenal1, libopenal-dev, libjpeg62-dev, libjpeg62, libfreetype6, libfreetype6-dev I get this error

Code: [Select]

agrualon@mikkel-laptop:~/SFML-2.0-snapshot$ cmake CMakeLists.txt
-- Could NOT find SNDFILE  (missing:  SNDFILE_INCLUDE_DIR SNDFILE_LIBRARY)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
GLEW_INCLUDE_PATH
   used as include directory in directory /home/agrualon/SFML-2.0-snapshot/src/SFML/Graphics
GLEW_LIBRARY
    linked by target "sfml-graphics" in directory /home/agrualon/SFML-2.0-snapshot/src/SFML/Graphics
SNDFILE_INCLUDE_DIR (ADVANCED)
   used as include directory in directory /home/agrualon/SFML-2.0-snapshot/src/SFML/Audio

-- Configuring incomplete, errors occurred!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Making a shape with textures, how?
« Reply #5 on: April 04, 2011, 01:41:15 pm »
You must install libglew and libsndfile.

By the way, when you install libxxx-dev you automatically get libxxx, no need to install it manually.
Laurent Gomila - SFML developer

hayer

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Making a shape with textures, how?
« Reply #6 on: April 04, 2011, 01:48:47 pm »
Well, got some futher, now I get;

||=== SFML, all ===|
/home/agrualon/SFML-2.0-snapshot/src/SFML/Window/Linux/VideoModeImpl.cpp|31|fatal error: X11/extensions/Xrandr.h: No such file or directory|
||=== Build finished: 1 errors, 0 warnings ===|


In Code::Blocks.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Making a shape with textures, how?
« Reply #7 on: April 04, 2011, 01:58:50 pm »
You must install libxrandr.

By the way, the list is in the tutorial
http://www.sfml-dev.org/tutorials/1.6/start-linux.php
Laurent Gomila - SFML developer

hayer

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Making a shape with textures, how?
« Reply #8 on: April 04, 2011, 02:24:15 pm »
Well, got it compiled and did a minor re-write of my source code.. But now I get

Code: [Select]

/home/agrualon/Cpp Projects/My SFML Test/main.cpp||In function ‘int main()’:|
/home/agrualon/Cpp Projects/My SFML Test/main.cpp|105|warning: comparison between signed and unsigned integer expressions|
/home/agrualon/Cpp Projects/My SFML Test/main.cpp||In function ‘void DrawShapes()’:|
/home/agrualon/Cpp Projects/My SFML Test/main.cpp|278|warning: comparison between signed and unsigned integer expressions|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window.so||undefined reference to `XRRConfigCurrentConfiguration'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window.so||undefined reference to `XRRSetScreenConfig'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window.so||undefined reference to `XRRFreeScreenConfigInfo'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window.so||undefined reference to `XRRGetScreenInfo'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window.so||undefined reference to `XRRConfigSizes'|
||=== Build finished: 5 errors, 2 warnings ===|


A couple of functions that aren't defined?_?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Making a shape with textures, how?
« Reply #9 on: April 04, 2011, 02:57:40 pm »
Did you compile SFML statically (BUILD_SHARE_LIBS=FALSE)?
Laurent Gomila - SFML developer

hayer

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Making a shape with textures, how?
« Reply #10 on: April 04, 2011, 03:04:22 pm »
Well, another error-log

Code: [Select]

/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window-s.a(VideoModeImpl.cpp.o)||In function `sf::priv::VideoModeImpl::GetDesktopMode()':|
VideoModeImpl.cpp|| undefined reference to `XOpenDisplay'|
VideoModeImpl.cpp|| undefined reference to `XQueryExtension'|
VideoModeImpl.cpp|| undefined reference to `XCloseDisplay'|
VideoModeImpl.cpp|| undefined reference to `XRRGetScreenInfo'|
VideoModeImpl.cpp|| undefined reference to `XRRConfigCurrentConfiguration'|
VideoModeImpl.cpp|| undefined reference to `XRRConfigSizes'|
VideoModeImpl.cpp|| undefined reference to `XRRFreeScreenConfigInfo'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window-s.a(VideoModeImpl.cpp.o)||In function `sf::priv::VideoModeImpl::GetFullscreenModes()':|
VideoModeImpl.cpp|| undefined reference to `XOpenDisplay'|
VideoModeImpl.cpp|| undefined reference to `XQueryExtension'|
VideoModeImpl.cpp|| undefined reference to `XCloseDisplay'|
VideoModeImpl.cpp|| undefined reference to `XRRGetScreenInfo'|
VideoModeImpl.cpp|| undefined reference to `XRRConfigSizes'|
VideoModeImpl.cpp|| undefined reference to `XListDepths'|
VideoModeImpl.cpp|| undefined reference to `XFree'|
VideoModeImpl.cpp|| undefined reference to `XRRFreeScreenConfigInfo'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window-s.a(WindowImplX11.cpp.o)||In function `sf::priv::WindowImplX11::KeysymToSF(unsigned long)':|
WindowImplX11.cpp|| undefined reference to `XConvertCase'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window-s.a(WindowImplX11.cpp.o)||In function `sf::priv::WindowImplX11::CleanUp()':|
WindowImplX11.cpp|| undefined reference to `XRRGetScreenInfo'|
WindowImplX11.cpp|| undefined reference to `XRRConfigCurrentConfiguration'|
WindowImplX11.cpp|| undefined reference to `XRRSetScreenConfig'|
WindowImplX11.cpp|| undefined reference to `XRRFreeScreenConfigInfo'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window-s.a(WindowImplX11.cpp.o)||In function `sf::priv::WindowImplX11::ProcessEvent(_XEvent)':|
WindowImplX11.cpp|| undefined reference to `XQueryKeymap'|
WindowImplX11.cpp|| undefined reference to `XLookupString'|
WindowImplX11.cpp|| undefined reference to `XFilterEvent'|
WindowImplX11.cpp|| undefined reference to `Xutf8LookupString'|
WindowImplX11.cpp|| undefined reference to `XUnsetICFocus'|
WindowImplX11.cpp|| undefined reference to `XSetICFocus'|
WindowImplX11.cpp|| undefined reference to `XLookupString'|
WindowImplX11.cpp|| undefined reference to `XLookupString'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window-s.a(WindowImplX11.cpp.o)||In function `sf::priv::WindowImplX11::CreateHiddenCursor()':|
WindowImplX11.cpp|| undefined reference to `XCreatePixmap'|
WindowImplX11.cpp|| undefined reference to `XCreateGC'|
WindowImplX11.cpp|| undefined reference to `XDrawPoint'|
WindowImplX11.cpp|| undefined reference to `XFreeGC'|
WindowImplX11.cpp|| undefined reference to `XCreatePixmapCursor'|
WindowImplX11.cpp|| undefined reference to `XFreePixmap'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window-s.a(WindowImplX11.cpp.o)||In function `sf::priv::WindowImplX11::SetIcon(unsigned int, unsigned int, unsigned char const*)':|
WindowImplX11.cpp|| undefined reference to `XCreateImage'|
WindowImplX11.cpp|| undefined reference to `XCreatePixmap'|
WindowImplX11.cpp|| undefined reference to `XCreateGC'|
WindowImplX11.cpp|| undefined reference to `XPutImage'|
WindowImplX11.cpp|| undefined reference to `XFreeGC'|
WindowImplX11.cpp|| undefined reference to `XCreatePixmapFromBitmapData'|
WindowImplX11.cpp|| undefined reference to `XAllocWMHints'|
WindowImplX11.cpp|| undefined reference to `XSetWMHints'|
WindowImplX11.cpp|| undefined reference to `XFree'|
WindowImplX11.cpp|| undefined reference to `XFlush'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window-s.a(WindowImplX11.cpp.o)||In function `sf::priv::WindowImplX11::Show(bool)':|
WindowImplX11.cpp|| undefined reference to `XUnmapWindow'|
WindowImplX11.cpp|| undefined reference to `XMapWindow'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window-s.a(WindowImplX11.cpp.o)||In function `sf::priv::WindowImplX11::SetTitle(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':|
WindowImplX11.cpp|| undefined reference to `XStoreName'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window-s.a(WindowImplX11.cpp.o)||In function `sf::priv::WindowImplX11::SetSize(unsigned int, unsigned int)':|
WindowImplX11.cpp|| undefined reference to `XResizeWindow'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window-s.a(WindowImplX11.cpp.o)||In function `sf::priv::WindowImplX11::SetPosition(int, int)':|
WindowImplX11.cpp|| undefined reference to `XMoveWindow'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window-s.a(WindowImplX11.cpp.o)||In function `sf::priv::WindowImplX11::SetCursorPosition(unsigned int, unsigned int)':|
WindowImplX11.cpp|| undefined reference to `XWarpPointer'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings ===|

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Making a shape with textures, how?
« Reply #11 on: April 04, 2011, 03:10:32 pm »
I was not telling you to do so, I was just waiting for an answer, and eventually tell you *not* to build SFML statically under Linux.

Did you install libxrandr-dev?
Laurent Gomila - SFML developer

hayer

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Making a shape with textures, how?
« Reply #12 on: April 04, 2011, 03:17:18 pm »
Oh, my mistake. Yes, I've installed libxrandr-dev and just changed back the libs.

hayer

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Making a shape with textures, how?
« Reply #13 on: April 04, 2011, 04:09:18 pm »
Okey, tried to include /usr/include/X11 - didnt work, then I tried /usr/include/ which didnt work netiher.. Tried to reinstall some packages. Rebooted.

Still not working.

Edit: Don't know what I just did; but now Im getting

Code: [Select]

/home/agrualon/Cpp Projects/My SFML Test/main.cpp||In function ‘int main()’:|
/home/agrualon/Cpp Projects/My SFML Test/main.cpp|107|warning: comparison between signed and unsigned integer expressions|
/home/agrualon/Cpp Projects/My SFML Test/main.cpp||In function ‘void DrawShapes()’:|
/home/agrualon/Cpp Projects/My SFML Test/main.cpp|283|warning: comparison between signed and unsigned integer expressions|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window.so||undefined reference to `XRRConfigCurrentConfiguration'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window.so||undefined reference to `XRRSetScreenConfig'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window.so||undefined reference to `XRRFreeScreenConfigInfo'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window.so||undefined reference to `XRRGetScreenInfo'|
/home/agrualon/SFML-2.0-snapshot-build/lib/libsfml-window.so||undefined reference to `XRRConfigSizes'|
||=== Build finished: 5 errors, 2 warnings ===|

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Making a shape with textures, how?
« Reply #14 on: April 04, 2011, 04:26:18 pm »
Quote
Edit: Don't know what I just did; but now Im getting

Isn't it the same as before?
Laurent Gomila - SFML developer

 

anything