Jump to content

  • Log In with Google      Sign In   
  • Create Account


hatfarm

Member Since 03 Apr 2013
Offline Last Active Sep 18 2013 08:14 AM
-----

Topics I've Started

CMake linking issue with SFML/GLEW in Linux

13 August 2013 - 07:04 PM

Okay, I decided I'd make a new post since the last one kinda got away from the original intent.  So, I'm trying to build my application and I've got all my code compiling, but it's not linking and I'm not sure why.  I kinda reworked the setup, I've got my engine that I've worked on and it compiles and links fine.  My game code is compiling, but it will not find the link to the GLEW and SFML libraries.  I cannot figure out why.  It works fine with my setup in Windows, but Linux apparently hates it.  Here's my top level CMakeLists.txt:

 

cmake_minimum_required(VERSION 2.6.4)
project(Balls)

ADD_SUBDIRECTORY(bate)

include_directories(
	${CMAKE_CURRENT_SOURCE_DIR}/include
	${BATE_INCLUDES}
)

set(EXEC_NAME "Balls to the Walls")

set(Balls_SRCS	
	src/application.cpp	
	src/ball.cpp
	src/ballswindow.cpp
	src/brick.cpp
	src/component.cpp
	src/entity.cpp	
	src/main.cpp
	src/menustate.cpp
	src/position.cpp
	src/system.cpp
	src/velocity.cpp
	
)

set(Balls_INC
	include/application.h
	include/ball.h
	include/ballswindow.h
	include/brick.h
	include/component.h
	include/entity.h
	include/menustate.h
	include/position.h
	include/system.h
	include/velocity.h
)

ADD_DEFINITIONS( -DSFML_STATIC )
	
add_executable(${EXEC_NAME} ${Balls_SRCS} ${Balls_INC})

SET_TARGET_PROPERTIES(${EXEC_NAME}
	PROPERTIES
	COMPILE_DEFINITIONS
	"GLEW_STATIC="
)

TARGET_LINK_LIBRARIES(${EXEC_NAME} BatE )

IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
    # Linux specific code
    SET_TARGET_PROPERTIES(${EXEC_NAME}
	PROPERTIES
	COMPILE_DEFINITIONS
	"IS_LINUX="
    )
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")

# Install target
install(TARGETS ${EXEC_NAME} DESTINATION bin)

BatE is my engine (Battle Engine).  I've tried linking SFML here, but that didn't change anything.  Any advice?


CMake Issue - Need Help Getting it to work with GLEW and SFML

23 May 2013 - 05:51 PM

Hello all, so I've been working with SFML and GLEW in MSVC 2010 and have had very few issues (despite using static libraries for both, which can be an issue).  I'm able to compile and run and have no linking issues or anything.  However, I have plenty of friends whom I'd like to play my game that use Linux exclusively (Macs also for that matter).  So, I wanted to use CMake to allow me to compile on several different platforms.  I followed along the articles written here (http://www.gamedev.net/page/resources/_/technical/general-programming/cross-platform-test-driven-development-environment-using-cmake-part-1-r2986).   I put together a successful CMakeLists.txt and it gets through fine, finding my GLEW and SFML directories.  However, I get GLEW linking errors when I try to compile.  It compiles the game fine, but when it gets to linking it cannot get past this GLEW stuff.  At first I just thought it was the GLEW in SFML conflicting with my GLEW, but no matter what order I put the libraries in, I have the same issue.  I'm hoping that since I can compile with MSVC2010 .sln file, but not with this, it's just a configuration issue.  Hopefully someone here with experience with these 3 systems can give me some advice.  Here's my CMakeList.txt:

 

cmake_minimum_required(VERSION 2.6)
project(BattleMap)

include_directories(
	"${PROJECT_BINARY_DIR}"
	$ENV{GLM_ROOT}
	$ENV{RAPIDXML_ROOT}
	$ENV{GLEW_ROOT}/include
)

set(EXECUTABLE_NAME "BattleMap")
set(BattleMap_SRCS	
	battlemap.cpp
	battlemap.h
	
	bufferobject.cpp
	bufferobject.h
	
	camera.cpp
	camera.h
	
	globals.h
	
	vertices.h
	
	texture.cpp
	texture.h
	
	vao.cpp
	vao.h
	
	supertexture.cpp
	supertexture.h
	
	shaderprog.cpp
	shaderprog.h
	
	scene.cpp
	scene.h
	
	submapscene.cpp
	submapscene.h
	
	mapscene.cpp
	mapscene.h
	
	mousepointerscene.cpp
	mousepointerscene.h
	
	application.cpp
	application.h
	
	main.cpp
)
	
add_executable(${EXECUTABLE_NAME} ${BattleMap_SRCS})

IF (WIN32)
	MESSAGE("IS Win32")
ELSE (WIN32)
	MESSAGE("NOT Win32")
ENDIF (WIN32)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})

IF (WIN32)
	add_library(glew_static STATIC IMPORTED)
	set_target_properties(glew_static PROPERTIES
		IMPORTED_LOCATION $ENV{GLEW_ROOT}/lib/glew32s.lib)
	target_link_libraries(${EXECUTABLE_NAME} glew_static)
ELSE (WIN32)
		find_package(GLEW REQUIRED)
ENDIF (WIN32)



# Detect and add SFML
find_package(SFML 2.0 REQUIRED system window graphics)
#find_package(GLEW REQUIRED)

if(SFML_FOUND)
  include_directories(${SFML_INCLUDE_DIR})
  target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES})
endif()

#if(GLEW_FOUND)
#	MESSAGE("GLEW include path found!")
#	include_directories(${GLEW_INCLUDE_PATH})
#	target_link_libraries(${EXECUTABLE_NAME} ${GLEW_LIBRARY})
#endif()

# Install target
install(TARGETS ${EXECUTABLE_NAME} DESTINATION bin)

 

Some of the GLEW stuff commented out is just me trying different orders for CMake.  If more information would be helpful, I'm more than happy to provide it.  Thanks ahead of time.


Diffuse Lighting Problem

05 May 2013 - 09:00 PM

So, the best way to show what the problem is is to post a picture:

 

My Test Stuff.5_5_21_44_32.png

 

As you can see, my light does not cover the whole map.  I've implemented it following this tutorial: http://ogldev.atspace.co.uk/www/tutorial18/tutorial18.html . No matter how I set the direction, it doesn't light the bottom part of the map.  I don't think it's a problem with the normals being calculated properly, but I really can't think of what else it could possibly be.  Any help would be greatly appreciated.


Why does this ordering matter? uniformMatrix4fv update issue?

27 April 2013 - 10:23 PM

So, I've got a couple of scenes I'm drawing (a custom mouse cursor and my map).  I've got a separate camera object that can be moved around to change what part of the map I'm looking at, I want to keep the camera separate because once I start putting objects on my map, I want them to use the same camera but a (slightly) different GLSL program.  Anyway, the way I'm doing it now is the camera is linked to the scene via a function that sends the MVP matrix from the camera to the scene.  Here's that function:

 

void MapScene::updateMVP(const glm::mat4 &mvp){
    m_sProg.useProgram();
    glBindVertexArray(m_vao);
    m_sProg.getUniformLocation("mvp", m_worldUniform);
    glUniformMatrix4fv(m_worldUniform, 1, GL_FALSE, glm::value_ptr(mvp));
    if(GL_NO_ERROR != glGetError())
        std::cerr << "Could not write MVP!\n";
}

 

This code works, for the most part.  I initialize my scenes and my camera, but if I don't do it in a specific order, I don't get the right results.  I initially didn't have the "useProgram();" call at the beginning of the updateMVP() function, but now that I do, I don't know why this won't work.  Here's what I write to get the desired results:

 

m_mapScene->initScene();
initCamera();
m_mouseScene->initScene();

 

If I put initCamera() at the bottom of this, I get just a tiny amount of the map to show (about the size of the mouse).  initCamera() just sets projection, model and view matrices as you normally would and then sends an updateMVP() call to my mapScene.  The crazy thing is, I call the updateMVP function during the render loop too, before I render any of my scenes.  Any ideas?  I can only think it's because of the 2d scene for the mouse, or just that it's a different program, but I don't understand why that would be a problem since the mapScene's shader program is set to be used before I try to do anything (I also don't get any of those cerr messages from a bad MVP write).

 

Any help would be appreciated.


OpenGL QuadTree Issue

18 April 2013 - 09:51 PM

I apologize if this is kind of all over the place.  I have a 3 month old so I had to write this in bits and pieces.  So, I've got a terrain that I'm happy with getting displayed okay.  It has no issues drawing so far, but once I populate the map with objects and characters, I imagine that I'll have issues.  Plus, I would really like to use a QuadTree for picking purposes.

 

I have a few questions. But first, a bit about my map.  It's a tile map essentially, just placing them in strategic positions so they look good after I do my MVP transformations.  However, the tiles themselves exist entirely in the xy-plane.  I put walls in the z-plane, but I don't care about being able to pick them (and they'll get drawn with their tile, no matter what).  Currently, I have a giant VBO and giant Index array that stores all of these.  I rotate the model matrix, then setup my lookat(view) and projection matrix and I'm good.  I have a specific camera matrix that goes between the world matrix and projection*view matrix that I translate in order to give me camera control.  I plan on keeping the one VBO, and the leaf nodes will contain the indexes for the tiles that it contains, and once we decide which ones to not cull, we put together a master IBO with only those indexes.

 

So, the first question is, what should I use as the coordinates to sort my quadtree around?  My first thought is to just use the xy coordinates that I initially laid them all out on.  However, that means any time I want to do picking or culling, I have to translate from screen space all the way to model space.  This seems pretty inefficient as I'd like to be able to highlight the tile that the mouse is currently over, which would require a WHOLE LOT of translation calculations.  I can't think of a better way to do it however, would this work?

 

Second question, how do I re-evaluate what to cull.  My thinking is, I'll decide what is on the screen currently, then draw a bit more than that (maybe another quarter of that size in each direction) so I don't have to change it all every frame if they're moving in 2 directions at once.  However, what's a good method for deciding when to do that evaluation?  How do I figure out what my screen is currently looking?  Do I just look at the model coordinates of each corner and if my tiles are in between those coordinates, I draw them (plus a few in each direction?).  This seems to have the same problem as the mouse issue above.

 

Third question, when picking, if a leaf node of the quadtree contains multiple tiles, how do I determine which tile was clicked on?  It's pretty obvious if they all contain a single tile, otherwise not so much.  Anyway, I'm tired and want to get back to working on this stuff.  Any help would be greatly appreciated.  Thanks.


PARTNERS