Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411634 Posts in 69394 Topics- by 58447 Members - Latest Member: wcored

May 13, 2024, 08:03:35 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)The grumpy old programmer room
Pages: 1 ... 218 219 [220] 221 222 ... 295
Print
Author Topic: The grumpy old programmer room  (Read 740140 times)
s_l_m
Level 8
***


Open to collabs


View Profile
« Reply #4380 on: November 20, 2013, 06:50:13 PM »

Apparently Unity can't generate random numbers from a second thread, because why wouldn't it have some weird bullshit like that?

Edit: I guess switching my code to use the system random instead of the built in Unity random functions works, it's just such a strange limitation
Logged

Think happy thoughts.
Geti
Level 10
*****



View Profile WWW
« Reply #4381 on: November 20, 2013, 07:02:01 PM »

Probably don't want race conditions for reproducibility (which the system random doesn't offer afaik) - I usually write a simple xorshift random for each thread or context that I need - helps to prevent breaking seeds for generators when you add a new subsystem (of course, sometimes its unavoidable, but it's better than calling some global)
Logged

s_l_m
Level 8
***


Open to collabs


View Profile
« Reply #4382 on: November 20, 2013, 07:06:23 PM »

Probably don't want race conditions for reproducibility (which the system random doesn't offer afaik) - I usually write a simple xorshift random for each thread or context that I need - helps to prevent breaking seeds for generators when you add a new subsystem (of course, sometimes its unavoidable, but it's better than calling some global)

Mhmm, I think I might just write a simple random generator, I am using System.random for now but I would much rather have this thread be as self contained as possible. Also, System.Random conflicts with the unity random stuff if you don't specify so it is probably for the better I avoid it
Logged

Think happy thoughts.
Whiteclaws
Level 10
*****


#include <funny.h>


View Profile
« Reply #4383 on: November 23, 2013, 10:46:17 AM »

ARGHHHH...

BECAUSE OF ONE SPACE IN MY GLSL SHADER , MY PROGRAM SHOWED A BLACK SCREEN

TRIED RE-WRITING 5 TIMES , AND BEEN SCRATCHING MY HEAD FOR 4 WEEKS AND MY CODE WAS GOOD FROM THE BEGINNING !!!!!

AND COMPILER DIDN'T SAY NOTHING ABOUT THIS ...

Quote
//Not Working
#version 330
 
 layout(location = 0) in vec3 Position;
 
 void main()
 {
    gl_Position = vec4(Position, 1);
 }
 
//Working
#version 330
 
layout(location = 0) in vec3 position;
 
void main()
{
    gl_Position = vec4(position,1);
}
 
////////////////////////////////////////////////////////////////////////////////////////////
Cry Cry Cry Cry Cry Cry Cry

Edit :
Uh...

My head hurts from me hitting the wall with it

I guess I learnt my lesson ... the hard way ...
C/C++ devs ... I feel your pain...
« Last Edit: November 23, 2013, 10:52:12 AM by Whiteclaws » Logged
Polly
Level 6
*



View Profile
« Reply #4384 on: November 23, 2013, 10:59:25 AM »

Whiteclaws, grab AMD's GPU ShaderAnalyzer to standalone compile shaders ( against a whole slew of cards )* Easiest way to catch these kind of mistakes ( and more ).

*Doesn't actually use your GPU, so works fine on NVIDIA / Intel etc. systems too.
Logged
ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #4385 on: November 23, 2013, 03:21:05 PM »

BECAUSE OF ONE SPACE IN MY GLSL SHADER , MY PROGRAM SHOWED A BLACK SCREEN

Was it the space, or the capitalization of Position? Latter seems more likely to me, but I don't know all the quirks of the GLSL compiler.
Logged

kamac
Level 10
*****


Notoriously edits his posts


View Profile
« Reply #4386 on: November 24, 2013, 01:42:08 AM »

I'd guess it was the space before the layout keyword, maybe?
Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #4387 on: November 25, 2013, 12:25:13 PM »

possibly, does the GLSL even take into account line breaks and carriage returns?
Logged

powly
Level 4
****



View Profile WWW
« Reply #4388 on: November 29, 2013, 11:00:25 AM »

It should ignore all white space that doesn't separate actual expressions apart from line breaks for single line comments (and expressions like 'int a' obviously need that space) so I'm very curious about what's going on. Always remember to consult the compilation error log (and recent drivers) since it actually tells you what's wrong - shader development is a big enough pain in the beginning even if you do. ShaderAnalyzer is a good way to check strictness if you're not on AMD hardware. There are also a couple of debug extensions that seem very nice but I haven't touched them myself quite yet so hard to say if I should recommend them Smiley

As a side note, neither version is valid GLSL; you're doing an implicit cast. It should be '1.0' in the vec4().
Logged
Saishy
Level 0
***



View Profile WWW
« Reply #4389 on: November 29, 2013, 10:14:17 PM »

I frequently run into problems because Unity think it's cool to discard any decimal result of a integer division.

Because logically, if you are dividing integers it should never have decimal results!

AAAAARRRGGG
Logged

TinyBird Games  We make tiny games!
ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #4390 on: November 30, 2013, 01:22:26 AM »

I frequently run into problems because Unity think it's cool to discard any decimal result of a integer division.

Most C-family languages work like that. Integer division is a distinct operation from floating point division. Can be a pain if you don't know/don't remember the exact semantics of the language you're using...
Logged

rosholger
Level 1
*



View Profile
« Reply #4391 on: December 01, 2013, 04:52:50 PM »

gaaaaaah!!
somewhere inside a loop that does't touch the this pointer, it's getting fucking corrupted!!  Crazy
fuck this!!
Logged
Geti
Level 10
*****



View Profile WWW
« Reply #4392 on: December 01, 2013, 06:21:01 PM »

Lol potential heap corruption.

You properly sure it's inside the loop?
Logged

Endurion
Level 2
**



View Profile WWW
« Reply #4393 on: December 02, 2013, 02:17:08 AM »

If the this-Pointer looks corrupted you usually need to look one stack trace level higher. You probably called a method on an invalid (deleted or not initialised) object.
Logged
rosholger
Level 1
*



View Profile
« Reply #4394 on: December 02, 2013, 08:18:54 AM »

Lol potential heap corruption.

You properly sure it's inside the loop?

yup pretty sure, since the this-pointer works before that loop but not after.

If the this-Pointer looks corrupted you usually need to look one stack trace level higher. You probably called a method on an invalid (deleted or not initialised) object.

the strange thing is that the this-pointer looks fine in the stack trace level above, and both are member functions of the same object.

i actually found the problem, it was a buffer overflow that caused it
Logged
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #4395 on: December 04, 2013, 10:22:21 AM »

I use to hate programming, but now it's not there I crave it so much Cry more so that getting back into drawing
Logged

Saishy
Level 0
***



View Profile WWW
« Reply #4396 on: December 06, 2013, 10:50:47 AM »

All hail unity and monodevelop
http://puu.sh/5DHbF.png
http://puu.sh/5D44Z

Can't program anymore.
Logged

TinyBird Games  We make tiny games!
Prads
Level 1
*



View Profile
« Reply #4397 on: December 10, 2013, 10:47:59 AM »

Trying to use GL_LINEAR filter for the texture but it's not working. It has no effect and texture looks same as using GL_NEAREST. I have done this in other programs and it has worked before, just can't figure out why it's not working now. Can anyone check it please?

Code:
glGenTextures(1, &frameTexture);
glBindTexture(GL_TEXTURE_2D, frameTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1024, 1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
Logged

makerimages
Level 2
**


Makerimages Studios


View Profile WWW
« Reply #4398 on: December 10, 2013, 11:14:57 AM »

Cant figure out why the text is not drawing

.h
Code:
#pragma once
#include <string>
#include "GameObject.h"
#include "GameWindow.h"
#include <SFML/Graphics.hpp>
class MessageBox
{
public:
MessageBox(void);
MessageBox(std::string title, std::string content,int x, int y,GameObject* gameO,GameWindow* wI);
~MessageBox(void);
void draw();
protected:
sf::Font font;
sf::Font* boxFont;
sf::Text* titleT;
sf::Text contentT;
int xPos;
int yPos;
sf::Sprite* spr;
GameObject* game;
GameWindow* windowIn;
};



.cpp
Code:
#include "MessageBox.h"

using namespace std;
MessageBox::MessageBox(string title, string content, int x, int y,GameObject* gameO, GameWindow* wI): xPos(x), yPos(y),game(gameO), windowIn(wI)
{

if(!font.loadFromFile("data/fonts/LCALLIG.ttf"))
{
printf("Error loading font! \n");
}
boxFont=&font;
titleT=&sf::Text(title,*boxFont);
spr=game->getSpriteManager()->getSprite(3);
spr->setPosition(xPos,yPos);

}


MessageBox::~MessageBox(void)
{
}
void MessageBox::draw()
{

windowIn->getWindow()->draw(*spr);
windowIn->getWindow()->draw(*titleT);



}
MessageBox::MessageBox(void)
{
 }


spr draws, on its own, titleT doesnt...
Logged

Makerimages-Its in the pixel
ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #4399 on: December 10, 2013, 11:16:58 AM »

Trying to use GL_LINEAR filter for the texture but it's not working. It has no effect and texture looks same as using GL_NEAREST. I have done this in other programs and it has worked before, just can't figure out why it's not working now. Can anyone check it please?

Are you scaling up or down? Given that it's a 1024x1024 texture, I'm guessing you might be scaling down by a lot. GL_LINEAR looks pretty bad with too much downscaling (sometimes similar to GL_NEAREST); you'd get better results with mipmaps.

As an aside, calling glTexParameter before glTexImage2D is supposedly optimized better on some architectures. Probably wouldn't hurt to swap those around.
Logged

Pages: 1 ... 218 219 [220] 221 222 ... 295
Print
Jump to:  

Theme orange-lt created by panic