sfml

Can't get depth testing to work in OpenGL

假如想象 提交于 2019-11-28 03:57:18
问题 I use SFML to create the window. In this screenshot the cube should be behind the pyramid but it just doesn't work. Here is the minimal code I used: #include <OpenGL/gl.h> #include <OpenGL/glu.h> #include <SFML/Graphics.hpp> #include "ResourcePath.hpp" void resize(); void drawScene(); void initGL(); float rtri = 0; float rquad = 0; float z = -10.0f; int main (int argc, const char * argv[]) { // Create the main window sf::RenderWindow *window = new sf::RenderWindow(); window->Create( sf:

#error gl.h included before glew.h

孤人 提交于 2019-11-28 03:27:41
问题 So I'm trying to move my OpenGL code from Main() into a specific class that will handle the 3D graphics only when necessary. Previously, the top of my main.cpp file looked like this: #define GLEW_STATIC #include <GL/glew.h> #include <SFML/Graphics.hpp> #include <cstdlib> #include <iostream> #include <fstream> #include "Game.h" This worked well enough. What I tried to do was move all the OpenGL-relevant code into methods of the Game class. So I removed #define GLEW_STATIC and #include <GL/glew

How do i link the SFML libraries in Visual Studio Code?

不问归期 提交于 2019-11-28 01:24:30
I've been trying for hours and I can't seem to do it I've downloaded extensions and asked for help around but everything is just confusing me at this point. I want to include the SFML libs in my project and I'm trying to use the the Visual Studio Code editor for it but it just won't comply for some reason. A picture of what it currently looks like. http://imgur.com/qJPlJua I've been trying this for hours yesterday also but it just doesn't want to work. I searched and I have finded. In the tasks.json file, define two tasks : "tasks": [ { "taskName": "Compilation", "isBuildCommand": true, "args"

How to call on a function found on another file?

丶灬走出姿态 提交于 2019-11-27 17:26:27
I'm recently starting to pick up C++ and the SFML library, and I was wondering if I defined a Sprite on a file appropriately called "player.cpp" how would I call it on my main loop located at "main.cpp"? Here is my code (Be aware that this is SFML 2.0, not 1.6!). main.cpp #include "stdafx.h" #include <SFML/Graphics.hpp> #include "player.cpp" int main() { sf::RenderWindow window(sf::VideoMode(800, 600), "Skylords - Alpha v1"); while (window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) window.close(); } window.clear(); window.draw(); window

sf::Texture as class member doesn't work?

半腔热情 提交于 2019-11-27 16:14:16
Heyy, I want to draw a sprite in my SFML application but its texture is always white when I use an image and a texture that are class members Class members: sf::Sprite myimg; sf::Image myimg_image; sf::Texture myimg_texture; When I then create the sprite like this in my cpp file // create image myimg_image.create(icon.width, icon.height, icon.pixelData); // create texture from image myimg_texture.create(icon.width, icon.height); myimg_texture.update(myimg_image); // apply texture to sprite myimg.setTexture(myimg_texture); It only draws a white sprite when I draw it with window.draw(myimg)

Declaring multiple object pointers on one line causes compiler error

坚强是说给别人听的谎言 提交于 2019-11-27 09:02:29
when I do this (in my class) public: Entity() { re_sprite_eyes = new sf::Sprite(); re_sprite_hair = new sf::Sprite(); re_sprite_body = new sf::Sprite(); } private: sf::Sprite* re_sprite_hair; sf::Sprite* re_sprite_body; sf::Sprite* re_sprite_eyes; Everything works fine. However, if I change the declarations to this: private: sf::Sprite* re_sprite_hair, re_sprite_body, re_sprite_eyes; I get this compiler error: error: no match for 'operator=' in '((Entity*)this)->Entity::re_sprite_eyes = (operator new(272u), (<statement>, ((sf::Sprite*)<anonymous>))) And then it says candidates for re_sprite

How do i link the SFML libraries in Visual Studio Code?

岁酱吖の 提交于 2019-11-26 23:31:20
问题 I've been trying for hours and I can't seem to do it I've downloaded extensions and asked for help around but everything is just confusing me at this point. I want to include the SFML libs in my project and I'm trying to use the the Visual Studio Code editor for it but it just won't comply for some reason. A picture of what it currently looks like. http://imgur.com/qJPlJua I've been trying this for hours yesterday also but it just doesn't want to work. 回答1: I searched and I have finded. In

2D Diamond (isometric) map editor - Textures extended infinitely?

£可爱£侵袭症+ 提交于 2019-11-26 14:47:51
问题 I'm currently developing a 2D isometric map editor. I display entity(cube, player) which contains points and textures. Each cubes are composed by 12 points.(12 points, but handled as 3 sides of 4 points when displayed by sfml(sf::VertexArray). (I know I include some '.cpp' times to times, I have a problem with my IDE(visual studio) which I'm trying to resolve, please do not care about it.) main.cpp #pragma once #include "globalfunctions.h" //global functions + main headers + class headers int

Declaring multiple object pointers on one line causes compiler error

此生再无相见时 提交于 2019-11-26 14:27:44
问题 when I do this (in my class) public: Entity() { re_sprite_eyes = new sf::Sprite(); re_sprite_hair = new sf::Sprite(); re_sprite_body = new sf::Sprite(); } private: sf::Sprite* re_sprite_hair; sf::Sprite* re_sprite_body; sf::Sprite* re_sprite_eyes; Everything works fine. However, if I change the declarations to this: private: sf::Sprite* re_sprite_hair, re_sprite_body, re_sprite_eyes; I get this compiler error: error: no match for 'operator=' in '((Entity*)this)->Entity::re_sprite_eyes =

How to call on a function found on another file?

我怕爱的太早我们不能终老 提交于 2019-11-26 11:59:46
问题 I\'m recently starting to pick up C++ and the SFML library, and I was wondering if I defined a Sprite on a file appropriately called \"player.cpp\" how would I call it on my main loop located at \"main.cpp\"? Here is my code (Be aware that this is SFML 2.0, not 1.6!). main.cpp #include \"stdafx.h\" #include <SFML/Graphics.hpp> #include \"player.cpp\" int main() { sf::RenderWindow window(sf::VideoMode(800, 600), \"Skylords - Alpha v1\"); while (window.isOpen()) { sf::Event event; while (window