[QUOTE=MakeR;37122385]This is taken straight from one of the open.gl exercises.
[cpp]const char* fragmentSource =
"#version 150\n"
"in float Color;"
"out vec4 outColor;"
"void main() {"
" outColor = vec4( Color, Color, Color, 1.0 );"
"}";
GLuint fragmentShader = glCreateShader( GL_FRAGMENT_SHADER );
glShaderSource( fragmentShader, 1, &fragmentSource, NULL );
glCompileShader( fragmentShader );[/cpp]
The shader source is hardcoded as a const char *. Alternatively you can load the shader source into a string from a file.[/QUOTE]
Didn't know there were exercises. Maybe I can continue now. Ty
[QUOTE=Naelstrom;37122280]Are you time-stamping your packets so you know exactly when they were sent? I had similar trouble with my networking when the client and server's times were off; time stamping packets allowed me to move the server backwards in time to the exact request of the client's actions. This caused much better synchronization and made the game more predictable.
Other than blaming networking problems I don't know what to say, sorry.[/QUOTE]
While that would work, it would allow anyone to spoof the time in the packets and ruin the whole point of having the server check if weapons can fire.
What I do now is sample input from the local player, send it to the server and just keep seeing if the weapon can fire aslong as the player has the fire button down. Fixes the problem but there's still a chance the last fire will play on the client but the server wont allow it yet.
It's still not a great way of networking it but I think it's much better than having individual weapon fire packets. It also allows for continuous firing weapons like a laser beam.
[QUOTE=laylay;37122452]While that would work, it would allow anyone to spoof the time in the packets and ruin the whole point of having the server check if weapons can fire.[/QUOTE]
It would also minimize the advantage of low ping, [url=https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking]Source calls it "lag compensation"[/url] and they pulled it off decently.
They didn't do it like I explained though, they generate the time difference entirely with the server.
[QUOTE=Meatpuppet;37121376]Guess I can't learn this then. Oh well, would be great if the tut showed me exactly what to do.[/QUOTE]
[img]http://i.imgur.com/hL9ry.png[/img]
No offense, but if you don't know how to read a file, you don't have much experience with C++ at all.
Interesting GWEN stuff going.
First time with the library, I must say it's pretty well designed.
[URL=http://imgur.com/Mkt7o][IMG]http://i.imgur.com/Mkt7ol.png[/IMG][/URL]
Slight hitch. All the colors are washed out. Using OpenGL 4.0, has anyone else had this issue?.
[QUOTE=Meatpuppet;37121376]So that's what that means?
Guess I can't learn this then. Oh well, would be great if the tut showed me exactly what to do.[/QUOTE]
[code]GLuint CreateShader(std::string cFilename, GLenum type) { //Takes filename of shader and type
std::string source = Read(cFilename); //Function that takes a filename and returns a string with the contents of the entire file (uses a streambuf_iterator in my case, but while file.is_good() works fine)
GLuint Shader = glCreateShader(type); //Initializes a temporary shader variable
const char* ssource = source.c_str();
glShaderSource(Shader, 1, &ssource, NULL); //This is stupid, but glShaderSource expects a const** char
glCompileShader(Shader); //Compiles shader
return Shader;
}
[/code]
Also, Overv's tutorial isn't exactly complete yet...
Try [url=http://en.wikibooks.org/wiki/OpenGL_Programming]this[/url]. BE WARNED: It's for OpenGL 2.1, so it's a bit outdated, but OpenGL is fully backwards compatible. If you follow this, make SURE that after you complete it, read up on more modern OpenGL. (Unless, like me, your graphics card only supports OpenGL 2.1 ...)
[url=http://www.arcsynthesis.org/gltut/]This[/url], on the other hand, is OpenGL 3.3, but it's a bit more complicated and doesn't seem to explain things as well.
Um, why is this happening? The code for the vertices is exactly like the code from the example.
[t]http://img37.imageshack.us/img37/466/90976185.png[/t]
Here is my code:
[url]http://pastebin.com/L7C5wHEV[/url]
Line 46, missing comma.
success thanks
[editline]7th August 2012[/editline]
next time you see me i'll be in the what are you working on thread
[QUOTE=ECrownofFire;37123511]Line 46, missing comma.[/QUOTE]
Reminds me of this
[url]http://stackoverflow.com/questions/11695110/why-is-this-program-valid-i-was-trying-to-create-a-syntax-error[/url]
[QUOTE=Overv;37124635][url]http://stackoverflow.com/questions/11695110/why-is-this-program-valid-i-was-trying-to-create-a-syntax-error[/url][/QUOTE]
This is why friends don't let friends use Perl.
The GWEN subforum seems to have mysteriously disappeared, so I guess I'll post my question here. I've looked over the unit test for hours but I can't see what I'm doing wrong
I'm trying to create new controls for the various types of GUI elements in my game, but am having trouble catching the events for them. Specifically, every time I instantiate a Base extended object, it takes over all the input.
The classes themselves are
[CODE]class GameChat : public Gwen::Controls::Base
{
public:
GWEN_CONTROL( GameChat, Gwen::Controls::Base );
// Functions, etc. follow
}
class FriendList : public Gwen::Controls::Base
{
public:
GWEN_CONTROL( FriendList, Gwen::Controls::Base );
// Functions, etc. follow
}[/CODE]
the constructors simply make some objects:
[CODE]GWEN_CONTROL_CONSTRUCTOR( GameChat )
{
chatBox = new Gwen::Controls::TabControl( this );
chatBox->SetBounds( 16, 608, 992, 144 );
chatBox->SetTabStripPosition( Gwen::Pos::Top );
chatBox->SetAllowReorder( true );
// Add tabs, etc.
}
GWEN_CONTROL_CONSTRUCTOR( FriendList )
{
Gwen::Controls::WindowControl* window = new Gwen::Controls::WindowControl( this );
window->SetTitle( L"Friend List" );
window->SetSize( 200, 200 );
window->SetPos( 700, 400 );
};[/CODE]
My input processing code is standard, and pretty much taken from the SFML example:
[CODE]sf::Event event;
while( App.pollEvent( event ) )
{
// Handle Gwen events
GwenInput.ProcessMessage( event );
//etc.[/CODE]
My canvas setup is also from the example:
[CODE]App.create( sf::VideoMode( 1024, 768, 32 ), "Game" );
// Initialize GWEN
Gwen::Renderer::SFML GwenRenderer( App );
Gwen::Skin::TexturedBase skin( &GwenRenderer );
skin.Init( "DefaultSkin.png" );
skin.SetDefaultFont( L"OpenSans.ttf", 12 );
Gwen::Controls::Canvas* pCanvas = new Gwen::Controls::Canvas( &skin );
pCanvas->SetSize( App.getSize().x, App.getSize().y );
// Create an input processor
GwenInput.Initialize( pCanvas, App );[/CODE]
My class declarations are nothing out of the ordinary:
[CODE]
GameChat* inGameChat = new GameChat( pCanvas );
FriendList* inGameFriendList = new FriendList( pCanvas );
[/CODE]
GameChat and FriendList are both classes derived from Gwen::Controls::Base and have their own control objects (Tabs, textboxes, etc.) which are initiated in their constructors.
My problem is that while both inGameChat and inGameFriendList both render without any problems, only the object that is created last responds to input. Thus, inGameFriendList responds and inGameChat doesn't, but if the objects are created in the opposite order, inGameChat responds and inGameFriendList doesn't.
I made a native GWEN object along side my two classes with [CODE]Gwen::Controls::CheckBox* cb = new Gwen::Controls::CheckBox( pCanvas );[/CODE] and it responded just fine, along with the last-created object of my own. I've looked through the Unit Test countless times, but fail to see why my first created objects don't respond to input and my second created objects do. Everything is compiled with MinGW GCC 4.7 on W7 64 bit. Any help would be greatly appreciated!
Guys, I really need some help setting up glfw.
I installed the package on Ubuntu (I'm on a vm),
and as directed in the open.gl tutorial website,
tried to run this bit of code using the terminal(g++ glTest.cpp -lglfw):
[code]
#include <GL/glfw.h>
int main()
{
glfwInit();
glfwSleep( 1.0 );
glfwTerminate();
}
[/code]
That gives me:
"OpenGL Warning: Failed to connect to host. Make sure 3D acceleration is enabled for this VM."
So now I shut down the vm,
turn on the 3d acceleration setting on virtualBox,
and boot up the vm.
I get this:
[url]http://i.minus.com/iboAkLBJa49nNl.JPG[/url]
So now, the Unity desktop environment is invisible;
and when I try to run the code again,
I don't get an error message.
Instead, nothing happens.
Why is Unity going stealth mode on me?
Why doesn't the console application window open?
Thanks in advance for your help.
The only solution I can think of is to install ubuntu on a different VM or actually install it on your computer.
A VM is good to get familiar with the OS, but you should install it properly if you want to do something with it.
If you add me on steam I can help you get started with a good distro and dev environment.
Why not just do the programming on your actual OS? you can run gcc/mingw on windows/linux/mac
Someone knows some good C libraries (cross-platform) to GUI? Grateful
thanks guys
Why won't this work? I've literally pasted the source code from the site, and it still shows a black screen.
[cpp]// Link statically with GLEW
#define GLEW_STATIC
// Headers
#include <GL/glew.h>
#include <SFML/Window.hpp>
#include <iostream>
#include <SOIL.h>
// Shader sources
const char* vertexSource =
"#version 150\n"
"in vec2 position;"
"in vec3 color;"
"in vec2 texcoord;"
"out vec3 Color;"
"out vec2 Texcoord;"
"void main() {"
" Color = color;"
" Texcoord = texcoord;"
" gl_Position = vec4( position, 0.0, 1.0 );"
"}";
const char* fragmentSource =
"#version 150\n"
"in vec3 Color;"
"in vec2 Texcoord;"
"out vec4 outColor;"
"uniform sampler2D tex;"
"void main() {"
" outColor = texture2D( tex, Texcoord ) * vec4( Color, 1.0 );"
"}";
int main()
{
sf::Window window( sf::VideoMode( 800, 600, 32 ), "OpenGL", sf::Style::Titlebar | sf::Style::Close );
// Initialize GLEW
glewExperimental = GL_TRUE;
glewInit();
// Create Vertex Array Object
GLuint vao;
glGenVertexArrays( 1, &vao );
glBindVertexArray( vao );
// Create a Vertex Buffer Object and copy the vertex data to it
GLuint vbo;
glGenBuffers( 1, &vbo );
float vertices[] = {
// Position Color Texcoords
-0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, // Top-left
0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, // Top-right
0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, // Bottom-right
-0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f // Bottom-left
};
glBindBuffer( GL_ARRAY_BUFFER, vbo );
glBufferData( GL_ARRAY_BUFFER, sizeof( vertices ), vertices, GL_STATIC_DRAW );
// Create an element array
GLuint ebo;
glGenBuffers( 1, &ebo );
GLuint elements[] = {
0, 1, 2,
2, 3, 0
};
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, ebo );
glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof( elements ), elements, GL_STATIC_DRAW );
// Create and compile the vertex shader
GLuint vertexShader = glCreateShader( GL_VERTEX_SHADER );
glShaderSource( vertexShader, 1, &vertexSource, NULL );
glCompileShader( vertexShader );
// Create and compile the fragment shader
GLuint fragmentShader = glCreateShader( GL_FRAGMENT_SHADER );
glShaderSource( fragmentShader, 1, &fragmentSource, NULL );
glCompileShader( fragmentShader );
// Link the vertex and fragment shader into a shader program
GLuint shaderProgram = glCreateProgram();
glAttachShader( shaderProgram, vertexShader );
glAttachShader( shaderProgram, fragmentShader );
glBindFragDataLocation( shaderProgram, 0, "outColor" );
glLinkProgram( shaderProgram );
glUseProgram( shaderProgram );
// Specify the layout of the vertex data
GLint posAttrib = glGetAttribLocation( shaderProgram, "position" );
glEnableVertexAttribArray( posAttrib );
glVertexAttribPointer( posAttrib, 2, GL_FLOAT, GL_FALSE, 7 * sizeof( float ), 0 );
GLint colAttrib = glGetAttribLocation( shaderProgram, "color" );
glEnableVertexAttribArray( colAttrib );
glVertexAttribPointer( colAttrib, 3, GL_FLOAT, GL_FALSE, 7 * sizeof( float ), (void*)( 2 * sizeof( float ) ) );
GLint texAttrib = glGetAttribLocation( shaderProgram, "texcoord" );
glEnableVertexAttribArray( texAttrib );
glVertexAttribPointer( texAttrib, 2, GL_FLOAT, GL_FALSE, 7 * sizeof( float ), (void*)( 5 * sizeof( float ) ) );
// Load texture
GLuint tex;
glGenTextures( 1, &tex );
int width, height;
unsigned char* image = SOIL_load_image( "sample.png", &width, &height, 0, SOIL_LOAD_RGB );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image );
SOIL_free_image_data( image );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
while ( window.IsOpened() )
{
sf::Event windowEvent;
while ( window.GetEvent( windowEvent ) )
{
switch ( windowEvent.Type )
{
case sf::Event::Closed:
window.Close();
break;
}
}
// Clear the screen to black
glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
glClear( GL_COLOR_BUFFER_BIT );
// Draw a rectangle from the 2 triangles using 6 indices
glDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0 );
// Swap buffers
window.Display();
}
glDeleteTextures( 1, &tex );
glDeleteProgram( shaderProgram );
glDeleteShader( fragmentShader );
glDeleteShader( vertexShader );
glDeleteBuffers( 1, &ebo );
glDeleteBuffers( 1, &vbo );
glDeleteVertexArrays( 1, &vao );
}[/cpp]
[editline]9th August 2012[/editline]
If I linked anything wrong, wouldn't it tell me? Every tut has worked before this one.
[QUOTE=Cesar Augusto;37142924]Someone knows some good C libraries (cross-platform) to GUI? Grateful[/QUOTE]
I only know of one for C: [URL="http://www.gtk.org/"]GTK+[/URL] (Qt and WxWidgets are good but they're for C++)
EDIT:
The bad thing about GTK+ is that people will have to install the runtime package in order to run your application.
[QUOTE=Meatpuppet;37144911]Why won't this work? I've literally pasted the source code from the site, and it still shows a black screen.
code
[editline]9th August 2012[/editline]
If I linked anything wrong, wouldn't it tell me? Every tut has worked before this one.[/QUOTE]
[url=http://bit.ly/OUJw53]Worked mostly fine for me[/url] using these libraries
[img]http://farmpolice.com/content/images/8Dk7UXigj1G3avxi.png[/img]
I had to convert your old sfml calls to the new ones and it works great other than it segfaults on close.
[editline]asdf[/editline]
This means your code is completely fine, other than I removed #define GLEW_STATIC because I don't like static linking, and maybe your libraries are bad.
[QUOTE=Naelstrom;37146289][url=http://bit.ly/OUJw53]Worked mostly fine for me[/url] using these libraries
[img]http://farmpolice.com/content/images/8Dk7UXigj1G3avxi.png[/img][/QUOTE]
nice grep trick
this also works fyi:
[img]http://i.imgur.com/RCA70.png[/img]
[QUOTE=paindoc;37117319]What are you guys' recomendation for books for someone looking to get into game development through C# or C++? I am not a complete beginner- I've done a significant amount of work with C and Arduino programming autonomous robots so understand the bare basics like code structure, loops, and functions.
That being said, I don't really know enough to just jump right in off tutorials online. So any recommendations are appreciated.
Thanks![/QUOTE]
The SFML website has some pretty good tutorials that introduce concepts like setting up a game loop and handling input. That should be enough to get you started.
[QUOTE=swift and shift;37146392]nice grep trick
this also works fyi:
[img]http://i.imgur.com/RCA70.png[/img][/QUOTE]
Oh damn, I had no idea.
I feel like an idiot. :(
I am working on a simple Love2d space-invaders like game to learn Lua and I am trying to make the enemy bodies fall down as Box2d physics rectangles when they get shot, but whenever I shoot them nothing happens. What's my mistake/mistakes?
[code]
// I removed all the non physics code
love.load()
love.physics.setMeter(64)
world = love.physics.newWorld(0, 9.81*64, true)
end
function CreateBody ()
local Block = {}
for i,v in ipairs (enemies) do // The enemies array contains the data for each enemy in the game
Block.body = love.physics.newBody( world, v.x, v.y, 5 , "dynamic")
Block.shape = love.physics.newRectangleShape(v.width, v.height)
Block.fixture = love.physics.newFixture (Block.body, Block.shape, 1)
table.insert (Bodies, Blocks)
end
end
love.draw()
for i,v in ipairs (Bodies) do
love.graphics.setColor (255,0,0,255)
love.graphics.polygon ("fill", v.shape:getPoints())
end
end
[/code]
[QUOTE=Naelstrom;37146289][url=http://bit.ly/OUJw53]Worked mostly fine for me[/url] using these libraries
[img]http://farmpolice.com/content/images/8Dk7UXigj1G3avxi.png[/img]
I had to convert your old sfml calls to the new ones and it works great other than it segfaults on close.
[editline]asdf[/editline]
This means your code is completely fine, other than I removed #define GLEW_STATIC because I don't like static linking, and maybe your libraries are bad.[/QUOTE]
What is that?
I'm not exactly sure if this is the right thread to ask in, but people directed me to the Programming subforum. I'm looking for help with an old Flash-based game called Hiidenportti. It's made by a Finnish company Valvegroup and I'm looking for someone to work with me to translate it. I can do translating pretty well, however I have no idea how to get the text out of the game, translate them and then get them back in.
If you're interested, send me a PM or something. You can also ask for details and I'll answer to the best of my ability. It's a somewhat old game however and runs on an old version of Flash so it's not a particularly new thing either.
[QUOTE=ShaunOfTheLive;37145915]I only know of one for C: [URL="http://www.gtk.org/"]GTK+[/URL] (Qt and WxWidgets are good but they're for C++)
EDIT:
The bad thing about GTK+ is that people will have to install the runtime package in order to run your application.[/QUOTE]
Yes, I know GTK+ and his problem, but I want to use other libraries. But thanks for help my friend! :)
[QUOTE=Cesar Augusto;37149960]Yes, I know GTK+ and his problem, but I want to use other libraries. But thanks for help my friend! :)[/QUOTE]
There aren't that many for C. You could try [URL="http://trac.enlightenment.org/e/wiki/Elementary"]Elementary[/URL] (part of the Enlightenment library). [URL="http://trac.enlightenment.org/e/wiki/EFLWindowsXP"]It compiles on Windows[/URL] but you have to use MinGW/MSYS.
[QUOTE=ShaunOfTheLive;37150540]There aren't that many for C. You could try [URL="http://trac.enlightenment.org/e/wiki/Elementary"]Elementary[/URL] (part of the Enlightenment library). [URL="http://trac.enlightenment.org/e/wiki/EFLWindowsXP"]It compiles on Windows[/URL] but you have to use MinGW/MSYS.[/QUOTE]
Useful. Thanks bro :)
[QUOTE=Naelstrom;37146289][url=http://bit.ly/OUJw53]Worked mostly fine for me[/url] using these libraries
[img]http://farmpolice.com/content/images/8Dk7UXigj1G3avxi.png[/img]
I had to convert your old sfml calls to the new ones and it works great other than it segfaults on close.
[editline]asdf[/editline]
This means your code is completely fine, other than I removed #define GLEW_STATIC because I don't like static linking, and maybe your libraries are bad.[/QUOTE]
What did you do? What environment is that?
Sorry, you need to Log In to post a reply to this thread.