[QUOTE=Ezhik;39598119]-snip-
[editline]15th February 2013[/editline]
learn to read, ezhik, learn to read...
[editline]15th February 2013[/editline]
okay different question (LOVE):
[php]function love.load()
love.graphics.setBackgroundColor (135, 206, 235)
love.physics.setMeter(64)
world = love.physics.newWorld(0, 9.81*64, true)
objects = {}
--ground
objects.ground = {}
objects.ground.body = love.physics.newBody(world, 800/2, 650-50/2) --defined from the middle
objects.ground.shape = love.physics.newRectangleShape(650,50)
objects.ground.fixture = love.physics.newFixture(objects.ground.body, objects.ground.shape)
end
function love.draw()
--to show the "ground" shape
love.graphics.setColor(72,160,14) --THIS BETTER BE GREEN
love.graphics.polygon("fill", objects.ground.body:getWorldPoints(objects.ground.shape:getPoints()))
love.graphics.setColor(200, 14, 47)
if isBlockM then
love.graphics.polygon("fill", objects.blockM.body:getWorldPoints(objects.blockM.shape:getPoints()))
end
if love.mouse.isDown("l") then
love.graphics.rectangle("line", x1, y1, love.mouse.getX() - x1, love.mouse.getY() - y1)
end
end
function love.update( dt )
world:update(dt) --so that stuff moves
end
function love.mousepressed( x, y, button )
--print("Mouse pressed: " .. x .. ", " .. y .. "; Button: " .. button)
x1 = x
y1 = y
end
function love.mousereleased( x, y, button )
x2 = x
y2 = y
print("x1 = " .. x1 .. "; y1 = " .. y1 .. "; x2 = " .. x2 .. "; y2 = " .. y2)
shapeX = (x1 + x2)/2
shapeY = (y1 + y2)/2
shapeW = x2 - x1
shapeH = y2 - y1
objects.blockM = {}
objects.blockM.body = love.physics.newBody(world, shapeX, shapeY, "dynamic")
objects.blockM.shape = love.physics.newRectangleShape(0, 0, shapeW, shapeH)
objects.blockM.fixture = love.physics.newFixture(objects.blockM.body, objects.blockM.shape, 2) --that 5 is density
isBlockM = true
end[/php]
how would i go around making every shape created with my mouse rendered? what i have now only shows the latest shape - although all other shapes are still there, so if i make a new box on top of an older one, it'll appear to float in midair[/QUOTE]
Try this, the reason only the last one showed was because you were overwriting the previous one with the new one (objects.blockM = {}). I've changed this and now objects.blockM is a table filled with blocks. I insert a new block with the table.insert, then I loop through the table in the draw in order to get the blocks.
Hope this helps!
[lua]function love.load()
love.graphics.setBackgroundColor (135, 206, 235)
love.physics.setMeter(64)
world = love.physics.newWorld(0, 9.81*64, true)
objects = {}
--ground
objects.ground = {}
objects.ground.body = love.physics.newBody(world, 800/2, 650-50/2) --defined from the middle
objects.ground.shape = love.physics.newRectangleShape(650,50)
objects.ground.fixture = love.physics.newFixture(objects.ground.body, objects.ground.shape)
end
function love.draw()
--to show the "ground" shape
love.graphics.setColor(72,160,14) --THIS BETTER BE GREEN
love.graphics.polygon("fill", objects.ground.body:getWorldPoints(objects.ground.shape:getPoints()))
love.graphics.setColor(200, 14, 47)
for k,blocky in pairs(objects.blockM) do
love.graphics.polygon("fill", blocky.body:getWorldPoints(blocky.shape:getPoints()))
end
if love.mouse.isDown("l") then
love.graphics.rectangle("line", x1, y1, love.mouse.getX() - x1, love.mouse.getY() - y1)
end
end
function love.update( dt )
world:update(dt) --so that stuff moves
end
function love.mousepressed( x, y, button )
--print("Mouse pressed: " .. x .. ", " .. y .. "; Button: " .. button)
x1 = x
y1 = y
end
function love.mousereleased( x, y, button )
x2 = x
y2 = y
print("x1 = " .. x1 .. "; y1 = " .. y1 .. "; x2 = " .. x2 .. "; y2 = " .. y2)
shapeX = (x1 + x2)/2
shapeY = (y1 + y2)/2
shapeW = x2 - x1
shapeH = y2 - y1
local block = {}
block.body = love.physics.newBody(world, shapeX, shapeY, "dynamic")
block.shape = love.physics.newRectangleShape(0, 0, shapeW, shapeH)
block.fixture = love.physics.newFixture(objects.blockM.body, objects.blockM.shape, 2) --that 5 is density
table.insert(objects.blockM, block)
end[/lua]
Howdy. I'm currently working on a project in Processing 1.5.1 and can't seem to figure out how to upload a picture from my computer onto a website such as [URL="http://images.google.com/imghp?hl=en"]google image search[/URL]. I've been messing around with both JSON and Java, as well as scouring the googles for some help, but to no avail. Anybody familiar enough with Processing to know how to solve this issue?
What exactly are you trying to do?
[QUOTE=Meader;39600380]Howdy. I'm currently working on a project in Processing 1.5.1 and can't seem to figure out how to upload a picture from my computer onto a website such as [URL="http://images.google.com/imghp?hl=en"]google images[/URL]. I've been messing around with both JSON and Java, as well as scouring the googles for some help, but to no avail. Anybody familiar enough with Processing to know how to solve this issue?[/QUOTE]
Um, I'm pretty sure you can't directly upload images to google images. They search for the images, not the other way around.
[QUOTE=Gulen;39600461]What exactly are you trying to do?[/QUOTE]
[QUOTE=Meader;39600380]upload a picture from my computer onto a website such as [URL="http://images.google.com/imghp?hl=en"]google image search[/URL]. [/QUOTE]
I have the sketch able to take a picture and save it in the sketch folder, but I'm unsure how to upload that JPEG from the sketch folder to a website.
[editline]15th February 2013[/editline]
[QUOTE=mobrockers2;39600542]Um, I'm pretty sure you can't directly upload images to google images. They search for the images, not the other way around.[/QUOTE]
Google Image Search allows you to upload an image and search based off of that image.
[QUOTE=Meader;39600551]I have the sketch able to take a picture and save it in the sketch folder, but I'm unsure how to upload that JPEG from the sketch folder to a website.
[editline]15th February 2013[/editline]
Google Image Search allows you to upload an image and search based off of that image.[/QUOTE]
Ah right, that's what you meant.
You need this:
[url]https://developers.google.com/custom-search/v1/overview[/url]
[QUOTE=mobrockers2;39600634]Ah right, that's what you meant.
You need this:
[url]https://developers.google.com/custom-search/v1/overview[/url][/QUOTE]
That gives me the API for google images, but not for search by image.
[QUOTE=Meader;39602046]That gives me the API for google images, but not for search by image.[/QUOTE]
That API is for search by image also.
[editline]15th February 2013[/editline]
Source: [url]https://developers.google.com/image-search/[/url]
[editline]15th February 2013[/editline]
Oh wait I think I misread :v:
[QUOTE=mobrockers2;39602146]That API is for search by image also.
[editline]15th February 2013[/editline]
Source: [URL]https://developers.google.com/image-search/[/URL]
[editline]15th February 2013[/editline]
Oh wait I think I misread :v:[/QUOTE]
Google hasn't released an API for "Search By Image" yet, so that's a no-go.
I was more interested in being able to upload an image to any website, like what would the code look like?
I'm using an HTTP library, but I could use JSON or JavaScript if necessary.
[QUOTE=Meader;39602350]Google hasn't released an API for "Search By Image" yet, so that's a no-go.
I was more interested in being able to upload an image to any website, like what would the code look like?
I'm using an HTTP library, but I could use JSON or JavaScript if necessary.[/QUOTE]
You can't just force something onto someone else's server (or shouldn't be able to), so it depends entirely on how and if any upload functionality is build.
[QUOTE=mobrockers2;39602393]You can't just force something onto someone else's server (or shouldn't be able to), so it depends entirely on how and if any upload functionality is build.[/QUOTE]
I follow. That's why I was using google image search, because it's designed to be open to taking image files.
[QUOTE=Donkie;39599395]Try this, the reason only the last one showed was because you were overwriting the previous one with the new one (objects.blockM = {}). I've changed this and now objects.blockM is a table filled with blocks. I insert a new block with the table.insert, then I loop through the table in the draw in order to get the blocks.
Hope this helps!
[lua]-snip-[/lua][/QUOTE]
okay i don't understand shit :suicide:
is there a way to use lua's arrays like in c++
[editline]16th February 2013[/editline]
also it didn't work
[editline]16th February 2013[/editline]
in cpp i'd be able to do something like this:
[cpp]for(int i=0, i<t, i++)
{
love.graphics.polygon("fill", objects[i].body:getWorldPoints(objects[i].shape:getPoints()));
}[/cpp]
where t is the number of stuff in the objects array
[QUOTE=SleepyAl;39598921]Alright, I'm really not that good with code, but since I'm only editing a source file and recompiling it I think I'm doing fine. Basically it's going to launch a game and trick Steam into thinking I'm using Linux instead of Windows. Here's the source code I'm compiling, C# in Visual Studio:
code
[/QUOTE]
Fixed it, don't need help.
So it turns out that [url=http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41933]gcc has a bug where you can't capture variadic arguments in lambdas[/url]. Anybody know of a workaround? I was thinking of a tuple but I don't know how to turn that back in to variadic arguments.
-snip-
[QUOTE=Philly c;39604334]So it turns out that [url=http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41933]gcc has a bug where you can't capture variadic arguments in lambdas[/url]. Anybody know of a workaround? I was thinking of a tuple but I don't know how to turn that back in to variadic arguments.[/QUOTE]
Maybe I'm just not familiar enough with C++11, but is there a reason why you need to use a lambda? I didn't think they could do anything more than regular functions and function pointers...
Can someone please explain to me how this can possible throw an access violation?
[cpp]if(weaponAmmo.find(wep) == weaponAmmo.end())
std::cout << "Crash";
return weaponAmmo.find(wep)->second;[/cpp]
Crash is not printed. I have tried return weaponAmmo[wep], but that fails too.
[QUOTE=Ezhik;39603287]okay i don't understand shit :suicide:
is there a way to use lua's arrays like in c++
[editline]16th February 2013[/editline]
also it didn't work
[editline]16th February 2013[/editline]
in cpp i'd be able to do something like this:
[cpp]for(int i=0, i<t, i++)
{
love.graphics.polygon("fill", objects[i].body:getWorldPoints(objects[i].shape:getPoints()));
}[/cpp]
where t is the number of stuff in the objects array[/QUOTE]
You can do that, but note that tables in Lua start from 1, not 0.
[lua]function love.load()
love.graphics.setBackgroundColor(135, 206, 235)
love.physics.setMeter(64)
world = love.physics.newWorld(0, 9.81*64, true)
-- objects table
objects = {}
-- ground object
objects.ground = {}
objects.ground.body = love.physics.newBody(world, 800/2, 650-50/2) -- defined from the middle
objects.ground.shape = love.physics.newRectangleShape(650,50)
objects.ground.fixture = love.physics.newFixture(objects.ground.body, objects.ground.shape)
end
function love.draw()
-- draw the ground
love.graphics.setColor(72,160,14)
love.graphics.polygon("fill", objects.ground.body:getWorldPoints(objects.ground.shape:getPoints()))
-- draw other objects
love.graphics.setColor(200, 14, 47)
for i=1, #objects do -- loop through the objects table (#objects = length of the objects table)
love.graphics.polygon("fill", objects[i].body:getWorldPoints(objects[i].shape:getPoints()))
end
-- draw the shape we are creating
if love.mouse.isDown("l") then
love.graphics.rectangle("line", x1, y1, love.mouse.getX() - x1, love.mouse.getY() - y1)
end
end
function love.update(dt)
world:update(dt)
end
function love.mousepressed(x, y, button)
x1 = x
y1 = y
end
function love.mousereleased(x, y, button)
local shapeX = (x1 + x)/2
local shapeY = (y1 + y)/2
local shapeW = x - x1
local shapeH = y - y1
local obj = {}
obj.body = love.physics.newBody(world, shapeX, shapeY, "dynamic")
obj.shape = love.physics.newRectangleShape(0, 0, shapeW, shapeH)
obj.fixture = love.physics.newFixture(obj.body, obj.shape, 2)
table.insert(objects, obj) -- equivalent to objects[i] = obj; where i is the length of the table + 1
end[/lua]
[QUOTE=WTF Nuke;39607145]Can someone please explain to me how this can possible throw an access violation?
[cpp]if(weaponAmmo.find(wep) == weaponAmmo.end())
std::cout << "Crash";
return weaponAmmo.find(wep)->second;[/cpp]
Crash is not printed. I have tried return weaponAmmo[wep], but that fails too.[/QUOTE]
It can be an invalid pointer that isn't weaponAmmo.end(), e.g null.
[editline]16th February 2013[/editline]
I think
[QUOTE=WTF Nuke;39607145]Can someone please explain to me how this can possible throw an access violation?
[cpp]if(weaponAmmo.find(wep) == weaponAmmo.end())
std::cout << "Crash";
return weaponAmmo.find(wep)->second;[/cpp]
Crash is not printed. I have tried return weaponAmmo[wep], but that fails too.[/QUOTE]
Are you sure that find(wep) is returning a weapon? BTW that if statement only works for one line, so maybe you should use braces.
Oh god, the reason it was crashing is not even relevant to that code, but because the class that calls that code was a null pointer. Sorry for my stupidity, it was too late for me to think straight (which is why I didn't fix it in the first place).
[QUOTE=WTF Nuke;39611008]Oh god, the reason it was crashing is not even relevant to that code, but because the class that calls that code was a null pointer. Sorry for my stupidity, it was too late for me to think straight (which is why I didn't fix it in the first place).[/QUOTE]
This is why you should use breakpoints!
God damnit opengl.
This is supposed to display a triangle. I have done this before, just like this, but it just doesn't draw anything. What am I doing wrong?
[CODE]
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL15.*;
import static org.lwjgl.opengl.GL20.*;
import static org.lwjgl.opengl.GL30.*;
import static org.lwjgl.opengl.GL32.*;
import org.lwjgl.opengl.*;
import org.lwjgl.util.vector.Vector4f;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import java.nio.FloatBuffer;
import java.util.ArrayList;
public class OpenGLWindow {
public static String WINDOW_TITLE = "OpenGL Window";
public static int WINDOW_WIDTH = 1080;
public static int WINDOW_HEIGHT = 720;
private String strVertexShader =
"#version 330 \n" +
"\n" +
"in vec4 vPosition;\n" +
"void main()\n" +
"{\n" +
" gl_Position = vPosition;\n" +
"}";
private String strFragmentShader =
"#version 330\n" +
"\n" +
"out vec4 outputColor;\n" +
"void main()\n" +
"{\n" +
" outputColor = vec4(1.0f, 1.0f, 1.0f, 1.0f);\n" +
"}";
private int vertexShader;
private int fragmentShader;
private int shaderProgram;
private int vbo;
private int vao;
private float points[] = {
-1.0f,-1.0f,0.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,
1.0f,-1.0f,0.0f,0.0f
};
public OpenGLWindow(){
try {
Display.setTitle(WINDOW_TITLE);
Display.setDisplayMode(new DisplayMode(WINDOW_WIDTH, WINDOW_HEIGHT));
Display.setResizable(false);
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
System.exit(0);
}
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0f, 0f, 0f, 1f);
resize(WINDOW_WIDTH,WINDOW_HEIGHT);
init();
while(!Display.isCloseRequested()){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
tick();
render();
Display.sync(60);
Display.update();
}
Display.destroy();
}
public void init(){
compileShader();
createShaderProgram();
initializeVBO();
vao = glGenVertexArrays();
glBindVertexArray(vao);
int vPosition = glGetAttribLocation(shaderProgram, "vPosition"); // get the location for the vPosition variable in the shader
glEnableVertexAttribArray(vPosition);
glVertexAttribPointer(vPosition,4,GL_FLOAT,false,0,0);
}
public void tick(){
}
public void render(){
glUseProgram(shaderProgram);
glDrawArrays(GL_TRIANGLES,0,3);
}
public void initializeVBO(){
FloatBuffer vertexPositionsBuffer = BufferUtils.createFloatBuffer(points.length);
vertexPositionsBuffer.put(points);
vertexPositionsBuffer.flip();
vbo = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, vertexPositionsBuffer, GL_STATIC_DRAW);
}
public void compileShader(){
int status;
vertexShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertexShader,strVertexShader);
glCompileShader(vertexShader);
status = glGetShaderi(vertexShader, GL_COMPILE_STATUS);
if(status != GL_FALSE){
System.out.println("Vertex shader compiled successfully");
}else{
System.out.println("Vertex shader failed to compile!");
}
fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragmentShader,strFragmentShader);
glCompileShader(fragmentShader);
status = glGetShaderi(fragmentShader, GL_COMPILE_STATUS);
if(status != GL_FALSE){
System.out.println("Fragment shader compiled successfully");
}else{
System.out.println("Fragment shader failed to compile!");
}
}
public void createShaderProgram(){
shaderProgram = glCreateProgram();
System.out.println("Shader program created successfully");
glAttachShader( shaderProgram, vertexShader );
glAttachShader( shaderProgram, fragmentShader );
glLinkProgram(shaderProgram);
System.out.println("Shader program linked successfully");
}
public void resize(int width, int height){
glViewport(0,0,width,height);
}
public static void main(String[] args) {
new OpenGLWindow();
System.exit(0);
}
}
[/CODE]
Ok this is stupid -_-
I'm making a general Game class that handles the game, there are more functions but I just want to get it working first.
game.cpp
[cpp]#include "game.h"
void game::launch() {
state = playing;
window.create(sf::VideoMode(1024, 768), "Crowdsource");
}
void game::draw() {
if(state != playing) return;
sf::Texture texture;
if (!texture.loadFromFile("square.png")) return;
sf::Sprite sprite(texture);
sf::Font font;
if (!font.loadFromFile("XPDR.TTF")) return;
sf::Text text("Hello SFML", font, 50);
window.clear();
window.draw(sprite);
window.draw(text);
window.display();
}
void game::handleEvents() {
if(state != playing) return;
sf::Event event;
while (window.pollEvent(event))
{
if(event.type == sf::Event::Closed)
window.close();
}
}
bool game::isClosed() {
return (!window.isOpen());
}[/cpp]
main.cpp
[cpp]int main()
{
GAME.launch();
while(!GAME.isClosed())
{
GAME.handleEvents();
GAME.draw();
}
return 0;
}[/cpp]
the error:
[cpp]Unhandled exception at 0x000007F92C021069 (ntdll.dll) in Crowdsource.exe: 0xC0000005: Access violation writing location 0x0000000000000008.[/cpp]
[QUOTE=Meatpuppet;39611107]This is why you should use breakpoints![/QUOTE]
I was using breakpoints, it wasn't broken there though.
[QUOTE=Meatpuppet;39611364]Ok this is stupid -_-
I'm making a general Game class that handles the game, there are more functions but I just want to get it working first.
game.cpp
[cpp]snip[/cpp]
main.cpp
[cpp]snip[/cpp]
the error:
[cpp]Unhandled exception at 0x000007F92C021069 (ntdll.dll) in Crowdsource.exe: 0xC0000005: Access violation writing location 0x0000000000000008.[/cpp][/QUOTE]
What line is it crashing on? According to the error you're trying to write to a pointer or reference that isn't set to anything.
e: nvm
[QUOTE=Robbis_1;39611670]What line is it crashing on? According to the error you're trying to write to a pointer or reference that isn't set to anything.[/QUOTE]
it crashes before the program even starts
[QUOTE=Meatpuppet;39611835]it crashes before the program even starts[/QUOTE]
Do you have any static or global variables?
[QUOTE=Robbis_1;39612112]Do you have any static or global variables?[/QUOTE]
game.h
[cpp]#pragma once
#include <SFML/Graphics.hpp>
class game {
public:
sf::RenderWindow window;
enum gameState { playing, paused };
gameState state;
void launch();
void draw();
void isColliding(sf::RectangleShape shape);
void increaseFieldSize(int size);
void handleEvents();
bool isClosed();
};
static game GAME;[/cpp]
GAME is used in main
Sorry, you need to Log In to post a reply to this thread.