opengl – How to set camera coordinates without making a Camera class?

Recently, I have been making a 3D game (and asking alot of questions about it), and yet again, I’ve run into another problem.

I’m trying to rotate a cube across the “camera” origin, which is easily set by doing this in the gameloop:

//Wrapping a push/pop matrix around the main push/pops from the object for rotating around origin.

            GL11.glPushMatrix();
            
            GL11.glRotatef(ROTDX += Mouse.getDX(), 0, 1, 0);
            GL11.glRotatef(ROTDY -= Mouse.getDY(), 1, 0, 0);
            
            GL11.glTranslatef(0, 0, -50.0f);

            GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);  
            
            GL11.glClearColor(1.0f, 1.0f, 0.2f, 1.0f);
             
            shader.start();
            
            a+=0.001f;
            
            if (a > 360) {
                a = 0;
            }
            
            int uniform1 = GL20.glGetUniformLocation(shader.getProgID(), "u_time");
            
            GL20.glUniform1f(GL20.glGetUniformLocation(shader.getProgID(), "u_time"), a);
            
            int res = GL20.glGetUniformLocation(shader.getProgID(), "u_resolution");
            
            GL20.glUniform2f(GL20.glGetUniformLocation(shader.getProgID(), "u_resolution"), 640.0f, 480.0f);
            
            GL11.glPushMatrix();
            
            GL11.glRotatef(DX += Mouse.getDX(), 0, 1, 0);
            GL11.glRotatef(DY -= Mouse.getDY(), 1, 0, 0);

            cube.drawCube();
            
            GL11.glPopMatrix();
            
            GL11.glPopMatrix();

But, I cannot seem to update the “center” of the screen or the origin of the “camera”.

Is this even possible without a custom Camera class?

Here are two images to show you what I mean:

Rotating on “viewport” or “camera” origin:

Rotating on camera origin

Still rotating on center of the original “viewport” or “camera” origin:

Still rotating on origin

And this is what I want to happen:

Rotate on “origin”

Rot1

Updates and rotates on updated “origin”

Rot2

Here is my whole main loop class:

package me.pale.main;

import java.io.File;

import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL20;
import org.lwjgl.util.glu.GLU;
import org.newdawn.slick.opengl.Texture;
import org.newdawn.slick.opengl.TextureLoader;
import org.newdawn.slick.util.ResourceLoader;

import me.pale.input.Input;
import me.pale.model.Model;
import me.pale.model.RGB;
import me.pale.shader.RegShader;

public class MainLoop extends RGB{
    
    boolean forward = false;
    boolean backward = false;
    boolean left = false;
    boolean right = false;
    
    boolean mouseVisible = false;
    
    float posx = 0;
    float posx2 = 0;
    float posy = 0;
    float posz = 0;
    float posz2 = 0;
    int b = 640;
    int c = 480;
    
    float a = 0;
    
    String vertex = "res/vertex.txt";
    String frag = "res/fragment.txt";
    
    File vertexShad = new File(this.getClass().getResource("/vertex.glsl").toString());
    File fragShad = new File(this.getClass().getResource("/fragment.glsl").toString());
    
    float rot = 0;
    float DX = 0;
    float DY = 0;
    
    float ROTDY = 0;
    float ROTDX = 0;
    
    Input i = new Input();
    
    RegShader shader;
    
    Model cube = new Model();
    
    Texture tex;
    
    public void init() throws LWJGLException, Exception {
        

        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.create();
        
        shader = new RegShader();
        
        // tex = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/test.png"));
        
        Display.sync(60);
        
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        // GL11.glLoadIdentity();
        // GL11.glOrtho(-640/2, 640/2, -480/2, 480/2, -200, 500);
        
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        
        GL11.glClearColor(0, 0, 0, 0);
        
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_LIGHTING);
        
        GL11.glEnable(GL11.GL_NORMALIZE);
        //GL11.glEnable(GL11.GL_BLEND);
        //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        
        GLU.gluPerspective(90.0f, 1.333f, 1.0f, 650.0f);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glDepthMask(true);
        GL11.glDepthFunc(GL11.GL_LESS);
        GL11.glLoadIdentity();
        
        Mouse.setGrabbed(true);
        
        // tex.bind();
        
        while (!Display.isCloseRequested()) {
            
            // GL11.glViewport(0, 0, b -= 1, c - 1);
            
            input();
            
            GL11.glPushMatrix();
            
            GL11.glRotatef(ROTDX += Mouse.getDX(), 0, 1, 0);
            GL11.glRotatef(ROTDY -= Mouse.getDY(), 1, 0, 0);
            
            GL11.glTranslatef(0, 0, -50.0f);
            // GL11.glPushMatrix();
            
            // GL11.glRotatef(ROTDX += Mouse.getDX(), 0, 1, 0);
            // GL11.glRotatef(ROTDY -= Mouse.getDY(), 1, 0, 0);
            
            // GL11.glTranslatef(0.0f, 0.0f, -50.0f);
            
            // GL11.glPopMatrix();
            
            // Clear the screen and depth buffer
            // GL11.glEnable(GL11.GL_DEPTH_TEST);
            GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);  
            
            GL11.glClearColor(1.0f, 1.0f, 0.2f, 1.0f);
             
            // set the color of the quad (R,G,B,A)
            // GL11.glColor3f(toRatio(12), toRatio(202), toRatio(222));
            
            shader.start();
            
            a+=0.001f;
            
            if (a > 360) {
                a = 0;
            }
            
            int uniform1 = GL20.glGetUniformLocation(shader.getProgID(), "u_time");
            
            GL20.glUniform1f(GL20.glGetUniformLocation(shader.getProgID(), "u_time"), a);
            
            int res = GL20.glGetUniformLocation(shader.getProgID(), "u_resolution");
            
            GL20.glUniform2f(GL20.glGetUniformLocation(shader.getProgID(), "u_resolution"), 640.0f, 480.0f);
            
            GL11.glPushMatrix();
            
            GL11.glRotatef(DX += Mouse.getDX(), 0, 1, 0);
            GL11.glRotatef(DY -= Mouse.getDY(), 1, 0, 0);
            
            // GL11.glRotatef(rot += 0.05f, 1, 1, 1);
            // GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());
           
            cube.drawCube();
            
            // GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
            
            GL11.glPopMatrix();
            
            GL11.glPopMatrix();
            
            shader.halt();
            
            Display.update();
            
        }
        
        shader.wash();
        tex.release();
        Display.destroy();
        
    }
    
    public void input() {
        
        if (forward) {
            
            posz = 0.1f;
            GL11.glTranslatef(posx, posy, posz);
            
        }
        
        if (backward) {
            
            posz = -0.1f;
            GL11.glTranslatef(posx, posy, posz);
            
        }
        
        if (left) {
            
            posx = 0.1f;
            GL11.glTranslatef(posx, posy, posz);
            
        }
        
        if (right) {
            
            posx = -0.1f;
            GL11.glTranslatef(posx, posy, posz);
            
        }
        
        if (!left && !right) {
            
            posx = 0;
            
        }
        
        if (!forward && !backward) {
            
            posz = 0;
            
        }
        
        if (!Keyboard.getEventKeyState()) { 
            
            forward = false;
            backward = false;
            left = false;
            right = false;
            
        }
            
        if (Keyboard.isKeyDown(Keyboard.KEY_A)) {
                
            left = true;
                
        }
            
        if (Keyboard.isKeyDown(Keyboard.KEY_D)) {
                
            right = true;
                
        }
            
        if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
                
            forward = true;
                
        }
            
        if (Keyboard.isKeyDown(Keyboard.KEY_S)) {
                
            backward = true;
                
        }
        
        if (i.isLMBDown()) {
            
            System.out.println("MOUSEX: " + i.getMouseX() + ", MOUSEY: " + i.getMouseY());
            
        }
        
        while (Keyboard.next()) {
            
            if (Keyboard.getEventKey() == Keyboard.KEY_M) {
                
                if (Keyboard.getEventKeyState()) {
                    
                    if (!mouseVisible) {
            
                        Mouse.setGrabbed(false);
                        mouseVisible = true;
                        
                    } else {
                    
                        Mouse.setGrabbed(true);
                        mouseVisible = false;
                        
                    }
                    
                }
                            
            }
            
            if (Keyboard.getEventKey() == Keyboard.KEY_B) {
                
                if (Keyboard.getEventKeyState()) {
                    
                    System.out.println("Key B Pressed.");
                    
                }
                
            }
            
            if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
                
                Display.destroy();
                System.exit(0);
                
            }
            
        }
        
    }
    
    public static void main(String() args) throws Exception {
        
        MainLoop ml = new MainLoop();
        ml.init();
        
    }

}

Any help much appreciated!

legal – Would making a satirical version of someone else’s character get me sued?

Licensing the rights to a popular character is definitely a hard process. Rather than licensing the rights to (insert hero here), what if I were to make a satirical version of the IP owner’s character(s) like Spaceballs did? What sort of legal trouble could I face for making a satirical rip-off of a character?

❓ASK – Newbie Making first Money Online | Proxies-free

Earnings Disclaimer:  All the posts published herein are merely based on individual views, and they do not expressly or by implications represent those of Proxies-free or its owner. It is hereby made clear that Proxies-free does not endorse, support, adopt or vouch any views, programs and/or business opportunities posted herein. Proxies-free also does not give and/or offer any investment advice to any members and/or it’s readers. All members and readers are advised to independently consult their own consultants, lawyers and/or families before making any investment and/or business decisions. This forum is merely a place for general discussions. It is hereby agreed by all members and/or readers that Proxies-free is in no way responsible and/or liable for any damages and/or losses suffered by anyone of you.

dual boot – Installing Ubuntu and Making it Work on 2021 BRAND NEW PC

For many years I have been a fan of the Linux environment, especially Ubuntu, Kubuntu, and Xubuntu. I bought a new laptop in January, an HP-17z-ca200 laptop that I had customized by HP. Here are the specifications:

2 TB 5400 rpm SATA
21 GB DDR4-2400 SDRAM (1x4GB, 1x8GB)
AMD Athlon Gold 3150U 2.4 Ghz 2 Cores + AMD Radeon Graphics
Originally shipped with Windows 10 Home x64
Realtek RTL8821ce Wifi Adapter

My issue is that I love Ubuntu, and decided to dual boot Ubuntu and Windows 10 – each would have ~1TB of disk space, and I had more RAM than I have ever had in my life, so I figured it would run FAST (considering I had an AsusEEE PC with 1 GB ram, and it ran Kubuntu 18.04 super quickly.)These are the problems:

Ubuntu 20.04 does NOT have support for my wifi adapter. So I had to install 3rd party drivers and all the drama, and it barely worked. So I ended up having to install Ubuntu 21.04, which worked fine with my wifi adapter, so I solved that issue. Once my system is started up, it runs fine, but it takes FOREVER to start up. I mean 2-3 minutes. I want to be able to shut my computer on and off when I start and finish work, and If linux is slower than Windows 10 then I feel like I’m wasting time, because I want Ubuntu because it is supposed to be faster. So after 3 minutes have passed and the computer turns on, it works okay, but then gets buggy over time and weird. I have cycled through the following distros to see if one would be quicker:

Xubuntu 21.04 (somehow slower than Ubuntu)
Lubuntu 21.04 (didn’t recognize my wifi adapter)
Ubuntu Budgie 21.04 (I didn’t like the look)
Ubuntu MATE (my current distro, works fine, boot time is quicker but not my favorite)
Elementary, Manjaro, Solus, Reborn, all needed no secure boot and I want secure boot on.

Other issues; SYSTEMD. Slows things down tremendously. I like snapd, but it increases boot time from anywhere from 12 to 40 seconds. GRUB takes many many seconds after selecting my OS to change into the boot screen of Ubuntu.

My optimal solution:

Some information on how to install Ubuntu 21.04 correctly, if I am somehow not doing it correctly,
Ways to decrease boot time. I have disabled ALL unnecessary startup services, messed with systemd-analyze blame, etc. Not sure what else to do.
Get GRUB time to 0, because whenever I do so it doesn’t recognize it and starts counting down from 10 or 30 randomly.
Information on what Linux OS would work best based on my hardware alone. If someone can look at my PC specs and tell me “so and so would be your best option.” I have used Distrochooser, but no help really. I am willing to disable secureboot.
Any other tips and suggestions.

I will install Ubuntu 21.04 now and replace Ubuntu MATE. After that, I can provide any command line outputs that are needed. Sorry if my plea sounds mean or anything, I am just a little frustrated with my system. I want to use Linux, not Windows, and it is annoying that I keep having to default to Windows 10 which is just buggy and annoying.

Any help would be wonderful. Thank you in advance,

-Aidan

Will making HTTP cookies unique to a given website make cookies aligned with the strictest privacy guidelines?

As far as I know, the only privacy problem with cookies is that in general, the owners of website Y could read what a visitor has searched for or had done in website X.

The privacy problem with cookies is that they can be used to track a user over multiple sites and specific web pages. And based on these information a profile can be created about the interests of the user – which allow targeted ads and similar.

… so other websites won’t be able to access it

Other websites cannot access the cookies or a site. Its the cookies these web sites itself set, i.e. cookies from Facebook when a like button is included in any page, cookies from Google if Google Analytics is used in a page etc.

This also means that your approach of unique cookies will not help, since it does not addresses the actual problem.

python – I am making a server-client chatting app and I am getting this error

I am making a server-client chatting app and I am getting this error on the server:

127.0.0.1 connected
Exception ignored in thread started by: <function clientthread at 0x00000275F407F040>
Traceback (most recent call last):
File "D:client-server stuffchatroom 2serverServer.py", line 65, in clientthread
conn.send("Welcome to this chatroom!")
TypeError: a bytes-like object is required, not 'str'

and this error on the client:

Traceback (most recent call last):
File "D:client-server stuffchatroom 2clientclient.py", line 27, in <module>
read_sockets,write_socket, error_socket = select.select(sockets_list,(),())
OSError: (WinError 10038) An operation was attempted on something that is not a socket

my code is on github here: https://github.com/NotCoolKiwiTeam/Project-EnderChat

Making Youtube playlist a continuous stream

I have several Youtube playlists from a whole LP, for example Pink Floyd’s The Wall. The problem is, it takes a moment from one video to another, sometimes making a cut in a continuous stream. This make me wonder if there is anyway to reduce the load time, or some kind of in-advance load of the next video? I have found that the Youtube Music app does this pretty well, and I want to enjoy the same experience on the desktop.

c – Making pixels of RGB barcode suitable for scanning

Similar to Microsoft’s HCCB before its discontinuation near 2015, Im trying to make a 2D barcode that uses RGB pixels to encode more than two possible states (Black/White).

Theoretically, at 100% data capacity, you could hold 16,777,216 different integers in a single pixel.
However, this level of storage is not feasible.


Consider the two RGB colors 47,213,71 and 47,213,72:

demonstration of two neighboring rgb values

This unperceivable difference would have to be detected reliably even in suboptimal environments and lighting.

This is why Microsoft’s HCCB only used 8 pre-determined colors, but I hypothesize modern cameras would still allow for greater detection and accuracy.


I wanted a barcode where you could change the gaps between colors, such that no two neighboring colors were less distant than the amount specified.

This way, a large gap like 128 could make each pixel represent a possible total of 8 colors – like Microsoft’s original HCCB; While a small gap like 1 would give you the aforementioned 16,777,216 colors.

Now that I’ve finished explaining why anyone would want to do this, I can show you my C code. I’m not sure I did a good job at this, and I feel as though either my method or execution should be changed completely, so here’s my approach to doing this

#include <stdio.h>
#include <stdint.h>

uint8_t* bind(uint32_t val, uint8_t bound){
  static uint8_t rgb(3);
  uint32_t buffer(3);
  uint32_t max = bound*(256/bound);

  buffer(0) = val * bound;
  buffer(1) = (buffer(0)/max)*bound;
  buffer(2) = (buffer(1)/max)*bound;

  rgb(0) = buffer(0) % max;
  rgb(1) = buffer(1) % max;
  rgb(2) = buffer(2) % max;

  return rgb;
}

uint32_t unbind(uint8_t* rgb, uint8_t bound){
  uint32_t max = 256/bound;
  return (rgb(0)/bound)+(rgb(1)/bound)*max+(rgb(2)/bound)*max*max;
}

int main(void) {
  uint32_t data = 1;
  uint8_t color_range = 128;

  uint8_t* colors = bind(data, color_range);
  uint32_t calculated = unbind(colors, color_range);

  printf("expected value: %unreturned value: %unn", data, calculated);
  printf("rgb value: %u,%u,%un", colors(0), colors(1), colors(2));
  return 0;
}