C++ :: SFML 2.0 Changing Alpha?
Sep 18, 2013I want to change the alpha of a sprite without changing any other colours
View 4 RepliesI want to change the alpha of a sprite without changing any other colours
View 4 RepliesI found a targa loader that works great and implemented it in my code.
But for some reason, the alpha region of my texture , just won't be alpha when I load the Texture in my code.
If I make a texture that is a full purple colored rectangle, and carve out the central part with an alpha zone, in-game the quad is all full purple, instead of having the central part being transparent.
I tried the following code too, and it doesn't work, I don't understand
//NPC
glEnable(GL_BLEND);// Enable Blending
NPC00->Draw();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);// Set The Blending To A Nice 50/50 Mode
glDisable(GL_BLEND);// Disable Blending
Draw Function, basically draws a Quad and applies the texture to it.
I'm just trying to get textures with alpha to work, I usually work with targas, so thats why I got a targa loader.
I want to use a new color for BaseColor in iTextSharp.
I can easily set a new color using RGB values from 0 to 255.
However, if I want to adjust the alpha value (and I know alpha ranges from 0 to 1), I can't make the alpha 0.5 because it's not an integer in the definition of BaseColor.
public BaseColor(int red, int green, int blue, int alpha);
So I can set my BaseColor like below:
static BaseColor newColor = new BaseColor(192, 192, 192);
but I can't use a non-int value for alpha. How can I easily convert double alpha values to integer values? What would be the range for alpha in int values and how do I, e.g., set the alpha value to 0.5 in int values?
EDIT: btw, I found online something like this: int alpha = (pixel >> 24). I don't understand why 24 and how can I break that into chunks I understand?
I made this function to check in string is alpha only or alphanumeric but always give me alfa way ?
Code:
int checkIfStringisAlfa(const char str[]){
int lenStr = getStringLength(str);
int i = 0;
int ret;
for(i = 0; i < lenStr; i++){
if(str[i] >= 'a' && str[i] <= 'z' || str[i] >= 'A' && str[i] <= 'Z'){
//printf(" alfa
[Code] .....
I am looking for a way to sort a string just by the alpha characters, not by the ASCII table. Therefore
string sort(string name) {
sort(name.begin(), name.end());
return name;
}
will not work. And I am looking for the most simple way to go about it!
How to stalk a random alpha letter in order in a minimum possible way.. and write the cases which the container can be stalked.
for example.. ACMICPC can be a store in three stalks.
ACC
M -----------> three stalks
IP
Another example... CBACBACBACBACBA can have three stalks
I'm trying to load a Quad with a Monster Image on it that will always face the Camera, a la Doom 2.
Now I don't know how to load an image with an Alpha part on it.
In 2D using SDL I always used tga files.
Here is my LoadTexture functions.
AUX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image
{
FILE *File=NULL; // File Handle
[Code].....
I am unable to check if the character in the 2D array is alpha
here is my code
#include<iostream>
#include<cctype>
#include<cassert>
#include<cstring>
const int maxChar = 20 ;
using namespace std ;
int main() {
int count = 0 ;
char d[2][20] = { "hi" , "di" } ;
[code]....
Why the first code snippet inserts properly into a list and the second code snippet does not. The position of the bold expressions are the only differences. iter, s and LS were declared elsewhere in main().
snippet 1.)
while (true) {
cout << "Enter string (ENTER to exit): ";
getline(cin, s);
if (s.size() == 0)
[Code] .....
I want to create 2 functions to (1) convert a passed string into proper case (capitalize the first alpha character of a string and every alpha character that follows a non-alpha character); (2) sort the array of names (after it has been converted to proper case).
I tried these two:
console.writeline (lower.toUpper());
void bubblesort (string array[],int length);
but I don't know if they are good.
I'm currently working on a 2D space shooter game in C++ using SFML library. What I need to know is how make an object (ex:laser) fire up from object (ex:player) when a user press button??
View 1 Replies View RelatedI use visual studio 2012. When I asked what I should use in order to put graphics into my program, I was told by the community that SFML works well. My only problem is that now I have SFML, where and how do I unpack it?
View 6 Replies View RelatedHow to change what the cursor is in sfml 2.0?
View 1 Replies View Relatedso im trying to make a blinking cursor to give it a terminal feel, but it is speradic, since it is going at cycles instead of seconds. how can i fix this?
#include <SFML/Graphics.hpp>
int main() {
sf::RenderWindow App(sf::VideoMode(900, 750), "Fuck it. Uploads Happen.");
sf::Font
Font;
[Code].....
So I have the following code using [URL] ..... It compiles correctly, but does not display the map on the screen. Is it an issue with my code or an issue with the map file itself?
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <level.h>
int main(){
sf::RenderWindow window(sf::VideoMode(640, 480), "");
[Code] ....
using SFML in visual studio 2012 ... this code gives blinking window.
#include<iostream>
#include<SFMLGraphics.hpp>
using namespace std;
sf::RenderWindow window (sf::VideoMode(800,600),"GAME");
[Code]....
How to make a red and black tree using SFML ....because i really need...I really don't know how to use SFML i only know how to use win32 console.
View 3 Replies View RelatedSo this is my first try animating on my own, without a reference right in front of me. It's not working, I did check some of the projects I've made in the past, but for one those were done with Allegro, and really it should be able to move over to SFML quite easily, but it's not. It does display on the window in the correct place, but there are 3 pictures in the file and I want it to cycle through them, but it shows all three at the same time, and it only works once. if I press space a second time, only one of the pictures shows up, and it doesn't cycle at all. Here is my .cpp file :
#include "headers.h"
#include "SwordSprite.h"
int top = 0;
int left = 88;
int right = 132;
int bottom = 35;
SwordSprite::SwordSprite() {
[Code] .....
I am having trouble setting up SFML 2.1 to run with the eclipse IDE for c++ development. I use MinGW for my compiler.
When I link my include folder, lib folder and dll's it will not run a simple SFML program.
I wrote some Code with SFML c++ and OGL that should display a rotatable Cube ....... it doesnt .. WHY?
#include<SFML/OpenGL.hpp>
#include<SFML/Graphics.hpp>
#include<iostream>
void display();
void specialKeys();
[code]....
I have the code and it compiles fine but it doesn't work. (i am using the coding made easy sfml 2.0 tutorials)
Code:
#include <SFML/Graphics.hpp>
#include <iostream>
#include <algorithm>
#include <vector>
class Player {
public:
sf::Sprite player;
[Code] ....
I have screen scrolling working but i want to have text scroll with the screen. because at the moment my player moves and the screen scrolls but the text doesn't.
View 15 Replies View RelatedAny way in sfml of changing the font style and/or size used in the window title for RenderWindow?
As a secondary point - can the colour and size of the title bar itself be changed?
So I did read, however it said also that it was memory intensive and I had a question... I also came across this:
Window.pushGLStates();
Window.draw("Sfml Text");
Window.popGLStates();
The problem here is that none of these commands exist!
Window.draw should exist and even though I have all the proper includes I still get it telling me that 'Draw' is not a member of sf::Window
I have encountered that error many times everywhere across my sfml related code, it's not like they removed all those features in the update (Which they did not) but, why then would it not be a member?
How can i made a Drop down list in SFML ? This drop down list contains names of different animals...
View 10 Replies View RelatedI am trying to position and sf::Text relatively to another sf::Text. Not over, or beneath or anything like that, but after- like so:
theTexts.push_back(UnitOfText(Text(outputstring,defaultFont, 15),theColor));
int i = (theTexts.size() - 1);
std::cout << i;
sf::FloatRect textRect ( theTexts[i].theText.getLocalBounds() );
theTexts[i].theText.setOrigin (textRect.width / 2, textRect.height / 2);
if(theTexts.size() > 1)
{
theTexts[i].theText.setPosition(theTexts[i - 1].theText.getLocalBounds().left,theTexts[i - 1].theText.getLocalBounds().top);
}